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 v3 5/8] sql: remove mem_apply_type() from OP_MustBeInt
Date: Mon, 29 Jun 2020 13:29:57 +0000	[thread overview]
Message-ID: <20200629132957.GB27240@tarantool.org> (raw)
In-Reply-To: <010e6a896440f240f504daf8c72b71095a17869b.1593096639.git.imeevma@gmail.com>

On 25 Jun 18:17, imeevma@tarantool.org wrote:
> diff --git a/src/box/sql/vdbe.c b/src/box/sql/vdbe.c
> index 276956170..a609fa985 100644
> --- a/src/box/sql/vdbe.c
> +++ b/src/box/sql/vdbe.c
> @@ -2122,17 +2122,13 @@ case OP_AddImm: {            /* in1 */
>   */
>  case OP_MustBeInt: {            /* jump, in1 */
>  	pIn1 = &aMem[pOp->p1];
> -	if ((pIn1->flags & (MEM_Int | MEM_UInt)) == 0) {
> -		mem_apply_type(pIn1, FIELD_TYPE_INTEGER);
> -		if ((pIn1->flags & (MEM_Int | MEM_UInt)) == 0) {
> -			if (pOp->p2==0) {
> -				diag_set(ClientError, ER_SQL_TYPE_MISMATCH,
> -					 sql_value_to_diag_str(pIn1), "integer");
> -				goto abort_due_to_error;
> -			} else {
> -				goto jump_to_p2;
> -			}
> -		}
> +	if ((pIn1->flags & (MEM_Int | MEM_UInt)) == 0 &&
> +	    mem_convert_to_integer(pIn1, true) != 0) {

Please split this conditions into two branches. Like this:

diff --git a/src/box/sql/vdbe.c b/src/box/sql/vdbe.c
index 2bc8c9817..da76d7321 100644
--- a/src/box/sql/vdbe.c
+++ b/src/box/sql/vdbe.c
@@ -2122,13 +2122,14 @@ case OP_AddImm: {            /* in1 */
  */
 case OP_MustBeInt: {            /* jump, in1 */
        pIn1 = &aMem[pOp->p1];
-       if ((pIn1->flags & (MEM_Int | MEM_UInt)) == 0 &&
-           mem_convert_to_integer(pIn1, true) != 0) {
-               if (pOp->p2 != 0)
-                       goto jump_to_p2;
-               diag_set(ClientError, ER_SQL_TYPE_MISMATCH,
-                        sql_value_to_diag_str(pIn1), "integer");
-               goto abort_due_to_error;
+       if ((pIn1->flags & (MEM_Int | MEM_UInt)) == 0) {
+               if (mem_convert_to_integer(pIn1, true) != 0) {
+                       if (pOp->p2 != 0)
+                               goto jump_to_p2;
+                       diag_set(ClientError, ER_SQL_TYPE_MISMATCH,
+                                sql_value_to_diag_str(pIn1), "integer");
+                       goto abort_due_to_error;
+               }
        }
        break;

It ehcnances code readability. Or even integrate this check into
mem_covert_to_ingeger().

The rest is OK (hope you carefully verified changed tests, since
I've only briefly looked through).

  reply	other threads:[~2020-06-29 13:29 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-25 15:17 [Tarantool-patches] [PATCH v3 0/8] Remove implicit cast imeevma
2020-06-25 15:17 ` [Tarantool-patches] [PATCH v3 1/8] sql: introduce mem_set_double() imeevma
2020-06-28 13:31   ` Nikita Pettik
2020-07-06 14:02     ` Nikita Pettik
2020-06-25 15:17 ` [Tarantool-patches] [PATCH v3 2/8] sql: change implicit cast for assignment imeevma
2020-06-30 11:50   ` Nikita Pettik
2020-07-05 14:26     ` Mergen Imeev
2020-07-06 21:27       ` Nikita Pettik
2020-07-07  9:29         ` Mergen Imeev
2020-07-07 15:35           ` Nikita Pettik
2020-07-10 10:49           ` Nikita Pettik
2020-06-25 15:17 ` [Tarantool-patches] [PATCH v3 3/8] sql: remove mem_apply_type() from OP_MakeRecord imeevma
2020-06-25 15:17 ` [Tarantool-patches] [PATCH v3 4/8] sql: replace ApplyType by CheckType for IN operator imeevma
2020-06-29 12:56   ` Nikita Pettik
2020-07-05 14:28     ` Mergen Imeev
2020-07-06 22:06       ` Nikita Pettik
2020-07-07 11:26         ` Mergen Imeev
2020-07-07 16:29           ` Nikita Pettik
2020-06-25 15:17 ` [Tarantool-patches] [PATCH v3 5/8] sql: remove mem_apply_type() from OP_MustBeInt imeevma
2020-06-29 13:29   ` Nikita Pettik [this message]
2020-07-05 14:29     ` Mergen Imeev
2020-06-25 15:17 ` [Tarantool-patches] [PATCH v3 6/8] sql: remove implicit cast for comparison imeevma
2020-06-29 23:51   ` Nikita Pettik
2020-07-05 14:47     ` Mergen Imeev
2020-07-06 23:11       ` Nikita Pettik
2020-06-25 15:17 ` [Tarantool-patches] [PATCH v3 7/8] sql: remove unused functions imeevma
2020-06-29 23:52   ` Nikita Pettik
2020-07-05 14:50     ` Mergen Imeev
2020-06-25 15:17 ` [Tarantool-patches] [PATCH v3 8/8] sql: show value and its type in type mismatch error imeevma
2020-06-30  0:22   ` Nikita Pettik
2020-07-05 15:03     ` Mergen Imeev
2020-07-06 21:44       ` Nikita Pettik

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=20200629132957.GB27240@tarantool.org \
    --to=korablev@tarantool.org \
    --cc=imeevma@tarantool.org \
    --cc=tarantool-patches@dev.tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH v3 5/8] sql: remove mem_apply_type() from OP_MustBeInt' \
    /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