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 5413D2E606 for ; Mon, 10 Jun 2019 09:56:53 -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 H86WcjbiXpZt for ; Mon, 10 Jun 2019 09:56:53 -0400 (EDT) Received: from smtp43.i.mail.ru (smtp43.i.mail.ru [94.100.177.103]) (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 0BCF52E6C2 for ; Mon, 10 Jun 2019 09:56:53 -0400 (EDT) From: imeevma@tarantool.org Subject: [tarantool-patches] [PATCH v1 16/28] sql: remove SQL_TOOBIG errcode Date: Mon, 10 Jun 2019 16:56:51 +0300 Message-Id: <94ba93d8866c7e8acf41f4ca99d3b6ee45a1ca10.1560174553.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 Removing this error code is part of getting rid of the SQL error system. --- src/box/sql/sqlInt.h | 2 -- src/box/sql/vdbeapi.c | 25 +++++++++++++------------ src/box/sql/vdbemem.c | 10 +++++++--- 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/src/box/sql/sqlInt.h b/src/box/sql/sqlInt.h index 180859a..f42b323 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 cf1afe4..ad8684d 100644 --- a/src/box/sql/vdbeapi.c +++ b/src/box/sql/vdbeapi.c @@ -262,7 +262,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. @@ -274,16 +274,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); @@ -295,10 +293,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 @@ -307,10 +306,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 @@ -395,7 +392,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; @@ -1181,7 +1180,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 2f7fe4f..443bff0 100644 --- a/src/box/sql/vdbemem.c +++ b/src/box/sql/vdbemem.c @@ -950,7 +950,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 */ @@ -994,7 +994,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); @@ -1018,7 +1020,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