Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladislav Shpilevoy via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: imeevma@tarantool.org
Cc: tarantool-patches@dev.tarantool.org
Subject: Re: [Tarantool-patches] [PATCH v1 1/1] sql: introduce DECIMAL to SQL built-in functions
Date: Mon, 15 Nov 2021 22:39:38 +0100	[thread overview]
Message-ID: <330552df-201e-82ac-a841-4dbb55c2a9d6@tarantool.org> (raw)
In-Reply-To: <351cadea401fc74c843e3e414d0da5242336563f.1636717171.git.imeevma@gmail.com>

Hi! Thanks for the patch!

> diff --git a/src/box/sql/func.c b/src/box/sql/func.c
> index 5abaf490d..684fcc275 100644
> --- a/src/box/sql/func.c
> +++ b/src/box/sql/func.c
> @@ -258,6 +258,20 @@ func_abs_double(struct sql_context *ctx, int argc, const struct Mem *argv)
>  	mem_set_double(ctx->pOut, arg->u.r < 0 ? -arg->u.r : arg->u.r);
>  }
>  
> +static void
> +func_abs_dec(struct sql_context *ctx, int argc, const struct Mem *argv)
> +{
> +	assert(argc == 1);
> +	(void)argc;
> +	const struct Mem *arg = &argv[0];
> +	if (mem_is_null(arg))
> +		return;
> +	assert(mem_is_dec(arg));
> +	decimal_t dec;
> +	decimal_abs(&dec, &arg->u.d);
> +	mem_set_dec(ctx->pOut, &dec);

You should be able to use the same argument both for in and out
values:

	decimal_abs(&arg->u.d, &arg->u.d);

In the 'documentation' of decNumber it is said to be allowed.
See the comment on the function 'decNumberAbs()'.

  reply	other threads:[~2021-11-15 21:39 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-12 11:40 Mergen Imeev via Tarantool-patches
2021-11-15 21:39 ` Vladislav Shpilevoy via Tarantool-patches [this message]
2021-11-19  8:14   ` Mergen Imeev via Tarantool-patches
2021-11-21 15:21     ` Vladislav Shpilevoy via Tarantool-patches
2021-11-22  7:41 Mergen Imeev via Tarantool-patches
2021-11-22 12:31 ` Kirill Yukhin via Tarantool-patches

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=330552df-201e-82ac-a841-4dbb55c2a9d6@tarantool.org \
    --to=tarantool-patches@dev.tarantool.org \
    --cc=imeevma@tarantool.org \
    --cc=v.shpilevoy@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH v1 1/1] sql: introduce DECIMAL to SQL built-in functions' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox