[tarantool-patches] [PATCH v4 6/8] sql: rework three errors of "unsupported" type

imeevma at tarantool.org imeevma at tarantool.org
Wed Mar 13 20:03:17 MSK 2019


Three errors of "unsupported" type were reworked in this patch.

Part of #3965
---
 src/box/errcode.h              |  1 +
 src/box/sql/analyze.c          |  7 ++++---
 src/box/sql/select.c           | 10 ++++++----
 test/box/misc.result           |  1 +
 test/sql-tap/analyzeD.test.lua |  2 +-
 test/sql-tap/join.test.lua     |  2 +-
 test/sql-tap/with1.test.lua    |  2 +-
 7 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/src/box/errcode.h b/src/box/errcode.h
index d234d26..7764aa3 100644
--- a/src/box/errcode.h
+++ b/src/box/errcode.h
@@ -239,6 +239,7 @@ struct errcode_record {
 	/*184 */_(ER_SQL_UNRECOGNIZED_SYNTAX,	"Syntax error near '%.*s'") \
 	/*185 */_(ER_SQL_UNKNOWN_TOKEN,		"Syntax error: unrecognized token: '%.*s'") \
 	/*186 */_(ER_SQL_PARSER_GENERIC,	"%s") \
+	/*187 */_(ER_SQL_ANALYZE_ARGUMENT,	"ANALYZE statement argument %s is not a base table") \
 
 /*
  * !IMPORTANT! Please follow instructions at start of the file
diff --git a/src/box/sql/analyze.c b/src/box/sql/analyze.c
index f95b34b..6ea598c 100644
--- a/src/box/sql/analyze.c
+++ b/src/box/sql/analyze.c
@@ -1121,9 +1121,10 @@ sqlAnalyze(Parse * pParse, Token * pName)
 			struct space *sp = space_by_name(z);
 			if (sp != NULL) {
 				if (sp->def->opts.is_view) {
-					sqlErrorMsg(pParse, "VIEW isn't "\
-							"allowed to be "\
-							"analyzed");
+					diag_set(ClientError,
+						 ER_SQL_ANALYZE_ARGUMENT,
+						 sp->def->name);
+					pParse->is_aborted = true;
 				} else {
 					vdbe_emit_analyze_table(pParse, sp);
 				}
diff --git a/src/box/sql/select.c b/src/box/sql/select.c
index 9a8ea9d..e26b08b 100644
--- a/src/box/sql/select.c
+++ b/src/box/sql/select.c
@@ -407,8 +407,9 @@ sqlJoinType(Parse * pParse, Token * pA, Token * pB, Token * pC)
 		jointype = JT_INNER;
 	} else if ((jointype & JT_OUTER) != 0
 		   && (jointype & (JT_LEFT | JT_RIGHT)) != JT_LEFT) {
-		sqlErrorMsg(pParse,
-				"RIGHT and FULL OUTER JOINs are not currently supported");
+		diag_set(ClientError, ER_UNSUPPORTED, "Tarantool",
+			 "RIGHT and FULL OUTER JOINs");
+		pParse->is_aborted = true;
 		jointype = JT_INNER;
 	}
 	return jointype;
@@ -2465,8 +2466,9 @@ generateWithRecursiveQuery(Parse * pParse,	/* Parsing context */
 	 * the value for the recursive-table. Store the results in the Queue.
 	 */
 	if (p->selFlags & SF_Aggregate) {
-		sqlErrorMsg(pParse,
-				"recursive aggregate queries not supported");
+		diag_set(ClientError, ER_UNSUPPORTED, "Tarantool",
+			 "recursive aggregate queries");
+		pParse->is_aborted = true;
 	} else {
 		p->pPrior = 0;
 		sqlSelect(pParse, p, &destQueue);
diff --git a/test/box/misc.result b/test/box/misc.result
index 9f0b2c7..c350bbd 100644
--- a/test/box/misc.result
+++ b/test/box/misc.result
@@ -515,6 +515,7 @@ t;
   184: box.error.SQL_UNRECOGNIZED_SYNTAX
   185: box.error.SQL_UNKNOWN_TOKEN
   186: box.error.SQL_PARSER_GENERIC
+  187: box.error.SQL_ANALYZE_ARGUMENT
 ...
 test_run:cmd("setopt delimiter ''");
 ---
diff --git a/test/sql-tap/analyzeD.test.lua b/test/sql-tap/analyzeD.test.lua
index 82ad7ff..1f00e80 100755
--- a/test/sql-tap/analyzeD.test.lua
+++ b/test/sql-tap/analyzeD.test.lua
@@ -177,7 +177,7 @@ test:do_catchsql_test(
 		ANALYZE v;
 	]], {
 		-- <analyzeD-1.12>
-		1, "VIEW isn't allowed to be analyzed"
+		1, "ANALYZE statement argument V is not a base table"
 		-- <analyzeD-1.12>
 	})
 
diff --git a/test/sql-tap/join.test.lua b/test/sql-tap/join.test.lua
index df272a9..da29f77 100755
--- a/test/sql-tap/join.test.lua
+++ b/test/sql-tap/join.test.lua
@@ -480,7 +480,7 @@ test:do_catchsql_test(
         SELECT * FROM t1 NATURAL RIGHT OUTER JOIN t2;
     ]], {
         -- <join-2.3>
-        1, "RIGHT and FULL OUTER JOINs are not currently supported"
+        1, "Tarantool does not support RIGHT and FULL OUTER JOINs"
         -- </join-2.3>
     })
 
diff --git a/test/sql-tap/with1.test.lua b/test/sql-tap/with1.test.lua
index add2345..16c9b12 100755
--- a/test/sql-tap/with1.test.lua
+++ b/test/sql-tap/with1.test.lua
@@ -1065,7 +1065,7 @@ test:do_catchsql_test(16.1, [[
   SELECT * FROM i;
 ]], {
   -- <16.1>
-  1, "recursive aggregate queries not supported"
+  1, "Tarantool does not support recursive aggregate queries"
   -- </16.1>
 })
 
-- 
2.7.4





More information about the Tarantool-patches mailing list