From: imeevma@tarantool.org To: v.shpilevoy@tarantool.org Cc: tarantool-patches@freelists.org Subject: [tarantool-patches] [PATCH v1 21/28] sql: remove SQL_IOERR errcode Date: Mon, 10 Jun 2019 16:57:00 +0300 [thread overview] Message-ID: <43d58b909cf12211899eef9e2997dc171ddccdf9.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/malloc.c | 2 +- src/box/sql/os_unix.c | 35 +++++++++++++++-------------------- src/box/sql/sqlInt.h | 31 +------------------------------ src/box/sql/vdbeaux.c | 38 ++------------------------------------ src/box/sql/vdbesort.c | 1 - 5 files changed, 19 insertions(+), 88 deletions(-) diff --git a/src/box/sql/malloc.c b/src/box/sql/malloc.c index 4b8ef8f..64873f2 100644 --- a/src/box/sql/malloc.c +++ b/src/box/sql/malloc.c @@ -780,7 +780,7 @@ int sqlApiExit(sql * db, int rc) { assert(db != 0); - if (db->mallocFailed || rc == SQL_IOERR_NOMEM) { + if (db->mallocFailed) { return apiOomError(db); } return rc & db->errMask; diff --git a/src/box/sql/os_unix.c b/src/box/sql/os_unix.c index e2bda51..f0cf4ac 100644 --- a/src/box/sql/os_unix.c +++ b/src/box/sql/os_unix.c @@ -396,7 +396,7 @@ findInodeInfo(unixFile * pFile, /* Unix file with file desc used in the key */ rc = fstat(fd, &statbuf); if (rc != 0) { storeLastErrno(pFile, errno); - return SQL_IOERR; + return -1; } memset(&fileId, 0, sizeof(fileId)); @@ -554,9 +554,9 @@ 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. + * protocol. If this happens, return -1. */ - rc = SQL_IOERR_RDLOCK; + rc = -1; storeLastErrno(pFile, errno); goto end_unlock; } @@ -570,7 +570,7 @@ posixUnlock(sql_file * id, int eFileLock, int handleNFSUnlock) if (unixFileLock(pFile, &lock) == 0) { pInode->eFileLock = SHARED_LOCK; } else { - rc = SQL_IOERR_UNLOCK; + rc = -1; storeLastErrno(pFile, errno); goto end_unlock; } @@ -588,7 +588,7 @@ posixUnlock(sql_file * id, int eFileLock, int handleNFSUnlock) if (unixFileLock(pFile, &lock) == 0) { pInode->eFileLock = NO_LOCK; } else { - rc = SQL_IOERR_UNLOCK; + rc = -1; storeLastErrno(pFile, errno); pInode->eFileLock = NO_LOCK; pFile->eFileLock = NO_LOCK; @@ -755,7 +755,7 @@ seekAndRead(unixFile * id, sql_int64 offset, void *pBuf, int cnt) /* * Read data from a file into a buffer. Return 0 if all - * bytes were read successfully and SQL_IOERR if anything goes + * bytes were read successfully and -1 if anything goes * wrong. */ static int @@ -792,12 +792,12 @@ unixRead(sql_file * id, void *pBuf, int amt, sql_int64 offset) return 0; } else if (got < 0) { /* lastErrno set by seekAndRead */ - return SQL_IOERR_READ; + return -1; } else { storeLastErrno(pFile, 0); /* not a system error */ /* Unread parts of the buffer must be zero-filled */ memset(&((char *)pBuf)[got], 0, amt - got); - return SQL_IOERR_SHORT_READ; + return -1; } } @@ -871,7 +871,7 @@ unixWrite(sql_file * id, const void *pBuf, int amt, sql_int64 offset) if (amt > wrote) { if (wrote < 0 && pFile->lastErrno != ENOSPC) { /* lastErrno set by seekAndWrite */ - return SQL_IOERR_WRITE; + return -1; } else { storeLastErrno(pFile, 0); /* not a system error */ return -1; @@ -941,7 +941,7 @@ fcntlSizeHint(unixFile * pFile, i64 nByte) struct stat buf; /* Used to hold return values of fstat() */ if (fstat(pFile->h, &buf)) - return SQL_IOERR_FSTAT; + return -1; nSize = ((nByte + pFile->szChunk - @@ -960,7 +960,7 @@ fcntlSizeHint(unixFile * pFile, i64 nByte) iWrite = nSize - 1; nWrite = seekAndWrite(pFile, iWrite, "", 1); if (nWrite != 1) - return SQL_IOERR_WRITE; + return -1; } } } @@ -1167,7 +1167,7 @@ unixMapfile(unixFile * pFd, i64 nMap) if (nMap < 0) { struct stat statbuf; /* Low-level file information */ if (fstat(pFd->h, &statbuf)) - return SQL_IOERR_FSTAT; + return -1; nMap = statbuf.st_size; } if (nMap > pFd->mmapSizeMax) { @@ -1472,7 +1472,7 @@ unixGetTempname(int nBuf, char *zBuf) zDir = unixTempFileDir(); if (zDir == 0) - return SQL_IOERR_GETTEMPPATH; + return -1; do { u64 r; sql_randomness(sizeof(r), &r); @@ -1559,7 +1559,7 @@ getFileMode(const char *zFile, /* File name */ *pUid = sStat.st_uid; *pGid = sStat.st_gid; } else { - rc = SQL_IOERR_FSTAT; + rc = -1; } return rc; } @@ -1816,12 +1816,7 @@ unixDelete(sql_vfs * NotUsed, /* VFS containing this as the xDelete method */ int rc = 0; UNUSED_PARAMETER(NotUsed); if (unlink(zPath) == (-1)) { - if (errno == ENOENT) { - rc = SQL_IOERR_DELETE_NOENT; - } else { - rc = -1; - } - return rc; + return -1; } #ifndef SQL_DISABLE_DIRSYNC if ((dirSync & 1) != 0) { diff --git a/src/box/sql/sqlInt.h b/src/box/sql/sqlInt.h index 0743952..cff8ef5 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 { - /** Some kind of disk I/O error occurred. */ - SQL_IOERR = 3, /** Abort due to constraint violation. */ - SQL_TARANTOOL_ERROR, + SQL_TARANTOOL_ERROR = 4, /** sql_step() has another row ready. */ SQL_ROW, /** sql_step() has finished executing. */ @@ -572,33 +570,6 @@ sql_exec(sql *, /* An open database */ void *, /* 1st argument to callback */ char **errmsg /* Error msg written here */ ); -#define SQL_IOERR_READ (SQL_IOERR | (1<<8)) -#define SQL_IOERR_SHORT_READ (SQL_IOERR | (2<<8)) -#define SQL_IOERR_WRITE (SQL_IOERR | (3<<8)) -#define SQL_IOERR_FSYNC (SQL_IOERR | (4<<8)) -#define SQL_IOERR_DIR_FSYNC (SQL_IOERR | (5<<8)) -#define SQL_IOERR_TRUNCATE (SQL_IOERR | (6<<8)) -#define SQL_IOERR_FSTAT (SQL_IOERR | (7<<8)) -#define SQL_IOERR_UNLOCK (SQL_IOERR | (8<<8)) -#define SQL_IOERR_RDLOCK (SQL_IOERR | (9<<8)) -#define SQL_IOERR_DELETE (SQL_IOERR | (10<<8)) -#define SQL_IOERR_BLOCKED (SQL_IOERR | (11<<8)) -#define SQL_IOERR_NOMEM (SQL_IOERR | (12<<8)) -#define SQL_IOERR_ACCESS (SQL_IOERR | (13<<8)) -#define SQL_IOERR_CHECKRESERVEDLOCK (SQL_IOERR | (14<<8)) -#define SQL_IOERR_LOCK (SQL_IOERR | (15<<8)) -#define SQL_IOERR_CLOSE (SQL_IOERR | (16<<8)) -#define SQL_IOERR_DIR_CLOSE (SQL_IOERR | (17<<8)) -#define SQL_IOERR_SHMOPEN (SQL_IOERR | (18<<8)) -#define SQL_IOERR_SHMSIZE (SQL_IOERR | (19<<8)) -#define SQL_IOERR_SHMLOCK (SQL_IOERR | (20<<8)) -#define SQL_IOERR_SHMMAP (SQL_IOERR | (21<<8)) -#define SQL_IOERR_SEEK (SQL_IOERR | (22<<8)) -#define SQL_IOERR_DELETE_NOENT (SQL_IOERR | (23<<8)) -#define SQL_IOERR_MMAP (SQL_IOERR | (24<<8)) -#define SQL_IOERR_GETTEMPPATH (SQL_IOERR | (25<<8)) -#define SQL_IOERR_CONVPATH (SQL_IOERR | (26<<8)) -#define SQL_IOERR_VNODE (SQL_IOERR | (27<<8)) /** * Subtype of a main type. Allows to do some subtype specific diff --git a/src/box/sql/vdbeaux.c b/src/box/sql/vdbeaux.c index 7408b9f..8e2ca35 100644 --- a/src/box/sql/vdbeaux.c +++ b/src/box/sql/vdbeaux.c @@ -2055,7 +2055,7 @@ checkActiveVdbeCnt(sql * db) * transaction is rolled back. If eOp is SAVEPOINT_RELEASE, then the * statement transaction is committed. * - * If an IO error occurs, an SQL_IOERR_XXX error code is returned. + * If an IO error occurs, -1 is returned. * Otherwise 0. */ int @@ -2161,14 +2161,6 @@ sqlVdbeHalt(Vdbe * p) /* This function contains the logic that determines if a statement or * transaction will be committed or rolled back as a result of the * execution of this virtual machine. - * - * If any of the following errors occur: - * - * SQL_IOERR - * - * Then the internal cache might have been left in an inconsistent - * state. We need to rollback the statement transaction, if there is - * one, or the complete transaction if there is no statement transaction. */ if (db->mallocFailed) { @@ -2184,32 +2176,7 @@ sqlVdbeHalt(Vdbe * p) * SQL statement does not read or write a database file. */ if (p->pc >= 0) { - int mrc; /* Primary error code from p->rc */ int eStatementOp = 0; - int isSpecialError; /* Set to true if a 'special' error */ - - /* Check for one of the special errors */ - mrc = p->rc & 0xff; - isSpecialError = mrc == SQL_IOERR; - if (isSpecialError) { - /* At least a savepoint transaction must be rolled back - * to restore the database to a consistent state. - * - * Even if the statement is read-only, it is important to perform - * a statement or transaction rollback operation. If the error - * occurred while writing to the journal, sub-journal or database - * file as part of an effort to free up cache space (see function - * pagerStress() in pager.c), the rollback is required to restore - * the pager to a consistent state. - * We are forced to roll back the active transaction. Before doing - * so, abort any other statements this handle currently has active. - */ - box_txn_rollback(); - closeCursorsAndFree(p); - sqlRollbackAll(p); - sqlCloseSavepoints(p); - p->nChange = 0; - } /* Check for immediate foreign key violations. */ if (p->rc == 0) { @@ -2224,8 +2191,7 @@ sqlVdbeHalt(Vdbe * p) */ if (p->auto_commit) { if (p->rc == 0 - || (p->errorAction == ON_CONFLICT_ACTION_FAIL - && !isSpecialError)) { + || (p->errorAction == ON_CONFLICT_ACTION_FAIL)) { rc = sqlVdbeCheckFk(p, 1); if (rc != 0) { /* Close all opened cursors if diff --git a/src/box/sql/vdbesort.c b/src/box/sql/vdbesort.c index 3ff6807..7caf13b 100644 --- a/src/box/sql/vdbesort.c +++ b/src/box/sql/vdbesort.c @@ -542,7 +542,6 @@ vdbePmaReadBlob(PmaReader * p, /* PmaReader from which to take the blob */ /* Readr data from the file. Return early if an error occurs. */ rc = sqlOsRead(p->pFd, p->aBuffer, nRead, p->iReadOff); - assert(rc != SQL_IOERR_SHORT_READ); if (rc != 0) return rc; } -- 2.7.4
next prev parent reply other threads:[~2019-06-10 13:57 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 ` [tarantool-patches] [PATCH v1 19/28] sql: remove SQL_ERROR errcode imeevma 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 ` imeevma [this message] 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=43d58b909cf12211899eef9e2997dc171ddccdf9.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 21/28] sql: remove SQL_IOERR 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