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 7F8E92D813 for ; Tue, 28 May 2019 07:39:44 -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 SVcEZ332zNRy for ; Tue, 28 May 2019 07:39:44 -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 424702DD10 for ; Tue, 28 May 2019 07:39:44 -0400 (EDT) From: imeevma@tarantool.org Subject: [tarantool-patches] [PATCH v1 7/9] sql: remove error SQL_MISMATCH Date: Tue, 28 May 2019 14:39:42 +0300 Message-Id: <5bd1b4f827e29d704bb009ed9bac6ddafe97e460.1559043252.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: v.shpilevoy@tarantool.org Cc: tarantool-patches@freelists.org This patch replaces SQL error SQL_MISMATCH by Tarantool error ER_SQL_TYPE_MISMATCH. --- src/box/sql/main.c | 1 - src/box/sql/sqlInt.h | 2 -- src/box/sql/vdbe.c | 6 ++++-- test/sql-tap/autoinc.test.lua | 2 +- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/box/sql/main.c b/src/box/sql/main.c index 0c6ad47..a3c6aa1 100644 --- a/src/box/sql/main.c +++ b/src/box/sql/main.c @@ -378,7 +378,6 @@ sqlErrStr(int rc) /* SQL_SCHEMA */ "database schema has changed", /* SQL_TOOBIG */ "string or blob too big", /* SQL_CONSTRAINT */ "constraint failed", - /* SQL_MISMATCH */ "datatype mismatch", /* SQL_MISUSE */ "library routine called out of sequence", /* SQL_RANGE */ "bind or column index out of range", diff --git a/src/box/sql/sqlInt.h b/src/box/sql/sqlInt.h index 7f47da6..3981fbf 100644 --- a/src/box/sql/sqlInt.h +++ b/src/box/sql/sqlInt.h @@ -384,8 +384,6 @@ enum sql_ret_code { SQL_TOOBIG, /** Abort due to constraint violation. */ SQL_CONSTRAINT, - /** Data type mismatch. */ - SQL_MISMATCH, /** Library used incorrectly. */ SQL_MISUSE, /** 2nd parameter to sql_bind out of range. */ diff --git a/src/box/sql/vdbe.c b/src/box/sql/vdbe.c index 169ac45..d48b5b8 100644 --- a/src/box/sql/vdbe.c +++ b/src/box/sql/vdbe.c @@ -1853,7 +1853,7 @@ case OP_AddImm: { /* in1 */ * Force the value in register P1 to be an integer. If the value * in P1 is not an integer and cannot be converted into an integer * without data loss, then jump immediately to P2, or if P2==0 - * raise an SQL_MISMATCH exception. + * raise an ER_SQL_TYPE_MISMATCH error. */ case OP_MustBeInt: { /* jump, in1 */ pIn1 = &aMem[pOp->p1]; @@ -1862,7 +1862,9 @@ case OP_MustBeInt: { /* jump, in1 */ VdbeBranchTaken((pIn1->flags&MEM_Int)==0, 2); if ((pIn1->flags & MEM_Int)==0) { if (pOp->p2==0) { - rc = SQL_MISMATCH; + diag_set(ClientError, ER_SQL_TYPE_MISMATCH, + sql_value_text(pIn1), "integer"); + rc = SQL_TARANTOOL_ERROR; goto abort_due_to_error; } else { goto jump_to_p2; diff --git a/test/sql-tap/autoinc.test.lua b/test/sql-tap/autoinc.test.lua index 257621b..3e3eaad 100755 --- a/test/sql-tap/autoinc.test.lua +++ b/test/sql-tap/autoinc.test.lua @@ -810,7 +810,7 @@ test:do_catchsql_test( INSERT INTO t1 SELECT s2, s2 FROM t1; ]], { -- - 1, "Failed to execute SQL statement: datatype mismatch" + 1, "Type mismatch: can not convert a to integer" -- }) -- 2.7.4