From: Stanislav Zudin <szudin@tarantool.org> To: "n.pettik" <korablev@tarantool.org>, tarantool-patches@freelists.org Subject: [tarantool-patches] Re: [PATCH] sql: remove useless pragmas Date: Fri, 8 Feb 2019 19:46:47 +0300 [thread overview] Message-ID: <2498e858-96b4-cd47-5ee7-2c1996d6b11d@tarantool.org> (raw) In-Reply-To: <EE20AA6E-8270-4010-9D91-C673734B3C12@tarantool.org> On 08.02.2019 17:03, n.pettik wrote: > > >> On 8 Feb 2019, at 13:17, Stanislav Zudin <szudin@tarantool.org >> <mailto:szudin@tarantool.org>> wrote: >> >> On 06.02.2019 16:21, n.pettik wrote: >>> >>>> On 6 Feb 2019, at 15:18, Stanislav Zudin <szudin@tarantool.org >>>> <mailto:szudin@tarantool.org>> wrote: >>>> >>>> The pragmas "query_only" and "read_uncommitted" didn't affect >>>> anything and were removed. >>> Nit: please, fit commit message into 72 symbols. >> Mea culpa >>> >>> What about “busy_timeout”? As I see from code it is also useless. >>> It may require to delete some code more code. >> It calls sqlite_busy_handler. Does this feature work? > > No, it doesn’t. You can remove it in a separate patch. Below you'll find a commit with removed pragma busy_timeout: The pragma "busy_timeout" is removed. SQLite's busyHandler functionality and functions sqlite3_sleep(), sqlite3OsSleep() were not used and were removed either. Closes #3733 --- Branch: https://github.com/tarantool/tarantool/tree/stanztt/gh-3733-obsolete-pragmas Issue: https://github.com/tarantool/tarantool/issues/3733 src/box/sql/main.c | 76 ----------------------------------------- src/box/sql/os.c | 6 ---- src/box/sql/os.h | 1 - src/box/sql/os_unix.c | 18 ---------- src/box/sql/pragma.c | 23 ++++--------- src/box/sql/pragma.h | 8 ----- src/box/sql/sqliteInt.h | 6 ---- src/box/sql/vdbe.c | 1 - 8 files changed, 6 insertions(+), 133 deletions(-) diff --git a/src/box/sql/main.c b/src/box/sql/main.c index 8574d6464..5555cb48e 100644 --- a/src/box/sql/main.c +++ b/src/box/sql/main.c @@ -640,43 +640,6 @@ sqlite3ErrStr(int rc) return zErr; } -/* - * This routine implements a busy callback that sleeps and tries - * again until a timeout value is reached. The timeout value is - * an integer number of milliseconds passed in as the first - * argument. - */ -static int -sqliteDefaultBusyCallback(void *ptr, /* Database connection */ - int count) /* Number of times table has been busy */ -{ - sqlite3 *db = (sqlite3 *) ptr; - int timeout = ((sqlite3 *) ptr)->busyTimeout; - if ((count + 1) * 1000 > timeout) { - return 0; - } - sqlite3OsSleep(db->pVfs, 1000000); - return 1; -} - -/* - * This routine sets the busy callback for an Sqlite database to the - * given callback function with the given argument. - */ -int -sqlite3_busy_handler(sqlite3 * db, int (*xBusy) (void *, int), void *pArg) -{ -#ifdef SQLITE_ENABLE_API_ARMOR - if (!sqlite3SafetyCheckOk(db)) - return SQLITE_MISUSE_BKPT; -#endif - db->busyHandler.xFunc = xBusy; - db->busyHandler.pArg = pArg; - db->busyHandler.nBusy = 0; - db->busyTimeout = 0; - return SQLITE_OK; -} - #ifndef SQLITE_OMIT_PROGRESS_CALLBACK /* * This routine sets the progress callback for an Sqlite database to the @@ -705,26 +668,6 @@ sqlite3_progress_handler(sqlite3 * db, } #endif -/* - * This routine installs a default busy handler that waits for the - * specified number of milliseconds before returning 0. - */ -int -sqlite3_busy_timeout(sqlite3 * db, int ms) -{ -#ifdef SQLITE_ENABLE_API_ARMOR - if (!sqlite3SafetyCheckOk(db)) - return SQLITE_MISUSE_BKPT; -#endif - if (ms > 0) { - sqlite3_busy_handler(db, sqliteDefaultBusyCallback, (void *)db); - db->busyTimeout = ms; - } else { - sqlite3_busy_handler(db, 0, 0); - } - return SQLITE_OK; -} - /* * Cause any pending operation to stop at its earliest opportunity. */ @@ -1676,25 +1619,6 @@ sqlite3IoerrnomemError(int lineno) } #endif -/* - * Sleep for a little while. Return the amount of time slept. - */ -int -sqlite3_sleep(int ms) -{ - sqlite3_vfs *pVfs; - int rc; - pVfs = sqlite3_vfs_find(0); - if (pVfs == 0) - return 0; - - /* This function works in milliseconds, but the underlying OsSleep() - * API uses microseconds. Hence the 1000's. - */ - rc = (sqlite3OsSleep(pVfs, 1000 * ms) / 1000); - return rc; -} - /* * Enable or disable the extended result codes. */ diff --git a/src/box/sql/os.c b/src/box/sql/os.c index 1fa6b332a..3840258dc 100644 --- a/src/box/sql/os.c +++ b/src/box/sql/os.c @@ -128,12 +128,6 @@ sqlite3OsRandomness(sqlite3_vfs * pVfs, int nByte, char *zBufOut) return pVfs->xRandomness(pVfs, nByte, zBufOut); } -int -sqlite3OsSleep(sqlite3_vfs * pVfs, int nMicro) -{ - return pVfs->xSleep(pVfs, nMicro); -} - int sqlite3OsGetLastError(sqlite3_vfs * pVfs) { diff --git a/src/box/sql/os.h b/src/box/sql/os.h index 947658300..c844fe7fa 100644 --- a/src/box/sql/os.h +++ b/src/box/sql/os.h @@ -146,7 +146,6 @@ int sqlite3OsUnfetch(sqlite3_file *, i64, void *); */ int sqlite3OsOpen(sqlite3_vfs *, const char *, sqlite3_file *, int, int *); int sqlite3OsRandomness(sqlite3_vfs *, int, char *); -int sqlite3OsSleep(sqlite3_vfs *, int); int sqlite3OsGetLastError(sqlite3_vfs *); int sqlite3OsCurrentTimeInt64(sqlite3_vfs *, sqlite3_int64 *); diff --git a/src/box/sql/os_unix.c b/src/box/sql/os_unix.c index b8816e0f9..2cbcd6db1 100644 --- a/src/box/sql/os_unix.c +++ b/src/box/sql/os_unix.c @@ -1988,23 +1988,6 @@ unixRandomness(sqlite3_vfs * NotUsed, int nBuf, char *zBuf) return nBuf; } -/* - * Sleep for a little while. Return the amount of time slept. - * The argument is the number of microseconds we want to sleep. - * The return value is the number of microseconds of sleep actually - * requested from the underlying operating system, a number which - * might be greater than or equal to the argument, but not less - * than the argument. - */ -static int -unixSleep(sqlite3_vfs * NotUsed, int microseconds) -{ - int seconds = (microseconds + 999999) / 1000000; - sleep(seconds); - UNUSED_PARAMETER(NotUsed); - return seconds * 1000000; -} - /* Fake system time in seconds since 1970. */ int sqlite3_current_time = 0; @@ -2078,7 +2061,6 @@ unixGetLastError(sqlite3_vfs * NotUsed, int NotUsed2, char *NotUsed3) unixOpen, /* xOpen */ \ unixDelete, /* xDelete */ \ unixRandomness, /* xRandomness */ \ - unixSleep, /* xSleep */ \ NULL, /* xCurrentTime */ \ unixGetLastError, /* xGetLastError */ \ unixCurrentTimeInt64, /* xCurrentTimeInt64 */ \ diff --git a/src/box/sql/pragma.c b/src/box/sql/pragma.c index 158e6269b..7391f034b 100644 --- a/src/box/sql/pragma.c +++ b/src/box/sql/pragma.c @@ -491,7 +491,6 @@ sqlite3Pragma(Parse * pParse, Token * pId, /* First part of [schema.]id field */ zRight = sqlite3NameFromToken(db, pValue); } zTable = sqlite3NameFromToken(db, pValue2); - db->busyHandler.nBusy = 0; /* Locate the pragma in the lookup table */ pPragma = pragmaLocate(zLeft); @@ -672,24 +671,14 @@ sqlite3Pragma(Parse * pParse, Token * pId, /* First part of [schema.]id field */ break; } - /* * PRAGMA busy_timeout * PRAGMA busy_timeout = N * - * - * Call sqlite3_busy_timeout(db, N). Return the current - * timeout value * if one is set. If no busy handler - * or a different busy handler is set * then 0 is - * returned. Setting the busy_timeout to 0 or negative * - * disables the timeout. - */ - /* case PragTyp_BUSY_TIMEOUT */ default:{ - assert(pPragma->ePragTyp == PragTyp_BUSY_TIMEOUT); - if (zRight) { - sqlite3_busy_timeout(db, sqlite3Atoi(zRight)); - } - returnSingleInt(v, db->busyTimeout); - break; + /* We shouldn't get here. */ + diag_set(ClientError, ER_UNKNOWN); + pParse->rc = SQL_TARANTOOL_ERROR; + pParse->nErr++; + goto pragma_out; } - } /* End of the PRAGMA switch */ + } /* The following block is a no-op unless SQLITE_DEBUG is * defined. Its only * purpose is to execute assert() diff --git a/src/box/sql/pragma.h b/src/box/sql/pragma.h index 168c70561..2857390c4 100644 --- a/src/box/sql/pragma.h +++ b/src/box/sql/pragma.h @@ -5,7 +5,6 @@ */ /* The various pragma types */ -#define PragTyp_BUSY_TIMEOUT 1 #define PragTyp_CASE_SENSITIVE_LIKE 2 #define PragTyp_COLLATION_LIST 3 #define PragTyp_FLAG 5 @@ -67,8 +66,6 @@ static const char *const pragCName[] = { /* 26 */ "on_update", /* 27 */ "on_delete", /* 28 */ "match", - /* Used by: busy_timeout */ - /* 29 */ "timeout", }; /* Definitions of all built-in pragmas */ @@ -85,11 +82,6 @@ typedef struct PragmaName { * to be sorted. For more info see pragma_locate function. */ static const PragmaName aPragmaName[] = { - { /* zName: */ "busy_timeout", - /* ePragTyp: */ PragTyp_BUSY_TIMEOUT, - /* ePragFlg: */ PragFlg_Result0, - /* ColNames: */ 29, 1, - /* iArg: */ 0}, { /* zName: */ "case_sensitive_like", /* ePragTyp: */ PragTyp_CASE_SENSITIVE_LIKE, /* ePragFlg: */ PragFlg_NoColumns, diff --git a/src/box/sql/sqliteInt.h b/src/box/sql/sqliteInt.h index db7a20aee..50668b775 100644 --- a/src/box/sql/sqliteInt.h +++ b/src/box/sql/sqliteInt.h @@ -329,7 +329,6 @@ struct sqlite3_vfs { int flags, int *pOutFlags); int (*xDelete) (sqlite3_vfs *, const char *zName, int syncDir); int (*xRandomness) (sqlite3_vfs *, int nByte, char *zOut); - int (*xSleep) (sqlite3_vfs *, int microseconds); int (*xCurrentTime) (sqlite3_vfs *, double *); int (*xGetLastError) (sqlite3_vfs *, int, char *); /* @@ -835,9 +834,6 @@ struct sqlite3_io_methods { int sqlite3_os_init(void); -int -sqlite3_busy_timeout(sqlite3 *, int ms); - sqlite3_int64 sqlite3_soft_heap_limit64(sqlite3_int64 N); @@ -1554,8 +1550,6 @@ struct sqlite3 { unsigned nProgressOps; /* Number of opcodes for progress callback */ #endif Hash aFunc; /* Hash table of connection functions */ - BusyHandler busyHandler; /* Busy callback */ - int busyTimeout; /* Busy handler timeout, in msec */ int *pnBytesFreed; /* If not NULL, increment this in DbFree() */ }; diff --git a/src/box/sql/vdbe.c b/src/box/sql/vdbe.c index 9fc362f0a..481727b5e 100644 --- a/src/box/sql/vdbe.c +++ b/src/box/sql/vdbe.c @@ -666,7 +666,6 @@ int sqlite3VdbeExec(Vdbe *p) p->iCurrentTime = 0; assert(p->explain==0); p->pResultSet = 0; - db->busyHandler.nBusy = 0; if (db->u1.isInterrupted) goto abort_due_to_interrupt; sqlite3VdbeIOTraceSql(p); #ifndef SQLITE_OMIT_PROGRESS_CALLBACK -- 2.17.1
next prev parent reply other threads:[~2019-02-08 16:46 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-02-06 12:18 [tarantool-patches] " Stanislav Zudin 2019-02-06 13:21 ` [tarantool-patches] " n.pettik 2019-02-08 10:17 ` Stanislav Zudin 2019-02-08 14:03 ` n.pettik 2019-02-08 16:46 ` Stanislav Zudin [this message] 2019-02-10 22:54 ` n.pettik
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=2498e858-96b4-cd47-5ee7-2c1996d6b11d@tarantool.org \ --to=szudin@tarantool.org \ --cc=korablev@tarantool.org \ --cc=tarantool-patches@freelists.org \ --subject='[tarantool-patches] Re: [PATCH] sql: remove useless pragmas' \ /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