From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id E8AA62E6AA for ; Mon, 10 Jun 2019 09:56:54 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Ng8gq2WpHKCW for ; Mon, 10 Jun 2019 09:56:54 -0400 (EDT) Received: from smtp54.i.mail.ru (smtp54.i.mail.ru [217.69.128.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id 9C69E2E676 for ; Mon, 10 Jun 2019 09:56:54 -0400 (EDT) From: imeevma@tarantool.org Subject: [tarantool-patches] [PATCH v1 17/28] sql: remove SQL_BUSY errcode Date: Mon, 10 Jun 2019 16:56:53 +0300 Message-Id: In-Reply-To: References: Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-Help: List-Unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-Subscribe: List-Owner: List-post: List-Archive: To: v.shpilevoy@tarantool.org Cc: tarantool-patches@freelists.org 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 f42b323..9f15893 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 896585c..c63f11c 100644 --- a/src/box/sql/vdbe.c +++ b/src/box/sql/vdbe.c @@ -752,7 +752,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); @@ -1068,13 +1068,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; } @@ -2886,11 +2882,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 { @@ -5291,7 +5283,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