From: imeevma@tarantool.org To: v.shpilevoy@tarantool.org Cc: tarantool-patches@freelists.org Subject: [tarantool-patches] [PATCH v1 09/28] sql: remove SQL_CANTOPEN errcode Date: Mon, 10 Jun 2019 16:56:39 +0300 [thread overview] Message-ID: <aa7a96eca14f1867f76ec7d93254d43d4d2d50e1.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/os_unix.c | 89 +++++++-------------------------------------------- src/box/sql/sqlInt.h | 2 -- 2 files changed, 11 insertions(+), 80 deletions(-) diff --git a/src/box/sql/os_unix.c b/src/box/sql/os_unix.c index d9e5656..18e42e5 100644 --- a/src/box/sql/os_unix.c +++ b/src/box/sql/os_unix.c @@ -318,66 +318,6 @@ struct unixInodeInfo { static unixInodeInfo *inodeList = 0; /* - * - * This function - unixLogErrorAtLine(), is only ever called via the macro - * unixLogError(). - * - * It is invoked after an error occurs in an OS function and errno has been - * set. It logs a message using sql_log() containing the current value of - * errno and, if possible, the human-readable equivalent from strerror() or - * strerror_r(). - * - * The first argument passed to the macro should be the error code that - * will be returned to sql (e.g. SQL_IOERR_DELETE, SQL_CANTOPEN). - * The two subsequent arguments should be the name of the OS function that - * failed (e.g. "unlink", "open") and the associated file-system path, - * if any. - */ -#define unixLogError(a,b,c) unixLogErrorAtLine(a,b,c,__LINE__) -static int -unixLogErrorAtLine(int errcode, /* sql error code */ - const char *zFunc, /* Name of OS function that failed */ - const char *zPath, /* File path associated with error */ - int iLine /* Source line number where error occurred */ - ) -{ - char *zErr; /* Message from strerror() or equivalent */ - int iErrno = errno; /* Saved syscall error number */ - - zErr = strerror(iErrno); - - if (zPath == 0) - zPath = ""; - sql_log(errcode, - "os_unix.c:%d: (%d) %s(%s) - %s", - iLine, iErrno, zFunc, zPath, zErr); - - return errcode; -} - -/* - * Close a file descriptor. - * - * We assume that close() almost always works, since it is only in a - * very sick application or on a very sick platform that it might fail. - * If it does fail, simply leak the file descriptor, but do log the - * error. - * - * Note that it is not safe to retry close() after EINTR since the - * file descriptor might have already been reused by another thread. - * So we don't even try to recover from an EINTR. Just log the error - * and move on. - */ -static void -robust_close(unixFile * pFile, int h, int lineno) -{ - if (close(h) != 0) { - unixLogErrorAtLine(SQL_IOERR_CLOSE, "close", - pFile ? pFile->zPath : 0, lineno); - } -} - -/* * Set the pFile->lastErrno. Do this in a subroutine as that provides * a convenient place to set a breakpoint. */ @@ -398,7 +338,7 @@ closePendingFds(unixFile * pFile) UnixUnusedFd *pNext; for (p = pInode->pUnused; p; p = pNext) { pNext = p->pNext; - robust_close(pFile, p->fd, __LINE__); + close(p->fd); sql_free(p); } pInode->pUnused = 0; @@ -705,7 +645,7 @@ closeUnixFile(sql_file * id) unixUnmapfile(pFile); #endif if (pFile->h >= 0) { - robust_close(pFile, pFile->h, __LINE__); + close(pFile->h); pFile->h = -1; } sql_free(pFile->pUnused); @@ -946,8 +886,7 @@ unixWrite(sql_file * id, const void *pBuf, int amt, sql_int64 offset) /* * Open a file descriptor to the directory containing file zFilename. * If successful, *pFd is set to the opened file descriptor and - * 0 is returned. If an error occurs, either SQL_NOMEM - * or SQL_CANTOPEN is returned and *pFd is set to an undefined + * 0 is returned. If an error occurs, -1 is set to an undefined * value. * * The directory file descriptor is used for only one thing - to @@ -987,7 +926,7 @@ openDirectory(const char *zFilename, int *pFd) *pFd = fd; if (fd >= 0) return 0; - return unixLogError(SQL_CANTOPEN, "openDirectory", zDirname); + return -1; } /* @@ -1032,8 +971,7 @@ fcntlSizeHint(unixFile * pFile, i64 nByte) if (pFile->szChunk <= 0) { if (robust_ftruncate(pFile->h, nByte)) { storeLastErrno(pFile, errno); - return unixLogError(SQL_IOERR_TRUNCATE, - "ftruncate", pFile->zPath); + return -1; } } @@ -1147,7 +1085,6 @@ unixRemapfile(unixFile * pFd, /* File descriptor object */ i64 nNew /* Required mapping size */ ) { - const char *zErr = "mmap"; int h = pFd->h; /* File descriptor open on db file */ u8 *pOrig = (u8 *) pFd->pMapRegion; /* Pointer to current file mapping */ i64 nOrig = pFd->mmapSizeActual; /* Size of pOrig region in bytes */ @@ -1170,7 +1107,6 @@ unixRemapfile(unixFile * pFd, /* File descriptor object */ munmap(pReq, nOrig - nReuse); #if !defined(__APPLE__) && !defined(__FreeBSD__) pNew = mremap(pOrig, nReuse, nNew, MREMAP_MAYMOVE); - zErr = "mremap"; #else pNew = mmap(pReq, nNew - nReuse, flags, MAP_SHARED, h, nReuse); if (pNew != MAP_FAILED) { @@ -1195,7 +1131,6 @@ unixRemapfile(unixFile * pFd, /* File descriptor object */ if (pNew == MAP_FAILED) { pNew = 0; nNew = 0; - unixLogError(0, zErr, pFd->zPath); /* If the mmap() above failed, assume that all subsequent mmap() calls * will probably fail too. Fall back to using xRead/xWrite exclusively @@ -1472,14 +1407,14 @@ fillInUnixFile(sql_vfs * pVfs, /* Pointer to vfs object */ * implicit assumption here is that if fstat() fails, things are in * such bad shape that dropping a lock or two doesn't matter much. */ - robust_close(pNew, h, __LINE__); + close(h); h = -1; } } storeLastErrno(pNew, 0); if (rc != 0) { if (h >= 0) - robust_close(pNew, h, __LINE__); + close(h); } else { pNew->pMethod = pLockingStyle; } @@ -1830,7 +1765,7 @@ unixOpen(sql_vfs * pVfs, /* The VFS for which this is the xOpen method */ fd = robust_open(zName, openFlags, openMode); } if (fd < 0) { - rc = unixLogError(SQL_CANTOPEN, "open", zName); + rc = -1; goto open_finished; } @@ -1886,7 +1821,7 @@ unixDelete(sql_vfs * NotUsed, /* VFS containing this as the xDelete method */ if (errno == ENOENT) { rc = SQL_IOERR_DELETE_NOENT; } else { - rc = unixLogError(SQL_IOERR_DELETE, "unlink", zPath); + rc = -1; } return rc; } @@ -1897,12 +1832,10 @@ unixDelete(sql_vfs * NotUsed, /* VFS containing this as the xDelete method */ if (rc == 0) { struct stat buf; if (fstat(fd, &buf)) { - rc = unixLogError(SQL_IOERR_DIR_FSYNC, - "fsync", zPath); + rc = -1; } - robust_close(0, fd, __LINE__); + close(fd); } else { - assert(rc == SQL_CANTOPEN); rc = 0; } } diff --git a/src/box/sql/sqlInt.h b/src/box/sql/sqlInt.h index 4c97acf..17033eb 100644 --- a/src/box/sql/sqlInt.h +++ b/src/box/sql/sqlInt.h @@ -370,8 +370,6 @@ enum sql_ret_code { SQL_NOTFOUND, /** Insertion failed because database is full. */ SQL_FULL, - /** Unable to open the database file. */ - SQL_CANTOPEN, /** The database schema changed. */ SQL_SCHEMA, /** String or BLOB exceeds size limit. */ -- 2.7.4
next prev 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 ` imeevma [this message] 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 ` [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=aa7a96eca14f1867f76ec7d93254d43d4d2d50e1.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 09/28] sql: remove SQL_CANTOPEN 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