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 4816B2FD7D for ; Sat, 25 May 2019 06:44:52 -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 ljWAZhdruWml for ; Sat, 25 May 2019 06:44:52 -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 0856F2FD6F for ; Sat, 25 May 2019 06:44:51 -0400 (EDT) From: imeevma@tarantool.org Subject: [tarantool-patches] [PATCH v1 12/21] sql: remove SQL_TOOBIG errcode Date: Sat, 25 May 2019 13:44:50 +0300 Message-Id: <8947c9a4984d9490a7557bd08fa629be158eccc9.1558780708.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 Removing this error code is part of getting rid of the SQL error system. --- src/box/bind.c | 13 ++----------- src/box/sql/sqlInt.h | 2 -- src/box/sql/vdbeapi.c | 25 +++++++++++++------------ src/box/sql/vdbemem.c | 10 +++++++--- 4 files changed, 22 insertions(+), 28 deletions(-) diff --git a/src/box/bind.c b/src/box/bind.c index 90d56d6..754f6c7 100644 --- a/src/box/bind.c +++ b/src/box/bind.c @@ -207,16 +207,7 @@ sql_bind_column(struct sql_stmt *stmt, const struct sql_bind *p, } if (rc == 0) return 0; - - switch (rc) { - case SQL_NOMEM: - diag_set(OutOfMemory, p->bytes, "vdbe", "bind value"); - break; - case SQL_TOOBIG: - default: - diag_set(ClientError, ER_SQL_BIND_VALUE, sql_bind_name(p), - mp_type_strs[p->type]); - break; - } + diag_set(ClientError, ER_SQL_BIND_VALUE, sql_bind_name(p), + mp_type_strs[p->type]); return -1; } diff --git a/src/box/sql/sqlInt.h b/src/box/sql/sqlInt.h index 0419933..fee6857 100644 --- a/src/box/sql/sqlInt.h +++ b/src/box/sql/sqlInt.h @@ -364,8 +364,6 @@ enum sql_ret_code { SQL_NOMEM, /** Some kind of disk I/O error occurred. */ SQL_IOERR, - /** String or BLOB exceeds size limit. */ - SQL_TOOBIG, /** Abort due to constraint violation. */ SQL_CONSTRAINT, SQL_TARANTOOL_ERROR, diff --git a/src/box/sql/vdbeapi.c b/src/box/sql/vdbeapi.c index 78b6db9..55b4b2e 100644 --- a/src/box/sql/vdbeapi.c +++ b/src/box/sql/vdbeapi.c @@ -272,7 +272,7 @@ sql_value_free(sql_value * pOld) * * The setStrOrError() function calls sqlVdbeMemSetStr() to store the * result as a string or blob but if the string or blob is too large, it - * then sets the error code to SQL_TOOBIG + * then sets the error code. * * The invokeValueDestructor(P,X) routine invokes destructor function X() * on value P is not going to be used and need to be destroyed. @@ -284,16 +284,14 @@ setResultStrOrError(sql_context * pCtx, /* Function context */ void (*xDel) (void *) /* Destructor function */ ) { - if (sqlVdbeMemSetStr(pCtx->pOut, z, n,1, xDel) == SQL_TOOBIG) { - diag_set(ClientError, ER_SQL_EXECUTE, "string or blob too big"); + if (sqlVdbeMemSetStr(pCtx->pOut, z, n,1, xDel) != 0) pCtx->is_aborted = true; - } } static int invokeValueDestructor(const void *p, /* Value to destroy */ void (*xDel) (void *), /* The destructor */ - sql_context * pCtx /* Set a SQL_TOOBIG error if no NULL */ + sql_context * pCtx /* Set an error if no NULL */ ) { assert(xDel != SQL_DYNAMIC); @@ -305,10 +303,11 @@ invokeValueDestructor(const void *p, /* Value to destroy */ xDel((void *)p); } if (pCtx) { - diag_set(ClientError, ER_SQL_EXECUTE, "string or blob too big"); + diag_set(ClientError, ER_SQL_EXECUTE, "string or blob is too "\ + "big"); pCtx->is_aborted = true; } - return SQL_TOOBIG; + return SQL_TARANTOOL_ERROR; } void @@ -317,10 +316,8 @@ sql_result_blob(sql_context * pCtx, ) { assert(n >= 0); - if (sqlVdbeMemSetStr(pCtx->pOut, z, n,0, xDel) == SQL_TOOBIG) { - diag_set(ClientError, ER_SQL_EXECUTE, "string or blob too big"); + if (sqlVdbeMemSetStr(pCtx->pOut, z, n,0, xDel) != 0) pCtx->is_aborted = true; - } } void @@ -405,7 +402,9 @@ sql_result_zeroblob64(sql_context * pCtx, u64 n) { Mem *pOut = pCtx->pOut; if (n > (u64) pOut->db->aLimit[SQL_LIMIT_LENGTH]) { - return SQL_TOOBIG; + diag_set(ClientError, ER_SQL_EXECUTE, "string or blob is too "\ + "big"); + return SQL_TARANTOOL_ERROR; } sqlVdbeMemSetZeroBlob(pCtx->pOut, (int)n); return 0; @@ -1189,7 +1188,9 @@ sql_bind_zeroblob64(sql_stmt * pStmt, int i, sql_uint64 n) int rc; Vdbe *p = (Vdbe *) pStmt; if (n > (u64) p->db->aLimit[SQL_LIMIT_LENGTH]) { - rc = SQL_TOOBIG; + diag_set(ClientError, ER_SQL_EXECUTE, "string or blob is too "\ + "big"); + rc = SQL_TARANTOOL_ERROR; } else { assert((n & 0x7FFFFFFF) == n); rc = sql_bind_zeroblob(pStmt, i, n); diff --git a/src/box/sql/vdbemem.c b/src/box/sql/vdbemem.c index 4bb82b8..8be2e69 100644 --- a/src/box/sql/vdbemem.c +++ b/src/box/sql/vdbemem.c @@ -936,7 +936,7 @@ sqlVdbeMemMove(Mem * pTo, Mem * pFrom) * size limit) then no memory allocation occurs. If the string can be * stored without allocating memory, then it is. If a memory allocation * is required to store the string, then value of pMem is unchanged. In - * either case, SQL_TOOBIG is returned. + * either case, error is returned. */ int sqlVdbeMemSetStr(Mem * pMem, /* Memory cell to set to string value */ @@ -980,7 +980,9 @@ sqlVdbeMemSetStr(Mem * pMem, /* Memory cell to set to string value */ nAlloc += 1; //SQL_UTF8 } if (nByte > iLimit) { - return SQL_TOOBIG; + diag_set(ClientError, ER_SQL_EXECUTE, "string or blob "\ + "is too big"); + return SQL_TARANTOOL_ERROR; } testcase(nAlloc == 0); testcase(nAlloc == 31); @@ -1004,7 +1006,9 @@ sqlVdbeMemSetStr(Mem * pMem, /* Memory cell to set to string value */ pMem->flags = flags; if (nByte > iLimit) { - return SQL_TOOBIG; + diag_set(ClientError, ER_SQL_EXECUTE, "string or blob is too "\ + "big"); + return SQL_TARANTOOL_ERROR; } return 0; -- 2.7.4