[patches] [PATCH V2 3/9] sql: remove OMIT_DEPRECATED code under define
Bulat Niatshin
niatshin at tarantool.org
Tue Feb 27 16:54:48 MSK 2018
Remove code under ifndef OMIT_DEPRECATED
For #3119
---
src/box/sql/func.c | 9 -----
src/box/sql/main.c | 86 --------------------------------------------
src/box/sql/malloc.c | 17 ---------
src/box/sql/os_unix.c | 22 +-----------
src/box/sql/prepare.c | 8 -----
src/box/sql/sqlite3.h | 96 -------------------------------------------------
src/box/sql/sqliteInt.h | 9 -----
src/box/sql/vdbe.c | 10 +-----
src/box/sql/vdbeapi.c | 66 ----------------------------------
9 files changed, 2 insertions(+), 321 deletions(-)
diff --git a/src/box/sql/func.c b/src/box/sql/func.c
index 38aba7271..f60cbee31 100644
--- a/src/box/sql/func.c
+++ b/src/box/sql/func.c
@@ -1576,15 +1576,6 @@ countStep(sqlite3_context * context, int argc, sqlite3_value ** argv)
if ((argc == 0 || SQLITE_NULL != sqlite3_value_type(argv[0])) && p) {
p->n++;
}
-#ifndef SQLITE_OMIT_DEPRECATED
- /* The sqlite3_aggregate_count() function is deprecated. But just to make
- * sure it still operates correctly, verify that its count agrees with our
- * internal count when using count(*) and when the total count can be
- * expressed as a 32-bit integer.
- */
- assert(argc == 1 || p == 0 || p->n > 0x7fffffff
- || p->n == sqlite3_aggregate_count(context));
-#endif
}
static void
diff --git a/src/box/sql/main.c b/src/box/sql/main.c
index 9cda5f3e9..5e1104ba9 100644
--- a/src/box/sql/main.c
+++ b/src/box/sql/main.c
@@ -1588,36 +1588,6 @@ sqlite3_create_function_v2(sqlite3 * db,
}
#ifndef SQLITE_OMIT_TRACE
-/*
- * Register a trace function. The pArg from the previously registered trace
- * is returned.
- *
- * A NULL trace function means that no tracing is executes. A non-NULL
- * trace is a pointer to a function that is invoked at the start of each
- * SQL statement.
- */
-#ifndef SQLITE_OMIT_DEPRECATED
-void *
-sqlite3_trace(sqlite3 * db, void (*xTrace) (void *, const char *), void *pArg)
-{
- void *pOld;
-
-#ifdef SQLITE_ENABLE_API_ARMOR
- if (!sqlite3SafetyCheckOk(db)) {
- (void)SQLITE_MISUSE_BKPT;
- return 0;
- }
-#endif
- sqlite3_mutex_enter(db->mutex);
- pOld = db->pTraceArg;
- db->mTrace = xTrace ? SQLITE_TRACE_LEGACY : 0;
- db->xTrace = (int (*)(u32, void *, void *, void *))xTrace;
- db->pTraceArg = pArg;
- sqlite3_mutex_leave(db->mutex);
- return pOld;
-}
-#endif /* SQLITE_OMIT_DEPRECATED */
-
/* Register a trace callback using the version-2 interface.
*/
int
@@ -1643,36 +1613,6 @@ sqlite3_trace_v2(sqlite3 * db, /* Trace this connection */
return SQLITE_OK;
}
-#ifndef SQLITE_OMIT_DEPRECATED
-/*
- * Register a profile function. The pArg from the previously registered
- * profile function is returned.
- *
- * A NULL profile function means that no profiling is executes. A non-NULL
- * profile is a pointer to a function that is invoked at the conclusion of
- * each SQL statement that is run.
- */
-void *
-sqlite3_profile(sqlite3 * db,
- void (*xProfile) (void *, const char *, sqlite_uint64),
- void *pArg)
-{
- void *pOld;
-
-#ifdef SQLITE_ENABLE_API_ARMOR
- if (!sqlite3SafetyCheckOk(db)) {
- (void)SQLITE_MISUSE_BKPT;
- return 0;
- }
-#endif
- sqlite3_mutex_enter(db->mutex);
- pOld = db->pProfileArg;
- db->xProfile = xProfile;
- db->pProfileArg = pArg;
- sqlite3_mutex_leave(db->mutex);
- return pOld;
-}
-#endif /* SQLITE_OMIT_DEPRECATED */
#endif /* SQLITE_OMIT_TRACE */
/*
@@ -2568,18 +2508,6 @@ sqlite3_open_v2(const char *filename, /* Database filename (UTF-8) */
return openDatabase(filename, ppDb, (unsigned int)flags, zVfs);
}
-#ifndef SQLITE_OMIT_DEPRECATED
-/*
- * This function is now an anachronism. It used to be used to recover from a
- * malloc() failure, but SQLite now does this automatically.
- */
-int
-sqlite3_global_recover(void)
-{
- return SQLITE_OK;
-}
-#endif
-
/*
* The following routines are substitutes for constants SQLITE_CORRUPT,
* SQLITE_MISUSE, SQLITE_CANTOPEN, SQLITE_NOMEM and possibly other error
@@ -2636,20 +2564,6 @@ sqlite3IoerrnomemError(int lineno)
}
#endif
-#ifndef SQLITE_OMIT_DEPRECATED
-/*
- * This is a convenience routine that makes sure that all thread-specific
- * data for this thread has been deallocated.
- *
- * SQLite no longer uses thread-specific data so this routine is now a
- * no-op. It is retained for historical compatibility.
- */
-void
-sqlite3_thread_cleanup(void)
-{
-}
-#endif
-
/*
* Return meta information about a specific column of a database table.
* See comment in sqlite3.h (sqlite.h.in) for details.
diff --git a/src/box/sql/malloc.c b/src/box/sql/malloc.c
index b7f3cae66..325faf53e 100644
--- a/src/box/sql/malloc.c
+++ b/src/box/sql/malloc.c
@@ -100,23 +100,6 @@ sqlite3MallocMutex(void)
return mem0.mutex;
}
-#ifndef SQLITE_OMIT_DEPRECATED
-/*
- * Deprecated external interface. It used to set an alarm callback
- * that was invoked when memory usage grew too large. Now it is a
- * no-op.
- */
-int
-sqlite3_memory_alarm(void (*xCallback) (void *pArg, sqlite3_int64 used, int N),
- void *pArg, sqlite3_int64 iThreshold)
-{
- (void)xCallback;
- (void)pArg;
- (void)iThreshold;
- return SQLITE_OK;
-}
-#endif
-
/*
* Set the soft heap-size limit for the library. Passing a zero or
* negative value indicates no limit.
diff --git a/src/box/sql/os_unix.c b/src/box/sql/os_unix.c
index 08e809529..1fb777857 100644
--- a/src/box/sql/os_unix.c
+++ b/src/box/sql/os_unix.c
@@ -5140,26 +5140,6 @@ unixCurrentTimeInt64(sqlite3_vfs * NotUsed, sqlite3_int64 * piNow)
return rc;
}
-#ifndef SQLITE_OMIT_DEPRECATED
-/*
- * Find the current time (in Universal Coordinated Time). Write the
- * current time and date as a Julian Day number into *prNow and
- * return 0. Return 1 if the time and date cannot be found.
- */
-static int
-unixCurrentTime(sqlite3_vfs * NotUsed, double *prNow)
-{
- sqlite3_int64 i = 0;
- int rc;
- UNUSED_PARAMETER(NotUsed);
- rc = unixCurrentTimeInt64(0, &i);
- *prNow = i / 86400000.0;
- return rc;
-}
-#else
-#define unixCurrentTime 0
-#endif
-
/*
* The xGetLastError() method is designed to return a better
* low-level error message when operating-system problems come up
@@ -6526,7 +6506,7 @@ sqlite3_os_init(void)
unixDlClose, /* xDlClose */ \
unixRandomness, /* xRandomness */ \
unixSleep, /* xSleep */ \
- unixCurrentTime, /* xCurrentTime */ \
+ 0, /* xCurrentTime */ \
unixGetLastError, /* xGetLastError */ \
unixCurrentTimeInt64, /* xCurrentTimeInt64 */ \
unixSetSystemCall, /* xSetSystemCall */ \
diff --git a/src/box/sql/prepare.c b/src/box/sql/prepare.c
index 36965a727..a319c5c4e 100644
--- a/src/box/sql/prepare.c
+++ b/src/box/sql/prepare.c
@@ -163,9 +163,6 @@ extern int
sqlite3InitDatabase(sqlite3 * db)
{
int rc;
-#ifndef SQLITE_OMIT_DEPRECATED
- int size;
-#endif
Db *pDb;
InitData initData;
@@ -193,12 +190,7 @@ sqlite3InitDatabase(sqlite3 * db)
pDb->pSchema->schema_cookie = 0;
if (pDb->pSchema->cache_size == 0) {
-#ifndef SQLITE_OMIT_DEPRECATED
- size = SQLITE_DEFAULT_CACHE_SIZE;
- pDb->pSchema->cache_size = size;
-#else
pDb->pSchema->cache_size = SQLITE_DEFAULT_CACHE_SIZE;
-#endif
}
/* Read the schema information out of the schema tables
diff --git a/src/box/sql/sqlite3.h b/src/box/sql/sqlite3.h
index f9821454a..5c7584866 100644
--- a/src/box/sql/sqlite3.h
+++ b/src/box/sql/sqlite3.h
@@ -100,7 +100,6 @@
* that we have taken it all out and gone back to using simple
* noop macros.
*/
-#define SQLITE_DEPRECATED
#define SQLITE_EXPERIMENTAL
/*
@@ -1013,11 +1012,6 @@ struct sqlite3_io_methods {
#define SQLITE_FCNTL_JOURNAL_POINTER 25
#define SQLITE_FCNTL_PDB 26
-/* deprecated names */
-#define SQLITE_GET_LOCKPROXYFILE SQLITE_FCNTL_GET_LOCKPROXYFILE
-#define SQLITE_SET_LOCKPROXYFILE SQLITE_FCNTL_SET_LOCKPROXYFILE
-#define SQLITE_LAST_ERRNO SQLITE_FCNTL_LAST_ERRNO
-
/*
* CAPI3REF: Mutex Handle
*
@@ -2735,51 +2729,6 @@ sqlite3_set_authorizer(sqlite3 *,
#define SQLITE_COPY 0 /* No longer used */
#define SQLITE_RECURSIVE 33 /* NULL NULL */
-/*
- * CAPI3REF: Tracing And Profiling Functions
- * METHOD: sqlite3
- *
- * These routines are deprecated. Use the [sqlite3_trace_v2()] interface
- * instead of the routines described here.
- *
- * These routines register callback functions that can be used for
- * tracing and profiling the execution of SQL statements.
- *
- * ^The callback function registered by sqlite3_trace() is invoked at
- * various times when an SQL statement is being run by [sqlite3_step()].
- * ^The sqlite3_trace() callback is invoked with a UTF-8 rendering of the
- * SQL statement text as the statement first begins executing.
- * ^(Additional sqlite3_trace() callbacks might occur
- * as each triggered subprogram is entered. The callbacks for triggers
- * contain a UTF-8 SQL comment that identifies the trigger.)^
- *
- * The [SQLITE_TRACE_SIZE_LIMIT] compile-time option can be used to limit
- * the length of [bound parameter] expansion in the output of sqlite3_trace().
- *
- * ^The callback function registered by sqlite3_profile() is invoked
- * as each SQL statement finishes. ^The profile callback contains
- * the original statement text and an estimate of wall-clock time
- * of how long that statement took to run. ^The profile callback
- * time is in units of nanoseconds, however the current implementation
- * is only capable of millisecond resolution so the six least significant
- * digits in the time are meaningless. Future versions of SQLite
- * might provide greater resolution on the profiler callback. The
- * sqlite3_profile() function is considered experimental and is
- * subject to change in future versions of SQLite.
-*/
-SQLITE_API SQLITE_DEPRECATED void *
-sqlite3_trace(sqlite3 *,
- void (*xTrace) (void *,
- const char *),
- void *);
-SQLITE_API SQLITE_DEPRECATED void *
-sqlite3_profile(sqlite3 *,
- void (*xProfile)
- (void *,
- const char *,
- sqlite3_uint64),
- void *);
-
/*
* CAPI3REF: SQL Trace Event Codes
* KEYWORDS: SQLITE_TRACE
@@ -4502,39 +4451,6 @@ sqlite3_create_function_v2(sqlite3 * db,
*/
#define SQLITE_DETERMINISTIC 0x800
-/*
- * CAPI3REF: Deprecated Functions
- * DEPRECATED
- *
- * These functions are [deprecated]. In order to maintain
- * backwards compatibility with older code, these functions continue
- * to be supported. However, new applications should avoid
- * the use of these functions. To encourage programmers to avoid
- * these functions, we will not explain what they do.
-*/
-#ifndef SQLITE_OMIT_DEPRECATED
-SQLITE_API SQLITE_DEPRECATED int
-sqlite3_aggregate_count(sqlite3_context
- *);
-
-SQLITE_API SQLITE_DEPRECATED int
-sqlite3_expired(sqlite3_stmt *);
-
-SQLITE_API SQLITE_DEPRECATED int
-sqlite3_transfer_bindings(sqlite3_stmt *,
- sqlite3_stmt *);
-
-SQLITE_API SQLITE_DEPRECATED
-int sqlite3_global_recover(void);
-
-SQLITE_API SQLITE_DEPRECATED
-void sqlite3_thread_cleanup(void);
-
-SQLITE_API SQLITE_DEPRECATED int
-sqlite3_memory_alarm(void (*)(void *, sqlite3_int64, int), void *,
- sqlite3_int64);
-#endif
-
/*
* CAPI3REF: Obtaining SQL Values
* METHOD: sqlite3_value
@@ -5393,18 +5309,6 @@ sqlite3_db_release_memory(sqlite3 *);
SQLITE_API sqlite3_int64
sqlite3_soft_heap_limit64(sqlite3_int64 N);
-/*
- * CAPI3REF: Deprecated Soft Heap Limit Interface
- * DEPRECATED
- *
- * This is a deprecated version of the [sqlite3_soft_heap_limit64()]
- * interface. This routine is provided for historical compatibility
- * only. All new applications should use the
- * [sqlite3_soft_heap_limit64()] interface rather than this one.
-*/
-SQLITE_API SQLITE_DEPRECATED
-void sqlite3_soft_heap_limit(int N);
-
/*
* CAPI3REF: Extract Metadata About A Column Of A Table
* METHOD: sqlite3
diff --git a/src/box/sql/sqliteInt.h b/src/box/sql/sqliteInt.h
index aebb61029..e8213219b 100644
--- a/src/box/sql/sqliteInt.h
+++ b/src/box/sql/sqliteInt.h
@@ -1026,15 +1026,6 @@ typedef int (*sqlite3_xauth) (void *, int, const char *, const char *,
const char *, const char *);
#endif
-#ifndef SQLITE_OMIT_DEPRECATED
-/* This is an extra SQLITE_TRACE macro that indicates "legacy" tracing
- * in the style of sqlite3_trace()
- */
-#define SQLITE_TRACE_LEGACY 0x80
-#else
-#define SQLITE_TRACE_LEGACY 0
-#endif /* SQLITE_OMIT_DEPRECATED */
-
/*
* Each database connection is an instance of the following structure.
*/
diff --git a/src/box/sql/vdbe.c b/src/box/sql/vdbe.c
index 1f496d0e6..52fb91df5 100644
--- a/src/box/sql/vdbe.c
+++ b/src/box/sql/vdbe.c
@@ -5547,18 +5547,10 @@ case OP_Init: { /* jump */
assert(pOp==p->aOp); /* Always instruction 0 */
#ifndef SQLITE_OMIT_TRACE
- if ((db->mTrace & (SQLITE_TRACE_STMT|SQLITE_TRACE_LEGACY))!=0
+ if ((db->mTrace & SQLITE_TRACE_STMT)!=0
&& !p->doingRerun
&& (zTrace = (pOp->p4.z ? pOp->p4.z : p->zSql))!=0
) {
-#ifndef SQLITE_OMIT_DEPRECATED
- if (db->mTrace & SQLITE_TRACE_LEGACY) {
- void (*x)(void*,const char*) = (void(*)(void*,const char*))db->xTrace;
- char *z = sqlite3VdbeExpandSql(p, zTrace);
- x(db->pTraceArg, z);
- sqlite3_free(z);
- } else
-#endif
{
(void)db->xTrace(SQLITE_TRACE_STMT, db->pTraceArg, p, zTrace);
}
diff --git a/src/box/sql/vdbeapi.c b/src/box/sql/vdbeapi.c
index 46622bff3..550c19315 100644
--- a/src/box/sql/vdbeapi.c
+++ b/src/box/sql/vdbeapi.c
@@ -37,23 +37,6 @@
#include "sqliteInt.h"
#include "vdbeInt.h"
-#ifndef SQLITE_OMIT_DEPRECATED
-/*
- * Return TRUE (non-zero) of the statement supplied as an argument needs
- * to be recompiled. A statement needs to be recompiled whenever the
- * execution environment changes in a way that would alter the program
- * that sqlite3_prepare() generates. For example, if new functions or
- * collating sequences are registered or if an authorizer function is
- * added or changed.
- */
-int
-sqlite3_expired(sqlite3_stmt * pStmt)
-{
- Vdbe *p = (Vdbe *) pStmt;
- return p == 0 || p->expired;
-}
-#endif
-
/*
* Check on a Vdbe to make sure it has not been finalized. Log
* an error and return true if it has been finalized (or is otherwise
@@ -915,24 +898,6 @@ sqlite3_set_auxdata(sqlite3_context * pCtx,
}
}
-#ifndef SQLITE_OMIT_DEPRECATED
-/*
- * Return the number of times the Step function of an aggregate has been
- * called.
- *
- * This function is deprecated. Do not use it for new code. It is
- * provide only to avoid breaking legacy code. New aggregate function
- * implementations should keep their own counts within their aggregate
- * context.
- */
-int
-sqlite3_aggregate_count(sqlite3_context * p)
-{
- assert(p && p->pMem && p->pFunc && p->pFunc->xFinalize);
- return p->pMem->n;
-}
-#endif
-
/*
* Return the number of columns in the result set for the statement pStmt.
*/
@@ -1581,37 +1546,6 @@ sqlite3TransferBindings(sqlite3_stmt * pFromStmt, sqlite3_stmt * pToStmt)
return SQLITE_OK;
}
-#ifndef SQLITE_OMIT_DEPRECATED
-/*
- * Deprecated external interface. Internal/core SQLite code
- * should call sqlite3TransferBindings.
- *
- * It is misuse to call this routine with statements from different
- * database connections. But as this is a deprecated interface, we
- * will not bother to check for that condition.
- *
- * If the two statements contain a different number of bindings, then
- * an SQLITE_ERROR is returned. Nothing else can go wrong, so otherwise
- * SQLITE_OK is returned.
- */
-int
-sqlite3_transfer_bindings(sqlite3_stmt * pFromStmt, sqlite3_stmt * pToStmt)
-{
- Vdbe *pFrom = (Vdbe *) pFromStmt;
- Vdbe *pTo = (Vdbe *) pToStmt;
- if (pFrom->nVar != pTo->nVar) {
- return SQLITE_ERROR;
- }
- if (pTo->isPrepareV2 && pTo->expmask) {
- pTo->expired = 1;
- }
- if (pFrom->isPrepareV2 && pFrom->expmask) {
- pFrom->expired = 1;
- }
- return sqlite3TransferBindings(pFromStmt, pToStmt);
-}
-#endif
-
/*
* Return the sqlite3* database handle to which the prepared statement given
* in the argument belongs. This is the same database handle that was
--
2.14.1
More information about the Tarantool-patches
mailing list