Tarantool development patches archive
 help / color / mirror / Atom feed
* [tarantool-patches] [PATCH v1 1/1] sql: make assertion to check only ephemeral spaces
@ 2019-05-17 15:51 imeevma
  2019-05-19 12:13 ` [tarantool-patches] " n.pettik
  2019-06-06 14:13 ` Kirill Yukhin
  0 siblings, 2 replies; 5+ messages in thread
From: imeevma @ 2019-05-17 15:51 UTC (permalink / raw)
  To: korablev; +Cc: tarantool-patches

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-06-06 14:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-17 15:51 [tarantool-patches] [PATCH v1 1/1] sql: make assertion to check only ephemeral spaces imeevma
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox