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 344802759A for ; Wed, 20 Feb 2019 04:47:42 -0500 (EST) 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 ec5no7Mf6cAj for ; Wed, 20 Feb 2019 04:47:42 -0500 (EST) Received: from smtp40.i.mail.ru (smtp40.i.mail.ru [94.100.177.100]) (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 5514D27449 for ; Wed, 20 Feb 2019 04:47:41 -0500 (EST) From: imeevma@tarantool.org Subject: [tarantool-patches] [PATCH v1 1/1] sql: add space name in error message Date: Wed, 20 Feb 2019 12:47:38 +0300 Message-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit 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 This patch adds space name to descriptions of some of new errors. Also it fixes name and description of a few errors. Part of #3965 --- https://github.com/tarantool/tarantool/issues/3965 https://github.com/tarantool/tarantool/tree/imeevma/gh-3965-use-diag_set-to-describe-error src/box/alter.cc | 2 +- src/box/errcode.h | 6 ++++-- src/box/sql/build.c | 3 ++- src/box/sql/resolve.c | 7 ++++++- src/box/sql/update.c | 2 +- src/box/tuple.h | 6 +++--- src/box/tuple_update.c | 6 +++--- test/box/misc.result | 4 +++- test/sql-tap/check.test.lua | 4 ++-- test/sql-tap/gh2130-index-refer-table.test.lua | 4 ++-- test/sql-tap/in1.test.lua | 2 +- test/sql-tap/index1.test.lua | 4 ++-- test/sql-tap/insert1.test.lua | 2 +- test/sql-tap/insert3.test.lua | 4 ++-- test/sql-tap/join.test.lua | 2 +- test/sql-tap/limit.test.lua | 4 ++-- test/sql-tap/select1.test.lua | 2 +- test/sql-tap/select5.test.lua | 4 ++-- test/sql-tap/tkt-4ef7e3cfca.test.lua | 2 +- test/sql-tap/tkt3346.test.lua | 2 +- test/sql-tap/tkt3442.test.lua | 2 +- test/sql-tap/triggerB.test.lua | 6 +++--- test/sql-tap/update.test.lua | 10 +++++----- test/sql-tap/with2.test.lua | 2 +- test/sql/gh-2929-primary-key.result | 2 +- test/sql/gh-3888-values-blob-assert.result | 4 ++-- test/sql/icu-upper-lower.result | 2 +- 27 files changed, 55 insertions(+), 45 deletions(-) diff --git a/src/box/alter.cc b/src/box/alter.cc index bea15c8..af2bcce 100644 --- a/src/box/alter.cc +++ b/src/box/alter.cc @@ -2733,7 +2733,7 @@ priv_def_create_from_tuple(struct priv_def *priv, struct tuple *tuple) const char *data = tuple_field(tuple, BOX_PRIV_FIELD_OBJECT_ID); if (data == NULL) { - tnt_raise(ClientError, ER_NO_SUCH_FIELD, + tnt_raise(ClientError, ER_NO_SUCH_FIELD_NO, BOX_PRIV_FIELD_OBJECT_ID + TUPLE_INDEX_BASE); } /* diff --git a/src/box/errcode.h b/src/box/errcode.h index e25e05c..1523b19 100644 --- a/src/box/errcode.h +++ b/src/box/errcode.h @@ -89,7 +89,7 @@ struct errcode_record { /* 34 */_(ER_NO_SUCH_TRIGGER, "Trigger '%s' doesn't exist") \ /* 35 */_(ER_NO_SUCH_INDEX_ID, "No index #%u is defined in space '%s'") \ /* 36 */_(ER_NO_SUCH_SPACE, "Space '%s' does not exist") \ - /* 37 */_(ER_NO_SUCH_FIELD, "Field %d was not found in the tuple") \ + /* 37 */_(ER_NO_SUCH_FIELD_NO, "Field %d was not found in the tuple") \ /* 38 */_(ER_EXACT_FIELD_COUNT, "Tuple field count %u does not match space field count %u") \ /* 39 */_(ER_FIELD_MISSING, "Tuple field %s required by space format is missing") \ /* 40 */_(ER_WAL_IO, "Failed to write to disk") \ @@ -205,7 +205,7 @@ struct errcode_record { /*150 */_(ER_CANT_CREATE_COLLATION, "Failed to initialize collation: %s.") \ /*151 */_(ER_WRONG_COLLATION_OPTIONS, "Wrong collation options (field %u): %s") \ /*152 */_(ER_NULLABLE_PRIMARY, "Primary index of the space '%s' can not contain nullable parts") \ - /*153 */_(ER_NO_SUCH_FIELD_NAME, "Field '%s' doesn't exist") \ + /*153 */_(ER_NO_SUCH_FIELD_NAME, "Field '%s' was not found in the space '%s' format") \ /*154 */_(ER_TRANSACTION_YIELD, "Transaction has been aborted by a fiber yield") \ /*155 */_(ER_NO_SUCH_GROUP, "Replication group '%s' does not exist") \ /*156 */_(ER_SQL_BIND_VALUE, "Bind value for parameter %s is out of range for type %s") \ @@ -228,6 +228,8 @@ struct errcode_record { /*173 */_(ER_DROP_COLLATION, "Can't drop collation %s : %s") \ /*174 */_(ER_ILLEGAL_COLLATION_MIX, "Illegal mix of collations") \ /*175 */_(ER_SQL_NO_SUCH_PRAGMA, "Pragma '%s' does not exist") \ + /*176 */_(ER_SQL_CANT_RESOLVE_FIELD, "Can’t resolve field '%s'") \ + /*177 */_(ER_INDEX_EXISTS_IN_SPACE, "Index '%s' already exists in space '%s'") \ /* * !IMPORTANT! Please follow instructions at start of the file diff --git a/src/box/sql/build.c b/src/box/sql/build.c index 886b6b7..03bfbfb 100644 --- a/src/box/sql/build.c +++ b/src/box/sql/build.c @@ -2186,7 +2186,8 @@ sql_create_index(struct Parse *parse, struct Token *token, goto exit_create_index; if (sql_space_index_by_name(space, name) != NULL) { if (!if_not_exist) { - diag_set(ClientError, ER_INDEX_EXISTS, name); + diag_set(ClientError, ER_INDEX_EXISTS_IN_SPACE, + name, def->name); sql_parser_error(parse); } goto exit_create_index; diff --git a/src/box/sql/resolve.c b/src/box/sql/resolve.c index bc208cc..aed9e26 100644 --- a/src/box/sql/resolve.c +++ b/src/box/sql/resolve.c @@ -435,7 +435,12 @@ lookupName(Parse * pParse, /* The parsing context */ pTopNC->nErr++; } if (cnt == 0) { - diag_set(ClientError, ER_NO_SUCH_FIELD_NAME, zCol); + if (zTab == NULL) { + diag_set(ClientError, ER_SQL_CANT_RESOLVE_FIELD, zCol); + } else { + diag_set(ClientError, ER_NO_SUCH_FIELD_NAME, zCol, + zTab); + } sql_parser_error(pParse); pTopNC->nErr++; } diff --git a/src/box/sql/update.c b/src/box/sql/update.c index cb303c1..dacf312 100644 --- a/src/box/sql/update.c +++ b/src/box/sql/update.c @@ -191,7 +191,7 @@ sqlUpdate(Parse * pParse, /* The parser context */ } if (j >= (int)def->field_count) { diag_set(ClientError, ER_NO_SUCH_FIELD_NAME, - pChanges->a[i].zName); + pChanges->a[i].zName, def->name); sql_parser_error(pParse); goto update_cleanup; } diff --git a/src/box/tuple.h b/src/box/tuple.h index e803260..45d873d 100644 --- a/src/box/tuple.h +++ b/src/box/tuple.h @@ -739,7 +739,7 @@ tuple_next_with_type(struct tuple_iterator *it, enum mp_type type) uint32_t fieldno = it->fieldno; const char *field = tuple_next(it); if (field == NULL) { - diag_set(ClientError, ER_NO_SUCH_FIELD, it->fieldno); + diag_set(ClientError, ER_NO_SUCH_FIELD_NO, it->fieldno); return NULL; } if (mp_typeof(*field) != type) { @@ -804,7 +804,7 @@ tuple_field_with_type(const struct tuple *tuple, uint32_t fieldno, { const char *field = tuple_field(tuple, fieldno); if (field == NULL) { - diag_set(ClientError, ER_NO_SUCH_FIELD, + diag_set(ClientError, ER_NO_SUCH_FIELD_NO, fieldno + TUPLE_INDEX_BASE); return NULL; } @@ -840,7 +840,7 @@ tuple_field_i64(const struct tuple *tuple, uint32_t fieldno, int64_t *out) { const char *field = tuple_field(tuple, fieldno); if (field == NULL) { - diag_set(ClientError, ER_NO_SUCH_FIELD, fieldno); + diag_set(ClientError, ER_NO_SUCH_FIELD_NO, fieldno); return -1; } uint64_t val; diff --git a/src/box/tuple_update.c b/src/box/tuple_update.c index 7bf2104..01c55fb 100644 --- a/src/box/tuple_update.c +++ b/src/box/tuple_update.c @@ -390,7 +390,7 @@ op_adjust_field_no(struct tuple_update *update, struct update_op *op, if (op->field_no >= 0) { if (op->field_no < field_max) return 0; - diag_set(ClientError, ER_NO_SUCH_FIELD, update->index_base + + diag_set(ClientError, ER_NO_SUCH_FIELD_NO, update->index_base + op->field_no); return -1; } else { @@ -398,7 +398,7 @@ op_adjust_field_no(struct tuple_update *update, struct update_op *op, op->field_no += field_max; return 0; } - diag_set(ClientError, ER_NO_SUCH_FIELD, op->field_no); + diag_set(ClientError, ER_NO_SUCH_FIELD_NO, op->field_no); return -1; } } @@ -1017,7 +1017,7 @@ update_read_ops(struct tuple_update *update, const char *expr, } else if (field_no < 0) { op->field_no = field_no; } else { - diag_set(ClientError, ER_NO_SUCH_FIELD, field_no); + diag_set(ClientError, ER_NO_SUCH_FIELD_NO, field_no); return -1; } if (op->meta->read_arg(update->index_base, op, &expr)) diff --git a/test/box/misc.result b/test/box/misc.result index fce6c67..80bde72 100644 --- a/test/box/misc.result +++ b/test/box/misc.result @@ -367,7 +367,7 @@ t; 34: box.error.NO_SUCH_TRIGGER 35: box.error.NO_SUCH_INDEX_ID 36: box.error.NO_SUCH_SPACE - 37: box.error.NO_SUCH_FIELD + 37: box.error.NO_SUCH_FIELD_NO 38: box.error.EXACT_FIELD_COUNT 39: box.error.FIELD_MISSING 40: box.error.WAL_IO @@ -505,6 +505,8 @@ t; 173: box.error.DROP_COLLATION 174: box.error.ILLEGAL_COLLATION_MIX 175: box.error.SQL_NO_SUCH_PRAGMA + 176: box.error.SQL_CANT_RESOLVE_FIELD + 177: box.error.INDEX_EXISTS_IN_SPACE ... test_run:cmd("setopt delimiter ''"); --- diff --git a/test/sql-tap/check.test.lua b/test/sql-tap/check.test.lua index d5c3f2c..2bb1b2e 100755 --- a/test/sql-tap/check.test.lua +++ b/test/sql-tap/check.test.lua @@ -344,7 +344,7 @@ test:do_catchsql_test( ); ]], { -- - 1, "Failed to create space 'T3': Field 'Q' doesn't exist" + 1, "Failed to create space 'T3': Can’t resolve field 'Q'" -- }) @@ -368,7 +368,7 @@ test:do_catchsql_test( ); ]], { -- - 1, "Failed to create space 'T3': Field 'X' doesn't exist" + 1, "Failed to create space 'T3': Field 'X' was not found in the space 'T2' format" -- }) diff --git a/test/sql-tap/gh2130-index-refer-table.test.lua b/test/sql-tap/gh2130-index-refer-table.test.lua index 99a7579..2ced0fa 100755 --- a/test/sql-tap/gh2130-index-refer-table.test.lua +++ b/test/sql-tap/gh2130-index-refer-table.test.lua @@ -41,7 +41,7 @@ test:do_catchsql_test( ]], { -- - 1, "Index 'SAME_INDEX_NAME' already exists" + 1, "Index 'SAME_INDEX_NAME' already exists in space 'T1'" -- }) @@ -52,7 +52,7 @@ test:do_catchsql_test( ]], { -- - 1, "Index 'SAME_INDEX_NAME' already exists" + 1, "Index 'SAME_INDEX_NAME' already exists in space 'T2'" -- }) diff --git a/test/sql-tap/in1.test.lua b/test/sql-tap/in1.test.lua index d32506c..41c0e0d 100755 --- a/test/sql-tap/in1.test.lua +++ b/test/sql-tap/in1.test.lua @@ -220,7 +220,7 @@ test:do_catchsql_test( SELECT a FROM t1 WHERE c IN (10,20) ]], { -- - 1, "Field 'C' doesn't exist" + 1, "Can’t resolve field 'C'" -- }) diff --git a/test/sql-tap/index1.test.lua b/test/sql-tap/index1.test.lua index 3979fe0..2ed1451 100755 --- a/test/sql-tap/index1.test.lua +++ b/test/sql-tap/index1.test.lua @@ -97,7 +97,7 @@ test:do_test( return test:catchsql "CREATE INDEX index1 ON test1(f4)" end, { -- - 1, "Field 'F4' doesn't exist" + 1, "Can’t resolve field 'F4'" -- }) @@ -115,7 +115,7 @@ test:do_test( return table.insert(v,msg) or v end, { -- - 1, "Field 'F4' doesn't exist" + 1, "Can’t resolve field 'F4'" -- }) diff --git a/test/sql-tap/insert1.test.lua b/test/sql-tap/insert1.test.lua index b1c8957..363fa8a 100755 --- a/test/sql-tap/insert1.test.lua +++ b/test/sql-tap/insert1.test.lua @@ -240,7 +240,7 @@ end, { SELECT * FROM t3 ORDER BY a; ]], { -- - 1, "Field 'A' doesn't exist" + 1, "Field 'A' was not found in the space 'T3' format" -- }) diff --git a/test/sql-tap/insert3.test.lua b/test/sql-tap/insert3.test.lua index 46f6399..47bd693 100755 --- a/test/sql-tap/insert3.test.lua +++ b/test/sql-tap/insert3.test.lua @@ -172,7 +172,7 @@ test:do_catchsql_test( INSERT INTO t3 (a,b,c)VALUES(1,2,3) ]], { -- - 1, "Field 'NOSUCHCOL' doesn't exist" + 1, "Can’t resolve field 'NOSUCHCOL'" -- }) @@ -195,7 +195,7 @@ test:do_catchsql_test( INSERT INTO t4 (a,b,c)VALUES(1,2,3) ]], { -- - 1, "Field 'NOSUCHCOL' doesn't exist" + 1, "Can’t resolve field 'NOSUCHCOL'" -- }) diff --git a/test/sql-tap/join.test.lua b/test/sql-tap/join.test.lua index b531bbd..bda4091 100755 --- a/test/sql-tap/join.test.lua +++ b/test/sql-tap/join.test.lua @@ -580,7 +580,7 @@ test:do_catchsql_test( SELECT * FROM t1 JOIN t2 ON t3.a=t2.b; ]], { -- - 1, "Field 'A' doesn't exist" + 1, "Field 'A' was not found in the space 'T3' format" -- }) diff --git a/test/sql-tap/limit.test.lua b/test/sql-tap/limit.test.lua index 033a345..a0c9c9f 100755 --- a/test/sql-tap/limit.test.lua +++ b/test/sql-tap/limit.test.lua @@ -795,7 +795,7 @@ test:do_catchsql_test( SELECT * FROM t1 LIMIT x ]], { -- - 1, "Field 'X' doesn't exist" + 1, "Can’t resolve field 'X'" -- }) @@ -805,7 +805,7 @@ test:do_catchsql_test( SELECT * FROM t1 LIMIT 1 OFFSET x ]], { -- - 1, "Field 'X' doesn't exist" + 1, "Can’t resolve field 'X'" -- }) diff --git a/test/sql-tap/select1.test.lua b/test/sql-tap/select1.test.lua index e21cf7b..6c35b6f 100755 --- a/test/sql-tap/select1.test.lua +++ b/test/sql-tap/select1.test.lua @@ -1391,7 +1391,7 @@ test:do_catchsql2_test( ORDER BY a; ]], { -- - 1,"Field 'X' doesn't exist" + 1,"Can’t resolve field 'X'" -- }) diff --git a/test/sql-tap/select5.test.lua b/test/sql-tap/select5.test.lua index 0d132db..d47e340 100755 --- a/test/sql-tap/select5.test.lua +++ b/test/sql-tap/select5.test.lua @@ -88,7 +88,7 @@ test:do_catchsql_test( SELECT y, count(*) FROM t1 GROUP BY z ORDER BY y ]], { -- - 1, "Field 'Z' doesn't exist" + 1, "Can’t resolve field 'Z'" -- }) @@ -128,7 +128,7 @@ test:do_catchsql_test( SELECT y, count(*) FROM t1 GROUP BY y HAVING count(*) - 1, "Field 'Z' doesn't exist" + 1, "Can’t resolve field 'Z'" -- }) diff --git a/test/sql-tap/tkt-4ef7e3cfca.test.lua b/test/sql-tap/tkt-4ef7e3cfca.test.lua index a30c45c..c76a3e1 100755 --- a/test/sql-tap/tkt-4ef7e3cfca.test.lua +++ b/test/sql-tap/tkt-4ef7e3cfca.test.lua @@ -31,7 +31,7 @@ test:do_catchsql_test( INSERT INTO x VALUES('assert'); ]], { -- <1.1> - 1, "Field 'A' doesn't exist" + 1, "Field 'A' was not found in the space 'ABC' format" -- }) diff --git a/test/sql-tap/tkt3346.test.lua b/test/sql-tap/tkt3346.test.lua index bcd4d41..269a34f 100755 --- a/test/sql-tap/tkt3346.test.lua +++ b/test/sql-tap/tkt3346.test.lua @@ -94,7 +94,7 @@ test:do_catchsql_test( SELECT * FROM (SELECT a,b FROM t1 WHERE 1=x.a) AS x; ]], { -- - 1, "Field 'A' doesn't exist" + 1, "Field 'A' was not found in the space 'X' format" -- }) diff --git a/test/sql-tap/tkt3442.test.lua b/test/sql-tap/tkt3442.test.lua index 743045d..bdfdf8e 100755 --- a/test/sql-tap/tkt3442.test.lua +++ b/test/sql-tap/tkt3442.test.lua @@ -75,7 +75,7 @@ test:do_catchsql_test( SELECT node FROM listhash WHERE id="5000" LIMIT 1; ]], { -- - 1, "Field '5000' doesn't exist" + 1, "Can’t resolve field '5000'" -- }) diff --git a/test/sql-tap/triggerB.test.lua b/test/sql-tap/triggerB.test.lua index 24f75b7..12d0564 100755 --- a/test/sql-tap/triggerB.test.lua +++ b/test/sql-tap/triggerB.test.lua @@ -60,7 +60,7 @@ test:do_catchsql_test( INSERT INTO x VALUES(3,1,2); ]], { -- - 1, "Field 'X' doesn't exist" + 1, "Field 'X' was not found in the space 'WEN' format" -- }) @@ -73,7 +73,7 @@ test:do_catchsql_test( UPDATE x SET y=y+1; ]], { -- - 1, "Field 'X' doesn't exist" + 1, "Field 'X' was not found in the space 'DLO' format" -- }) @@ -111,7 +111,7 @@ test:do_test( ]] end, { -- - 1, "Field 'C' doesn't exist" + 1, "Field 'C' was not found in the space 'OLD' format" -- }) diff --git a/test/sql-tap/update.test.lua b/test/sql-tap/update.test.lua index c911969..71a4f64 100755 --- a/test/sql-tap/update.test.lua +++ b/test/sql-tap/update.test.lua @@ -58,7 +58,7 @@ test:do_catchsql_test("update-3.2", [[ UPDATE test1 SET f1=f3*2 WHERE f2==32 ]], { -- - 1, "Field 'F3' doesn't exist" + 1, "Can’t resolve field 'F3'" -- }) @@ -66,7 +66,7 @@ test:do_catchsql_test("update-3.3", [[ UPDATE test1 SET f1=test2.f1*2 WHERE f2==32 ]], { -- - 1, "Field 'F1' doesn't exist" + 1, "Field 'F1' was not found in the space 'TEST2' format" -- }) @@ -74,7 +74,7 @@ test:do_catchsql_test("update-3.4", [[ UPDATE test1 SET f3=f1*2 WHERE f2==32 ]], { -- - 1, "Field 'F3' doesn't exist" + 1, "Field 'F3' was not found in the space 'TEST1' format" -- }) @@ -854,7 +854,7 @@ test:do_catchsql_test("update-9.1", [[ UPDATE test1 SET x=11 WHERE f1=1025 ]], { -- - 1, "Field 'X' doesn't exist" + 1, "Field 'X' was not found in the space 'TEST1' format" -- }) @@ -870,7 +870,7 @@ test:do_catchsql_test("update-9.3", [[ UPDATE test1 SET f1=11 WHERE x=1025 ]], { -- - 1, "Field 'X' doesn't exist" + 1, "Can’t resolve field 'X'" -- }) diff --git a/test/sql-tap/with2.test.lua b/test/sql-tap/with2.test.lua index 5b00dfd..c27a9d1 100755 --- a/test/sql-tap/with2.test.lua +++ b/test/sql-tap/with2.test.lua @@ -600,7 +600,7 @@ test:do_catchsql_test("6.10", [[ SELECT * FROM x ]], { -- <6.10> - 1, "Field 'C' doesn't exist" + 1, "Can’t resolve field 'C'" -- }) diff --git a/test/sql/gh-2929-primary-key.result b/test/sql/gh-2929-primary-key.result index aa91813..280e900 100644 --- a/test/sql/gh-2929-primary-key.result +++ b/test/sql/gh-2929-primary-key.result @@ -40,5 +40,5 @@ box.sql.execute("DROP TABLE t1") -- box.sql.execute("CREATE TABLE tx (a INT, PRIMARY KEY (b));") --- -- error: Field 'B' doesn't exist +- error: Can’t resolve field 'B' ... diff --git a/test/sql/gh-3888-values-blob-assert.result b/test/sql/gh-3888-values-blob-assert.result index 95a81c7..67948cd 100644 --- a/test/sql/gh-3888-values-blob-assert.result +++ b/test/sql/gh-3888-values-blob-assert.result @@ -34,12 +34,12 @@ box.sql.execute('SELECT float') -- check 'VALUES' against ID (should fail) box.sql.execute('VALUES(TheColumnName)') --- -- error: Field 'THECOLUMNNAME' doesn't exist +- error: Can’t resolve field 'THECOLUMNNAME' ... -- check 'SELECT' against ID (should fail) box.sql.execute('SELECT TheColumnName') --- -- error: Field 'THECOLUMNNAME' doesn't exist +- error: Can’t resolve field 'THECOLUMNNAME' ... -- check 'VALUES' well-formed expression (returns value) box.sql.execute('VALUES(-0.5e-2)') diff --git a/test/sql/icu-upper-lower.result b/test/sql/icu-upper-lower.result index 0ecfd23..61d6546 100644 --- a/test/sql/icu-upper-lower.result +++ b/test/sql/icu-upper-lower.result @@ -163,7 +163,7 @@ box.sql.execute("select upper('1', 2)") ... box.sql.execute("select upper(\"1\")") --- -- error: Field '1' doesn't exist +- error: Can’t resolve field '1' ... box.sql.execute("select upper()") --- -- 2.7.4