Tarantool development patches archive
 help / color / mirror / Atom feed
From: imeevma@tarantool.org
To: korablev@tarantool.org
Cc: tarantool-patches@freelists.org
Subject: [tarantool-patches] [PATCH v1 15/21] sql: remove SQL_ERROR errcode
Date: Sat, 25 May 2019 13:44:55 +0300	[thread overview]
Message-ID: <8a7f4fed1b30e4d6f6778b065888bb8beb880e79.1558780708.git.imeevma@gmail.com> (raw)
In-Reply-To: <cover.1558780708.git.imeevma@gmail.com>

Removing this error code is part of getting rid of the SQL error
system.
---
 src/box/sql/date.c     |  4 ++--
 src/box/sql/main.c     |  2 +-
 src/box/sql/os_unix.c  |  5 ++---
 src/box/sql/select.c   | 12 ++++++------
 src/box/sql/sqlInt.h   |  4 +---
 src/box/sql/status.c   |  2 +-
 src/box/sql/vdbe.c     |  2 +-
 src/box/sql/vdbeapi.c  |  2 +-
 src/box/sql/vdbeaux.c  | 12 ++++++------
 src/box/sql/vdbemem.c  |  6 +++---
 src/box/sql/vdbesort.c |  2 +-
 11 files changed, 25 insertions(+), 28 deletions(-)

diff --git a/src/box/sql/date.c b/src/box/sql/date.c
index e193035..547932b 100644
--- a/src/box/sql/date.c
+++ b/src/box/sql/date.c
@@ -578,7 +578,7 @@ osLocaltime(time_t * t, struct tm *pTm)
  * (a.k.a. GMT) for the time value p where p is in UTC. If no error occurs,
  * return this value and set *pRc to 0.
  *
- * Or, if an error does occur, set *pRc to SQL_ERROR. The returned value
+ * Or, if an error does occur, set *pRc to -1. The returned value
  * is undefined in this case.
  */
 static sql_int64
@@ -619,7 +619,7 @@ localtimeOffset(DateTime * p,	/* Date at which to calculate offset */
 	if (osLocaltime(&t, &sLocal)) {
 		diag_set(ClientError, ER_SQL_EXECUTE, "local time unavailable");
 		pCtx->is_aborted = true;
-		*pRc = SQL_ERROR;
+		*pRc = -1;
 		return 0;
 	}
 	y.Y = sLocal.tm_year + 1900;
diff --git a/src/box/sql/main.c b/src/box/sql/main.c
index 052683e..8474836 100644
--- a/src/box/sql/main.c
+++ b/src/box/sql/main.c
@@ -320,7 +320,7 @@ sql_create_function_v2(sql * db,
 			   void (*xFinal) (sql_context *),
 			   void (*xDestroy) (void *))
 {
-	int rc = SQL_ERROR;
+	int rc = -1;
 	FuncDestructor *pArg = 0;
 
 	if (xDestroy) {
diff --git a/src/box/sql/os_unix.c b/src/box/sql/os_unix.c
index 69f6867..8b3aec1 100644
--- a/src/box/sql/os_unix.c
+++ b/src/box/sql/os_unix.c
@@ -1482,7 +1482,7 @@ unixGetTempname(int nBuf, char *zBuf)
 				 "%s/" SQL_TEMP_FILE_PREFIX "%llx%c", zDir,
 				 r, 0);
 		if (zBuf[nBuf - 2] != 0 || (iLimit++) > 10)
-			return SQL_ERROR;
+			return -1;
 	} while (access(zBuf, 0) == 0);
 	return 0;
 }
@@ -1877,8 +1877,7 @@ int sql_current_time = 0;
  * epoch of noon in Greenwich on November 24, 4714 B.C according to the
  * proleptic Gregorian calendar.
  *
- * On success, return 0.  Return SQL_ERROR if the time and date
- * cannot be found.
+ * On success, return 0.
  */
 static int
 unixCurrentTimeInt64(sql_vfs * NotUsed, sql_int64 * piNow)
diff --git a/src/box/sql/select.c b/src/box/sql/select.c
index 39a7383..5aad7f3 100644
--- a/src/box/sql/select.c
+++ b/src/box/sql/select.c
@@ -4422,7 +4422,7 @@ is_simple_count(struct Select *select, struct AggInfo *agg_info)
  * If the source-list item passed as an argument was augmented with an
  * INDEXED BY clause, then try to locate the specified index. If there
  * was such a clause and the named index cannot be found, return
- * SQL_ERROR and leave an error in pParse. Otherwise, populate
+ * -1 and set an error. Otherwise, populate
  * pFrom->pIndex and return 0.
  */
 int
@@ -4443,7 +4443,7 @@ sqlIndexedByLookup(Parse * pParse, struct SrcList_item *pFrom)
 			diag_set(ClientError, ER_NO_SUCH_INDEX_NAME,
 				 zIndexedBy, space->def->name);
 			pParse->is_aborted = true;
-			return SQL_ERROR;
+			return -1;
 		}
 		pFrom->pIBIndex = idx->def;
 	}
@@ -4632,14 +4632,14 @@ withExpand(Walker * pWalker, struct SrcList_item *pFrom)
 			diag_set(ClientError, ER_SQL_PARSER_GENERIC,
 				 tt_sprintf(pCte->zCteErr, pCte->zName));
 			pParse->is_aborted = true;
-			return SQL_ERROR;
+			return -1;
 		}
 		if (pFrom->fg.isTabFunc) {
 			const char *err = "'%s' is not a function";
 			diag_set(ClientError, ER_SQL_PARSER_GENERIC,
 				 tt_sprintf(err, pFrom->zName));
 			pParse->is_aborted = true;
-			return SQL_ERROR;
+			return -1;
 		}
 
 		assert(pFrom->space == NULL);
@@ -4677,7 +4677,7 @@ withExpand(Walker * pWalker, struct SrcList_item *pFrom)
 					   "table: %s", pCte->zName);
 			diag_set(ClientError, ER_SQL_PARSER_GENERIC, err_msg);
 			pParse->is_aborted = true;
-			return SQL_ERROR;
+			return -1;
 		}
 		assert(ref_counter == 0 ||
 			((pSel->selFlags & SF_Recursive) && ref_counter == 1));
@@ -4700,7 +4700,7 @@ withExpand(Walker * pWalker, struct SrcList_item *pFrom)
 				diag_set(ClientError, ER_SQL_PARSER_GENERIC, err_msg);
 				pParse->is_aborted = true;
 				pParse->pWith = pSavedWith;
-				return SQL_ERROR;
+				return -1;
 			}
 			pEList = pCte->pCols;
 		}
diff --git a/src/box/sql/sqlInt.h b/src/box/sql/sqlInt.h
index 802a367..a7b3355 100644
--- a/src/box/sql/sqlInt.h
+++ b/src/box/sql/sqlInt.h
@@ -356,10 +356,8 @@ struct sql_vfs {
 #define SQL_LIMIT_WORKER_THREADS           10
 
 enum sql_ret_code {
-	/** Common error code. */
-	SQL_ERROR = 1,
 	/** A malloc() failed. */
-	SQL_NOMEM,
+	SQL_NOMEM = 2,
 	/** Some kind of disk I/O error occurred. */
 	SQL_IOERR,
 	/** Abort due to constraint violation. */
diff --git a/src/box/sql/status.c b/src/box/sql/status.c
index 10be3d9..d6de484 100644
--- a/src/box/sql/status.c
+++ b/src/box/sql/status.c
@@ -257,7 +257,7 @@ sql_db_status(sql * db,	/* The database connection whose status is desired */
 		}
 
 	default:{
-			rc = SQL_ERROR;
+			rc = -1;
 		}
 	}
 	return rc;
diff --git a/src/box/sql/vdbe.c b/src/box/sql/vdbe.c
index 9a9ca55..e3f8ee3 100644
--- a/src/box/sql/vdbe.c
+++ b/src/box/sql/vdbe.c
@@ -981,7 +981,7 @@ case OP_Halt: {
 		assert(! diag_is_empty(diag_get()));
 	}
 	rc = sqlVdbeHalt(p);
-	assert(rc == 0 || rc==SQL_ERROR);
+	assert(rc == 0 || rc == -1);
 	rc = p->rc ? SQL_TARANTOOL_ERROR : SQL_DONE;
 	goto vdbe_return;
 }
diff --git a/src/box/sql/vdbeapi.c b/src/box/sql/vdbeapi.c
index 55b4b2e..8fd4c20 100644
--- a/src/box/sql/vdbeapi.c
+++ b/src/box/sql/vdbeapi.c
@@ -718,7 +718,7 @@ columnMallocFailure(sql_stmt * pStmt)
 {
 	/* If malloc() failed during an encoding conversion within an
 	 * sql_column_XXX API, then set the return code of the statement to
-	 * SQL_NOMEM. The next call to _step() (if any) will return SQL_ERROR
+	 * SQL_NOMEM. The next call to _step() (if any) will return -1
 	 * and _finalize() will return NOMEM.
 	 */
 	Vdbe *p = (Vdbe *) pStmt;
diff --git a/src/box/sql/vdbeaux.c b/src/box/sql/vdbeaux.c
index 308373b..e056c40 100644
--- a/src/box/sql/vdbeaux.c
+++ b/src/box/sql/vdbeaux.c
@@ -1434,7 +1434,7 @@ sqlVdbeList(Vdbe * p)
 		 * sql_column_text16() failed.
 		 */
 		sqlOomFault(db);
-		return SQL_ERROR;
+		return -1;
 	}
 
 	/* When the number of output rows reaches nRow, that means the
@@ -1540,7 +1540,7 @@ sqlVdbeList(Vdbe * p)
 
 		if (sqlVdbeMemClearAndResize(pMem, 256)) {
 			assert(p->db->mallocFailed);
-			return SQL_ERROR;
+			return -1;
 		}
 		pMem->flags = MEM_Str | MEM_Term;
 		zP4 = displayP4(pOp, pMem->z, pMem->szMalloc);
@@ -1557,7 +1557,7 @@ sqlVdbeList(Vdbe * p)
 		if (p->explain == 1) {
 			if (sqlVdbeMemClearAndResize(pMem, 4)) {
 				assert(p->db->mallocFailed);
-				return SQL_ERROR;
+				return -1;
 			}
 			pMem->flags = MEM_Str | MEM_Term;
 			pMem->n = 2;
@@ -1567,7 +1567,7 @@ sqlVdbeList(Vdbe * p)
 #ifdef SQL_ENABLE_EXPLAIN_COMMENTS
 			if (sqlVdbeMemClearAndResize(pMem, 500)) {
 				assert(p->db->mallocFailed);
-				return SQL_ERROR;
+				return -1;
 			}
 			pMem->flags = MEM_Str | MEM_Term;
 			pMem->n = displayComment(pOp, zP4, pMem->z, 500);
@@ -2085,7 +2085,7 @@ sqlVdbeCloseStatement(Vdbe * p, int eOp)
  * This function is called when a transaction opened by the database
  * handle associated with the VM passed as an argument is about to be
  * committed. If there are outstanding deferred foreign key constraint
- * violations, return SQL_ERROR. Otherwise, 0.
+ * violations, return -1. Otherwise, 0.
  *
  * If there are outstanding FK violations and this function returns
  * SQL_TARANTOOL_ERROR and set an error.
@@ -2250,7 +2250,7 @@ sqlVdbeHalt(Vdbe * p)
 					 */
 					if (NEVER(p->pDelFrame)) {
 						closeCursorsAndFree(p);
-						return SQL_ERROR;
+						return -1;
 					}
 				} else {
 					/* The auto-commit flag is true, the vdbe program was successful
diff --git a/src/box/sql/vdbemem.c b/src/box/sql/vdbemem.c
index 8be2e69..860e382 100644
--- a/src/box/sql/vdbemem.c
+++ b/src/box/sql/vdbemem.c
@@ -543,7 +543,7 @@ sqlVdbeMemIntegerify(Mem * pMem, bool is_forced)
 
 	double d;
 	if (sqlVdbeRealValue(pMem, &d) || (int64_t) d != d) {
-		return SQL_ERROR;
+		return -1;
 	}
 	pMem->u.i = (int64_t) d;
 	MemSetTypeFlag(pMem, MEM_Int);
@@ -560,7 +560,7 @@ sqlVdbeMemRealify(Mem * pMem)
 	assert(EIGHT_BYTE_ALIGNMENT(pMem));
 	double v;
 	if (sqlVdbeRealValue(pMem, &v))
-		return SQL_ERROR;
+		return -1;
 
 	pMem->u.r = v;
 	MemSetTypeFlag(pMem, MEM_Real);
@@ -585,7 +585,7 @@ sqlVdbeMemNumerify(Mem * pMem)
 		} else {
 			double v;
 			if (sqlVdbeRealValue(pMem, &v))
-				return SQL_ERROR;
+				return -1;
 			pMem->u.r = v;
 			MemSetTypeFlag(pMem, MEM_Real);
 			mem_apply_integer_type(pMem);
diff --git a/src/box/sql/vdbesort.c b/src/box/sql/vdbesort.c
index f7fc8e1..b6ae888 100644
--- a/src/box/sql/vdbesort.c
+++ b/src/box/sql/vdbesort.c
@@ -1027,7 +1027,7 @@ vdbeSorterJoinThread(SortSubtask * pTask)
 #ifdef SQL_DEBUG_SORTER_THREADS
 		int bDone = pTask->bDone;
 #endif
-		void *pRet = SQL_INT_TO_PTR(SQL_ERROR);
+		void *pRet = SQL_INT_TO_PTR(-1);
 		vdbeSorterBlockDebug(pTask, !bDone, "enter");
 		(void)sqlThreadJoin(pTask->pThread, &pRet);
 		vdbeSorterBlockDebug(pTask, !bDone, "exit");
-- 
2.7.4

  parent reply	other threads:[~2019-05-25 10:44 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-25 10:44 [tarantool-patches] [PATCH v1 00/21] sql: remove SQL error system imeevma
2019-05-25 10:44 ` [tarantool-patches] [PATCH v1 01/21] sql: remove unused functions of " imeevma
2019-05-25 10:44 ` [tarantool-patches] [PATCH v1 02/21] sql: disable lookaside system imeevma
2019-05-25 10:44 ` [tarantool-patches] [PATCH v1 03/21] sql: remove SQL_OK error/status code imeevma
2019-05-25 14:45   ` [tarantool-patches] " n.pettik
2019-05-26  9:39     ` Mergen Imeev
2019-05-25 10:44 ` [tarantool-patches] [PATCH v1 04/21] sql: remove SQL_PERM, SQL_WARNING, SQL_ABORT errcodes imeevma
2019-05-25 10:44 ` [tarantool-patches] [PATCH v1 05/21] sql: remove SQL_CANTOPEN errcode imeevma
2019-05-25 10:44 ` [tarantool-patches] [PATCH v1 06/21] sql: remove SQL_NOTFOUND error/status code imeevma
2019-05-25 14:58   ` [tarantool-patches] " n.pettik
2019-05-25 20:26     ` Konstantin Osipov
2019-05-26 16:07       ` n.pettik
2019-05-26  9:45     ` Mergen Imeev
2019-05-25 10:44 ` [tarantool-patches] [PATCH v1 07/21] sql: remove SQL_LOCKED errcode imeevma
2019-05-25 10:44 ` [tarantool-patches] [PATCH v1 08/21] sql: remove SQL_FULL errcode imeevma
2019-05-25 10:44 ` [tarantool-patches] [PATCH v1 09/21] sql: remove SQL_MISUSE errcode imeevma
2019-05-25 10:44 ` [tarantool-patches] [PATCH v1 10/21] sql: remove SQL_RANGE errcode imeevma
2019-05-25 10:44 ` [tarantool-patches] [PATCH v1 11/21] sql: remove SQL_SCHEMA errcode imeevma
2019-05-25 16:18   ` [tarantool-patches] " n.pettik
2019-05-26  9:46     ` Mergen Imeev
2019-05-25 10:44 ` [tarantool-patches] [PATCH v1 12/21] sql: remove SQL_TOOBIG errcode imeevma
2019-05-25 16:11   ` [tarantool-patches] " n.pettik
2019-05-26 12:12     ` Mergen Imeev
2019-05-25 10:44 ` [tarantool-patches] [PATCH v1 13/21] sql: remove SQL_BUSY errcode imeevma
2019-05-25 10:44 ` [tarantool-patches] [PATCH v1 14/21] sql: remove SQL_CONSTRAINT errcode imeevma
2019-05-25 10:44 ` imeevma [this message]
2019-05-25 10:44 ` [tarantool-patches] [PATCH v1 16/21] sql: remove SQL_NOMEM errcode imeevma
2019-05-25 10:44 ` [tarantool-patches] [PATCH v1 17/21] sql: remove SQL_IOERR errcode imeevma
2019-05-25 10:45 ` [tarantool-patches] [PATCH v1 18/21] sql: remove SQL_TARANTOOL_ERROR errcode imeevma
2019-05-25 10:45 ` [tarantool-patches] [PATCH v1 19/21] sql: remove field errMask from struct sql imeevma
2019-05-25 10:45 ` [tarantool-patches] [PATCH v1 20/21] sql: replace rc by is_aborted in struct Parse imeevma
2019-05-25 15:46   ` [tarantool-patches] " n.pettik
2019-05-26  9:49     ` Mergen Imeev
2019-05-25 10:45 ` [tarantool-patches] [PATCH v1 21/21] sql: remove sql_log() imeevma
2019-05-25 16:36 ` [tarantool-patches] Re: [PATCH v1 00/21] sql: remove SQL error system n.pettik
2019-05-28 11:12   ` Mergen Imeev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8a7f4fed1b30e4d6f6778b065888bb8beb880e79.1558780708.git.imeevma@gmail.com \
    --to=imeevma@tarantool.org \
    --cc=korablev@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='Re: [tarantool-patches] [PATCH v1 15/21] sql: remove SQL_ERROR errcode' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox