[tarantool-patches] [PATCH v4 2/2] sql: remove busy handler
Stanislav Zudin
szudin at tarantool.org
Tue Feb 12 10:31:51 MSK 2019
SQLite's busyHandler functionality and functions sqlite3_sleep(),
sqlite3OsSleep() were not used and were removed.
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 | 23 -------------
src/box/sql/vdbe.c | 1 -
8 files changed, 6 insertions(+), 150 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 7285455c9..62ff1f2b2 100644
--- a/src/box/sql/pragma.c
+++ b/src/box/sql/pragma.c
@@ -464,7 +464,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);
@@ -644,24 +643,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..1633c1a35 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 *);
/*
@@ -825,7 +824,6 @@ struct sqlite3_io_methods {
#define SQLITE_FCNTL_VFSNAME 11
#define SQLITE_FCNTL_POWERSAFE_OVERWRITE 12
#define SQLITE_FCNTL_PRAGMA 13
-#define SQLITE_FCNTL_BUSYHANDLER 14
#define SQLITE_FCNTL_TEMPFILENAME 15
#define SQLITE_FCNTL_MMAP_SIZE 16
#define SQLITE_FCNTL_TRACE 17
@@ -835,9 +833,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);
@@ -1310,22 +1305,6 @@ extern const int sqlite3one;
#undef WHERETRACE_ENABLED
#endif
-/*
- * An instance of the following structure is used to store the busy-handler
- * callback for a given sqlite handle.
- *
- * The sqlite.busyHandler member of the sqlite struct contains the busy
- * callback for the database handle. Each pager opened via the sqlite
- * handle is passed a pointer to sqlite.busyHandler. The busy-handler
- * callback is currently invoked only from within pager.c.
- */
-typedef struct BusyHandler BusyHandler;
-struct BusyHandler {
- int (*xFunc) (void *, int); /* The busy callback */
- void *pArg; /* First arg to busy callback */
- int nBusy; /* Incremented with each busy call */
-};
-
/*
* A convenience macro that returns the number of elements in
* an array.
@@ -1554,8 +1533,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
More information about the Tarantool-patches
mailing list