Tarantool development patches archive
 help / color / mirror / Atom feed
From: imeevma@tarantool.org
To: v.shpilevoy@tarantool.org
Cc: tarantool-patches@freelists.org
Subject: [tarantool-patches] [PATCH v1 19/28] sql: remove SQL_ERROR errcode
Date: Mon, 10 Jun 2019 16:56:56 +0300	[thread overview]
Message-ID: <52f7bb2f54b32177d2f271ee4d866002c85c1f51.1560174553.git.imeevma@gmail.com> (raw)
In-Reply-To: <cover.1560174553.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  |  4 ++--
 src/box/sql/vdbesort.c |  2 +-
 11 files changed, 24 insertions(+), 27 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 6e22153..a1bed97 100644
--- a/src/box/sql/select.c
+++ b/src/box/sql/select.c
@@ -4410,7 +4410,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
@@ -4431,7 +4431,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;
 	}
@@ -4620,14 +4620,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);
@@ -4665,7 +4665,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));
@@ -4688,7 +4688,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 ec4eb29..3aabcb2 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 57d6d60..c8ca8c4 100644
--- a/src/box/sql/vdbe.c
+++ b/src/box/sql/vdbe.c
@@ -1068,7 +1068,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 ad8684d..db8687b 100644
--- a/src/box/sql/vdbeapi.c
+++ b/src/box/sql/vdbeapi.c
@@ -708,7 +708,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 443bff0..933ad6f 100644
--- a/src/box/sql/vdbemem.c
+++ b/src/box/sql/vdbemem.c
@@ -562,7 +562,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);
@@ -587,7 +587,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-06-10 13:56 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-10 13:56 [tarantool-patches] [PATCH v1 00/28] sql: Remove SQL error system imeevma
2019-06-10 13:56 ` [tarantool-patches] [PATCH v1 01/28] sql: remove field zErrMsg from struct Vdbe imeevma
2019-06-10 13:56 ` [tarantool-patches] [PATCH v1 02/28] sql: remove field pErr from struct sql imeevma
2019-06-10 13:56 ` [tarantool-patches] [PATCH v1 03/28] sql: remove field errCode " imeevma
2019-06-10 13:56 ` [tarantool-patches] [PATCH v1 04/28] sql: remove sqlError() and remove sqlErrorWithMsg() imeevma
2019-06-13 22:25   ` [tarantool-patches] " Vladislav Shpilevoy
2019-06-15  9:45     ` Mergen Imeev
2019-06-10 13:56 ` [tarantool-patches] [PATCH v1 05/28] sql: remove unused functions of SQL error system imeevma
2019-06-10 13:56 ` [tarantool-patches] [PATCH v1 06/28] sql: disable lookaside system imeevma
2019-06-13 22:25   ` [tarantool-patches] " Vladislav Shpilevoy
2019-06-15  9:47     ` Mergen Imeev
2019-06-10 13:56 ` [tarantool-patches] [PATCH v1 07/28] sql: remove SQL_OK error/status code imeevma
2019-06-13 22:24   ` [tarantool-patches] " Vladislav Shpilevoy
2019-06-15  9:52     ` Mergen Imeev
2019-06-10 13:56 ` [tarantool-patches] [PATCH v1 08/28] sql: remove SQL_PERM, SQL_WARNING, SQL_ABORT errcodes imeevma
2019-06-10 13:56 ` [tarantool-patches] [PATCH v1 09/28] sql: remove SQL_CANTOPEN errcode imeevma
2019-06-10 13:56 ` [tarantool-patches] [PATCH v1 10/28] sql: remove SQL_NOTFOUND error/status code imeevma
2019-06-10 13:56 ` [tarantool-patches] [PATCH v1 11/28] sql: remove SQL_LOCKED errcode imeevma
2019-06-10 13:56 ` [tarantool-patches] [PATCH v1 12/28] sql: remove SQL_FULL errcode imeevma
2019-06-10 13:56 ` [tarantool-patches] [PATCH v1 13/28] sql: remove SQL_MISUSE errcode imeevma
2019-06-10 13:56 ` [tarantool-patches] [PATCH v1 14/28] sql: remove SQL_RANGE errcode imeevma
2019-06-10 13:56 ` [tarantool-patches] [PATCH v1 15/28] sql: remove SQL_SCHEMA errcode imeevma
2019-06-13 22:24   ` [tarantool-patches] " Vladislav Shpilevoy
2019-06-15  9:55     ` Mergen Imeev
2019-06-10 13:56 ` [tarantool-patches] [PATCH v1 16/28] sql: remove SQL_TOOBIG errcode imeevma
2019-06-13 22:24   ` [tarantool-patches] " Vladislav Shpilevoy
2019-06-15  9:57     ` Mergen Imeev
2019-06-10 13:56 ` [tarantool-patches] [PATCH v1 17/28] sql: remove SQL_BUSY errcode imeevma
2019-06-10 13:56 ` [tarantool-patches] [PATCH v1 18/28] sql: remove SQL_CONSTRAINT errcode imeevma
2019-06-13 22:24   ` [tarantool-patches] " Vladislav Shpilevoy
2019-06-15 10:00     ` Mergen Imeev
2019-06-18 20:40       ` Vladislav Shpilevoy
2019-06-19  8:02         ` Mergen Imeev
2019-06-10 13:56 ` imeevma [this message]
2019-06-10 13:56 ` [tarantool-patches] [PATCH v1 20/28] sql: remove SQL_NOMEM errcode imeevma
2019-06-13 22:24   ` [tarantool-patches] " Vladislav Shpilevoy
2019-06-15 10:01     ` Mergen Imeev
2019-06-10 13:57 ` [tarantool-patches] [PATCH v1 21/28] sql: remove SQL_IOERR errcode imeevma
2019-06-10 13:57 ` [tarantool-patches] [PATCH v1 22/28] sql: remove SQL_TARANTOOL_ERROR errcode imeevma
2019-06-10 13:57 ` [tarantool-patches] [PATCH v1 23/28] sql: remove field errMask from struct sql imeevma
2019-06-10 13:57 ` [tarantool-patches] [PATCH v1 24/28] sql: replace rc by is_aborted in struct VDBE imeevma
2019-06-10 13:57 ` [tarantool-patches] [PATCH v1 25/28] sql: remove sql_log() imeevma
2019-06-13 22:24   ` [tarantool-patches] " Vladislav Shpilevoy
2019-06-15 10:02     ` Mergen Imeev
2019-06-10 13:57 ` [tarantool-patches] [PATCH v1 26/28] sql: cleanup of legacy memory management system imeevma
2019-06-13 22:24   ` [tarantool-patches] " Vladislav Shpilevoy
2019-06-15 10:04     ` Mergen Imeev
2019-06-18 20:40       ` Vladislav Shpilevoy
2019-06-19  8:04         ` Mergen Imeev
2019-06-10 13:57 ` [tarantool-patches] [PATCH v1 27/28] sql: make function return void instead of int imeevma
2019-06-10 13:57 ` [tarantool-patches] [PATCH v1 28/28] sql: remove function sqlApiExit() imeevma
2019-06-11 10:00 ` [tarantool-patches] Re: [PATCH v1 00/28] sql: Remove SQL error system Imeev Mergen
2019-06-13 22:24 ` Vladislav Shpilevoy
2019-06-15 10:08   ` Mergen Imeev
2019-06-19 19:11 ` Vladislav Shpilevoy
2019-06-20 16:08 ` Kirill Yukhin

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=52f7bb2f54b32177d2f271ee4d866002c85c1f51.1560174553.git.imeevma@gmail.com \
    --to=imeevma@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --cc=v.shpilevoy@tarantool.org \
    --subject='Re: [tarantool-patches] [PATCH v1 19/28] 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