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 647622FC69 for ; Sat, 15 Jun 2019 05:57:38 -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 QV6t8hba5sZC for ; Sat, 15 Jun 2019 05:57:38 -0400 (EDT) Received: from smtpng1.m.smailru.net (smtpng1.m.smailru.net [94.100.181.251]) (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 1DFCF2FC5B for ; Sat, 15 Jun 2019 05:57:38 -0400 (EDT) Date: Sat, 15 Jun 2019 12:57:35 +0300 From: Mergen Imeev Subject: [tarantool-patches] Re: [PATCH v1 16/28] sql: remove SQL_TOOBIG errcode Message-ID: <20190615095735.GE32365@tarantool.org> References: <94ba93d8866c7e8acf41f4ca99d3b6ee45a1ca10.1560174553.git.imeevma@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: 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: Vladislav Shpilevoy Cc: tarantool-patches@freelists.org On Fri, Jun 14, 2019 at 12:24:51AM +0200, Vladislav Shpilevoy wrote: > Thanks for the patch! > > Consider my review fixes below and on the branch > in a separate commit. > Thank you! New patch: m 2d50f8d28fb991190358a2ef49367909390d8fd1 Mon Sep 17 00:00:00 2001 Date: Tue, 21 May 2019 17:44:59 +0300 Subject: [PATCH] sql: remove SQL_TOOBIG errcode Removing this error code is part of getting rid of the SQL error system. diff --git a/src/box/sql/sqlInt.h b/src/box/sql/sqlInt.h index 9dfecb7..1056411 100644 --- a/src/box/sql/sqlInt.h +++ b/src/box/sql/sqlInt.h @@ -333,8 +333,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 46ca499..1ffb93e 100644 --- a/src/box/sql/vdbeapi.c +++ b/src/box/sql/vdbeapi.c @@ -258,7 +258,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. @@ -270,16 +270,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); @@ -291,10 +289,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 @@ -303,10 +302,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 @@ -391,7 +388,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; @@ -1124,7 +1123,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 3052bec..2a29b9e 100644 --- a/src/box/sql/vdbemem.c +++ b/src/box/sql/vdbemem.c @@ -949,7 +949,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 */ @@ -993,7 +993,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); @@ -1017,7 +1019,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;