Tarantool development patches archive
 help / color / mirror / Atom feed
From: Nikita Pettik <korablev@tarantool.org>
To: Kirill Shcherbatov <kshcherbatov@tarantool.org>
Cc: tarantool-patches@freelists.org, tarantool-patches@dev.tarantool.org
Subject: Re: [Tarantool-patches] [tarantool-patches] [PATCH v4 4/4] sql: use name instead of function pointer for UDF
Date: Tue, 15 Oct 2019 18:15:57 +0300	[thread overview]
Message-ID: <20191015151557.GA93939@tarantool.org> (raw)
In-Reply-To: <af095dba-bacd-e35f-9143-30ae59188697@tarantool.org>

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
> 

  parent reply	other threads:[~2019-10-15 15:15 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1570539526.git.kshcherbatov@tarantool.org>
     [not found] ` <8232b0466f3878280a9ad35cb08f437610a36486.1570539526.git.kshcherbatov@tarantool.org>
2019-10-14 16:49   ` [Tarantool-patches] [tarantool-patches] [PATCH v4 1/4] box: add an ability to disable CK constraints Nikita Pettik
2019-10-15 11:13     ` [Tarantool-patches] [tarantool-patches] " Kirill Shcherbatov
2019-10-15 21:47       ` Nikita Pettik
2019-10-16  5:52         ` Konstantin Osipov
2019-10-16 11:19           ` Nikita Pettik
2019-10-16 13:50             ` Kirill Shcherbatov
2019-10-16 18:09               ` Nikita Pettik
     [not found] ` <d4002407f749fff0c1f0facb1ed4cf66b8b7edd6.1570539526.git.kshcherbatov@tarantool.org>
2019-10-14 16:56   ` [Tarantool-patches] [tarantool-patches] [PATCH v4 2/4] sql: " Nikita Pettik
2019-10-15 11:13     ` [Tarantool-patches] [tarantool-patches] " Kirill Shcherbatov
2019-10-16 18:10       ` Nikita Pettik
     [not found] ` <f462f55eebcb13abb8a0611a4d84d7ed8b1a6b6a.1570539526.git.kshcherbatov@tarantool.org>
     [not found]   ` <af095dba-bacd-e35f-9143-30ae59188697@tarantool.org>
2019-10-15 15:15     ` Nikita Pettik [this message]
2019-10-16 13:51       ` [Tarantool-patches] [tarantool-patches] Re: [PATCH v4 4/4] sql: use name instead of function pointer for UDF Kirill Shcherbatov
2019-10-16 18:08         ` Nikita Pettik
     [not found] ` <4eb8f545449842bc4c468ccf50c494e4c44c32d6.1570539526.git.kshcherbatov@tarantool.org>
     [not found]   ` <20191013125109.GA24391@atlas>
     [not found]     ` <7114925b-190a-4f0d-409f-974d2e6a65dd@tarantool.org>
2019-10-17 13:58       ` [Tarantool-patches] [tarantool-patches] Re: [PATCH v4 3/4] box: do not evaluate ck constraints on recovery Nikita Pettik
2019-10-17 14:12         ` Konstantin Osipov
2019-10-17 14:39           ` Nikita Pettik
2019-10-17 15:18             ` Konstantin Osipov
2019-10-17 16:28               ` 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=20191015151557.GA93939@tarantool.org \
    --to=korablev@tarantool.org \
    --cc=kshcherbatov@tarantool.org \
    --cc=tarantool-patches@dev.tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='Re: [Tarantool-patches] [tarantool-patches] [PATCH v4 4/4] sql: use name instead of function pointer for UDF' \
    /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