Tarantool development patches archive
 help / color / mirror / Atom feed
From: Nikita Pettik <korablev@tarantool.org>
To: imeevma@tarantool.org
Cc: tarantool-patches@dev.tarantool.org
Subject: Re: [Tarantool-patches] [PATCH v5 2/6] sql: add implicit cast between numbers in OP_Seek*
Date: Thu, 17 Sep 2020 15:34:09 +0000	[thread overview]
Message-ID: <20200917153409.GH10599@tarantool.org> (raw)
In-Reply-To: <dc9d1b3a51fcf5f53031e69c640643d432906fa2.1598000242.git.imeevma@gmail.com>

On 21 Aug 12:19, imeevma@tarantool.org wrote:
> This patch adds new rules for implicit casting between numbers in
> OP_Seek * opcodes. They are still not used because the ApplyType
> opcode is converting numbers, but this will be changed in the next
> patch. Conversion within the ApplyType opcode can affect the
> result of comparison operations.
> 
> Part of #4230
> ---
>  src/box/sql/vdbe.c | 332 +++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 332 insertions(+)
> 
> diff --git a/src/box/sql/vdbe.c b/src/box/sql/vdbe.c
> index 7405009a7..822d7e177 100644
> --- a/src/box/sql/vdbe.c
> +++ b/src/box/sql/vdbe.c
> @@ -522,6 +522,268 @@ mem_convert_to_numeric(struct Mem *mem, enum field_type type)
>  	return mem_convert_to_integer(mem);
>  }
>  
> +/**
> + * Convert the numeric value contained in the MEM to UNSIGNED.
> + * @see mem_prepare_for_cmp() for more info.
> + *
> + * @param mem The MEM that contains the numeric value.
> + * @param[in][out] oc Operation code.
> + * @retval 0 if the conversion was successful, -1 otherwise.
> + */
> +static int

Would be nice to see sort of table containing value/action columns,
i.e. what should be done in each seprate case. These three functions are
quite complicated and can contain bugs with ease. At first sight I find
no obvious mistakes.

> +/**
> + * Convert the numeric value contained in the MEM to another
> + * numeric type according to the specified operation. If the
> + * conversion is successful, we will get the converted MEM. If the
> + * conversion fails, the MEM will not be changed.
> + *
> + * @param mem The MEM that contains the numeric value.
> + * @param type The type to convert to.
> + * @param[in][out] oc Operation code.

Just [out] - all parameters are in

> + * @retval 0 if the conversion was successful, -1 otherwise.
> + */
> +static int
> +mem_prepare_for_cmp(struct Mem *mem, enum field_type type, int *oc, int eqOnly)

Please rename according to guides eqOnly param and mention it in the comment.

> +{
> +	if (type == FIELD_TYPE_UNSIGNED)
> +		return mem_prepare_for_cmp_to_uint(mem, oc, eqOnly);
> +	if (type == FIELD_TYPE_INTEGER)
> +		return mem_prepare_for_cmp_to_int(mem, oc, eqOnly);
> +	assert(type == FIELD_TYPE_DOUBLE);
> +	return mem_prepare_for_cmp_to_double(mem, oc, eqOnly);
> +}
> +
>  /*
>   * pMem currently only holds a string type (or maybe a BLOB that we can
>   * interpret as a string if we want to).  Compute its corresponding

  reply	other threads:[~2020-09-17 15:34 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-21  9:19 [Tarantool-patches] [PATCH v5 0/6] sql; remove implicit cast for comparison imeevma
2020-08-21  9:19 ` [Tarantool-patches] [PATCH v5 1/6] sql: remove unused DOUBLE to INTEGER conversion imeevma
2020-09-17 14:48   ` Nikita Pettik
2020-09-28 15:50     ` Mergen Imeev
2020-08-21  9:19 ` [Tarantool-patches] [PATCH v5 2/6] sql: add implicit cast between numbers in OP_Seek* imeevma
2020-09-17 15:34   ` Nikita Pettik [this message]
2020-09-28 15:55     ` Mergen Imeev
2020-08-21  9:19 ` [Tarantool-patches] [PATCH v5 3/6] sql: change comparison between numbers using index imeevma
2020-09-18  8:08   ` Nikita Pettik
2020-09-28 16:10     ` Mergen Imeev
2020-08-21  9:19 ` [Tarantool-patches] [PATCH v5 4/6] sql: remove implicit cast from comparison opcodes imeevma
2020-08-21  9:19 ` [Tarantool-patches] [PATCH v5 5/6] sql: fix implicit cast in opcode MustBeInt imeevma
2020-08-21  9:19 ` [Tarantool-patches] [PATCH v5 6/6] sql: remove implicit cast from MakeRecord opcode imeevma
2020-09-18 12:28   ` Nikita Pettik
2020-09-28 16:19     ` Mergen Imeev

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=20200917153409.GH10599@tarantool.org \
    --to=korablev@tarantool.org \
    --cc=imeevma@tarantool.org \
    --cc=tarantool-patches@dev.tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH v5 2/6] sql: add implicit cast between numbers in OP_Seek*' \
    /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