[tarantool-patches] [PATCH v1 13/21] sql: remove SQL_BUSY errcode

imeevma at tarantool.org imeevma at tarantool.org
Sat May 25 13:44:51 MSK 2019


Removing this error code is part of getting rid of the SQL error
system.
---
 src/box/sql/main.c    |  2 +-
 src/box/sql/os_unix.c |  4 +---
 src/box/sql/sqlInt.h  |  2 --
 src/box/sql/vdbe.c    | 20 ++++++--------------
 src/box/sql/vdbeaux.c | 14 ++++----------
 5 files changed, 12 insertions(+), 30 deletions(-)

diff --git a/src/box/sql/main.c b/src/box/sql/main.c
index 65d8de5..052683e 100644
--- a/src/box/sql/main.c
+++ b/src/box/sql/main.c
@@ -266,7 +266,7 @@ sqlCreateFunc(sql * db,
 
 
 	/* Check if an existing function is being overridden or deleted. If so,
-	 * and there are active VMs, then return SQL_BUSY. If a function
+	 * and there are active VMs, then return an error. If a function
 	 * is being overridden/deleted but there are no active VMs, allow the
 	 * operation to continue but invalidate all precompiled statements.
 	 */
diff --git a/src/box/sql/os_unix.c b/src/box/sql/os_unix.c
index fa28c46..69f6867 100644
--- a/src/box/sql/os_unix.c
+++ b/src/box/sql/os_unix.c
@@ -554,9 +554,7 @@ posixUnlock(sql_file * id, int eFileLock, int handleNFSUnlock)
 					/* In theory, the call to unixFileLock() cannot fail because another
 					 * process is holding an incompatible lock. If it does, this
 					 * indicates that the other process is not following the locking
-					 * protocol. If this happens, return SQL_IOERR_RDLOCK. Returning
-					 * SQL_BUSY would confuse the upper layer (in practice it causes
-					 * an assert to fail).
+					 * protocol. If this happens, return SQL_IOERR_RDLOCK.
 					 */
 					rc = SQL_IOERR_RDLOCK;
 					storeLastErrno(pFile, errno);
diff --git a/src/box/sql/sqlInt.h b/src/box/sql/sqlInt.h
index fee6857..3cf2b8d 100644
--- a/src/box/sql/sqlInt.h
+++ b/src/box/sql/sqlInt.h
@@ -358,8 +358,6 @@ struct sql_vfs {
 enum sql_ret_code {
 	/** Common error code. */
 	SQL_ERROR = 1,
-	/** The database file is locked. */
-	SQL_BUSY,
 	/** A malloc() failed. */
 	SQL_NOMEM,
 	/** Some kind of disk I/O error occurred. */
diff --git a/src/box/sql/vdbe.c b/src/box/sql/vdbe.c
index 27ad06f..f4859b8 100644
--- a/src/box/sql/vdbe.c
+++ b/src/box/sql/vdbe.c
@@ -638,7 +638,7 @@ int sqlVdbeExec(Vdbe *p)
 		 */
 		goto no_mem;
 	}
-	assert(p->rc==0 || (p->rc&0xff)==SQL_BUSY);
+	assert(p->rc == 0);
 	p->rc = 0;
 	p->iCurrentTime = 0;
 	assert(p->explain==0);
@@ -981,13 +981,9 @@ case OP_Halt: {
 		assert(! diag_is_empty(diag_get()));
 	}
 	rc = sqlVdbeHalt(p);
-	assert(rc==SQL_BUSY || rc==0 || rc==SQL_ERROR);
-	if (rc==SQL_BUSY) {
-		p->rc = SQL_BUSY;
-	} else {
-		assert(rc==0 || (p->rc&0xff)==SQL_CONSTRAINT);
-		rc = p->rc ? SQL_TARANTOOL_ERROR : SQL_DONE;
-	}
+	assert(rc == 0 || rc==SQL_ERROR);
+	assert(rc==0 || (p->rc&0xff)==SQL_CONSTRAINT);
+	rc = p->rc ? SQL_TARANTOOL_ERROR : SQL_DONE;
 	goto vdbe_return;
 }
 
@@ -2900,11 +2896,7 @@ case OP_Savepoint: {
 				if ((rc = sqlVdbeCheckFk(p, 1))!=0) {
 					goto vdbe_return;
 				}
-				if (sqlVdbeHalt(p)==SQL_BUSY) {
-					p->pc = (int)(pOp - aOp);
-					p->rc = rc = SQL_BUSY;
-					goto vdbe_return;
-				}
+				sqlVdbeHalt(p);
 				if (p->rc != 0)
 					goto abort_due_to_error;
 			} else {
@@ -5313,7 +5305,7 @@ vdbe_return:
 	assert(rc!=0 || nExtraDelete==0
 		|| sql_strlike_ci("DELETE%", p->zSql, 0) != 0
 		);
-	assert(rc == 0 || rc == SQL_BUSY || rc == SQL_TARANTOOL_ERROR ||
+	assert(rc == 0 || rc == SQL_TARANTOOL_ERROR ||
 	       rc == SQL_ROW || rc == SQL_DONE);
 	return rc;
 
diff --git a/src/box/sql/vdbeaux.c b/src/box/sql/vdbeaux.c
index efc5103..4f06369 100644
--- a/src/box/sql/vdbeaux.c
+++ b/src/box/sql/vdbeaux.c
@@ -1420,8 +1420,7 @@ sqlVdbeList(Vdbe * p)
 
 	assert(p->explain);
 	assert(p->magic == VDBE_MAGIC_RUN);
-	assert(p->rc == 0 || p->rc == SQL_BUSY
-	       || p->rc == SQL_NOMEM);
+	assert(p->rc == 0 || p->rc == SQL_NOMEM);
 
 	/* Even though this opcode does not use dynamic strings for
 	 * the result, result columns may become dynamic if the user calls
@@ -2161,9 +2160,7 @@ sql_savepoint(MAYBE_UNUSED Vdbe *p, const char *zName)
  * SQL_MAGIC_RUN to SQL_MAGIC_HALT.  It is harmless to
  * call this on a VM that is in the SQL_MAGIC_HALT state.
  *
- * Return an error code.  If the commit could not complete because of
- * lock contention, return SQL_BUSY.  If SQL_BUSY is returned, it
- * means the close did not happen and needs to be repeated.
+ * Return an error code.
  */
 int
 sqlVdbeHalt(Vdbe * p)
@@ -2268,10 +2265,7 @@ sqlVdbeHalt(Vdbe * p)
 					     0 : SQL_TARANTOOL_ERROR;
 					closeCursorsAndFree(p);
 				}
-				if (rc == SQL_BUSY && !p->pDelFrame) {
-					closeCursorsAndFree(p);
-					return SQL_BUSY;
-				} else if (rc != 0) {
+				if (rc != 0) {
 					p->rc = rc;
 					box_txn_rollback();
 					closeCursorsAndFree(p);
@@ -2348,7 +2342,7 @@ sqlVdbeHalt(Vdbe * p)
 
 	assert(db->nVdbeActive > 0 || box_txn() ||
 	       p->anonymous_savepoint == NULL);
-	return (p->rc == SQL_BUSY ? SQL_BUSY : 0);
+	return 0;
 }
 
 /*
-- 
2.7.4





More information about the Tarantool-patches mailing list