[tarantool-patches] [PATCH v1 12/21] sql: remove SQL_TOOBIG errcode
imeevma at tarantool.org
imeevma at tarantool.org
Sat May 25 13:44:50 MSK 2019
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
More information about the Tarantool-patches
mailing list