Tarantool development patches archive
 help / color / mirror / Atom feed
From: "n.pettik" <korablev@tarantool.org>
To: tarantool-patches@freelists.org
Cc: szudin@tarantool.org
Subject: [tarantool-patches] Re: [PATCH] sql: do not let VALUES statement treat the type definition keywords as values
Date: Mon, 28 Jan 2019 20:30:31 +0300	[thread overview]
Message-ID: <2A6AF308-C6A5-4122-AC73-B429C1487CC5@tarantool.org> (raw)
In-Reply-To: <20190125105031.31745-1-szudin@tarantool.org>

Decorations are not such vital as content of patch surely,
but still should be OK.

Firstly,  try to limit the subject line to 50 characters or so.

Then, if you send patch v2, please indicate it to format-patch
utility by passing --subject-prefix='PATCH v2’

> The "box.sql.execute('values(blob)')" causes an accert

Nit: accert -> assert.

> in the expression processing, because the parser doesn't distinguish the keyword "BLOB" from the binary value (in the form X'hex’).
> 
> This fix adds an additional checks in the SQL grammar. Thus the expressions such as "VALUES(BLOB)", "SELECT FLOAT" and so on are treated as a syntax errors.

Wrap the body of commit message to 72 characters or so.

> 
> Closes #3888
> —

Place links to your branch and issue here
(not at the very bottom of patch).

Patch itself is OK, just few nits.

> diff --git a/src/box/sql/parse.y b/src/box/sql/parse.y
> index 0bcf41594..73a324522 100644
> --- a/src/box/sql/parse.y
> +++ b/src/box/sql/parse.y
> @@ -211,7 +211,7 @@ columnname(A) ::= nm(A) typedef(Y). {sqlite3AddColumn(pParse,&A,&Y);}
>   IGNORE INITIALLY INSTEAD NO MATCH PLAN
>   QUERY KEY OFFSET RAISE RELEASE REPLACE RESTRICT
> %ifdef SQLITE_OMIT_COMPOUND_SELECT
> -  INTERSECT 
> +  INTERSECT

Extra diff.

> %endif SQLITE_OMIT_COMPOUND_SELECT
>   RENAME CTIME_KW IF
>   .
> @@ -823,12 +823,15 @@ idlist(A) ::= nm(Y).
>         p->affinity = AFFINITY_TEXT;
>         break;
>       case TK_BLOB:
> +      case TK_BLOB_KW:
>         p->affinity = AFFINITY_BLOB;

Why do we need to assign affinity to keywords?

>         break;
>       case TK_INTEGER:
> +      case TK_INTEGER_KW:
>         p->affinity = AFFINITY_INTEGER;
>         break;
>       case TK_FLOAT:
> +      case TK_FLOAT_KW:
>         p->affinity = AFFINITY_REAL;
>         break;
>       }
> diff --git a/test/sql/gh-3888-values-blob-assert.test.lua b/test/sql/gh-3888-values-blob-assert.test.lua
> new file mode 100644
> index 000000000..dafb73716
> --- /dev/null
> +++ b/test/sql/gh-3888-values-blob-assert.test.lua
> @@ -0,0 +1,37 @@
> +-- sql: assertion fault on VALUES #3888
> +-- Very simple query leads to assertion fault:
> +--
> +-- box.cfg{}
> +-- box.sql.execute("values(blob)")
> +-- Assertion failed: (pExpr->u.zToken[0] == 'x' || pExpr->u.zToken[0] == 'X'),
> +-- function sqlite3ExprCodeTarget,
> +-- file /Users/n.pettik/tarantool/src/box/sql/expr.c, line 3759.
> +-- Abort trap: 6

To be honest, I’d rather put short description of bug,
then copying content of ticket (which is available on github).

Sort of:

Make sure that tokens representing values of integer, float,
and blob constants are different from tokens representing
keywords of the same names.

> -- 
> 2.17.1
> 
> ---
> Branch: https://github.com/tarantool/tarantool/tree/sz/gh-3888-values-blob-assert
> Issue: https://github.com/tarantool/tarantool/issues/3888

Next time move these links up.

      reply	other threads:[~2019-01-28 17:30 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-25 10:50 [tarantool-patches] " Stanislav Zudin
2019-01-28 17:30 ` n.pettik [this message]

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=2A6AF308-C6A5-4122-AC73-B429C1487CC5@tarantool.org \
    --to=korablev@tarantool.org \
    --cc=szudin@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='[tarantool-patches] Re: [PATCH] sql: do not let VALUES statement treat the type definition keywords as values' \
    /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