From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id BEAAE2FA68 for ; Fri, 17 May 2019 11:52:00 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id sqYIuCxWb6Vp for ; Fri, 17 May 2019 11:52:00 -0400 (EDT) Received: from smtp49.i.mail.ru (smtp49.i.mail.ru [94.100.177.109]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id 7A66B2FA65 for ; Fri, 17 May 2019 11:52:00 -0400 (EDT) From: imeevma@tarantool.org Subject: [tarantool-patches] [PATCH v1 1/1] sql: make assertion to check only ephemeral spaces Date: Fri, 17 May 2019 18:51:58 +0300 Message-Id: Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-Help: List-Unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-Subscribe: List-Owner: List-post: List-Archive: To: korablev@tarantool.org Cc: tarantool-patches@freelists.org At some point, it became possible to use SELECT on spaces created in Lua. Since it is allowed to create temporary spaces in Lua, this led to an error. To avoid this error, now not all temporary spaces are checked, but only ephemeral spaces. Close #4139 --- https://github.com/tarantool/tarantool/issues/4139 https://github.com/tarantool/tarantool/tree/imeevma/gh-4139-assertion-on-temporary-space src/box/sql.c | 1 + src/box/sql/build.c | 6 +++--- test/sql/misc.result | 22 ++++++++++++++++++++++ test/sql/misc.test.lua | 9 +++++++++ 4 files changed, 35 insertions(+), 3 deletions(-) diff --git a/src/box/sql.c b/src/box/sql.c index fbfa599..3bf263d 100644 --- a/src/box/sql.c +++ b/src/box/sql.c @@ -1281,6 +1281,7 @@ sql_ephemeral_space_def_new(struct Parse *parser, const char *name) memcpy(def->name, name, name_len); def->name[name_len] = '\0'; def->opts.is_temporary = true; + def->opts.is_ephemeral = true; return def; } diff --git a/src/box/sql/build.c b/src/box/sql/build.c index 6051a25..33005c5 100644 --- a/src/box/sql/build.c +++ b/src/box/sql/build.c @@ -2762,14 +2762,14 @@ sqlSrcListDelete(sql * db, SrcList * pList) if (pItem->fg.isTabFunc) sql_expr_list_delete(db, pItem->u1.pFuncArg); /* - * Space is either not temporary which means that - * it came from space cache; or space is temporary + * Space is either not ephemeral which means that + * it came from space cache; or space is ephemeral * but has no indexes and check constraints. * The latter proves that it is not the space * which might come from CREATE TABLE routines. */ assert(pItem->space == NULL || - !pItem->space->def->opts.is_temporary || + !pItem->space->def->opts.is_ephemeral || (pItem->space->index == NULL && pItem->space->def->opts.checks == NULL)); sql_select_delete(db, pItem->pSelect); diff --git a/test/sql/misc.result b/test/sql/misc.result index b117e15..bc8b10e 100644 --- a/test/sql/misc.result +++ b/test/sql/misc.result @@ -106,3 +106,25 @@ box.execute('SELECT X\'4D6564766564\'') rows: - ['Medved'] ... +-- +-- gh-4139: assertion when reading a temporary space. +-- +format = {{name = 'id', type = 'integer'}} +--- +... +s = box.schema.space.create('s',{format=format, temporary=true}) +--- +... +i = s:create_index('i') +--- +... +box.execute('select * from "s"') +--- +- metadata: + - name: id + type: integer + rows: [] +... +s:drop() +--- +... diff --git a/test/sql/misc.test.lua b/test/sql/misc.test.lua index 0b1c34d..fdc19f3 100644 --- a/test/sql/misc.test.lua +++ b/test/sql/misc.test.lua @@ -26,3 +26,12 @@ box.execute('SELECT 1.5;') box.execute('SELECT 1.0;') box.execute('SELECT \'abc\';') box.execute('SELECT X\'4D6564766564\'') + +-- +-- gh-4139: assertion when reading a temporary space. +-- +format = {{name = 'id', type = 'integer'}} +s = box.schema.space.create('s',{format=format, temporary=true}) +i = s:create_index('i') +box.execute('select * from "s"') +s:drop() -- 2.7.4