[tarantool-patches] Re: [PATCH] sql: do not let VALUES statement treat the type definition keywords as values

n.pettik korablev at tarantool.org
Mon Jan 28 20:30:31 MSK 2019


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.





More information about the Tarantool-patches mailing list