Tarantool development patches archive
 help / color / mirror / Atom feed
* [tarantool-patches] [PATCH v1 0/2] sql: remove error ER_SQL
@ 2019-04-24 19:57 imeevma
  2019-04-24 19:57 ` [tarantool-patches] [PATCH v1 1/2] sql: remove errors SQL_TARANTOOL_*_FAIL imeevma
  2019-04-24 19:57 ` [tarantool-patches] [PATCH v1 2/2] sql: remove error ER_SQL imeevma
  0 siblings, 2 replies; 3+ messages in thread
From: imeevma @ 2019-04-24 19:57 UTC (permalink / raw)
  To: korablev; +Cc: tarantool-patches

This patch removes the ER_SQL error code. If we apply only the
"sql: remove error ER_SQL" patch, then some errors will have
"Failed to execute SQL statement: Failed to execute SQL statement:
..." in their descriptions. Instead of fixing this, I decided to
remove SQL_TARANTOOL_*_FAIL SQL errors as this is related to issue
#4074.

https://github.com/tarantool/tarantool/tree/imeevma/small-patches

Mergen Imeev (2):
  sql: remove errors SQL_TARANTOOL_*_FAIL
  sql: remove error ER_SQL

 src/box/alter.cc                                   |  4 +--
 src/box/errcode.h                                  |  2 +-
 src/box/sql.c                                      | 37 ++++++++--------------
 src/box/sql/build.c                                |  2 +-
 src/box/sql/delete.c                               |  4 +--
 src/box/sql/main.c                                 |  3 --
 src/box/sql/resolve.c                              |  2 +-
 src/box/sql/sqlInt.h                               |  3 --
 src/box/sql/tarantoolInt.h                         |  5 +--
 src/box/sql/trigger.c                              |  6 ++--
 src/box/sql/vdbe.c                                 |  2 +-
 test/box/misc.result                               |  1 -
 test/sql-tap/autoinc.test.lua                      |  2 +-
 test/sql-tap/gh-2931-savepoints.test.lua           |  4 +--
 .../gh-3307-xfer-optimization-issue.test.lua       | 10 +++---
 test/sql-tap/gh2259-in-stmt-trans.test.lua         |  8 ++---
 test/sql-tap/gh2964-abort.test.lua                 |  2 +-
 test/sql-tap/intpkey.test.lua                      |  2 +-
 test/sql-tap/misc1.test.lua                        |  2 +-
 test/sql-tap/select3.test.lua                      |  2 +-
 test/sql-tap/select5.test.lua                      | 10 +++---
 test/sql-tap/table.test.lua                        |  8 ++---
 test/sql-tap/tkt-4a03edc4c8.test.lua               |  2 +-
 test/sql-tap/trigger1.test.lua                     |  6 ++--
 test/sql-tap/unique.test.lua                       | 10 +++---
 test/sql/collation.result                          | 18 ++++-------
 test/sql/delete.result                             |  7 ++--
 test/sql/errinj.result                             |  6 ++--
 test/sql/foreign-keys.result                       |  3 +-
 test/sql/insert-unique.result                      |  6 ++--
 test/sql/iproto.result                             |  3 +-
 test/sql/on-conflict.result                        |  4 +--
 test/sql/persistency.result                        |  6 ++--
 test/sql/transition.result                         |  6 ++--
 test/sql/triggers.result                           | 21 ++++++------
 35 files changed, 95 insertions(+), 124 deletions(-)

-- 
2.7.4

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [tarantool-patches] [PATCH v1 1/2] sql: remove errors SQL_TARANTOOL_*_FAIL
  2019-04-24 19:57 [tarantool-patches] [PATCH v1 0/2] sql: remove error ER_SQL imeevma
@ 2019-04-24 19:57 ` imeevma
  2019-04-24 19:57 ` [tarantool-patches] [PATCH v1 2/2] sql: remove error ER_SQL imeevma
  1 sibling, 0 replies; 3+ messages in thread
From: imeevma @ 2019-04-24 19:57 UTC (permalink / raw)
  To: korablev; +Cc: tarantool-patches

Errors SQL_TARANTOOL_DELETE_FAIL, SQL_TARANTOOL_ITERATOR_FAIL and
SQL_TARANTOOL_INSERT_FAIL have almost no functionality, but can
lead to incorrect behavior. This patch replaces them with
SQL_TARANTOOL_ERROR. It will simplify work with the errors.
---
 src/box/sql.c                                      | 37 ++++++++--------------
 src/box/sql/main.c                                 |  3 --
 src/box/sql/sqlInt.h                               |  3 --
 src/box/sql/tarantoolInt.h                         |  5 +--
 src/box/sql/vdbe.c                                 |  2 +-
 test/sql-tap/autoinc.test.lua                      |  2 +-
 test/sql-tap/gh-2931-savepoints.test.lua           |  4 +--
 .../gh-3307-xfer-optimization-issue.test.lua       | 10 +++---
 test/sql-tap/gh2259-in-stmt-trans.test.lua         |  8 ++---
 test/sql-tap/gh2964-abort.test.lua                 |  2 +-
 test/sql-tap/intpkey.test.lua                      |  2 +-
 test/sql-tap/misc1.test.lua                        |  2 +-
 test/sql-tap/table.test.lua                        |  8 ++---
 test/sql-tap/tkt-4a03edc4c8.test.lua               |  2 +-
 test/sql-tap/trigger1.test.lua                     |  6 ++--
 test/sql-tap/unique.test.lua                       | 10 +++---
 test/sql/collation.result                          | 18 ++++-------
 test/sql/errinj.result                             |  6 ++--
 test/sql/foreign-keys.result                       |  3 +-
 test/sql/insert-unique.result                      |  6 ++--
 test/sql/iproto.result                             |  3 +-
 test/sql/persistency.result                        |  6 ++--
 test/sql/transition.result                         |  6 ++--
 test/sql/triggers.result                           |  2 +-
 24 files changed, 62 insertions(+), 94 deletions(-)

diff --git a/src/box/sql.c b/src/box/sql.c
index 1fb93e1..3593242 100644
--- a/src/box/sql.c
+++ b/src/box/sql.c
@@ -162,15 +162,6 @@ const char *tarantoolErrorMessage()
 	return box_error_message(box_error_last());
 }
 
-int
-is_tarantool_error(int rc)
-{
-	return (rc == SQL_TARANTOOL_ERROR ||
-		rc == SQL_TARANTOOL_ITERATOR_FAIL ||
-		rc == SQL_TARANTOOL_DELETE_FAIL ||
-		rc == SQL_TARANTOOL_INSERT_FAIL);
-}
-
 const void *tarantoolsqlPayloadFetch(BtCursor *pCur, u32 *pAmt)
 {
 	assert(pCur->curFlags & BTCF_TaCursor ||
@@ -421,7 +412,7 @@ int tarantoolsqlEphemeralInsert(struct space *space, const char *tuple,
 	assert(space != NULL);
 	mp_tuple_assert(tuple, tuple_end);
 	if (space_ephemeral_replace(space, tuple, tuple_end) != 0)
-		return SQL_TARANTOOL_INSERT_FAIL;
+		return SQL_TARANTOOL_ERROR;
 	return SQL_OK;
 }
 
@@ -448,7 +439,7 @@ insertOrReplace(struct space *space, const char *tuple, const char *tuple_end,
 	request.type = type;
 	mp_tuple_assert(request.tuple, request.tuple_end);
 	int rc = box_process_rw(&request, space, NULL);
-	return rc == 0 ? SQL_OK : SQL_TARANTOOL_INSERT_FAIL;
+	return rc == 0 ? SQL_OK : SQL_TARANTOOL_ERROR;
 }
 
 int tarantoolsqlInsert(struct space *space, const char *tuple,
@@ -483,12 +474,12 @@ int tarantoolsqlEphemeralDelete(BtCursor *pCur)
 				pCur->iter->index->def->key_def,
 				&key_size);
 	if (key == NULL)
-		return SQL_TARANTOOL_DELETE_FAIL;
+		return SQL_TARANTOOL_ERROR;
 
 	int rc = space_ephemeral_delete(pCur->space, key);
 	if (rc != 0) {
 		diag_log();
-		return SQL_TARANTOOL_DELETE_FAIL;
+		return SQL_TARANTOOL_ERROR;
 	}
 	return SQL_OK;
 }
@@ -509,11 +500,11 @@ int tarantoolsqlDelete(BtCursor *pCur, u8 flags)
 				pCur->iter->index->def->key_def,
 				&key_size);
 	if (key == NULL)
-		return SQL_TARANTOOL_DELETE_FAIL;
+		return SQL_TARANTOOL_ERROR;
 	rc = sql_delete_by_key(pCur->space, pCur->index->def->iid, key,
 			       key_size);
 
-	return rc == 0 ? SQL_OK : SQL_TARANTOOL_DELETE_FAIL;
+	return rc == 0 ? SQL_OK : SQL_TARANTOOL_ERROR;
 }
 
 int
@@ -531,7 +522,7 @@ sql_delete_by_key(struct space *space, uint32_t iid, char *key,
 	assert(space_index(space, iid)->def->opts.is_unique);
 	int rc = box_process_rw(&request, space, &unused);
 
-	return rc == 0 ? SQL_OK : SQL_TARANTOOL_DELETE_FAIL;
+	return rc == 0 ? SQL_OK : SQL_TARANTOOL_ERROR;
 }
 
 /*
@@ -553,7 +544,7 @@ int tarantoolsqlEphemeralClearTable(BtCursor *pCur)
 						    0 /* part_count */);
 	if (it == NULL) {
 		pCur->eState = CURSOR_INVALID;
-		return SQL_TARANTOOL_ITERATOR_FAIL;
+		return SQL_TARANTOOL_ERROR;
 	}
 
 	struct tuple *tuple;
@@ -565,7 +556,7 @@ int tarantoolsqlEphemeralClearTable(BtCursor *pCur)
 					&key_size);
 		if (space_ephemeral_delete(pCur->space, key) != 0) {
 			iterator_delete(it);
-			return SQL_TARANTOOL_DELETE_FAIL;
+			return SQL_TARANTOOL_ERROR;
 		}
 	}
 	iterator_delete(it);
@@ -592,7 +583,7 @@ int tarantoolsqlClearTable(struct space *space, uint32_t *tuple_count)
 	struct index *pk = space_index(space, 0 /* PK */);
 	struct iterator *iter = index_create_iterator(pk, ITER_ALL, nil_key, 0);
 	if (iter == NULL)
-		return SQL_TARANTOOL_ITERATOR_FAIL;
+		return SQL_TARANTOOL_ERROR;
 	while (iterator_next(iter, &tuple) == 0 && tuple != NULL) {
 		request.key = tuple_extract_key(tuple, pk->def->key_def,
 						&key_size);
@@ -600,7 +591,7 @@ int tarantoolsqlClearTable(struct space *space, uint32_t *tuple_count)
 		rc = box_process_rw(&request, space, &unused);
 		if (rc != 0) {
 			iterator_delete(iter);
-			return SQL_TARANTOOL_DELETE_FAIL;
+			return SQL_TARANTOOL_ERROR;
 		}
 		(*tuple_count)++;
 	}
@@ -899,7 +890,7 @@ cursor_seek(BtCursor *pCur, int *pRes)
 	uint32_t part_count = mp_decode_array(&key);
 	if (key_validate(pCur->index->def, pCur->iter_type, key, part_count)) {
 		diag_log();
-		return SQL_TARANTOOL_ITERATOR_FAIL;
+		return SQL_TARANTOOL_ERROR;
 	}
 
 	struct space *space = pCur->space;
@@ -913,7 +904,7 @@ cursor_seek(BtCursor *pCur, int *pRes)
 		if (txn != NULL)
 			txn_rollback_stmt();
 		pCur->eState = CURSOR_INVALID;
-		return SQL_TARANTOOL_ITERATOR_FAIL;
+		return SQL_TARANTOOL_ERROR;
 	}
 	if (txn != NULL)
 		txn_commit_ro_stmt(txn);
@@ -940,7 +931,7 @@ cursor_advance(BtCursor *pCur, int *pRes)
 
 	struct tuple *tuple;
 	if (iterator_next(pCur->iter, &tuple) != 0)
-		return SQL_TARANTOOL_ITERATOR_FAIL;
+		return SQL_TARANTOOL_ERROR;
 	if (pCur->last_tuple)
 		box_tuple_unref(pCur->last_tuple);
 	if (tuple) {
diff --git a/src/box/sql/main.c b/src/box/sql/main.c
index fe1135a..ed07553 100644
--- a/src/box/sql/main.c
+++ b/src/box/sql/main.c
@@ -383,9 +383,6 @@ sqlErrStr(int rc)
 		/* SQL_MISUSE      */
 		    "library routine called out of sequence",
 		/* SQL_RANGE       */ "bind or column index out of range",
-		/* SQL_TARANTOOL_ITERATOR_FAIL */ "Tarantool's iterator failed",
-		/* SQL_TARANTOOL_INSERT_FAIL */ "Tarantool's insert failed",
-		/* SQL_TARANTOOL_DELETE_FAIL */ "Tarantool's delete failed",
 		/* SQL_TARANTOOL_ERROR */ "SQL-/Tarantool error",
 	};
 	const char *zErr = "unknown error";
diff --git a/src/box/sql/sqlInt.h b/src/box/sql/sqlInt.h
index 8c8d0be..9cd003c 100644
--- a/src/box/sql/sqlInt.h
+++ b/src/box/sql/sqlInt.h
@@ -392,9 +392,6 @@ enum sql_ret_code {
 	SQL_MISUSE,
 	/** 2nd parameter to sql_bind out of range. */
 	SQL_RANGE,
-	SQL_TARANTOOL_ITERATOR_FAIL,
-	SQL_TARANTOOL_INSERT_FAIL,
-	SQL_TARANTOOL_DELETE_FAIL,
 	SQL_TARANTOOL_ERROR,
 	/** Warnings from sql_log(). */
 	SQL_WARNING,
diff --git a/src/box/sql/tarantoolInt.h b/src/box/sql/tarantoolInt.h
index 2b04d96..f15e147 100644
--- a/src/box/sql/tarantoolInt.h
+++ b/src/box/sql/tarantoolInt.h
@@ -13,8 +13,6 @@ struct fk_constraint_def;
 /* Misc */
 const char *tarantoolErrorMessage();
 
-int is_tarantool_error(int rc);
-
 /* Storage interface. */
 const void *tarantoolsqlPayloadFetch(BtCursor * pCur, u32 * pAmt);
 
@@ -51,8 +49,7 @@ int tarantoolsqlDelete(BtCursor * pCur, u8 flags);
  * @param key Key of record to be deleted.
  * @param key_size Size of key.
  *
- * @retval SQL_OK on success, SQL_TARANTOOL_DELETE_FAIL
- *         otherwise.
+ * @retval SQL_OK on success, SQL_TARANTOOL_ERROR otherwise.
  */
 int
 sql_delete_by_key(struct space *space, uint32_t iid, char *key,
diff --git a/src/box/sql/vdbe.c b/src/box/sql/vdbe.c
index d452892..6350db0 100644
--- a/src/box/sql/vdbe.c
+++ b/src/box/sql/vdbe.c
@@ -5489,7 +5489,7 @@ abort_due_to_error:
 		/* Avoiding situation when Tarantool error is set,
 		 * but error message isn't.
 		 */
-		if (is_tarantool_error(rc) && tarantoolErrorMessage()) {
+		if (rc == SQL_TARANTOOL_ERROR && tarantoolErrorMessage()) {
 			msg = tarantoolErrorMessage();
 		} else {
 			msg = sqlErrStr(rc);
diff --git a/test/sql-tap/autoinc.test.lua b/test/sql-tap/autoinc.test.lua
index 4db2783..257621b 100755
--- a/test/sql-tap/autoinc.test.lua
+++ b/test/sql-tap/autoinc.test.lua
@@ -531,7 +531,7 @@ test:do_catchsql_test(
         INSERT INTO t6 VALUES(NULL,1);
     ]], {
         -- <autoinc-6.2>
-        1, "Failed to execute SQL statement: Sequence 'T6' has overflowed"
+        1, "Sequence 'T6' has overflowed"
         -- </autoinc-6.2>
     })
 
diff --git a/test/sql-tap/gh-2931-savepoints.test.lua b/test/sql-tap/gh-2931-savepoints.test.lua
index 5c0daef..6123fc4 100755
--- a/test/sql-tap/gh-2931-savepoints.test.lua
+++ b/test/sql-tap/gh-2931-savepoints.test.lua
@@ -81,13 +81,13 @@ local testcases = {
 		{0,{1,2,10,11,1,2,4,10,11}}},
 	{"14",
 		[[insert into t1 values(4);]],
-		{1,"Failed to execute SQL statement: Duplicate key exists in unique index 'pk_unnamed_T2_1' in space 'T2'"}},
+		{1,"Duplicate key exists in unique index 'pk_unnamed_T2_1' in space 'T2'"}},
 	{"15",
 		[[select * from t1 union all select * from t2;]],
 		{0,{1,2,10,11,1,2,4,10,11}}},
 	{"16",
 		[[insert or rollback into t1 values(4);]],
-		{1,"Failed to execute SQL statement: Duplicate key exists in unique index 'pk_unnamed_T2_1' in space 'T2'"}},
+		{1,"Duplicate key exists in unique index 'pk_unnamed_T2_1' in space 'T2'"}},
 	{"17",  -- should work as transaction is rolled back
 		[[insert or rollback into t1 values(4);
 		select * from t1 union all select * from t2;]],
diff --git a/test/sql-tap/gh-3307-xfer-optimization-issue.test.lua b/test/sql-tap/gh-3307-xfer-optimization-issue.test.lua
index 859a6ff..bb8a498 100755
--- a/test/sql-tap/gh-3307-xfer-optimization-issue.test.lua
+++ b/test/sql-tap/gh-3307-xfer-optimization-issue.test.lua
@@ -139,7 +139,7 @@ test:do_catchsql_xfer_test(
         INSERT INTO t2 SELECT * FROM t1;
     ]], {
         -- <xfer-optimization-1.9>
-        1, "Failed to execute SQL statement: Duplicate key exists in unique index 'pk_unnamed_T2_1' in space 'T2'"
+        1, "Duplicate key exists in unique index 'pk_unnamed_T2_1' in space 'T2'"
         -- <xfer-optimization-1.9>
     }, {
         exp_xfer_count = 0
@@ -210,7 +210,7 @@ test:do_catchsql_xfer_test(
             INSERT INTO t2 SELECT * FROM t1;
     ]], {
         -- <xfer-optimization-1.13>
-        1, "Failed to execute SQL statement: Duplicate key exists in unique index 'pk_unnamed_T2_1' in space 'T2'"
+        1, "Duplicate key exists in unique index 'pk_unnamed_T2_1' in space 'T2'"
         -- <xfer-optimization-1.13>
     }, {
         exp_xfer_count = 0
@@ -245,7 +245,7 @@ test:do_catchsql_xfer_test(
             INSERT OR ABORT INTO t2 SELECT * FROM t1;
     ]], {
         -- <xfer-optimization-1.20>
-        1, "Failed to execute SQL statement: Duplicate key exists in unique index 'pk_unnamed_T2_1' in space 'T2'"
+        1, "Duplicate key exists in unique index 'pk_unnamed_T2_1' in space 'T2'"
         -- <xfer-optimization-1.20>
     }, {
         exp_xfer_count = 1
@@ -313,7 +313,7 @@ test:do_catchsql_xfer_test(
             INSERT OR ROLLBACK INTO t2 SELECT * FROM t1;
     ]], {
         -- <xfer-optimization-1.24>
-        1, "Failed to execute SQL statement: Duplicate key exists in unique index 'pk_unnamed_T2_1' in space 'T2'"
+        1, "Duplicate key exists in unique index 'pk_unnamed_T2_1' in space 'T2'"
         -- <xfer-optimization-1.24>
     }, {
         exp_xfer_count = 0
@@ -381,7 +381,7 @@ test:do_catchsql_xfer_test(
             INSERT OR FAIL INTO t2 SELECT * FROM t1;
     ]], {
         -- <xfer-optimization-1.28>
-        1, "Failed to execute SQL statement: Duplicate key exists in unique index 'pk_unnamed_T2_1' in space 'T2'"
+        1, "Duplicate key exists in unique index 'pk_unnamed_T2_1' in space 'T2'"
         -- <xfer-optimization-1.28>
     }, {
         exp_xfer_count = 1
diff --git a/test/sql-tap/gh2259-in-stmt-trans.test.lua b/test/sql-tap/gh2259-in-stmt-trans.test.lua
index 36f5e90..6bd0550 100755
--- a/test/sql-tap/gh2259-in-stmt-trans.test.lua
+++ b/test/sql-tap/gh2259-in-stmt-trans.test.lua
@@ -18,7 +18,7 @@ for _, prefix in pairs({"BEFORE", "AFTER"}) do
 
     test:do_catchsql_test(prefix..'_insert1',
                           'INSERT INTO t1 VALUES(1, 2)',
-                          {1,"Failed to execute SQL statement: Duplicate key exists in unique index 'pk_unnamed_T2_2' in space 'T2'"})
+                          {1,"Duplicate key exists in unique index 'pk_unnamed_T2_2' in space 'T2'"})
 
     test:do_execsql_test(prefix..'_insert1_check1',
                          'SELECT *  FROM t1',
@@ -34,7 +34,7 @@ for _, prefix in pairs({"BEFORE", "AFTER"}) do
 
     test:do_catchsql_test(prefix..'_update1',
                           'UPDATE t1 SET s1=1',
-                          {1,"Failed to execute SQL statement: Duplicate key exists in unique index 'pk_unnamed_T2_2' in space 'T2'"})
+                          {1,"Duplicate key exists in unique index 'pk_unnamed_T2_2' in space 'T2'"})
 
     test:do_execsql_test(prefix..'_update1_check1',
                          'SELECT *  FROM t1',
@@ -52,7 +52,7 @@ for _, prefix in pairs({"BEFORE", "AFTER"}) do
 
     test:do_catchsql_test(prefix..'delete1',
                           'DELETE FROM t1;',
-                          {1, "Failed to execute SQL statement: Duplicate key exists in unique index 'pk_unnamed_T2_2' in space 'T2'"})
+                          {1, "Duplicate key exists in unique index 'pk_unnamed_T2_2' in space 'T2'"})
 
     -- Nothing should be inserted due to abort
     test:do_execsql_test('delete1_check1',
@@ -69,7 +69,7 @@ end
 -- Check multi-insert
 test:do_catchsql_test('insert2',
                       'INSERT INTO t1 VALUES (5, 6), (6, 7)',
-                      {1, "Failed to execute SQL statement: Duplicate key exists in unique index 'pk_unnamed_T2_2' in space 'T2'"})
+                      {1, "Duplicate key exists in unique index 'pk_unnamed_T2_2' in space 'T2'"})
 test:do_execsql_test('insert2_check',
                      'SELECT * FROM t1;',
                      {3, 3})
diff --git a/test/sql-tap/gh2964-abort.test.lua b/test/sql-tap/gh2964-abort.test.lua
index db9a111..3bce569 100755
--- a/test/sql-tap/gh2964-abort.test.lua
+++ b/test/sql-tap/gh2964-abort.test.lua
@@ -12,7 +12,7 @@ test:do_catchsql_test(
     test_prefix.."1.0.2",
     "CREATE TABLE t2 (a int primary key);")
 
-local insert_err = {1, "Failed to execute SQL statement: Duplicate key exists in unique index 'pk_unnamed_T2_1' in space 'T2'"}
+local insert_err = {1, "Duplicate key exists in unique index 'pk_unnamed_T2_1' in space 'T2'"}
 local data = {
 --id|TRIG TYPE|INSERT TYPE|insert error|commit error| result
  {1, "AFTER", "or abort",   insert_err, {0},          {1,1,2}},
diff --git a/test/sql-tap/intpkey.test.lua b/test/sql-tap/intpkey.test.lua
index b2e8084..bec2670 100755
--- a/test/sql-tap/intpkey.test.lua
+++ b/test/sql-tap/intpkey.test.lua
@@ -96,7 +96,7 @@ test:do_catchsql_test(
         INSERT INTO t1 VALUES(5,'second','entry');
     ]], {
         -- <intpkey-1.6>
-        1, "Failed to execute SQL statement: Duplicate key exists in unique index 'pk_unnamed_T1_1' in space 'T1'"
+        1, "Duplicate key exists in unique index 'pk_unnamed_T1_1' in space 'T1'"
         -- </intpkey-1.6>
     })
 
diff --git a/test/sql-tap/misc1.test.lua b/test/sql-tap/misc1.test.lua
index cd0e103..dbc0699 100755
--- a/test/sql-tap/misc1.test.lua
+++ b/test/sql-tap/misc1.test.lua
@@ -383,7 +383,7 @@ test:do_catchsql_test(
         INSERT INTO t5 VALUES(1,2,4);
     ]], {
         -- <misc1-7.4>
-        1, "Failed to execute SQL statement: Duplicate key exists in unique index 'pk_unnamed_T5_1' in space 'T5'"
+        1, "Duplicate key exists in unique index 'pk_unnamed_T5_1' in space 'T5'"
         -- </misc1-7.4>
     })
 
diff --git a/test/sql-tap/table.test.lua b/test/sql-tap/table.test.lua
index 5b793c0..04fd175 100755
--- a/test/sql-tap/table.test.lua
+++ b/test/sql-tap/table.test.lua
@@ -1211,7 +1211,7 @@ test:do_catchsql_test(
         INSERT INTO T21 VALUES(1, 2, 2);
     ]], {
         -- <table-21.2>
-        1, "Failed to execute SQL statement: Duplicate key exists in unique index 'pk_unnamed_T21_1' in space 'T21'"
+        1, "Duplicate key exists in unique index 'pk_unnamed_T21_1' in space 'T21'"
         -- </table-21.2>
     })
 
@@ -1283,7 +1283,7 @@ test:do_catchsql_test(
         INSERT INTO T22 VALUES(2, 1, 1);
     ]], {
         -- <table-22.3>
-        1,"Failed to execute SQL statement: Duplicate key exists in unique index 'unique_ONE_2' in space 'T22'"
+        1,"Duplicate key exists in unique index 'unique_ONE_2' in space 'T22'"
         -- </table-22.3>
     })
 
@@ -1308,7 +1308,7 @@ test:do_catchsql_test(
         INSERT INTO T24 VALUES(2, 1, 1);
     ]], {
         -- <table-22.5>
-        1, "Failed to execute SQL statement: Duplicate key exists in unique index 'unique_TWO_2' in space 'T24'"
+        1, "Duplicate key exists in unique index 'unique_TWO_2' in space 'T24'"
         -- </table-22.5>
     })
 
@@ -1362,7 +1362,7 @@ test:do_catchsql_test(
         INSERT INTO T28 VALUES(11);
     ]], {
         -- <table-22.9>
-        1,"Failed to execute SQL statement: Duplicate key exists in unique index 'pk_unnamed_T28_1' in space 'T28'"
+        1,"Duplicate key exists in unique index 'pk_unnamed_T28_1' in space 'T28'"
         -- </table-22.9>
     })
 
diff --git a/test/sql-tap/tkt-4a03edc4c8.test.lua b/test/sql-tap/tkt-4a03edc4c8.test.lua
index 0f44d4f..cb7a982 100755
--- a/test/sql-tap/tkt-4a03edc4c8.test.lua
+++ b/test/sql-tap/tkt-4a03edc4c8.test.lua
@@ -38,7 +38,7 @@ test:do_test(
         ]]
     end, {
         -- <tkt-4a03ed-1.1>
-        1, "Failed to execute SQL statement: Duplicate key exists in unique index 'pk_unnamed_T1_1' in space 'T1'"
+        1, "Duplicate key exists in unique index 'pk_unnamed_T1_1' in space 'T1'"
         -- </tkt-4a03ed-1.1>
     })
 
diff --git a/test/sql-tap/trigger1.test.lua b/test/sql-tap/trigger1.test.lua
index dfc2822..64763fa 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, "Failed to execute SQL statement: SQL error: cannot create INSTEAD OF trigger on space: T1"
+        1, "SQL error: cannot create INSTEAD OF trigger on space: T1"
         -- </trigger1-1.12>
     })
 
@@ -274,7 +274,7 @@ test:do_catchsql_test(
         end;
     ]], {
         -- <trigger1-1.13>
-        1, "Failed to execute SQL statement: SQL error: cannot create BEFORE trigger on view: V1"
+        1, "SQL error: cannot create BEFORE trigger on view: V1"
         -- </trigger1-1.13>
     })
 
@@ -289,7 +289,7 @@ test:do_catchsql_test(
         end;
     ]], {
         -- <trigger1-1.14>
-        1, "Failed to execute SQL statement: SQL error: cannot create AFTER trigger on view: V1"
+        1, "SQL error: cannot create AFTER trigger on view: V1"
         -- </trigger1-1.14>
     })
 
diff --git a/test/sql-tap/unique.test.lua b/test/sql-tap/unique.test.lua
index a9add83..fbd73a6 100755
--- a/test/sql-tap/unique.test.lua
+++ b/test/sql-tap/unique.test.lua
@@ -70,7 +70,7 @@ test:do_catchsql_test(
         INSERT INTO t1(a,b,c) VALUES(1,3,4)
     ]], {
         -- <unique-1.3>
-        1, "Failed to execute SQL statement: Duplicate key exists in unique index 'pk_unnamed_T1_1' in space 'T1'"
+        1, "Duplicate key exists in unique index 'pk_unnamed_T1_1' in space 'T1'"
         -- </unique-1.3>
     })
 
@@ -91,7 +91,7 @@ test:do_catchsql_test(
         INSERT INTO t1(a,b,c) VALUES(3,2,4)
     ]], {
         -- <unique-1.5>
-        1, "Failed to execute SQL statement: Duplicate key exists in unique index 'unique_unnamed_T1_2' in space 'T1'"
+        1, "Duplicate key exists in unique index 'unique_unnamed_T1_2' in space 'T1'"
         -- </unique-1.5>
     })
 
@@ -167,7 +167,7 @@ test:do_catchsql_test(
         INSERT INTO t2 VALUES(3, 1,5);
     ]], {
         -- <unique-2.3>
-        1, "Failed to execute SQL statement: Duplicate key exists in unique index 'I2' in space 'T2'"
+        1, "Duplicate key exists in unique index 'I2' in space 'T2'"
         -- </unique-2.3>
     })
 
@@ -287,7 +287,7 @@ test:do_catchsql_test(
         SELECT a,b,c,d FROM t3 ORDER BY a,b,c,d;
     ]], {
         -- <unique-3.4>
-        1, "Failed to execute SQL statement: Duplicate key exists in unique index 'unique_unnamed_T3_2' in space 'T3'"
+        1, "Duplicate key exists in unique index 'unique_unnamed_T3_2' in space 'T3'"
         -- </unique-3.4>
     })
 
@@ -444,7 +444,7 @@ test:do_catchsql_test(
         INSERT INTO t5 VALUES(2, 1,2,3,4,5,6);
     ]], {
         -- <unique-5.2>
-        1, "Failed to execute SQL statement: Duplicate key exists in unique index 'unique_unnamed_T5_2' in space 'T5'"
+        1, "Duplicate key exists in unique index 'unique_unnamed_T5_2' in space 'T5'"
         -- </unique-5.2>
     })
 
diff --git a/test/sql/collation.result b/test/sql/collation.result
index 6f14d1e..5a931b8 100644
--- a/test/sql/collation.result
+++ b/test/sql/collation.result
@@ -676,8 +676,7 @@ box.execute("INSERT INTO t3b VALUES ('A');")
 ...
 box.execute("INSERT INTO t3b VALUES ('a');")
 ---
-- error: 'Failed to execute SQL statement: Duplicate key exists in unique index ''pk_unnamed_T3B_1''
-    in space ''T3B'''
+- error: Duplicate key exists in unique index 'pk_unnamed_T3B_1' in space 'T3B'
 ...
 box.execute("SELECT * FROM t3b;")
 ---
@@ -741,8 +740,7 @@ box.execute("INSERT INTO t3c VALUES ('A');")
 ...
 box.execute("INSERT INTO t3c VALUES ('a');")
 ---
-- error: 'Failed to execute SQL statement: Duplicate key exists in unique index ''pk_unnamed_T3C_1''
-    in space ''T3C'''
+- error: Duplicate key exists in unique index 'pk_unnamed_T3C_1' in space 'T3C'
 ...
 box.execute("SELECT * FROM t3c;")
 ---
@@ -806,8 +804,7 @@ box.execute("INSERT INTO t3d VALUES ('A');")
 ...
 box.execute("INSERT INTO t3d VALUES ('a');")
 ---
-- error: 'Failed to execute SQL statement: Duplicate key exists in unique index ''pk_unnamed_T3D_1''
-    in space ''T3D'''
+- error: Duplicate key exists in unique index 'pk_unnamed_T3D_1' in space 'T3D'
 ...
 box.execute("SELECT * FROM t3d;")
 ---
@@ -837,8 +834,7 @@ box.execute("INSERT INTO t3e VALUES ('a');")
 ...
 box.execute("INSERT INTO t3e VALUES ('A');")
 ---
-- error: 'Failed to execute SQL statement: Duplicate key exists in unique index ''pk_unnamed_T3E_1''
-    in space ''T3E'''
+- error: Duplicate key exists in unique index 'pk_unnamed_T3E_1' in space 'T3E'
 ...
 box.execute("SELECT * FROM t3e;")
 ---
@@ -901,8 +897,7 @@ box.execute("INSERT INTO t3f VALUES ('A');")
 ...
 box.execute("INSERT INTO t3f VALUES ('a');")
 ---
-- error: 'Failed to execute SQL statement: Duplicate key exists in unique index ''pk_unnamed_T3F_1''
-    in space ''T3F'''
+- error: Duplicate key exists in unique index 'pk_unnamed_T3F_1' in space 'T3F'
 ...
 box.execute("SELECT * FROM t3f;")
 ---
@@ -932,8 +927,7 @@ box.execute("INSERT INTO t3g VALUES ('a');")
 ...
 box.execute("INSERT INTO t3g VALUES ('A');")
 ---
-- error: 'Failed to execute SQL statement: Duplicate key exists in unique index ''pk_unnamed_T3G_1''
-    in space ''T3G'''
+- error: Duplicate key exists in unique index 'pk_unnamed_T3G_1' in space 'T3G'
 ...
 box.execute("SELECT * FROM t3g;")
 ---
diff --git a/test/sql/errinj.result b/test/sql/errinj.result
index ee36a38..75faad1 100644
--- a/test/sql/errinj.result
+++ b/test/sql/errinj.result
@@ -189,7 +189,7 @@ box.error.injection.set("ERRINJ_WAL_IO", true)
 ...
 box.execute("CREATE TRIGGER t1t INSERT ON t1 FOR EACH ROW BEGIN INSERT INTO t2 VALUES (1, 1); END;")
 ---
-- error: 'Failed to execute SQL statement: Failed to write to disk'
+- error: Failed to write to disk
 ...
 box.execute("CREATE INDEX t1a ON t1(a);")
 ---
@@ -257,7 +257,7 @@ box.error.injection.set("ERRINJ_WAL_IO", true)
 ...
 box.execute("DROP TRIGGER t1t;")
 ---
-- error: 'Failed to execute SQL statement: Failed to write to disk'
+- error: Failed to write to disk
 ...
 box.error.injection.set("ERRINJ_WAL_IO", false)
 ---
@@ -374,7 +374,7 @@ errinj.set("ERRINJ_WAL_IO", true)
 ...
 box.execute("ALTER TABLE t3 DROP CONSTRAINT fk1;")
 ---
-- error: 'Failed to execute SQL statement: Failed to write to disk'
+- error: Failed to write to disk
 ...
 box.execute("INSERT INTO t3 VALUES(1, 1, 3);")
 ---
diff --git a/test/sql/foreign-keys.result b/test/sql/foreign-keys.result
index 66eb94b..f3cca5c 100644
--- a/test/sql/foreign-keys.result
+++ b/test/sql/foreign-keys.result
@@ -181,8 +181,7 @@ t = box.space._fk_constraint:insert(t)
 --
 box.execute("DROP INDEX i1 on t1;")
 ---
-- error: 'Failed to execute SQL statement: Can''t modify space ''T1'': can not drop
-    a referenced index'
+- error: 'Can''t modify space ''T1'': can not drop a referenced index'
 ...
 -- Referenced index can't be altered as well, if alter leads to
 -- rebuild of index (e.g. index still can be renamed).
diff --git a/test/sql/insert-unique.result b/test/sql/insert-unique.result
index 61b35a3..236046f 100644
--- a/test/sql/insert-unique.result
+++ b/test/sql/insert-unique.result
@@ -28,14 +28,12 @@ box.execute("INSERT INTO zoobar VALUES (111, 222, 'c3', 444)")
 -- PK must be unique
 box.execute("INSERT INTO zoobar VALUES (112, 222, 'c3', 444)")
 ---
-- error: 'Failed to execute SQL statement: Duplicate key exists in unique index ''pk_unnamed_ZOOBAR_1''
-    in space ''ZOOBAR'''
+- error: Duplicate key exists in unique index 'pk_unnamed_ZOOBAR_1' in space 'ZOOBAR'
 ...
 -- Unique index must be respected
 box.execute("INSERT INTO zoobar VALUES (111, 223, 'c3', 444)")
 ---
-- error: 'Failed to execute SQL statement: Duplicate key exists in unique index ''ZOOBAR2''
-    in space ''ZOOBAR'''
+- error: Duplicate key exists in unique index 'ZOOBAR2' in space 'ZOOBAR'
 ...
 -- Cleanup
 box.execute("DROP INDEX zoobar2 ON zoobar")
diff --git a/test/sql/iproto.result b/test/sql/iproto.result
index e734872..73497b4 100644
--- a/test/sql/iproto.result
+++ b/test/sql/iproto.result
@@ -437,8 +437,7 @@ future1:wait_result()
 future2:wait_result()
 ---
 - null
-- 'Failed to execute SQL statement: Duplicate key exists in unique index ''pk_unnamed_TEST_1''
-  in space ''TEST'''
+- Duplicate key exists in unique index 'pk_unnamed_TEST_1' in space 'TEST'
 ...
 future3:wait_result()
 ---
diff --git a/test/sql/persistency.result b/test/sql/persistency.result
index 14b0f5d..15bee39 100644
--- a/test/sql/persistency.result
+++ b/test/sql/persistency.result
@@ -31,8 +31,7 @@ box.execute("INSERT INTO foobar VALUES (1000, 'foobar')")
 ...
 box.execute("INSERT INTO foobar VALUES (1, 'duplicate')")
 ---
-- error: 'Failed to execute SQL statement: Duplicate key exists in unique index ''pk_unnamed_FOOBAR_1''
-    in space ''FOOBAR'''
+- error: Duplicate key exists in unique index 'pk_unnamed_FOOBAR_1' in space 'FOOBAR'
 ...
 -- simple select
 box.execute("SELECT bar, foo, 42, 'awesome' FROM foobar")
@@ -416,8 +415,7 @@ box.execute("SELECT \"name\", \"opts\" FROM \"_trigger\"")
 -- prove barfoo2 still exists
 box.execute("INSERT INTO barfoo VALUES ('xfoo', 1)")
 ---
-- error: 'Failed to execute SQL statement: Duplicate key exists in unique index ''pk_unnamed_BARFOO_1''
-    in space ''BARFOO'''
+- error: Duplicate key exists in unique index 'pk_unnamed_BARFOO_1' in space 'BARFOO'
 ...
 box.execute("SELECT * FROM barfoo")
 ---
diff --git a/test/sql/transition.result b/test/sql/transition.result
index 9aea0cf..ff53361 100644
--- a/test/sql/transition.result
+++ b/test/sql/transition.result
@@ -28,8 +28,7 @@ box.execute("INSERT INTO foobar VALUES (1000, 'foobar')")
 ...
 box.execute("INSERT INTO foobar VALUES (1, 'duplicate')")
 ---
-- error: 'Failed to execute SQL statement: Duplicate key exists in unique index ''pk_unnamed_FOOBAR_1''
-    in space ''FOOBAR'''
+- error: Duplicate key exists in unique index 'pk_unnamed_FOOBAR_1' in space 'FOOBAR'
 ...
 -- simple select
 box.execute("SELECT bar, foo, 42, 'awesome' FROM foobar")
@@ -312,8 +311,7 @@ box.execute("INSERT INTO barfoo VALUES ('foobar', 1000)")
 -- prove barfoo2 was created
 box.execute("INSERT INTO barfoo VALUES ('xfoo', 1)")
 ---
-- error: 'Failed to execute SQL statement: Duplicate key exists in unique index ''pk_unnamed_BARFOO_1''
-    in space ''BARFOO'''
+- error: Duplicate key exists in unique index 'pk_unnamed_BARFOO_1' in space 'BARFOO'
 ...
 box.execute("SELECT foo, bar FROM barfoo")
 ---
diff --git a/test/sql/triggers.result b/test/sql/triggers.result
index 77b88f4..16df1fb 100644
--- a/test/sql/triggers.result
+++ b/test/sql/triggers.result
@@ -480,7 +480,7 @@ space_id = box.space.T1.id
 ...
 box.execute("CREATE TRIGGER tr1 AFTER INSERT ON t1 FOR EACH ROW WHEN new.a = ? BEGIN SELECT 1; END;")
 ---
-- error: 'Failed to execute SQL statement: bindings are not allowed in DDL'
+- error: bindings are not allowed in DDL
 ...
 tuple = {"TR1", space_id, {sql = [[CREATE TRIGGER tr1 AFTER INSERT ON t1 FOR EACH ROW WHEN new.a = ? BEGIN SELECT 1; END;]]}}
 ---
-- 
2.7.4

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [tarantool-patches] [PATCH v1 2/2] sql: remove error ER_SQL
  2019-04-24 19:57 [tarantool-patches] [PATCH v1 0/2] sql: remove error ER_SQL imeevma
  2019-04-24 19:57 ` [tarantool-patches] [PATCH v1 1/2] sql: remove errors SQL_TARANTOOL_*_FAIL imeevma
@ 2019-04-24 19:57 ` imeevma
  1 sibling, 0 replies; 3+ messages in thread
From: imeevma @ 2019-04-24 19:57 UTC (permalink / raw)
  To: korablev; +Cc: tarantool-patches

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 67c0109..9d5b269 100644
--- a/src/box/sql/build.c
+++ b/src/box/sql/build.c
@@ -469,7 +469,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 507448d..a9de6b6 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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-04-24 19:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-24 19:57 [tarantool-patches] [PATCH v1 0/2] sql: remove error ER_SQL imeevma
2019-04-24 19:57 ` [tarantool-patches] [PATCH v1 1/2] sql: remove errors SQL_TARANTOOL_*_FAIL imeevma
2019-04-24 19:57 ` [tarantool-patches] [PATCH v1 2/2] sql: remove error ER_SQL imeevma

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox