[patches] [PATCH V2 1/2] sql: fix non-working 'INDEXED BY' clause

Bulat Niatshin niatshin at tarantool.org
Mon Mar 5 15:22:12 MSK 2018


Fix non-working 'INDEXED BY' clause for SELECT statement,
which caused syntax-error during execution.

Closes #2996
---
 src/box/sql/parse.y                 |  2 +-
 test/sql/gh2966-indexed-by.result   | 21 +++++++++++++++++++++
 test/sql/gh2966-indexed-by.test.lua | 10 ++++++++++
 3 files changed, 32 insertions(+), 1 deletion(-)
 create mode 100644 test/sql/gh2966-indexed-by.result
 create mode 100644 test/sql/gh2966-indexed-by.test.lua

diff --git a/src/box/sql/parse.y b/src/box/sql/parse.y
index 914fc53b8..f87672ca4 100644
--- a/src/box/sql/parse.y
+++ b/src/box/sql/parse.y
@@ -205,7 +205,7 @@ columnname(A) ::= nm(A) typetoken(Y). {sqlite3AddColumn(pParse,&A,&Y);}
 %fallback ID
   ABORT ACTION ADD AFTER AUTOINCREMENT BEFORE CASCADE
   CONFLICT DEFERRED END FAIL
-  IGNORE INDEXED INITIALLY INSTEAD ISNULL NO NOTNULL  MATCH PLAN
+  IGNORE INITIALLY INSTEAD ISNULL NO NOTNULL  MATCH PLAN
   QUERY KEY OFFSET RAISE RELEASE REPLACE RESTRICT
 %ifdef SQLITE_OMIT_COMPOUND_SELECT
   INTERSECT 
diff --git a/test/sql/gh2966-indexed-by.result b/test/sql/gh2966-indexed-by.result
new file mode 100644
index 000000000..6a39d2f9b
--- /dev/null
+++ b/test/sql/gh2966-indexed-by.result
@@ -0,0 +1,21 @@
+box.cfg{}
+---
+...
+-- Check that 'INDEXED BY' clause works correctly without
+-- raising syntax error, which happened earlier after keyword patch
+-- (ban keywords reserved by standard)
+box.sql.execute("CREATE TABLE a (id PRIMARY KEY, a INTEGER);");
+---
+...
+box.sql.execute("CREATE INDEX i on a(a);");
+---
+...
+box.sql.execute("INSERT INTO a VALUES (1,2), (3,4), (5,6);");
+---
+...
+box.sql.execute("SELECT id FROM a INDEXED BY i");
+---
+- - [1]
+  - [3]
+  - [5]
+...
diff --git a/test/sql/gh2966-indexed-by.test.lua b/test/sql/gh2966-indexed-by.test.lua
new file mode 100644
index 000000000..e67ab18f4
--- /dev/null
+++ b/test/sql/gh2966-indexed-by.test.lua
@@ -0,0 +1,10 @@
+box.cfg{}
+
+-- Check that 'INDEXED BY' clause works correctly without
+-- raising syntax error, which happened earlier after keyword patch
+-- (ban keywords reserved by standard)
+
+box.sql.execute("CREATE TABLE a (id PRIMARY KEY, a INTEGER);");
+box.sql.execute("CREATE INDEX i on a(a);");
+box.sql.execute("INSERT INTO a VALUES (1,2), (3,4), (5,6);");
+box.sql.execute("SELECT id FROM a INDEXED BY i");
-- 
2.14.1




More information about the Tarantool-patches mailing list