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 02/12] sql: remove error ER_SQL
Date: Sun,  5 May 2019 15:17:04 +0300	[thread overview]
Message-ID: <7ca98c0706d128fee51709a02f3ff04877565b00.1557056617.git.imeevma@gmail.com> (raw)
In-Reply-To: <cover.1557056617.git.imeevma@gmail.com>

The ER_SQL error code is very similar to the ER_SQL_EXECUTE error
code: they have almost identical description and usage. To avoid
misunderstandings, it is better to remove one of them. The ER_SQL
error code has a slightly more vague description, so it was
decided to remove it.
---
 src/box/alter.cc               |  4 ++--
 src/box/errcode.h              |  2 +-
 src/box/sql/build.c            |  2 +-
 src/box/sql/delete.c           |  4 ++--
 src/box/sql/resolve.c          |  2 +-
 src/box/sql/trigger.c          |  6 +++---
 test/box/misc.result           |  1 -
 test/sql-tap/select3.test.lua  |  2 +-
 test/sql-tap/select5.test.lua  | 10 +++++-----
 test/sql-tap/trigger1.test.lua |  6 +++---
 test/sql/delete.result         |  7 ++++---
 test/sql/on-conflict.result    |  4 ++--
 test/sql/triggers.result       | 19 +++++++++++--------
 13 files changed, 36 insertions(+), 33 deletions(-)

diff --git a/src/box/alter.cc b/src/box/alter.cc
index 9279426..fbcff69 100644
--- a/src/box/alter.cc
+++ b/src/box/alter.cc
@@ -3550,7 +3550,7 @@ on_replace_dd_trigger(struct trigger * /* trigger */, void *event)
 		if (strlen(trigger_name) != trigger_name_len ||
 		    memcmp(trigger_name_src, trigger_name,
 			   trigger_name_len) != 0) {
-			tnt_raise(ClientError, ER_SQL,
+			tnt_raise(ClientError, ER_SQL_EXECUTE,
 				  "trigger name does not match extracted "
 				  "from SQL");
 		}
@@ -3558,7 +3558,7 @@ on_replace_dd_trigger(struct trigger * /* trigger */, void *event)
 			tuple_field_u32_xc(new_tuple,
 					   BOX_TRIGGER_FIELD_SPACE_ID);
 		if (space_id != sql_trigger_space_id(new_trigger)) {
-			tnt_raise(ClientError, ER_SQL,
+			tnt_raise(ClientError, ER_SQL_EXECUTE,
 				  "trigger space_id does not match the value "
 				  "resolved on AST building from SQL");
 		}
diff --git a/src/box/errcode.h b/src/box/errcode.h
index 3f8cb8e..6c9bcc4 100644
--- a/src/box/errcode.h
+++ b/src/box/errcode.h
@@ -212,7 +212,7 @@ struct errcode_record {
 	/*157 */_(ER_SQL_BIND_TYPE,             "Bind value type %s for parameter %s is not supported") \
 	/*158 */_(ER_SQL_BIND_PARAMETER_MAX,    "SQL bind parameter limit reached: %d") \
 	/*159 */_(ER_SQL_EXECUTE,               "Failed to execute SQL statement: %s") \
-	/*160 */_(ER_SQL,			"SQL error: %s") \
+	/*160 */_(ER_UNUSED,			"") \
 	/*161 */_(ER_SQL_BIND_NOT_FOUND,	"Parameter %s was not found in the statement") \
 	/*162 */_(ER_ACTION_MISMATCH,		"Field %s contains %s on conflict action, but %s in index parts") \
 	/*163 */_(ER_VIEW_MISSING_SQL,		"Space declared as a view must have SQL statement") \
diff --git a/src/box/sql/build.c b/src/box/sql/build.c
index 72be410..1151425 100644
--- a/src/box/sql/build.c
+++ b/src/box/sql/build.c
@@ -467,7 +467,7 @@ sql_column_add_nullable_action(struct Parse *parser,
 		const char *action =
 			on_conflict_action_strs[field->nullable_action];
 		err = tt_sprintf(err, field->name, def->name, action);
-		diag_set(ClientError, ER_SQL, err);
+		diag_set(ClientError, ER_SQL_EXECUTE, err);
 		parser->is_aborted = true;
 		return;
 	}
diff --git a/src/box/sql/delete.c b/src/box/sql/delete.c
index a95b071..ca59abc 100644
--- a/src/box/sql/delete.c
+++ b/src/box/sql/delete.c
@@ -104,7 +104,7 @@ sql_table_truncate(struct Parse *parse, struct SrcList *tab_list)
 	if (! rlist_empty(&space->parent_fk_constraint)) {
 		const char *err = "can not truncate space '%s' because other "
 				  "objects depend on it";
-		diag_set(ClientError, ER_SQL,
+		diag_set(ClientError, ER_SQL_EXECUTE,
 			 tt_sprintf(err, space->def->name));
 		goto tarantool_error;
 	}
@@ -112,7 +112,7 @@ sql_table_truncate(struct Parse *parse, struct SrcList *tab_list)
 		const char *err_msg =
 			tt_sprintf("can not truncate space '%s' because space "\
 				   "is a view", space->def->name);
-		diag_set(ClientError, ER_SQL, err_msg);
+		diag_set(ClientError, ER_SQL_EXECUTE, err_msg);
 		goto tarantool_error;
 	}
 	sqlVdbeAddOp2(v, OP_Clear, space->def->id, true);
diff --git a/src/box/sql/resolve.c b/src/box/sql/resolve.c
index 504096e..e136312 100644
--- a/src/box/sql/resolve.c
+++ b/src/box/sql/resolve.c
@@ -1333,7 +1333,7 @@ resolveSelectStep(Walker * pWalker, Select * p)
 				return WRC_Abort;
 			if ((sNC.ncFlags & NC_HasAgg) == 0 ||
 			    (sNC.ncFlags & NC_HasUnaggregatedId) != 0) {
-				diag_set(ClientError, ER_SQL, "HAVING "
+				diag_set(ClientError, ER_SQL_EXECUTE, "HAVING "
 					 "argument must appear in the GROUP BY "
 					 "clause or be used in an aggregate "
 					 "function");
diff --git a/src/box/sql/trigger.c b/src/box/sql/trigger.c
index 14e4198..4fdbb60 100644
--- a/src/box/sql/trigger.c
+++ b/src/box/sql/trigger.c
@@ -445,7 +445,7 @@ sql_trigger_replace(const char *name, uint32_t space_id,
 	if (trigger != NULL) {
 		/* Do not create a trigger on a system space. */
 		if (space_is_system(space)) {
-			diag_set(ClientError, ER_SQL,
+			diag_set(ClientError, ER_SQL_EXECUTE,
 				 "cannot create trigger on system table");
 			return -1;
 		}
@@ -454,7 +454,7 @@ sql_trigger_replace(const char *name, uint32_t space_id,
 		 * views only support INSTEAD of triggers.
 		 */
 		if (space->def->opts.is_view && trigger->tr_tm != TK_INSTEAD) {
-			diag_set(ClientError, ER_SQL,
+			diag_set(ClientError, ER_SQL_EXECUTE,
 				 tt_sprintf("cannot create %s "\
                          "trigger on view: %s", trigger->tr_tm == TK_BEFORE ?
 						"BEFORE" : "AFTER",
@@ -462,7 +462,7 @@ sql_trigger_replace(const char *name, uint32_t space_id,
 			return -1;
 		}
 		if (!space->def->opts.is_view && trigger->tr_tm == TK_INSTEAD) {
-			diag_set(ClientError, ER_SQL,
+			diag_set(ClientError, ER_SQL_EXECUTE,
 				 tt_sprintf("cannot create "\
                          "INSTEAD OF trigger on space: %s", space->def->name));
 			return -1;
diff --git a/test/box/misc.result b/test/box/misc.result
index a1f7a09..8eabc57 100644
--- a/test/box/misc.result
+++ b/test/box/misc.result
@@ -489,7 +489,6 @@ t;
   157: box.error.SQL_BIND_TYPE
   158: box.error.SQL_BIND_PARAMETER_MAX
   159: box.error.SQL_EXECUTE
-  160: box.error.SQL
   161: box.error.SQL_BIND_NOT_FOUND
   162: box.error.ACTION_MISMATCH
   163: box.error.VIEW_MISSING_SQL
diff --git a/test/sql-tap/select3.test.lua b/test/sql-tap/select3.test.lua
index cb97363..2807d42 100755
--- a/test/sql-tap/select3.test.lua
+++ b/test/sql-tap/select3.test.lua
@@ -200,7 +200,7 @@ test:do_catchsql_test("select3-3.1", [[
   SELECT log, count(*) FROM t1 HAVING log>=4
 ]], {
   -- <select3-3.1>
-  1, "SQL error: HAVING argument must appear in the GROUP BY clause or be used in an aggregate function"
+  1, "Failed to execute SQL statement: HAVING argument must appear in the GROUP BY clause or be used in an aggregate function"
   -- </select3-3.1>
 })
 
diff --git a/test/sql-tap/select5.test.lua b/test/sql-tap/select5.test.lua
index 1353b39..d34de31 100755
--- a/test/sql-tap/select5.test.lua
+++ b/test/sql-tap/select5.test.lua
@@ -424,7 +424,7 @@ test:do_catchsql_test(
         SELECT s1 FROM te40 HAVING s1 = 1;
     ]], {
     -- <select5-9.1>
-    1, "SQL error: HAVING argument must appear in the GROUP BY clause or be used in an aggregate function"
+    1, "Failed to execute SQL statement: HAVING argument must appear in the GROUP BY clause or be used in an aggregate function"
     -- </select5-9.1>
 })
 
@@ -434,7 +434,7 @@ test:do_catchsql_test(
         SELECT SUM(s1) FROM te40 HAVING s1 = 2;
     ]], {
     -- <select5-9.2>
-    1, "SQL error: HAVING argument must appear in the GROUP BY clause or be used in an aggregate function"
+    1, "Failed to execute SQL statement: HAVING argument must appear in the GROUP BY clause or be used in an aggregate function"
     -- </select5-9.2>
 })
 
@@ -444,7 +444,7 @@ test:do_catchsql_test(
         SELECT s1 FROM te40 HAVING SUM(s1) = 2;
     ]], {
     -- <select5-9.3>
-    1, "SQL error: HAVING argument must appear in the GROUP BY clause or be used in an aggregate function"
+    1, "Failed to execute SQL statement: HAVING argument must appear in the GROUP BY clause or be used in an aggregate function"
     -- </select5-9.3>
 })
 
@@ -484,7 +484,7 @@ test:do_catchsql_test(
         SELECT SUM(s1),s2 FROM te40 HAVING SUM(s1) > 0;
     ]], {
     -- <select5-9.7>
-    1, "SQL error: HAVING argument must appear in the GROUP BY clause or be used in an aggregate function"
+    1, "Failed to execute SQL statement: HAVING argument must appear in the GROUP BY clause or be used in an aggregate function"
     -- </select5-9.7>
 })
 
@@ -494,7 +494,7 @@ test:do_catchsql_test(
         SELECT SUM(s1) FROM te40 HAVING SUM(s1) > 0 and s2 > 0;
     ]], {
     -- <select5-9.8>
-    1, "SQL error: HAVING argument must appear in the GROUP BY clause or be used in an aggregate function"
+    1, "Failed to execute SQL statement: HAVING argument must appear in the GROUP BY clause or be used in an aggregate function"
     -- </select5-9.8>
 })
 
diff --git a/test/sql-tap/trigger1.test.lua b/test/sql-tap/trigger1.test.lua
index 64763fa..38d7c55 100755
--- a/test/sql-tap/trigger1.test.lua
+++ b/test/sql-tap/trigger1.test.lua
@@ -260,7 +260,7 @@ test:do_catchsql_test(
         end;
     ]], {
         -- <trigger1-1.12>
-        1, "SQL error: cannot create INSTEAD OF trigger on space: T1"
+        1, "Failed to execute SQL statement: cannot create INSTEAD OF trigger on space: T1"
         -- </trigger1-1.12>
     })
 
@@ -274,7 +274,7 @@ test:do_catchsql_test(
         end;
     ]], {
         -- <trigger1-1.13>
-        1, "SQL error: cannot create BEFORE trigger on view: V1"
+        1, "Failed to execute SQL statement: cannot create BEFORE trigger on view: V1"
         -- </trigger1-1.13>
     })
 
@@ -289,7 +289,7 @@ test:do_catchsql_test(
         end;
     ]], {
         -- <trigger1-1.14>
-        1, "SQL error: cannot create AFTER trigger on view: V1"
+        1, "Failed to execute SQL statement: cannot create AFTER trigger on view: V1"
         -- </trigger1-1.14>
     })
 
diff --git a/test/sql/delete.result b/test/sql/delete.result
index 0e442e5..0bc389f 100644
--- a/test/sql/delete.result
+++ b/test/sql/delete.result
@@ -128,7 +128,8 @@ box.execute("CREATE VIEW v1 AS SELECT * FROM t1;")
 ...
 box.execute("TRUNCATE TABLE v1;")
 ---
-- error: 'SQL error: can not truncate space ''V1'' because space is a view'
+- error: 'Failed to execute SQL statement: can not truncate space ''V1'' because space
+    is a view'
 ...
 -- Can't truncate table with FK.
 box.execute("CREATE TABLE t2(x INT PRIMARY KEY REFERENCES t1(id));")
@@ -137,8 +138,8 @@ box.execute("CREATE TABLE t2(x INT PRIMARY KEY REFERENCES t1(id));")
 ...
 box.execute("TRUNCATE TABLE t1;")
 ---
-- error: 'SQL error: can not truncate space ''T1'' because other objects depend on
-    it'
+- error: 'Failed to execute SQL statement: can not truncate space ''T1'' because other
+    objects depend on it'
 ...
 -- Table triggers should be ignored.
 box.execute("DROP TABLE t2;")
diff --git a/test/sql/on-conflict.result b/test/sql/on-conflict.result
index 2f29f5b..be89caf 100644
--- a/test/sql/on-conflict.result
+++ b/test/sql/on-conflict.result
@@ -59,8 +59,8 @@ box.execute("CREATE TABLE te17 (s1 INT NULL PRIMARY KEY);")
 ...
 box.execute("CREATE TABLE test (a int PRIMARY KEY, b int NULL ON CONFLICT IGNORE);")
 ---
-- error: 'SQL error: NULL declaration for column ''B'' of table ''TEST'' has been
-    already set to ''none'''
+- error: 'Failed to execute SQL statement: NULL declaration for column ''B'' of table
+    ''TEST'' has been already set to ''none'''
 ...
 box.execute("CREATE TABLE test (a int, b int NULL, c int, PRIMARY KEY(a, b, c))")
 ---
diff --git a/test/sql/triggers.result b/test/sql/triggers.result
index 16df1fb..a4c927c 100644
--- a/test/sql/triggers.result
+++ b/test/sql/triggers.result
@@ -45,22 +45,24 @@ tuple = {"T1t", space_id, {sql = "CREATE TRIGGER t1t AFTER INSERT ON t1 FOR EACH
 ...
 box.space._trigger:insert(tuple)
 ---
-- error: 'SQL error: trigger name does not match extracted from SQL'
+- error: 'Failed to execute SQL statement: trigger name does not match extracted from
+    SQL'
 ...
 tuple = {"T1t", space_id, {sql = "CREATE TRIGGER t12t AFTER INSERT ON t1 FOR EACH ROW BEGIN INSERT INTO t2 VALUES(1); END;"}}
 ---
 ...
 box.space._trigger:insert(tuple)
 ---
-- error: 'SQL error: trigger name does not match extracted from SQL'
+- error: 'Failed to execute SQL statement: trigger name does not match extracted from
+    SQL'
 ...
 tuple = {"T2T", box.space.T1.id + 1, {sql = "CREATE TRIGGER t2t AFTER INSERT ON t1 FOR EACH ROW BEGIN INSERT INTO t2 VALUES(1); END;"}}
 ---
 ...
 box.space._trigger:insert(tuple)
 ---
-- error: 'SQL error: trigger space_id does not match the value resolved on AST building
-    from SQL'
+- error: 'Failed to execute SQL statement: trigger space_id does not match the value
+    resolved on AST building from SQL'
 ...
 immutable_part(box.space._trigger:select())
 ---
@@ -244,7 +246,8 @@ tuple = {"T1T", space_id, {sql = [[create trigger t1t instead of update on t1 fo
 ...
 box.space._trigger:insert(tuple)
 ---
-- error: 'SQL error: cannot create INSTEAD OF trigger on space: T1'
+- error: 'Failed to execute SQL statement: cannot create INSTEAD OF trigger on space:
+    T1'
 ...
 box.execute("CREATE VIEW V1 AS SELECT * FROM t1;")
 ---
@@ -258,14 +261,14 @@ tuple = {"V1T", space_id, {sql = [[create trigger v1t before update on v1 for ea
 ...
 box.space._trigger:insert(tuple)
 ---
-- error: 'SQL error: cannot create BEFORE trigger on view: V1'
+- error: 'Failed to execute SQL statement: cannot create BEFORE trigger on view: V1'
 ...
 tuple = {"V1T", space_id, {sql = [[create trigger v1t AFTER update on v1 for each row begin delete from t1 WHERE a=old.a+2; end;]]}}
 ---
 ...
 box.space._trigger:insert(tuple)
 ---
-- error: 'SQL error: cannot create AFTER trigger on view: V1'
+- error: 'Failed to execute SQL statement: cannot create AFTER trigger on view: V1'
 ...
 space_id =  box.space._fk_constraint.id
 ---
@@ -275,7 +278,7 @@ tuple = {"T1T", space_id, {sql = [[create trigger t1t instead of update on "_fk_
 ...
 box.space._trigger:insert(tuple)
 ---
-- error: 'SQL error: cannot create trigger on system table'
+- error: 'Failed to execute SQL statement: cannot create trigger on system table'
 ...
 box.execute("DROP VIEW V1;")
 ---
-- 
2.7.4

  parent reply	other threads:[~2019-05-05 12:17 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-05 12:17 [tarantool-patches] [PATCH v1 00/12] sql: set errors in VDBE using diag_set() imeevma
2019-05-05 12:17 ` [tarantool-patches] [PATCH v1 01/12] sql: remove errors SQL_TARANTOOL_*_FAIL imeevma
2019-05-15 13:18   ` [tarantool-patches] " n.pettik
2019-05-25  9:16     ` Imeev Mergen
2019-05-05 12:17 ` imeevma [this message]
2019-05-15 13:18   ` [tarantool-patches] Re: [PATCH v1 02/12] sql: remove error ER_SQL n.pettik
2019-05-05 12:17 ` [tarantool-patches] [PATCH v1 03/12] sql: rework diag_set() in OP_Halt imeevma
2019-05-15 13:18   ` [tarantool-patches] " n.pettik
2019-05-05 12:17 ` [tarantool-patches] [PATCH v1 04/12] sql: make SQL_TARANTOOL_ERROR the only errcode of OP_Halt imeevma
2019-05-15 13:18   ` [tarantool-patches] " n.pettik
2019-05-25  9:18     ` Imeev Mergen
2019-05-05 12:17 ` [tarantool-patches] [PATCH v1 05/12] sql: remove error SQL_INTERRUPT imeevma
2019-05-15 13:18   ` [tarantool-patches] " n.pettik
2019-05-05 12:17 ` [tarantool-patches] [PATCH v1 06/12] sql: remove error SQL_MISMATCH imeevma
2019-05-15 13:19   ` [tarantool-patches] " n.pettik
2019-05-05 12:17 ` [tarantool-patches] [PATCH v1 07/12] sql: set errors in VDBE using diag_set() imeevma
2019-05-15 13:26   ` [tarantool-patches] " n.pettik
2019-05-25 10:24     ` Mergen Imeev
2019-05-25 10:36       ` Imeev Mergen
2019-05-05 12:17 ` [tarantool-patches] [PATCH v1 08/12] sql: remove field zErrMsg from struct Vdbe imeevma
2019-05-15 13:30   ` [tarantool-patches] " n.pettik
2019-05-25  9:25     ` Imeev Mergen
2019-05-05 12:17 ` [tarantool-patches] [PATCH v1 09/12] sql: remove field pErr from struct sql imeevma
2019-05-05 12:17 ` [tarantool-patches] [PATCH v1 10/12] sql: remove field errCode " imeevma
2019-05-15 13:32   ` [tarantool-patches] " n.pettik
2019-05-25  9:25     ` Imeev Mergen
2019-05-05 12:17 ` [tarantool-patches] [PATCH v1 11/12] sql: remove sqlError() and remove sqlErrorWithMsg() imeevma
2019-05-05 12:17 ` [tarantool-patches] [PATCH v1 12/12] sql: use diag_set() to set an error in SQL functions imeevma
2019-05-15 14:12   ` [tarantool-patches] " n.pettik
2019-05-25  9:45     ` Mergen Imeev
2019-05-25 10:36       ` Imeev Mergen

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=7ca98c0706d128fee51709a02f3ff04877565b00.1557056617.git.imeevma@gmail.com \
    --to=imeevma@tarantool.org \
    --cc=korablev@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='Re: [tarantool-patches] [PATCH v1 02/12] sql: remove error ER_SQL' \
    /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