From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp29.i.mail.ru (smtp29.i.mail.ru [94.100.177.89]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id B148046970E for ; Sun, 22 Dec 2019 18:00:43 +0300 (MSK) References: <20191221185730.16148-1-k.sosnin@tarantool.org> From: Vladislav Shpilevoy Message-ID: <980af590-b69a-26ed-690f-d7ecadf3749e@tarantool.org> Date: Sun, 22 Dec 2019 16:00:41 +0100 MIME-Version: 1.0 In-Reply-To: <20191221185730.16148-1-k.sosnin@tarantool.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [Tarantool-patches] [PATCH] sql: fix assertion fail when selecting from _vfunc List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Chris Sosnin , tarantool-patches@dev.tarantool.org, Kirill Yukhin LGTM. On 21/12/2019 19:57, Chris Sosnin wrote: > Hi! Thank you for the review and for your fixes! > > I agree with your changes, although I had to fix the test > because it does not fail even without this fix. New query > will cause assertion with an old format. > The patch below: > > The assertion mentioned #4666 fails because it was forgotten to update > _vfunc format along with _func in 2.2.1. This leads to bad allocation > of vdbe cursor and setting wrong memory to 0. > > Closes #4666 > --- > branch: https://github.com/tarantool/tarantool/tree/ksosnin/gh-4666-select-from-vfunc > issue: https://github.com/tarantool/tarantool/issues/4666 > > src/box/bootstrap.snap | Bin 5921 -> 5916 bytes > src/box/lua/upgrade.lua | 7 +++++++ > test/box-py/bootstrap.result | 9 ++++++++- > test/sql/engine.cfg | 1 + > test/sql/gh-4666-sql-select-from-vfunc.result | 11 +++++++++++ > .../gh-4666-sql-select-from-vfunc.test.lua | 4 ++++ > 6 files changed, 31 insertions(+), 1 deletion(-) > create mode 100644 test/sql/gh-4666-sql-select-from-vfunc.result > create mode 100644 test/sql/gh-4666-sql-select-from-vfunc.test.lua > > diff --git a/src/box/lua/upgrade.lua b/src/box/lua/upgrade.lua > index 07f1e0317..e57c23547 100644 > --- a/src/box/lua/upgrade.lua > +++ b/src/box/lua/upgrade.lua > @@ -951,8 +951,15 @@ local function drop_func_collation() > _func.index.name:alter({parts = {{'name', 'string'}}}) > end > > +local function update_vfunc_format() > + local _func = box.space[box.schema.FUNC_ID] > + local _vfunc = box.space[box.schema.VFUNC_ID] > + _vfunc:format(_func:format()) > +end > + > local function upgrade_to_2_3_1() > drop_func_collation() > + update_vfunc_format() > end > > -------------------------------------------------------------------------------- > diff --git a/test/box-py/bootstrap.result b/test/box-py/bootstrap.result > index 938a7631e..56bb43872 100644 > --- a/test/box-py/bootstrap.result > +++ b/test/box-py/bootstrap.result > @@ -63,7 +63,14 @@ box.space._space:select{} > 'type': 'string'}, {'name': 'last_altered', 'type': 'string'}]] > - [297, 1, '_vfunc', 'sysview', 0, {}, [{'name': 'id', 'type': 'unsigned'}, {'name': 'owner', > 'type': 'unsigned'}, {'name': 'name', 'type': 'string'}, {'name': 'setuid', > - 'type': 'unsigned'}]] > + 'type': 'unsigned'}, {'name': 'language', 'type': 'string'}, {'name': 'body', > + 'type': 'string'}, {'name': 'routine_type', 'type': 'string'}, {'name': 'param_list', > + 'type': 'array'}, {'name': 'returns', 'type': 'string'}, {'name': 'aggregate', > + 'type': 'string'}, {'name': 'sql_data_access', 'type': 'string'}, {'name': 'is_deterministic', > + 'type': 'boolean'}, {'name': 'is_sandboxed', 'type': 'boolean'}, {'name': 'is_null_call', > + 'type': 'boolean'}, {'name': 'exports', 'type': 'array'}, {'name': 'opts', > + 'type': 'map'}, {'name': 'comment', 'type': 'string'}, {'name': 'created', > + 'type': 'string'}, {'name': 'last_altered', 'type': 'string'}]] > - [304, 1, '_user', 'memtx', 0, {}, [{'name': 'id', 'type': 'unsigned'}, {'name': 'owner', > 'type': 'unsigned'}, {'name': 'name', 'type': 'string'}, {'name': 'type', > 'type': 'string'}, {'name': 'auth', 'type': 'map'}]] > diff --git a/test/sql/engine.cfg b/test/sql/engine.cfg > index 284c42082..5e8199ad8 100644 > --- a/test/sql/engine.cfg > +++ b/test/sql/engine.cfg > @@ -5,6 +5,7 @@ > "sql-debug.test.lua": { > "memtx": {"engine": "memtx"} > }, > + "gh-4666-sql-select-from-vfunc.test.lua": { }, > "bind.test.lua": { > "remote": {"remote": "true"}, > "local": {"remote": "false"} > diff --git a/test/sql/gh-4666-sql-select-from-vfunc.result b/test/sql/gh-4666-sql-select-from-vfunc.result > new file mode 100644 > index 000000000..d57c66867 > --- /dev/null > +++ b/test/sql/gh-4666-sql-select-from-vfunc.result > @@ -0,0 +1,11 @@ > +-- > +-- Make sure assertion does not fail. > +-- > +box.execute([[select "id" from "_vfunc" where "id" = 1;]]) > +--- > +- metadata: > + - name: id > + type: unsigned > + rows: > + - [1] > +... > diff --git a/test/sql/gh-4666-sql-select-from-vfunc.test.lua b/test/sql/gh-4666-sql-select-from-vfunc.test.lua > new file mode 100644 > index 000000000..fa296e1e1 > --- /dev/null > +++ b/test/sql/gh-4666-sql-select-from-vfunc.test.lua > @@ -0,0 +1,4 @@ > +-- > +-- Make sure assertion does not fail. > +-- > +box.execute([[select "id" from "_vfunc" where "id" = 1;]]) >