[Tarantool-patches] [tarantool-patches] [PATCH v4 4/4] sql: use name instead of function pointer for UDF

Nikita Pettik korablev at tarantool.org
Tue Oct 15 18:15:57 MSK 2019


On 15 Oct 14:13, Kirill Shcherbatov wrote:
> > Could you add test case covering mentioned situation?
> Yes. Appended.
> 
> =================================================
> 
> This patch changes OP_Function parameters convention: now a
> function's name is passed instead of pointer to the function
> object. This allows to normally handle the situation, when UDF
> has been deleted to the moment of the VDBE code execution.
> In particular case this may happen with CK constraints that
> refers to a deleted persistent function.
> 
> Closes #4176
> ---
>  src/box/sql/expr.c       | 17 ++++++++++++-----
>  src/box/sql/vdbe.c       | 11 ++++++++---
>  test/sql/checks.result   | 28 ++++++++++++++++++++++++++++
>  test/sql/checks.test.lua | 11 +++++++++++
>  4 files changed, 59 insertions(+), 8 deletions(-)
> 
> diff --git a/test/sql/checks.result b/test/sql/checks.result
> index b8bd19a84..02ee82a4b 100644
> --- a/test/sql/checks.result
> +++ b/test/sql/checks.result
> @@ -918,6 +918,34 @@ box.execute("DROP TABLE test;")
>  ---
>  - row_count: 1
>  ...
> +--
> +-- gh-4176: Can't recover if check constraint involves function.
> +--
> +function myfunc(x) return x < 10 end
> +---
> +...
> +box.schema.func.create('MYFUNC', {param_list = {'integer'}, returns = 'integer', is_deterministic = true, exports = {'LUA', 'SQL'}})
> +---
> +...
> +box.execute("CREATE TABLE t6(a  INT CHECK (myfunc(a)) primary key);");
> +---
> +- row_count: 1
> +...
> +myfunc = nil
> +---
> +...
> +box.execute("INSERT INTO t6 VALUES(11);");
> +---
> +- null
> +- Procedure 'MYFUNC' is not defined

Something is wrong with this test case. Firstly, it works fine
even on master branch. Secondly, I've dropped myfunc = nil and
got the same error (on master as well) - i.e. INSERT fails with
'procedure is not defined' error even if function is not dropped.
Obviously, to make it crash on master you should drop function
before insertion; to fix second problem you should uppercase function's
name.

> +box.execute("DROP TABLE t6")
> +---
> +- row_count: 1
> +...
> +box.func.MYFUNC:drop()
> +---
> +...
>  test_run:cmd("clear filter")
>  ---
>  - true
> diff --git a/test/sql/checks.test.lua b/test/sql/checks.test.lua
> index 832322190..fa68920f6 100644
> --- a/test/sql/checks.test.lua
> +++ b/test/sql/checks.test.lua
> @@ -302,4 +302,15 @@ assert(box.space.TEST.ck_constraint.some_ck.is_enabled == true)
>  box.space.TEST:insert({12})
>  box.execute("DROP TABLE test;")
>  
> +--
> +-- gh-4176: Can't recover if check constraint involves function.
> +--
> +function myfunc(x) return x < 10 end
> +box.schema.func.create('MYFUNC', {param_list = {'integer'}, returns = 'integer', is_deterministic = true, exports = {'LUA', 'SQL'}})
> +box.execute("CREATE TABLE t6(a  INT CHECK (myfunc(a)) primary key);");
> +myfunc = nil
> +box.execute("INSERT INTO t6 VALUES(11);");
> +box.execute("DROP TABLE t6")
> +box.func.MYFUNC:drop()
> +
>  test_run:cmd("clear filter")
> -- 
> 2.23.0
> 


More information about the Tarantool-patches mailing list