[tarantool-patches] Re: [PATCH v1 3/3] sql: dissallow bindings for DDL

n.pettik korablev at tarantool.org
Tue Sep 11 00:52:59 MSK 2018


>    sql: dissallow bindings for DDL
> 
>    Bindings could not be used in stored ASTs because they allocate
>    memory registers and process assignments during parsing(temporal register
>    should be allocated for each variable in parse context, but it is temporal).
>    Original sqlite3 did validations that AST to be persisted doesn't have
>    auto-assigment Varibles on triggers and checks creation.
>    On DDL integration completion we've got rid this mechanism.
>    Now it should be returned.
>    We use flag 'parse_only' which is set by parser on compiling AST to
>    determine attempt to use bindings in DDL(triggers, defaults and checks
>    creation) that is incorrect and raise an error.
> 
>    Closes #3653.

Please, don’t *silently* skip my comments (yep, still they are minor but
should be taken into consideration since the rest of patch is OK):

‘''
Could we keep previous error message? It looks satisfactory actually.
The same for triggers: could we use message like
“Failed to create trigger ‘…’: parameters prohibited in trigger definition”?
Or present your persuasive arguments :)
‘’’

I ‘member that we discussed smth about error messages but really
can’t recall exactly what. So, please, answer on this nit or fix it.

> diff --git a/test/sql/checks.test.lua b/test/sql/checks.test.lua
> index fb95809..3506d5c 100644
> --- a/test/sql/checks.test.lua
> +++ b/test/sql/checks.test.lua
> @@ -43,11 +43,27 @@ format = {{name = 'X', type = 'unsigned'}}
> t = {513, 1, 'test', 'memtx', 0, opts, format}
> s = box.space._space:insert(t)
> 
> -
> --
> -- gh-3611: Segfault on table creation with check referencing this table
> --
> box.sql.execute("CREATE TABLE w2 (s1 INT PRIMARY KEY, CHECK ((SELECT COUNT(*) FROM w2) = 0));")
> box.sql.execute("DROP TABLE w2;")
> 
> +--
> +-- gh-3653: Dissallow bindings for DDL
> +--
> +box.sql.execute("CREATE TABLE t1(a INT PRIMARY KEY, b INT);")
> +space_id = box.space.T1.id
> +box.sql.execute("CREATE TRIGGER tr1 AFTER INSERT ON t1 WHEN new.a = ? BEGIN SELECT 1; END;")
> +tuple = {"TR1", space_id, {sql = [[CREATE TRIGGER tr1 AFTER INSERT ON t1 WHEN new.a = ? BEGIN SELECT 1; END;]]}}

This test should be moved to test/sql/triggers.test.lua
(Since this test is about checks only).






More information about the Tarantool-patches mailing list