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 614202DDD1 for ; Fri, 26 Apr 2019 08:23:24 -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 xvsiPTf642Hi for ; Fri, 26 Apr 2019 08:23:24 -0400 (EDT) Received: from smtp50.i.mail.ru (smtp50.i.mail.ru [94.100.177.110]) (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 1BC722DDCC for ; Fri, 26 Apr 2019 08:23:24 -0400 (EDT) From: imeevma@tarantool.org Subject: [tarantool-patches] [PATCH v1 2/3] sql: remove error SQL_MISMATCH Date: Fri, 26 Apr 2019 15:23:22 +0300 Message-Id: <25258efae14db8e28d1a473f931346b9cae3ddcf.1556281123.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 This patch replaces SQL error SQL_MISMATCH by Tarantool error ER_SQL_TYPE_MISMATCH. Part of #4074 --- 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 88d1cc5..655ea62 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 c2eec93..bdf7429 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