[tarantool-patches] Re: [PATCH v1 16/28] sql: remove SQL_TOOBIG errcode

Mergen Imeev imeevma at tarantool.org
Sat Jun 15 12:57:35 MSK 2019


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;





More information about the Tarantool-patches mailing list