Tarantool development patches archive
 help / color / mirror / Atom feed
From: imeevma@tarantool.org
To: korablev@tarantool.org
Cc: tarantool-patches@freelists.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	[thread overview]
Message-ID: <df273b4cb385e0e4e9f061918e2b54a375358aa1.1558108255.git.imeevma@gmail.com> (raw)

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

             reply	other threads:[~2019-05-17 15:52 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-17 15:51 imeevma [this message]
2019-05-19 12:13 ` [tarantool-patches] " n.pettik
2019-05-21 15:06   ` Mergen Imeev
2019-05-25 13:48     ` n.pettik
2019-06-06 14:13 ` Kirill Yukhin

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=df273b4cb385e0e4e9f061918e2b54a375358aa1.1558108255.git.imeevma@gmail.com \
    --to=imeevma@tarantool.org \
    --cc=korablev@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='Re: [tarantool-patches] [PATCH v1 1/1] sql: make assertion to check only ephemeral spaces' \
    /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