From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 0A16D2BD18 for ; Sun, 5 May 2019 08:17:07 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id mzAUpSqcKfDb for ; Sun, 5 May 2019 08:17:06 -0400 (EDT) Received: from smtpng3.m.smailru.net (smtpng3.m.smailru.net [94.100.177.149]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id 7E8D62BF3B for ; Sun, 5 May 2019 08:17:06 -0400 (EDT) From: imeevma@tarantool.org Subject: [tarantool-patches] [PATCH v1 02/12] sql: remove error ER_SQL Date: Sun, 5 May 2019 15:17:04 +0300 Message-Id: <7ca98c0706d128fee51709a02f3ff04877565b00.1557056617.git.imeevma@gmail.com> In-Reply-To: References: Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-Help: List-Unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-Subscribe: List-Owner: List-post: List-Archive: To: korablev@tarantool.org Cc: tarantool-patches@freelists.org 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 ]], { -- - 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" -- }) 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; ]], { -- - 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" -- }) @@ -434,7 +434,7 @@ test:do_catchsql_test( SELECT SUM(s1) FROM te40 HAVING s1 = 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" -- }) @@ -444,7 +444,7 @@ test:do_catchsql_test( SELECT s1 FROM te40 HAVING SUM(s1) = 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" -- }) @@ -484,7 +484,7 @@ test:do_catchsql_test( SELECT SUM(s1),s2 FROM te40 HAVING SUM(s1) > 0; ]], { -- - 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" -- }) @@ -494,7 +494,7 @@ test:do_catchsql_test( SELECT SUM(s1) FROM te40 HAVING SUM(s1) > 0 and s2 > 0; ]], { -- - 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" -- }) 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; ]], { -- - 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" -- }) @@ -274,7 +274,7 @@ test:do_catchsql_test( end; ]], { -- - 1, "SQL error: cannot create BEFORE trigger on view: V1" + 1, "Failed to execute SQL statement: cannot create BEFORE trigger on view: V1" -- }) @@ -289,7 +289,7 @@ test:do_catchsql_test( end; ]], { -- - 1, "SQL error: cannot create AFTER trigger on view: V1" + 1, "Failed to execute SQL statement: cannot create AFTER trigger on view: V1" -- }) 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