Tarantool development patches archive
 help / color / mirror / Atom feed
* [tarantool-patches] [PATCH v1 0/3] sql: remove unused code from SQL
@ 2019-04-09 17:17 imeevma
  2019-04-09 17:17 ` [tarantool-patches] [PATCH v1 1/3] sql: remove legacy.c imeevma
                   ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: imeevma @ 2019-04-09 17:17 UTC (permalink / raw)
  To: korablev; +Cc: tarantool-patches

This patch-set removes part of unused code from SQL. That is
needed for #4074.

https://github.com/tarantool/tarantool/issues/4074
https://github.com/tarantool/tarantool/tree/imeevma/gh-4074-remove-unused-code

Mergen Imeev (3):
  sql: remove legacy.c
  sql: remove unused macros in SQL
  sql: remove unused functions from main.c

 src/box/sql/CMakeLists.txt |    1 -
 src/box/sql/analyze.c      |   12 +-
 src/box/sql/build.c        |    2 -
 src/box/sql/expr.c         |    8 -
 src/box/sql/fault.c        |    6 -
 src/box/sql/func.c         |   10 -
 src/box/sql/global.c       |    9 +-
 src/box/sql/legacy.c       |  187 -------
 src/box/sql/main.c         | 1186 +-------------------------------------------
 src/box/sql/malloc.c       |   21 -
 src/box/sql/os.c           |   14 -
 src/box/sql/os_unix.c      |    5 -
 src/box/sql/prepare.c      |    4 -
 src/box/sql/printf.c       |   35 --
 src/box/sql/random.c       |   14 -
 src/box/sql/select.c       |    2 -
 src/box/sql/sqlInt.h       |  108 +---
 src/box/sql/status.c       |   25 +-
 src/box/sql/treeview.c     |    2 -
 src/box/sql/update.c       |    2 -
 src/box/sql/util.c         |   41 --
 src/box/sql/vdbe.c         |   24 -
 src/box/sql/vdbeInt.h      |    4 -
 src/box/sql/vdbeapi.c      |   15 -
 src/box/sql/vdbeaux.c      |   29 +-
 src/box/sql/vdbemem.c      |    8 -
 26 files changed, 20 insertions(+), 1754 deletions(-)
 delete mode 100644 src/box/sql/legacy.c

-- 
2.7.4

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [tarantool-patches] [PATCH v1 1/3] sql: remove legacy.c
  2019-04-09 17:17 [tarantool-patches] [PATCH v1 0/3] sql: remove unused code from SQL imeevma
@ 2019-04-09 17:17 ` imeevma
  2019-04-10  7:26   ` [tarantool-patches] " Konstantin Osipov
  2019-04-11  0:02   ` n.pettik
  2019-04-09 17:17 ` [tarantool-patches] [PATCH v1 2/3] sql: remove unused macros in SQL imeevma
  2019-04-09 17:17 ` [tarantool-patches] [PATCH v1 3/3] sql: remove unused functions from main.c imeevma
  2 siblings, 2 replies; 16+ messages in thread
From: imeevma @ 2019-04-09 17:17 UTC (permalink / raw)
  To: korablev; +Cc: tarantool-patches

The module legacy.c is not used and should be removed.

Needed for #4074
---
 src/box/sql/CMakeLists.txt |   1 -
 src/box/sql/analyze.c      |  12 +--
 src/box/sql/legacy.c       | 187 ---------------------------------------------
 src/box/sql/sqlInt.h       |   7 --
 4 files changed, 7 insertions(+), 200 deletions(-)
 delete mode 100644 src/box/sql/legacy.c

diff --git a/src/box/sql/CMakeLists.txt b/src/box/sql/CMakeLists.txt
index b9dbe14..886d671 100644
--- a/src/box/sql/CMakeLists.txt
+++ b/src/box/sql/CMakeLists.txt
@@ -38,7 +38,6 @@ add_library(sql STATIC
     global.c
     hash.c
     insert.c
-    legacy.c
     main.c
     malloc.c
     os.c
diff --git a/src/box/sql/analyze.c b/src/box/sql/analyze.c
index 0c02050..379b2e3 100644
--- a/src/box/sql/analyze.c
+++ b/src/box/sql/analyze.c
@@ -1218,7 +1218,7 @@ decode_stat_string(const char *stat_string, int stat_size, tRowcnt *stat_exact,
  * @param argv Callback arguments.
  * @retval 0 on success, -1 otherwise.
  */
-static int
+int
 analysis_loader(void *data, int argc, char **argv, char **unused)
 {
 	assert(argc == 3);
@@ -1704,11 +1704,13 @@ sql_analysis_load(struct sql *db)
 	info.db = db;
 	info.stats = stats;
 	info.index_count = 0;
-	const char *load_stat1 =
+	MAYBE_UNUSED const char *load_stat1 =
 		"SELECT \"tbl\",\"idx\",\"stat\" FROM \"_sql_stat1\"";
-	/* Load new statistics out of the _sql_stat1 table. */
-	if (sql_exec(db, load_stat1, analysis_loader, &info, 0) != 0)
-		goto fail;
+	/*
+	 * Here was loading new statistics out of the _sql_stat1
+	 * table using analysis_loader. This part of code was
+	 * removed due to removal of sql_exec().
+	 */
 	if (info.index_count == 0) {
 		box_txn_commit();
 		return SQL_OK;
diff --git a/src/box/sql/legacy.c b/src/box/sql/legacy.c
deleted file mode 100644
index 599fba0..0000000
--- a/src/box/sql/legacy.c
+++ /dev/null
@@ -1,187 +0,0 @@
-/*
- * Copyright 2010-2017, Tarantool AUTHORS, please see AUTHORS file.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * 1. Redistributions of source code must retain the above
- *    copyright notice, this list of conditions and the
- *    following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above
- *    copyright notice, this list of conditions and the following
- *    disclaimer in the documentation and/or other materials
- *    provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
- * <COPYRIGHT HOLDER> OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
- * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*
- * Main file for the sql library.  The routines in this file
- * implement the programmer interface to the library.  Routines in
- * other files are for internal use by sql and should not be
- * accessed by users of the library.
- */
-
-#include "sqlInt.h"
-#include "box/session.h"
-
-/*
- * Execute SQL code.  Return one of the SQL_ success/failure
- * codes.  Also write an error message into memory obtained from
- * malloc() and make *pzErrMsg point to that message.
- *
- * If the SQL is a query, then for each row in the query result
- * the xCallback() function is called.  pArg becomes the first
- * argument to xCallback().  If xCallback=NULL then no callback
- * is invoked, even for queries.
- */
-int
-sql_exec(sql * db,	/* The database on which the SQL executes */
-	     const char *zSql,	/* The SQL to be executed */
-	     sql_callback xCallback,	/* Invoke this callback routine */
-	     void *pArg,	/* First argument to xCallback() */
-	     char **pzErrMsg	/* Write error messages here */
-    )
-{
-	int rc = SQL_OK;	/* Return code */
-	const char *zLeftover;	/* Tail of unprocessed SQL */
-	sql_stmt *pStmt = 0;	/* The current SQL statement */
-	char **azCols = 0;	/* Names of result columns */
-	int callbackIsInit;	/* True if callback data is initialized */
-	struct session *user_session = current_session();
-
-	if (!sqlSafetyCheckOk(db))
-		return SQL_MISUSE;
-	if (zSql == 0)
-		zSql = "";
-
-	sqlError(db, SQL_OK);
-	while (rc == SQL_OK && zSql[0]) {
-		int nCol;
-		char **azVals = 0;
-
-		pStmt = 0;
-		rc = sql_prepare_v2(db, zSql, -1, &pStmt, &zLeftover);
-		assert(rc == SQL_OK || pStmt == 0);
-		if (rc != SQL_OK) {
-			continue;
-		}
-		if (!pStmt) {
-			/* this happens for a comment or white-space */
-			zSql = zLeftover;
-			continue;
-		}
-
-		callbackIsInit = 0;
-		nCol = sql_column_count(pStmt);
-
-		while (1) {
-			int i;
-			rc = sql_step(pStmt);
-			/* Invoke the callback function if required */
-			if (xCallback && (SQL_ROW == rc ||
-					  (SQL_DONE == rc && !callbackIsInit
-					   && user_session->
-					   sql_flags & SQL_NullCallback))) {
-				if (!callbackIsInit) {
-					azCols =
-					    sqlDbMallocZero(db,
-								2 * nCol *
-								sizeof(const
-								       char *) +
-								1);
-					if (azCols == 0) {
-						goto exec_out;
-					}
-					for (i = 0; i < nCol; i++) {
-						azCols[i] =
-						    (char *)
-						    sql_column_name(pStmt,
-									i);
-						/* sqlVdbeSetColName() installs column names as UTF8
-						 * strings so there is no way for sql_column_name() to fail.
-						 */
-						assert(azCols[i] != 0);
-					}
-					callbackIsInit = 1;
-				}
-				if (rc == SQL_ROW) {
-					azVals = &azCols[nCol];
-					for (i = 0; i < nCol; i++) {
-						azVals[i] =
-						    (char *)
-						    sql_column_text(pStmt,
-									i);
-						if (!azVals[i]
-						    &&
-						    sql_column_type(pStmt,
-									i) !=
-						    SQL_NULL) {
-							sqlOomFault(db);
-							goto exec_out;
-						}
-					}
-				}
-				if (xCallback(pArg, nCol, azVals, azCols)) {
-					/* EVIDENCE-OF: R-38229-40159 If the callback function to
-					 * sql_exec() returns non-zero, then sql_exec() will
-					 * return SQL_ABORT.
-					 */
-					rc = SQL_ABORT;
-					sqlVdbeFinalize((Vdbe *) pStmt);
-					pStmt = 0;
-					sqlError(db, SQL_ABORT);
-					goto exec_out;
-				}
-			}
-
-			if (rc != SQL_ROW) {
-				rc = sqlVdbeFinalize((Vdbe *) pStmt);
-				pStmt = 0;
-				zSql = zLeftover;
-				while (sqlIsspace(zSql[0]))
-					zSql++;
-				break;
-			}
-		}
-
-		sqlDbFree(db, azCols);
-		azCols = 0;
-	}
-
- exec_out:
-	if (pStmt)
-		sqlVdbeFinalize((Vdbe *) pStmt);
-	sqlDbFree(db, azCols);
-
-	rc = sqlApiExit(db, rc);
-	if (rc != SQL_OK && pzErrMsg) {
-		int nErrMsg = 1 + sqlStrlen30(sql_errmsg(db));
-		*pzErrMsg = sqlMalloc(nErrMsg);
-		if (*pzErrMsg) {
-			memcpy(*pzErrMsg, sql_errmsg(db), nErrMsg);
-		} else {
-			rc = SQL_NOMEM;
-			sqlError(db, SQL_NOMEM);
-		}
-	} else if (pzErrMsg) {
-		*pzErrMsg = 0;
-	}
-
-	assert((rc & db->errMask) == rc);
-	return rc;
-}
diff --git a/src/box/sql/sqlInt.h b/src/box/sql/sqlInt.h
index b322602..1a42d0d 100644
--- a/src/box/sql/sqlInt.h
+++ b/src/box/sql/sqlInt.h
@@ -593,13 +593,6 @@ sql_column_value(sql_stmt *,
 int
 sql_finalize(sql_stmt * pStmt);
 
-int
-sql_exec(sql *,	/* An open database */
-	     const char *sql,	/* SQL to be evaluated */
-	     int (*callback) (void *, int, char **, char **),	/* Callback function */
-	     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))
-- 
2.7.4

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [tarantool-patches] [PATCH v1 2/3] sql: remove unused macros in SQL
  2019-04-09 17:17 [tarantool-patches] [PATCH v1 0/3] sql: remove unused code from SQL imeevma
  2019-04-09 17:17 ` [tarantool-patches] [PATCH v1 1/3] sql: remove legacy.c imeevma
@ 2019-04-09 17:17 ` imeevma
  2019-04-10  7:28   ` [tarantool-patches] " Konstantin Osipov
                     ` (2 more replies)
  2019-04-09 17:17 ` [tarantool-patches] [PATCH v1 3/3] sql: remove unused functions from main.c imeevma
  2 siblings, 3 replies; 16+ messages in thread
From: imeevma @ 2019-04-09 17:17 UTC (permalink / raw)
  To: korablev; +Cc: tarantool-patches

Thise macros unused and should be removed.

Needed for #4074
---
 src/box/sql/expr.c     |   8 --
 src/box/sql/fault.c    |   6 --
 src/box/sql/func.c     |  10 ---
 src/box/sql/global.c   |   6 --
 src/box/sql/main.c     | 230 +------------------------------------------------
 src/box/sql/malloc.c   |  21 -----
 src/box/sql/os.c       |  14 ---
 src/box/sql/os_unix.c  |   5 --
 src/box/sql/prepare.c  |   4 -
 src/box/sql/printf.c   |  35 --------
 src/box/sql/random.c   |  11 ---
 src/box/sql/sqlInt.h   |  61 +------------
 src/box/sql/status.c   |  25 +-----
 src/box/sql/treeview.c |   2 -
 src/box/sql/update.c   |   2 -
 src/box/sql/util.c     |  41 ---------
 src/box/sql/vdbe.c     |  12 ---
 src/box/sql/vdbeInt.h  |   4 -
 src/box/sql/vdbeapi.c  |  15 ----
 src/box/sql/vdbeaux.c  |  29 +------
 src/box/sql/vdbemem.c  |   8 --
 21 files changed, 10 insertions(+), 539 deletions(-)

diff --git a/src/box/sql/expr.c b/src/box/sql/expr.c
index 6ff41a5..a95d576 100644
--- a/src/box/sql/expr.c
+++ b/src/box/sql/expr.c
@@ -3287,7 +3287,6 @@ sqlExprCodeIN(Parse * pParse,	/* Parsing and code generating context */
 	sqlDbFree(pParse->db, zAff);
 }
 
-#ifndef SQL_OMIT_FLOATING_POINT
 /*
  * Generate an instruction that will put the floating point
  * value described by z[0..n-1] into register iMem.
@@ -3309,7 +3308,6 @@ codeReal(Vdbe * v, const char *z, int negateFlag, int iMem)
 				      P4_REAL);
 	}
 }
-#endif
 
 /**
  * Generate an instruction that will put the integer describe by
@@ -3760,13 +3758,11 @@ sqlExprCodeTarget(Parse * pParse, Expr * pExpr, int target)
 			expr_code_int(pParse, pExpr, false, target);
 			return target;
 		}
-#ifndef SQL_OMIT_FLOATING_POINT
 	case TK_FLOAT:{
 			assert(!ExprHasProperty(pExpr, EP_IntValue));
 			codeReal(v, pExpr->u.zToken, 0, target);
 			return target;
 		}
-#endif
 	case TK_STRING:{
 			assert(!ExprHasProperty(pExpr, EP_IntValue));
 			sqlVdbeLoadString(v, target, pExpr->u.zToken);
@@ -3923,12 +3919,10 @@ sqlExprCodeTarget(Parse * pParse, Expr * pExpr, int target)
 			if (pLeft->op == TK_INTEGER) {
 				expr_code_int(pParse, pLeft, true, target);
 				return target;
-#ifndef SQL_OMIT_FLOATING_POINT
 			} else if (pLeft->op == TK_FLOAT) {
 				assert(!ExprHasProperty(pExpr, EP_IntValue));
 				codeReal(v, pLeft->u.zToken, 1, target);
 				return target;
-#endif
 			} else {
 				tempX.op = TK_INTEGER;
 				tempX.flags = EP_IntValue | EP_TokenOnly;
@@ -4283,7 +4277,6 @@ sqlExprCodeTarget(Parse * pParse, Expr * pExpr, int target)
 				    pExpr->space_def->fields[
 					pExpr->iColumn].name, target));
 
-#ifndef SQL_OMIT_FLOATING_POINT
 			/* If the column has type NUMBER, it may currently be stored as an
 			 * integer. Use OP_Realify to make sure it is really real.
 			 */
@@ -4291,7 +4284,6 @@ sqlExprCodeTarget(Parse * pParse, Expr * pExpr, int target)
 				pExpr->iColumn].type == FIELD_TYPE_NUMBER) {
 				sqlVdbeAddOp1(v, OP_Realify, target);
 			}
-#endif
 			break;
 		}
 
diff --git a/src/box/sql/fault.c b/src/box/sql/fault.c
index d83af36..8ee774e 100644
--- a/src/box/sql/fault.c
+++ b/src/box/sql/fault.c
@@ -65,14 +65,8 @@ static SQL_WSD struct BenignMallocHooks {
  * case where writable static data is supported, wsdHooks can refer directly
  * to the "sqlHooks" state vector declared above.
  */
-#ifdef SQL_OMIT_WSD
-#define wsdHooksInit \
-  BenignMallocHooks *x = &GLOBAL(BenignMallocHooks,sqlHooks)
-#define wsdHooks x[0]
-#else
 #define wsdHooksInit
 #define wsdHooks sqlHooks
-#endif
 
 /*
  * Register hooks to call when sqlBeginBenignMalloc() and
diff --git a/src/box/sql/func.c b/src/box/sql/func.c
index b86a95d..9288dbe 100644
--- a/src/box/sql/func.c
+++ b/src/box/sql/func.c
@@ -498,7 +498,6 @@ substrFunc(sql_context * context, int argc, sql_value ** argv)
 /*
  * Implementation of the round() function
  */
-#ifndef SQL_OMIT_FLOATING_POINT
 static void
 roundFunc(sql_context * context, int argc, sql_value ** argv)
 {
@@ -535,7 +534,6 @@ roundFunc(sql_context * context, int argc, sql_value ** argv)
 	}
 	sql_result_double(context, r);
 }
-#endif
 
 /*
  * Allocate nByte bytes of space using sqlMalloc(). If the
@@ -1547,7 +1545,6 @@ totalFinalize(sql_context * context)
 {
 	SumCtx *p;
 	p = sql_aggregate_context(context, 0);
-	/* (double)0 In case of SQL_OMIT_FLOATING_POINT... */
 	sql_result_double(context, p ? p->rSum : (double)0);
 }
 
@@ -1703,11 +1700,6 @@ sql_overload_function(sql * db, const char *zName,
 {
 	int rc = SQL_OK;
 
-#ifdef SQL_ENABLE_API_ARMOR
-	if (!sqlSafetyCheckOk(db) || zName == 0 || nArg < -2) {
-		return SQL_MISUSE;
-	}
-#endif
 	if (sqlFindFunction(db, zName, nArg, 0) == 0) {
 		rc = sqlCreateFunc(db, zName, type, nArg, 0, 0,
 				       sqlInvalidFunction, 0, 0, 0);
@@ -1841,10 +1833,8 @@ sqlRegisterBuiltinFunctions(void)
 		FUNCTION(unicode, 1, 0, 0, unicodeFunc, FIELD_TYPE_STRING),
 		FUNCTION(char, -1, 0, 0, charFunc, FIELD_TYPE_STRING),
 		FUNCTION(abs, 1, 0, 0, absFunc, FIELD_TYPE_NUMBER),
-#ifndef SQL_OMIT_FLOATING_POINT
 		FUNCTION(round, 1, 0, 0, roundFunc, FIELD_TYPE_INTEGER),
 		FUNCTION(round, 2, 0, 0, roundFunc, FIELD_TYPE_INTEGER),
-#endif
 		FUNCTION_COLL(upper, 1, 0, 1, UpperICUFunc),
 		FUNCTION_COLL(lower, 1, 0, 1, LowerICUFunc),
 		FUNCTION(hex, 1, 0, 0, hexFunc, FIELD_TYPE_STRING),
diff --git a/src/box/sql/global.c b/src/box/sql/global.c
index 159b35e..f48cb8c 100644
--- a/src/box/sql/global.c
+++ b/src/box/sql/global.c
@@ -200,10 +200,6 @@ SQL_WSD struct sqlConfig sqlConfig = {
 	0,			/* isMallocInit */
 	0,			/* xLog */
 	0,			/* pLogArg */
-#ifdef SQL_ENABLE_SQLLOG
-	0,			/* xSqllog */
-	0,			/* pSqllogArg */
-#endif
 #ifdef SQL_VDBE_COVERAGE
 	0,			/* xVdbeBranch */
 	0,			/* pVbeBranchArg */
@@ -240,9 +236,7 @@ FuncDefHash sqlBuiltinFunctions;
  * Changing the pending byte during operation will result in undefined
  * and incorrect behavior.
  */
-#ifndef SQL_OMIT_WSD
 int sqlPendingByte = 0x40000000;
-#endif
 
 #include "opcodes.h"
 /*
diff --git a/src/box/sql/main.c b/src/box/sql/main.c
index 0b3bd20..9cc6536 100644
--- a/src/box/sql/main.c
+++ b/src/box/sql/main.c
@@ -40,22 +40,6 @@
 #include "version.h"
 #include "box/session.h"
 
-#ifdef SQL_ENABLE_FTS3
-#include "fts3.h"
-#endif
-#ifdef SQL_ENABLE_RTREE
-#include "rtree.h"
-#endif
-#ifdef SQL_ENABLE_ICU
-#include "sqlicu.h"
-#endif
-#ifdef SQL_ENABLE_JSON1
-int sqlJson1Init(sql *);
-#endif
-#ifdef SQL_ENABLE_FTS5
-int sqlFts5Init(sql *);
-#endif
-
 #if !defined(SQL_OMIT_TRACE) && defined(SQL_ENABLE_IOTRACE)
 /*
  * If the following function pointer is not NULL and if
@@ -89,9 +73,7 @@ char *sql_data_directory = 0;
  *
  * This routine must be called to initialize the memory allocation,
  * and VFS subsystems prior to doing any serious work with
- * sql.  But as long as you do not compile with SQL_OMIT_AUTOINIT
- * this routine will be called automatically by key routines such as
- * sql_open().
+ * sql.
  *
  * This routine is a no-op except on its very first call for the process,
  * or for the first call after a call to sql_shutdown.
@@ -119,16 +101,6 @@ int
 sql_initialize(void)
 {
 	int rc = SQL_OK;
-#ifdef SQL_EXTRA_INIT
-	int bRunExtraInit = 0;	/* Extra initialization needed */
-#endif
-
-#ifdef SQL_OMIT_WSD
-	rc = sql_wsd_init(4096, 24);
-	if (rc != SQL_OK) {
-		return rc;
-	}
-#endif
 
 	/* If the following assert() fails on some obscure processor/compiler
 	 * combination, the work-around is to set the correct pointer
@@ -170,12 +142,6 @@ sql_initialize(void)
 	if (sqlGlobalConfig.isInit == 0
 	    && sqlGlobalConfig.inProgress == 0) {
 		sqlGlobalConfig.inProgress = 1;
-#ifdef SQL_ENABLE_SQLLOG
-		{
-			extern void sql_init_sqllog(void);
-			sql_init_sqllog();
-		}
-#endif
 		memset(&sqlBuiltinFunctions, 0,
 		       sizeof(sqlBuiltinFunctions));
 		sqlRegisterBuiltinFunctions();
@@ -184,9 +150,6 @@ sql_initialize(void)
 		}
 		if (rc == SQL_OK) {
 			sqlGlobalConfig.isInit = 1;
-#ifdef SQL_EXTRA_INIT
-			bRunExtraInit = 1;
-#endif
 		}
 		sqlGlobalConfig.inProgress = 0;
 	}
@@ -197,7 +160,6 @@ sql_initialize(void)
 	 * reason.  So we run it once during initialization.
 	 */
 #ifndef NDEBUG
-#ifndef SQL_OMIT_FLOATING_POINT
 	/* This section of code's only "output" is via assert() statements. */
 	if (rc == SQL_OK) {
 		u64 x = (((u64) 1) << 63) - 1;
@@ -208,17 +170,6 @@ sql_initialize(void)
 		assert(sqlIsNaN(y));
 	}
 #endif
-#endif
-
-	/* Do extra initialization steps requested by the SQL_EXTRA_INIT
-	 * compile-time option.
-	 */
-#ifdef SQL_EXTRA_INIT
-	if (bRunExtraInit) {
-		int SQL_EXTRA_INIT(const char *);
-		rc = SQL_EXTRA_INIT(0);
-	}
-#endif
 
 	return rc;
 }
@@ -234,13 +185,6 @@ sql_initialize(void)
 int
 sql_shutdown(void)
 {
-#ifdef SQL_OMIT_WSD
-	int rc = sql_wsd_init(4096, 24);
-	if (rc != SQL_OK) {
-		return rc;
-	}
-#endif
-
 	if (sqlGlobalConfig.isInit) {
 #ifdef SQL_EXTRA_SHUTDOWN
 		void SQL_EXTRA_SHUTDOWN(void);
@@ -354,16 +298,6 @@ sql_config(int op, ...)
 			break;
 		}
 
-#ifdef SQL_ENABLE_SQLLOG
-	case SQL_CONFIG_SQLLOG:{
-			typedef void (*SQLLOGFUNC_t) (void *, sql *,
-						      const char *, int);
-			sqlGlobalConfig.xSqllog = va_arg(ap, SQLLOGFUNC_t);
-			sqlGlobalConfig.pSqllogArg = va_arg(ap, void *);
-			break;
-		}
-#endif
-
 	case SQL_CONFIG_MMAP_SIZE:{
 			/* EVIDENCE-OF: R-58063-38258 SQL_CONFIG_MMAP_SIZE takes two 64-bit
 			 * integer (sql_int64) values that are the default mmap size limit
@@ -556,13 +490,6 @@ sqlClose(sql * db, int forceZombie)
 				    "statements");
 		return SQL_BUSY;
 	}
-#ifdef SQL_ENABLE_SQLLOG
-	if (sqlGlobalConfig.xSqllog) {
-		/* Closing the handle. Fourth parameter is passed the value 2. */
-		sqlGlobalConfig.xSqllog(sqlGlobalConfig.pSqllogArg, db,
-					    0, 2);
-	}
-#endif
 
 	/* Convert the connection into a zombie and then close it.
 	 */
@@ -650,11 +577,6 @@ void
 sql_progress_handler(sql * db,
 			 int nOps, int (*xProgress) (void *), void *pArg)
 {
-#ifdef SQL_ENABLE_API_ARMOR
-	if (!sqlSafetyCheckOk(db)) {
-		return;
-	}
-#endif
 	if (nOps > 0) {
 		db->xProgress = xProgress;
 		db->nProgressOps = (unsigned)nOps;
@@ -673,12 +595,6 @@ sql_progress_handler(sql * db,
 void
 sql_interrupt(sql * db)
 {
-#ifdef SQL_ENABLE_API_ARMOR
-	if (!sqlSafetyCheckOk(db)
-	    && (db == 0 || db->magic != SQL_MAGIC_ZOMBIE)) {
-		return;
-	}
-#endif
 	db->u1.isInterrupted = 1;
 }
 
@@ -775,11 +691,6 @@ sql_create_function_v2(sql * db,
 	int rc = SQL_ERROR;
 	FuncDestructor *pArg = 0;
 
-#ifdef SQL_ENABLE_API_ARMOR
-	if (!sqlSafetyCheckOk(db)) {
-		return SQL_MISUSE;
-	}
-#endif
 	if (xDestroy) {
 		pArg =
 		    (FuncDestructor *) sqlDbMallocZero(db,
@@ -814,11 +725,6 @@ sql_trace_v2(sql * db,		/* Trace this connection */
 		 int (*xTrace) (unsigned, void *, void *, void *),	/* Callback to invoke */
 		 void *pArg)		/* Context */
 {
-#ifdef SQL_ENABLE_API_ARMOR
-	if (!sqlSafetyCheckOk(db)) {
-		return SQL_MISUSE;
-	}
-#endif
 	if (mTrace == 0)
 		xTrace = 0;
 	if (xTrace == 0)
@@ -843,11 +749,6 @@ sql_commit_hook(sql * db,	/* Attach the hook to this database */
 {
 	void *pOld;
 
-#ifdef SQL_ENABLE_API_ARMOR
-	if (!sqlSafetyCheckOk(db)) {
-		return 0;
-	}
-#endif
 	pOld = db->pCommitArg;
 	db->xCommitCallback = xCallback;
 	db->pCommitArg = pArg;
@@ -866,11 +767,6 @@ sql_update_hook(sql * db,	/* Attach the hook to this database */
 {
 	void *pRet;
 
-#ifdef SQL_ENABLE_API_ARMOR
-	if (!sqlSafetyCheckOk(db)) {
-		return 0;
-	}
-#endif
 	pRet = db->pUpdateArg;
 	db->xUpdateCallback = xCallback;
 	db->pUpdateArg = pArg;
@@ -888,11 +784,6 @@ sql_rollback_hook(sql * db,	/* Attach the hook to this database */
 {
 	void *pRet;
 
-#ifdef SQL_ENABLE_API_ARMOR
-	if (!sqlSafetyCheckOk(db)) {
-		return 0;
-	}
-#endif
 	pRet = db->pRollbackArg;
 	db->xRollbackCallback = xCallback;
 	db->pRollbackArg = pArg;
@@ -1103,12 +994,6 @@ sql_limit(sql * db, int limitId, int newLimit)
 {
 	int oldLimit;
 
-#ifdef SQL_ENABLE_API_ARMOR
-	if (!sqlSafetyCheckOk(db)) {
-		return -1;
-	}
-#endif
-
 	/* EVIDENCE-OF: R-30189-54097 For each limit category SQL_LIMIT_NAME
 	 * there is a hard upper bound set at compile-time by a C preprocessor
 	 * macro called SQL_MAX_NAME. (The "_LIMIT_" in the name is changed to
@@ -1449,15 +1334,9 @@ sql_init_db(sql **out_db)
 	sql *db;
 	int rc;			/* Return code */
 
-#ifdef SQL_ENABLE_API_ARMOR
-	if (ppDb == 0)
-		return SQL_MISUSE;
-#endif
-#ifndef SQL_OMIT_AUTOINIT
 	rc = sql_initialize();
 	if (rc)
 		return rc;
-#endif
 
 	/* Allocate the sql data structure */
 	db = sqlMallocZero(sizeof(sql));
@@ -1488,54 +1367,6 @@ sql_init_db(sql **out_db)
 	sqlRegisterPerConnectionBuiltinFunctions(db);
 	rc = sql_errcode(db);
 
-#ifdef SQL_ENABLE_FTS5
-	/* Register any built-in FTS5 module before loading the automatic
-	 * extensions. This allows automatic extensions to register FTS5
-	 * tokenizers and auxiliary functions.
-	 */
-	if (!db->mallocFailed && rc == SQL_OK) {
-		rc = sqlFts5Init(db);
-	}
-#endif
-
-#ifdef SQL_ENABLE_FTS1
-	if (!db->mallocFailed) {
-		extern int sqlFts1Init(sql *);
-		rc = sqlFts1Init(db);
-	}
-#endif
-
-#ifdef SQL_ENABLE_FTS2
-	if (!db->mallocFailed && rc == SQL_OK) {
-		extern int sqlFts2Init(sql *);
-		rc = sqlFts2Init(db);
-	}
-#endif
-
-#ifdef SQL_ENABLE_FTS3	/* automatically defined by SQL_ENABLE_FTS4 */
-	if (!db->mallocFailed && rc == SQL_OK) {
-		rc = sqlFts3Init(db);
-	}
-#endif
-
-#ifdef SQL_ENABLE_ICU
-	if (!db->mallocFailed && rc == SQL_OK) {
-		rc = sqlIcuInit(db);
-	}
-#endif
-
-#ifdef SQL_ENABLE_RTREE
-	if (!db->mallocFailed && rc == SQL_OK) {
-		rc = sqlRtreeInit(db);
-	}
-#endif
-
-#ifdef SQL_ENABLE_JSON1
-	if (!db->mallocFailed && rc == SQL_OK) {
-		rc = sqlJson1Init(db);
-	}
-#endif
-
 	if (rc)
 		sqlError(db, rc);
 
@@ -1553,13 +1384,6 @@ opendb_out:
 		db->magic = SQL_MAGIC_SICK;
 
 	*out_db = db;
-#ifdef SQL_ENABLE_SQLLOG
-	if (sqlGlobalConfig.xSqllog) {
-		/* Opening a db handle. Fourth parameter is passed 0. */
-		void *pArg = sqlGlobalConfig.pSqllogArg;
-		sqlGlobalConfig.xSqllog(pArg, db, zFilename, 0);
-	}
-#endif
 
 	return rc;
 }
@@ -1570,10 +1394,6 @@ opendb_out:
 int
 sql_extended_result_codes(sql * db, int onoff)
 {
-#ifdef SQL_ENABLE_API_ARMOR
-	if (!sqlSafetyCheckOk(db))
-		return SQL_MISUSE;
-#endif
 	db->errMask = onoff ? 0xffffffff : 0xff;
 	return SQL_OK;
 }
@@ -1669,13 +1489,11 @@ sql_test_control(int op, ...)
 		 */
 	case SQL_TESTCTRL_PENDING_BYTE:{
 			rc = PENDING_BYTE;
-#ifndef SQL_OMIT_WSD
 			{
 				unsigned int newVal = va_arg(ap, unsigned int);
 				if (newVal)
 					sqlPendingByte = newVal;
 			}
-#endif
 			break;
 		}
 
@@ -1924,49 +1742,3 @@ sql_uri_int64(const char *zFilename,	/* Filename as passed to xOpen */
 		bDflt = v;
 	return bDflt;
 }
-
-
-#ifdef SQL_ENABLE_SNAPSHOT
-/*
- * Obtain a snapshot handle for the snapshot of database zDb currently
- * being read by handle db.
- */
-int
-sql_snapshot_get(sql * db,
-		     const char *zDb, sql_snapshot ** ppSnapshot)
-{
-	int rc = SQL_ERROR;
-	return rc;
-}
-
-/*
- * Open a read-transaction on the snapshot idendified by pSnapshot.
- */
-int
-sql_snapshot_open(sql * db,
-		      const char *zDb, sql_snapshot * pSnapshot)
-{
-	int rc = SQL_ERROR;
-	return rc;
-}
-
-/*
- * Recover as many snapshots as possible from the wal file associated with
- * schema zDb of database db.
- */
-int
-sql_snapshot_recover(sql * db, const char *zDb)
-{
-	int rc = SQL_ERROR;
-	return rc;
-}
-
-/*
- * Free a snapshot handle obtained from sql_snapshot_get().
- */
-void
-sql_snapshot_free(sql_snapshot * pSnapshot)
-{
-	sql_free(pSnapshot);
-}
-#endif				/* SQL_ENABLE_SNAPSHOT */
diff --git a/src/box/sql/malloc.c b/src/box/sql/malloc.c
index dc018fc..d6f99b4 100644
--- a/src/box/sql/malloc.c
+++ b/src/box/sql/malloc.c
@@ -185,11 +185,6 @@ sql_soft_heap_limit64(sql_int64 n)
 	sql_int64 priorLimit;
 	sql_int64 excess;
 	sql_int64 nUsed;
-#ifndef SQL_OMIT_AUTOINIT
-	int rc = sql_initialize();
-	if (rc)
-		return -1;
-#endif
 	priorLimit = mem0.alarmThreshold;
 	if (n < 0) {
 		return priorLimit;
@@ -372,20 +367,12 @@ sqlMalloc(u64 n)
 void *
 sql_malloc(int n)
 {
-#ifndef SQL_OMIT_AUTOINIT
-	if (sql_initialize())
-		return 0;
-#endif
 	return n <= 0 ? 0 : sqlMalloc(n);
 }
 
 void *
 sql_malloc64(sql_uint64 n)
 {
-#ifndef SQL_OMIT_AUTOINIT
-	if (sql_initialize())
-		return 0;
-#endif
 	return sqlMalloc(n);
 }
 
@@ -661,10 +648,6 @@ sqlRealloc(void *pOld, u64 nBytes)
 void *
 sql_realloc(void *pOld, int n)
 {
-#ifndef SQL_OMIT_AUTOINIT
-	if (sql_initialize())
-		return 0;
-#endif
 	if (n < 0)
 		n = 0;		/* IMP: R-26507-47431 */
 	return sqlRealloc(pOld, n);
@@ -673,10 +656,6 @@ sql_realloc(void *pOld, int n)
 void *
 sql_realloc64(void *pOld, sql_uint64 n)
 {
-#ifndef SQL_OMIT_AUTOINIT
-	if (sql_initialize())
-		return 0;
-#endif
 	return sqlRealloc(pOld, n);
 }
 
diff --git a/src/box/sql/os.c b/src/box/sql/os.c
index 76a15ed..eb7450b 100644
--- a/src/box/sql/os.c
+++ b/src/box/sql/os.c
@@ -213,11 +213,6 @@ sql_vfs *
 sql_vfs_find(const char *zVfs)
 {
 	sql_vfs *pVfs = 0;
-#ifndef SQL_OMIT_AUTOINIT
-	int rc = sql_initialize();
-	if (rc)
-		return 0;
-#endif
 	for (pVfs = vfsList; pVfs; pVfs = pVfs->pNext) {
 		if (zVfs == 0)
 			break;
@@ -256,15 +251,6 @@ vfsUnlink(sql_vfs * pVfs)
 int
 sql_vfs_register(sql_vfs * pVfs, int makeDflt)
 {
-#ifndef SQL_OMIT_AUTOINIT
-	int rc = sql_initialize();
-	if (rc)
-		return rc;
-#endif
-#ifdef SQL_ENABLE_API_ARMOR
-	if (pVfs == 0)
-		return SQL_MISUSE;
-#endif
 
 	vfsUnlink(pVfs);
 	if (makeDflt || vfsList == 0) {
diff --git a/src/box/sql/os_unix.c b/src/box/sql/os_unix.c
index b659985..615d539 100644
--- a/src/box/sql/os_unix.c
+++ b/src/box/sql/os_unix.c
@@ -1693,11 +1693,6 @@ getFileMode(const char *zFile,	/* File name */
  * corresponding database file and sets *pMode to this value. Whenever
  * possible, journal files are created using the same permissions
  * as the associated database file.
- *
- * If the SQL_ENABLE_8_3_NAMES option is enabled, then the
- * original filename is unavailable.  But 8_3_NAMES is only used for
- * FAT filesystems and permissions do not matter there, so just use
- * the default permissions.
  */
 static int
 findCreateFileMode(const char *zPath,	/* Path of file (possibly) being created */
diff --git a/src/box/sql/prepare.c b/src/box/sql/prepare.c
index 4ae6c13..3df6b5c 100644
--- a/src/box/sql/prepare.c
+++ b/src/box/sql/prepare.c
@@ -194,10 +194,6 @@ sqlLockAndPrepare(sql * db,		/* Database handle. */
 {
 	int rc;
 
-#ifdef SQL_ENABLE_API_ARMOR
-	if (ppStmt == 0)
-		return SQL_MISUSE;
-#endif
 	*ppStmt = 0;
 	if (!sqlSafetyCheckOk(db) || zSql == 0) {
 		return SQL_MISUSE;
diff --git a/src/box/sql/printf.c b/src/box/sql/printf.c
index 592f906..31d21db 100644
--- a/src/box/sql/printf.c
+++ b/src/box/sql/printf.c
@@ -80,12 +80,10 @@ static const et_info fmtinfo[] = {
 	{'u', 10, 0, etRADIX, 0, 0},
 	{'x', 16, 0, etRADIX, 16, 1},
 	{'X', 16, 0, etRADIX, 0, 4},
-#ifndef SQL_OMIT_FLOATING_POINT
 	{'f', 0, 1, etFLOAT, 0, 0},
 	{'e', 0, 1, etEXP, 30, 0},
 	{'E', 0, 1, etEXP, 14, 0},
 	{'G', 0, 1, etGENERIC, 14, 0},
-#endif
 	{'i', 10, 1, etRADIX, 0, 0},
 	{'n', 0, 0, etSIZE, 0, 0},
 	{'%', 0, 0, etPERCENT, 0, 0},
@@ -99,11 +97,6 @@ static const et_info fmtinfo[] = {
 };
 
 /*
- * If SQL_OMIT_FLOATING_POINT is defined, then none of the floating point
- * conversions will work.
- */
-#ifndef SQL_OMIT_FLOATING_POINT
-/*
  * "*val" is a double such that 0.1 <= *val < 10.0
  * Return the ascii code for the leading digit of *val, then
  * multiply "*val" by 10.0 to renormalize.
@@ -130,7 +123,6 @@ et_getdigit(LONGDOUBLE_TYPE * val, int *cnt)
 	*val = (*val - d) * 10.0;
 	return (char)digit;
 }
-#endif				/* SQL_OMIT_FLOATING_POINT */
 
 /*
  * Set the StrAccum object to an error mode.
@@ -213,13 +205,11 @@ sqlVXPrintf(StrAccum * pAccum,	/* Accumulate results here */
 	char *zOut;		/* Rendering buffer */
 	int nOut;		/* Size of the rendering buffer */
 	char *zExtra = 0;	/* Malloced memory used by some conversion */
-#ifndef SQL_OMIT_FLOATING_POINT
 	int exp, e2;		/* exponent of real numbers */
 	int nsd;		/* Number of significant digits returned */
 	double rounder;		/* Used for rounding floating point values */
 	etByte flag_dp;		/* True if decimal point should be shown */
 	etByte flag_rtz;	/* True if trailing zeros should be removed */
-#endif
 	PrintfArguments *pArgList = 0;	/* Arguments for SQL_PRINTF_SQLFUNC */
 	char buf[etBUFSIZE];	/* Conversion buffer */
 
@@ -499,9 +489,6 @@ sqlVXPrintf(StrAccum * pAccum,	/* Accumulate results here */
 			} else {
 				realvalue = va_arg(ap, double);
 			}
-#ifdef SQL_OMIT_FLOATING_POINT
-			length = 0;
-#else
 			if (precision < 0)
 				precision = 6;	/* Set default precision */
 			if (realvalue < 0.0) {
@@ -682,7 +669,6 @@ sqlVXPrintf(StrAccum * pAccum,	/* Accumulate results here */
 					bufpt[i++] = '0';
 				length = width;
 			}
-#endif				/* !defined(SQL_OMIT_FLOATING_POINT) */
 			break;
 		case etSIZE:
 			if (!bArgList) {
@@ -1082,16 +1068,6 @@ sql_vmprintf(const char *zFormat, va_list ap)
 	char *z;
 	char zBase[SQL_PRINT_BUF_SIZE];
 	StrAccum acc;
-
-#ifdef SQL_ENABLE_API_ARMOR
-	if (zFormat == 0) {
-		return 0;
-	}
-#endif
-#ifndef SQL_OMIT_AUTOINIT
-	if (sql_initialize())
-		return 0;
-#endif
 	sqlStrAccumInit(&acc, 0, zBase, sizeof(zBase), SQL_MAX_LENGTH);
 	sqlVXPrintf(&acc, zFormat, ap);
 	z = sqlStrAccumFinish(&acc);
@@ -1107,10 +1083,6 @@ sql_mprintf(const char *zFormat, ...)
 {
 	va_list ap;
 	char *z;
-#ifndef SQL_OMIT_AUTOINIT
-	if (sql_initialize())
-		return 0;
-#endif
 	va_start(ap, zFormat);
 	z = sql_vmprintf(zFormat, ap);
 	va_end(ap);
@@ -1136,13 +1108,6 @@ sql_vsnprintf(int n, char *zBuf, const char *zFormat, va_list ap)
 	StrAccum acc;
 	if (n <= 0)
 		return zBuf;
-#ifdef SQL_ENABLE_API_ARMOR
-	if (zBuf == 0 || zFormat == 0) {
-		if (zBuf)
-			zBuf[0] = 0;
-		return zBuf;
-	}
-#endif
 	sqlStrAccumInit(&acc, 0, zBuf, n, 0);
 	sqlVXPrintf(&acc, zFormat, ap);
 	zBuf[acc.nChar] = 0;
diff --git a/src/box/sql/random.c b/src/box/sql/random.c
index fe98e55..2de1890 100644
--- a/src/box/sql/random.c
+++ b/src/box/sql/random.c
@@ -62,18 +62,7 @@ sql_randomness(int N, void *pBuf)
 	 * case where writable static data is supported, wsdPrng can refer directly
 	 * to the "sqlPrng" state vector declared above.
 	 */
-#ifdef SQL_OMIT_WSD
-	struct sqlPrngType *p =
-	    &GLOBAL(struct sqlPrngType, sqlPrng);
-#define wsdPrng p[0]
-#else
 #define wsdPrng sqlPrng
-#endif
-
-#ifndef SQL_OMIT_AUTOINIT
-	if (sql_initialize())
-		return;
-#endif
 
 	if (N <= 0 || pBuf == 0) {
 		wsdPrng.isInit = 0;
diff --git a/src/box/sql/sqlInt.h b/src/box/sql/sqlInt.h
index 1a42d0d..cfeb49c 100644
--- a/src/box/sql/sqlInt.h
+++ b/src/box/sql/sqlInt.h
@@ -945,18 +945,6 @@ sql_bind_parameter_lindex(sql_stmt * pStmt, const char *zName,
  * If compiling for a processor that lacks floating point support,
  * substitute integer for floating-point
  */
-#ifdef SQL_OMIT_FLOATING_POINT
-#define double sql_int64
-#define float sql_int64
-#define LONGDOUBLE_TYPE sql_int64
-#ifndef SQL_BIG_DBL
-#define SQL_BIG_DBL (((sql_int64)1)<<50)
-#endif
-#define SQL_OMIT_DATETIME_FUNCS 1
-#define SQL_OMIT_TRACE 1
-#undef SQL_MIXED_ENDIAN_64BIT_FLOAT
-#undef SQL_HAVE_ISNAN
-#endif
 #ifndef SQL_BIG_DBL
 #define SQL_BIG_DBL (1e99)
 #endif
@@ -1301,30 +1289,13 @@ extern const int sqlone;
 #define SQL_DYNAMIC   ((sql_destructor_type)sqlMallocSize)
 
 /*
- * When sql_OMIT_WSD is defined, it means that the target platform does
- * not support Writable Static Data (WSD) such as global and static variables.
- * All variables must either be on the stack or dynamically allocated from
- * the heap.  When WSD is unsupported, the variable declarations scattered
- * throughout the sql code must become constants instead.  The sql_WSD
- * macro is used for this purpose.  And instead of referencing the variable
- * directly, we use its constant as a key to lookup the run-time allocated
- * buffer that holds real variable.  The constant is also the initializer
- * for the run-time allocated buffer.
- *
- * In the usual case where WSD is supported, the sql_WSD and GLOBAL
- * macros become no-ops and have zero performance impact.
- */
-#ifdef SQL_OMIT_WSD
-#define SQL_WSD const
-#define GLOBAL(t,v) (*(t*)sql_wsd_find((void*)&(v), sizeof(v)))
-#define sqlGlobalConfig GLOBAL(struct sqlConfig, sqlConfig)
-int sql_wsd_init(int N, int J);
-void *sql_wsd_find(void *K, int L);
-#else
+ * The usual case where Writable Static Data (WSD) is supported,
+ * the sql_WSD and GLOBAL macros become no-ops and have zero
+ * performance impact.
+ */
 #define SQL_WSD
 #define GLOBAL(t,v) v
 #define sqlGlobalConfig sqlConfig
-#endif
 
 /*
  * The following macros are used to suppress compiler warnings and to
@@ -2930,10 +2901,6 @@ struct sqlConfig {
 	int isMallocInit;	/* True after malloc is initialized */
 	void (*xLog) (void *, int, const char *);	/* Function for logging */
 	void *pLogArg;		/* First argument to xLog() */
-#ifdef SQL_ENABLE_SQLLOG
-	void (*xSqllog) (void *, sql *, const char *, int);
-	void *pSqllogArg;
-#endif
 #ifdef SQL_VDBE_COVERAGE
 	/* The following callback (if not NULL) is invoked on every VDBE branch
 	 * operation.  Set the callback using sql_TESTCTRL_VDBE_COVERAGE.
@@ -3041,15 +3008,6 @@ struct TreeView {
 }
 
 /*
- * FTS4 is really an extension for FTS3.  It is enabled using the
- * sql_ENABLE_FTS3 macro.  But to avoid confusion we also call
- * the sql_ENABLE_FTS4 macro to serve as an alias for sql_ENABLE_FTS3.
- */
-#if defined(SQL_ENABLE_FTS4) && !defined(SQL_ENABLE_FTS3)
-#define SQL_ENABLE_FTS3 1
-#endif
-
-/*
  * The following macros mimic the standard library functions toupper(),
  * isspace(), isalnum(), isdigit() and isxdigit(), respectively. The
  * sql versions only work for ASCII characters, regardless of locale.
@@ -3118,11 +3076,7 @@ void sqlStatusUp(int, int);
 void sqlStatusDown(int, int);
 void sqlStatusHighwater(int, int);
 
-#ifndef SQL_OMIT_FLOATING_POINT
 int sqlIsNaN(double);
-#else
-#define sqlIsNaN(X)  0
-#endif
 
 /*
  * An instance of the following structure holds information about SQL
@@ -4546,11 +4500,6 @@ int sqlAddInt64(i64 *, i64);
 int sqlSubInt64(i64 *, i64);
 int sqlMulInt64(i64 *, i64);
 int sqlAbsInt32(int);
-#ifdef SQL_ENABLE_8_3_NAMES
-void sqlFileSuffix3(const char *, char *);
-#else
-#define sqlFileSuffix3(X,Y)
-#endif
 u8 sqlGetBoolean(const char *z, u8);
 
 const void *sqlValueText(sql_value *);
@@ -4571,10 +4520,8 @@ extern const unsigned char sqlCtypeMap[];
 extern const Token sqlIntTokens[];
 extern SQL_WSD struct sqlConfig sqlConfig;
 extern FuncDefHash sqlBuiltinFunctions;
-#ifndef SQL_OMIT_WSD
 extern int sqlPendingByte;
 #endif
-#endif
 
 /**
  * Generate code to implement the "ALTER TABLE xxx RENAME TO yyy"
diff --git a/src/box/sql/status.c b/src/box/sql/status.c
index 2abf7a5..bc170c8 100644
--- a/src/box/sql/status.c
+++ b/src/box/sql/status.c
@@ -54,18 +54,12 @@ static SQL_WSD struct sqlStatType {
 
 
 /* The "wsdStat" macro will resolve to the status information
- * state vector.  If writable static data is unsupported on the target,
- * we have to locate the state vector at run-time.  In the more common
- * case where writable static data is supported, wsdStat can refer directly
- * to the "sqlStat" state vector declared above.
+ * state vector. In the common case where writable static data is
+ * supported, wsdStat can refer directly  to the "sqlStat" state
+ * vector declared above.
  */
-#ifdef SQL_OMIT_WSD
-#define wsdStatInit  sqlStatType *x = &GLOBAL(sqlStatType,sqlStat)
-#define wsdStat x[0]
-#else
 #define wsdStatInit
 #define wsdStat sqlStat
-#endif
 
 /*
  * Return the current value of a status parameter.
@@ -144,10 +138,6 @@ sql_status64(int op,
 	if (op < 0 || op >= ArraySize(wsdStat.nowValue)) {
 		return SQL_MISUSE;
 	}
-#ifdef SQL_ENABLE_API_ARMOR
-	if (pCurrent == 0 || pHighwater == 0)
-		return SQL_MISUSE;
-#endif
 	*pCurrent = wsdStat.nowValue[op];
 	*pHighwater = wsdStat.mxValue[op];
 	if (resetFlag) {
@@ -161,10 +151,6 @@ sql_status(int op, int *pCurrent, int *pHighwater, int resetFlag)
 {
 	sql_int64 iCur = 0, iHwtr = 0;
 	int rc;
-#ifdef SQL_ENABLE_API_ARMOR
-	if (pCurrent == 0 || pHighwater == 0)
-		return SQL_MISUSE;
-#endif
 	rc = sql_status64(op, &iCur, &iHwtr, resetFlag);
 	if (rc == 0) {
 		*pCurrent = (int)iCur;
@@ -185,11 +171,6 @@ sql_db_status(sql * db,	/* The database connection whose status is desired */
     )
 {
 	int rc = SQL_OK;	/* Return code */
-#ifdef SQL_ENABLE_API_ARMOR
-	if (!sqlSafetyCheckOk(db) || pCurrent == 0 || pHighwater == 0) {
-		return SQL_MISUSE;
-	}
-#endif
 	switch (op) {
 	case SQL_DBSTATUS_LOOKASIDE_USED:{
 			*pCurrent = db->lookaside.nOut;
diff --git a/src/box/sql/treeview.c b/src/box/sql/treeview.c
index 1fd8668..5acea58 100644
--- a/src/box/sql/treeview.c
+++ b/src/box/sql/treeview.c
@@ -349,12 +349,10 @@ sqlTreeViewExpr(TreeView * pView, const Expr * pExpr, u8 moreToFollow)
 			}
 			break;
 		}
-#ifndef SQL_OMIT_FLOATING_POINT
 	case TK_FLOAT:{
 			sqlTreeViewLine(pView, "%s", pExpr->u.zToken);
 			break;
 		}
-#endif
 	case TK_STRING:{
 			sqlTreeViewLine(pView, "%Q", pExpr->u.zToken);
 			break;
diff --git a/src/box/sql/update.c b/src/box/sql/update.c
index aeaa863..35c0019 100644
--- a/src/box/sql/update.c
+++ b/src/box/sql/update.c
@@ -58,11 +58,9 @@ sqlColumnDefault(Vdbe *v, struct space_def *def, int i, int ireg)
 		if (pValue) {
 			sqlVdbeAppendP4(v, pValue, P4_MEM);
 		}
-#ifndef SQL_OMIT_FLOATING_POINT
 		if (type == FIELD_TYPE_NUMBER) {
 			sqlVdbeAddOp1(v, OP_Realify, ireg);
 		}
-#endif
 	}
 }
 
diff --git a/src/box/sql/util.c b/src/box/sql/util.c
index 52a8663..d5c93f8 100644
--- a/src/box/sql/util.c
+++ b/src/box/sql/util.c
@@ -77,7 +77,6 @@ int
 }
 #endif
 
-#ifndef SQL_OMIT_FLOATING_POINT
 /*
  * Return true if the floating point value is Not a Number (NaN).
  *
@@ -114,7 +113,6 @@ sqlIsNaN(double x)
 	testcase(rc);
 	return rc;
 }
-#endif				/* SQL_OMIT_FLOATING_POINT */
 
 /*
  * Compute a string length that is limited to what can be stored in
@@ -413,7 +411,6 @@ sql_strnicmp(const char *zLeft, const char *zRight, int N)
 int
 sqlAtoF(const char *z, double *pResult, int length)
 {
-#ifndef SQL_OMIT_FLOATING_POINT
 	int incr = 1; // UTF-8
 	const char *zEnd = z + length;
 	/* sign * significand * (10 ^ (esign * exponent)) */
@@ -594,9 +591,6 @@ sqlAtoF(const char *z, double *pResult, int length)
 
 	/* return true if number and no extra non-whitespace chracters after */
 	return z == zEnd && nDigits > 0 && eValid && nonNum == 0;
-#else
-	return !sqlAtoi64(z, pResult, length);
-#endif				/* SQL_OMIT_FLOATING_POINT */
 }
 
 /*
@@ -1363,41 +1357,6 @@ sqlAbsInt32(int x)
 	return -x;
 }
 
-#ifdef SQL_ENABLE_8_3_NAMES
-/*
- * If SQL_ENABLE_8_3_NAMES is set at compile-time and if the database
- * filename in zBaseFilename is a URI with the "8_3_names=1" parameter and
- * if filename in z[] has a suffix (a.k.a. "extension") that is longer than
- * three characters, then shorten the suffix on z[] to be the last three
- * characters of the original suffix.
- *
- * If SQL_ENABLE_8_3_NAMES is set to 2 at compile-time, then always
- * do the suffix shortening regardless of URI parameter.
- *
- * Examples:
- *
- *     test.db-journal    =>   test.nal
- *     test.db-wal        =>   test.wal
- *     test.db-shm        =>   test.shm
- *     test.db-mj7f3319fa =>   test.9fa
- */
-void
-sqlFileSuffix3(const char *zBaseFilename, char *z)
-{
-#if SQL_ENABLE_8_3_NAMES<2
-	if (sql_uri_boolean(zBaseFilename, "8_3_names", 0))
-#endif
-	{
-		int i, sz;
-		sz = sqlStrlen30(z);
-		for (i = sz - 1; i > 0 && z[i] != '/' && z[i] != '.'; i--) {
-		}
-		if (z[i] == '.' && ALWAYS(sz > i + 4))
-			memmove(&z[i + 1], &z[sz - 3], 4);
-	}
-}
-#endif
-
 /*
  * Find (an approximate) sum of two LogEst values.  This computation is
  * not a simple "+" operator because LogEst is stored as a logarithmic
diff --git a/src/box/sql/vdbe.c b/src/box/sql/vdbe.c
index ed7bf88..f746559 100644
--- a/src/box/sql/vdbe.c
+++ b/src/box/sql/vdbe.c
@@ -530,10 +530,8 @@ memTracePrint(Mem *p)
 		printf(" si:%lld", p->u.i);
 	} else if (p->flags & MEM_Int) {
 		printf(" i:%lld", p->u.i);
-#ifndef SQL_OMIT_FLOATING_POINT
 	} else if (p->flags & MEM_Real) {
 		printf(" r:%g", p->u.r);
-#endif
 	} else {
 		char zBuf[200];
 		sqlVdbeMemPrettyPrint(p, zBuf);
@@ -1140,7 +1138,6 @@ case OP_Int64: {           /* out2 */
 	break;
 }
 
-#ifndef SQL_OMIT_FLOATING_POINT
 /* Opcode: Real * P2 * P4 *
  * Synopsis: r[P2]=P4
  *
@@ -1154,7 +1151,6 @@ case OP_Real: {            /* same as TK_FLOAT, out2 */
 	pOut->u.r = *pOp->p4.pReal;
 	break;
 }
-#endif
 
 /* Opcode: String8 * P2 * P4 *
  * Synopsis: r[P2]='P4'
@@ -1692,7 +1688,6 @@ case OP_Remainder: {           /* same as TK_REM, in1, in2, out3 */
 		case OP_Subtract:    rB -= rA;       break;
 		case OP_Multiply:    rB *= rA;       break;
 		case OP_Divide: {
-			/* (double)0 In case of SQL_OMIT_FLOATING_POINT... */
 			if (rA == (double)0)
 				goto division_by_zero;
 			rB /= rA;
@@ -1708,10 +1703,6 @@ case OP_Remainder: {           /* same as TK_REM, in1, in2, out3 */
 			break;
 		}
 		}
-#ifdef SQL_OMIT_FLOATING_POINT
-		pOut->u.i = rB;
-		MemSetTypeFlag(pOut, MEM_Int);
-#else
 		if (sqlIsNaN(rB)) {
 			goto arithmetic_result_is_null;
 		}
@@ -1720,7 +1711,6 @@ case OP_Remainder: {           /* same as TK_REM, in1, in2, out3 */
 		if (((type1|type2)&MEM_Real)==0 && !bIntint) {
 			mem_apply_integer_type(pOut);
 		}
-#endif
 	}
 	break;
 
@@ -2006,7 +1996,6 @@ case OP_MustBeInt: {            /* jump, in1 */
 	break;
 }
 
-#ifndef SQL_OMIT_FLOATING_POINT
 /* Opcode: Realify P1 * * * *
  *
  * If register P1 holds an integer convert it to a real value.
@@ -2023,7 +2012,6 @@ case OP_Realify: {                  /* in1 */
 	}
 	break;
 }
-#endif
 
 #ifndef SQL_OMIT_CAST
 /* Opcode: Cast P1 P2 * * *
diff --git a/src/box/sql/vdbeInt.h b/src/box/sql/vdbeInt.h
index c84f22c..577b022 100644
--- a/src/box/sql/vdbeInt.h
+++ b/src/box/sql/vdbeInt.h
@@ -481,11 +481,7 @@ void sqlVdbeMemMove(Mem *, Mem *);
 int sqlVdbeMemNulTerminate(Mem *);
 int sqlVdbeMemSetStr(Mem *, const char *, int, u8, void (*)(void *));
 void sqlVdbeMemSetInt64(Mem *, i64);
-#ifdef SQL_OMIT_FLOATING_POINT
-#define sqlVdbeMemSetDouble sqlVdbeMemSetInt64
-#else
 void sqlVdbeMemSetDouble(Mem *, double);
-#endif
 void sqlVdbeMemInit(Mem *, sql *, u32);
 void sqlVdbeMemSetNull(Mem *);
 void sqlVdbeMemSetZeroBlob(Mem *, int);
diff --git a/src/box/sql/vdbeapi.c b/src/box/sql/vdbeapi.c
index be5c9df..e6219e2 100644
--- a/src/box/sql/vdbeapi.c
+++ b/src/box/sql/vdbeapi.c
@@ -1074,11 +1074,6 @@ columnName(sql_stmt * pStmt,
 	Vdbe *p;
 	int n;
 	sql *db;
-#ifdef SQL_ENABLE_API_ARMOR
-	if (pStmt == 0) {
-		return 0;
-	}
-#endif
 	ret = 0;
 	p = (Vdbe *) pStmt;
 	db = p->db;
@@ -1576,11 +1571,6 @@ sql_stmt *
 sql_next_stmt(sql * pDb, sql_stmt * pStmt)
 {
 	sql_stmt *pNext;
-#ifdef SQL_ENABLE_API_ARMOR
-	if (!sqlSafetyCheckOk(pDb)) {
-		return 0;
-	}
-#endif
 	if (pStmt == 0) {
 		pNext = (sql_stmt *) pDb->pVdbe;
 	} else {
@@ -1597,11 +1587,6 @@ sql_stmt_status(sql_stmt * pStmt, int op, int resetFlag)
 {
 	Vdbe *pVdbe = (Vdbe *) pStmt;
 	u32 v;
-#ifdef SQL_ENABLE_API_ARMOR
-	if (!pStmt) {
-		return 0;
-	}
-#endif
 	v = pVdbe->aCounter[op];
 	if (resetFlag)
 		pVdbe->aCounter[op] = 0;
diff --git a/src/box/sql/vdbeaux.c b/src/box/sql/vdbeaux.c
index 0cc3c14..136c14e 100644
--- a/src/box/sql/vdbeaux.c
+++ b/src/box/sql/vdbeaux.c
@@ -136,7 +136,7 @@ sqlVdbeSetSql(Vdbe * p, const char *z, int n, int isPrepareV2)
 	assert(isPrepareV2 == 1 || isPrepareV2 == 0);
 	if (p == 0)
 		return;
-#if defined(SQL_OMIT_TRACE) && !defined(SQL_ENABLE_SQLLOG)
+#if defined(SQL_OMIT_TRACE)
 	if (!isPrepareV2)
 		return;
 #endif
@@ -2552,30 +2552,6 @@ sqlVdbeTransferError(Vdbe * p)
 	return rc;
 }
 
-#ifdef SQL_ENABLE_SQLLOG
-/*
- * If an SQL_CONFIG_SQLLOG hook is registered and the VM has been run,
- * invoke it.
- */
-static void
-vdbeInvokeSqllog(Vdbe * v)
-{
-	if (sqlGlobalConfig.xSqllog && v->rc == SQL_OK && v->zSql
-	    && v->pc >= 0) {
-		char *zExpanded = sqlVdbeExpandSql(v, v->zSql);
-		assert(v->db->init.busy == 0);
-		if (zExpanded) {
-			sqlGlobalConfig.xSqllog(sqlGlobalConfig.
-						    pSqllogArg, v->db,
-						    zExpanded, 1);
-			sqlDbFree(v->db, zExpanded);
-		}
-	}
-}
-#else
-#define vdbeInvokeSqllog(x)
-#endif
-
 /*
  * Clean up a VDBE after execution but do not delete the VDBE just yet.
  * Write any error messages into *pzErrMsg.  Return the result code.
@@ -2605,7 +2581,6 @@ sqlVdbeReset(Vdbe * p)
 	 * instructions yet, leave the main database error information unchanged.
 	 */
 	if (p->pc >= 0) {
-		vdbeInvokeSqllog(p);
 		sqlVdbeTransferError(p);
 		sqlDbFree(db, p->zErrMsg);
 		p->zErrMsg = 0;
@@ -3084,7 +3059,7 @@ serialGet(const unsigned char *buf,	/* Buffer to deserialize from */
 		/* EVIDENCE-OF: R-57343-49114 Value is a big-endian IEEE 754-2008 64-bit
 		 * floating point number.
 		 */
-#if !defined(NDEBUG) && !defined(SQL_OMIT_FLOATING_POINT)
+#if !defined(NDEBUG)
 		/* Verify that integers and floating point values use the same
 		 * byte order.  Or, that if SQL_MIXED_ENDIAN_64BIT_FLOAT is
 		 * defined that 64-bit floating point values really are mixed
diff --git a/src/box/sql/vdbemem.c b/src/box/sql/vdbemem.c
index 15a2f55..85fc08c 100644
--- a/src/box/sql/vdbemem.c
+++ b/src/box/sql/vdbemem.c
@@ -418,11 +418,6 @@ sqlVdbeMemRelease(Mem * p)
 static int
 doubleToInt64(double r, int64_t *i)
 {
-#ifdef SQL_OMIT_FLOATING_POINT
-	/* When floating-point is omitted, double and int64 are the same thing */
-	*i = r;
-	return 0;
-#else
 	/*
 	 * Many compilers we encounter do not define constants for the
 	 * minimum and maximum 64-bit integers, or they define them
@@ -443,7 +438,6 @@ doubleToInt64(double r, int64_t *i)
 		*i = (int64_t) r;
 		return *i != r;
 	}
-#endif
 }
 
 /*
@@ -726,7 +720,6 @@ sqlVdbeMemSetInt64(Mem * pMem, i64 val)
 	}
 }
 
-#ifndef SQL_OMIT_FLOATING_POINT
 /*
  * Delete any previous value and set the value stored in *pMem to val,
  * manifest type REAL.
@@ -740,7 +733,6 @@ sqlVdbeMemSetDouble(Mem * pMem, double val)
 		pMem->flags = MEM_Real;
 	}
 }
-#endif
 
 /*
  * Return true if the Mem object contains a TEXT or BLOB that is
-- 
2.7.4

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [tarantool-patches] [PATCH v1 3/3] sql: remove unused functions from main.c
  2019-04-09 17:17 [tarantool-patches] [PATCH v1 0/3] sql: remove unused code from SQL imeevma
  2019-04-09 17:17 ` [tarantool-patches] [PATCH v1 1/3] sql: remove legacy.c imeevma
  2019-04-09 17:17 ` [tarantool-patches] [PATCH v1 2/3] sql: remove unused macros in SQL imeevma
@ 2019-04-09 17:17 ` imeevma
  2019-04-10  7:31   ` [tarantool-patches] " Konstantin Osipov
  2019-04-11  0:14   ` n.pettik
  2 siblings, 2 replies; 16+ messages in thread
From: imeevma @ 2019-04-09 17:17 UTC (permalink / raw)
  To: korablev; +Cc: tarantool-patches

These functions unused and should be removed.

Needed for #4074
---
 src/box/sql/build.c  |   2 -
 src/box/sql/global.c |   3 +-
 src/box/sql/main.c   | 956 +--------------------------------------------------
 src/box/sql/random.c |   3 -
 src/box/sql/select.c |   2 -
 src/box/sql/sqlInt.h |  40 +--
 src/box/sql/vdbe.c   |  12 -
 7 files changed, 3 insertions(+), 1015 deletions(-)

diff --git a/src/box/sql/build.c b/src/box/sql/build.c
index a06ba3e..3442442 100644
--- a/src/box/sql/build.c
+++ b/src/box/sql/build.c
@@ -327,8 +327,6 @@ sqlStartTable(Parse *pParse, Token *pName, int noErr)
 		if (!noErr) {
 			diag_set(ClientError, ER_SPACE_EXISTS, zName);
 			pParse->is_aborted = true;
-		} else {
-			assert(!db->init.busy || CORRUPT_DB);
 		}
 		goto cleanup;
 	}
diff --git a/src/box/sql/global.c b/src/box/sql/global.c
index f48cb8c..9af671a 100644
--- a/src/box/sql/global.c
+++ b/src/box/sql/global.c
@@ -228,8 +228,7 @@ FuncDefHash sqlBuiltinFunctions;
  * During testing, it is often desirable to move the pending byte to
  * a different position in the file.  This allows code that has to
  * deal with the pending byte to run on files that are much smaller
- * than 1 GiB.  The sql_test_control() interface can be used to
- * move the pending byte.
+ * than 1 GiB.
  *
  * IMPORTANT:  Changing the pending byte to any value other than
  * 0x40000000 results in an incompatible database file format!
diff --git a/src/box/sql/main.c b/src/box/sql/main.c
index 9cc6536..fe1135a 100644
--- a/src/box/sql/main.c
+++ b/src/box/sql/main.c
@@ -75,8 +75,7 @@ char *sql_data_directory = 0;
  * and VFS subsystems prior to doing any serious work with
  * sql.
  *
- * This routine is a no-op except on its very first call for the process,
- * or for the first call after a call to sql_shutdown.
+ * This routine is a no-op except on its very first call for the process.
  *
  * The first thread to call this routine runs the initialization to
  * completion.  If subsequent threads call this routine before the first
@@ -175,177 +174,6 @@ sql_initialize(void)
 }
 
 /*
- * Undo the effects of sql_initialize().  Must not be called while
- * there are outstanding database connections or memory allocations or
- * while any part of sql is otherwise in use in any thread.  This
- * routine is not threadsafe.  But it is safe to invoke this routine
- * on when sql is already shut down.  If sql is already shut down
- * when this routine is invoked, then this routine is a harmless no-op.
- */
-int
-sql_shutdown(void)
-{
-	if (sqlGlobalConfig.isInit) {
-#ifdef SQL_EXTRA_SHUTDOWN
-		void SQL_EXTRA_SHUTDOWN(void);
-		SQL_EXTRA_SHUTDOWN();
-#endif
-		sql_os_end();
-		sqlGlobalConfig.isInit = 0;
-	}
-	if (sqlGlobalConfig.isMallocInit) {
-		sqlMallocEnd();
-		sqlGlobalConfig.isMallocInit = 0;
-
-#ifndef SQL_OMIT_SHUTDOWN_DIRECTORIES
-		/* The heap subsystem has now been shutdown and these values are supposed
-		 * to be NULL or point to memory that was obtained from sql_malloc(),
-		 * which would rely on that heap subsystem; therefore, make sure these
-		 * values cannot refer to heap memory that was just invalidated when the
-		 * heap subsystem was shutdown.  This is only done if the current call to
-		 * this function resulted in the heap subsystem actually being shutdown.
-		 */
-		sql_data_directory = 0;
-		sql_temp_directory = 0;
-#endif
-	}
-
-	return SQL_OK;
-}
-
-/*
- * This API allows applications to modify the global configuration of
- * the sql library at run-time.
- *
- * This routine should only be called when there are no outstanding
- * database connections or memory allocations.  This routine is not
- * threadsafe.  Failure to heed these warnings can lead to unpredictable
- * behavior.
- */
-int
-sql_config(int op, ...)
-{
-	va_list ap;
-	int rc = SQL_OK;
-
-	/* sql_config() shall return SQL_MISUSE if it is invoked while
-	 * the sql library is in use.
-	 */
-	if (sqlGlobalConfig.isInit)
-		return SQL_MISUSE;
-
-	va_start(ap, op);
-	switch (op) {
-	case SQL_CONFIG_MEMSTATUS:{
-			/* EVIDENCE-OF: R-61275-35157 The SQL_CONFIG_MEMSTATUS option takes
-			 * single argument of type int, interpreted as a boolean, which enables
-			 * or disables the collection of memory allocation statistics.
-			 */
-			sqlGlobalConfig.bMemstat = va_arg(ap, int);
-			break;
-		}
-	case SQL_CONFIG_SCRATCH:{
-			/* EVIDENCE-OF: R-08404-60887 There are three arguments to
-			 * SQL_CONFIG_SCRATCH: A pointer an 8-byte aligned memory buffer from
-			 * which the scratch allocations will be drawn, the size of each scratch
-			 * allocation (sz), and the maximum number of scratch allocations (N).
-			 */
-			sqlGlobalConfig.pScratch = va_arg(ap, void *);
-			sqlGlobalConfig.szScratch = va_arg(ap, int);
-			sqlGlobalConfig.nScratch = va_arg(ap, int);
-			break;
-		}
-
-	case SQL_CONFIG_LOOKASIDE:{
-			sqlGlobalConfig.szLookaside = va_arg(ap, int);
-			sqlGlobalConfig.nLookaside = va_arg(ap, int);
-			break;
-		}
-
-		/* Record a pointer to the logger function and its first argument.
-		 * The default is NULL.  Logging is disabled if the function pointer is
-		 * NULL.
-		 */
-	case SQL_CONFIG_LOG:{
-			typedef void (*LOGFUNC_t) (void *, int, const char *);
-			sqlGlobalConfig.xLog = va_arg(ap, LOGFUNC_t);
-			sqlGlobalConfig.pLogArg = va_arg(ap, void *);
-			break;
-		}
-
-		/* EVIDENCE-OF: R-55548-33817 The compile-time setting for URI filenames
-		 * can be changed at start-time using the
-		 * sql_config(SQL_CONFIG_URI,1) or
-		 * sql_config(SQL_CONFIG_URI,0) configuration calls.
-		 */
-	case SQL_CONFIG_URI:{
-			/* EVIDENCE-OF: R-25451-61125 The SQL_CONFIG_URI option takes a single
-			 * argument of type int. If non-zero, then URI handling is globally
-			 * enabled. If the parameter is zero, then URI handling is globally
-			 * disabled.
-			 */
-			sqlGlobalConfig.bOpenUri = va_arg(ap, int);
-			break;
-		}
-
-	case SQL_CONFIG_COVERING_INDEX_SCAN:{
-			/* EVIDENCE-OF: R-36592-02772 The SQL_CONFIG_COVERING_INDEX_SCAN
-			 * option takes a single integer argument which is interpreted as a
-			 * boolean in order to enable or disable the use of covering indices for
-			 * full table scans in the query optimizer.
-			 */
-			sqlGlobalConfig.bUseCis = va_arg(ap, int);
-			break;
-		}
-
-	case SQL_CONFIG_MMAP_SIZE:{
-			/* EVIDENCE-OF: R-58063-38258 SQL_CONFIG_MMAP_SIZE takes two 64-bit
-			 * integer (sql_int64) values that are the default mmap size limit
-			 * (the default setting for PRAGMA mmap_size) and the maximum allowed
-			 * mmap size limit.
-			 */
-			sql_int64 szMmap = va_arg(ap, sql_int64);
-			sql_int64 mxMmap = va_arg(ap, sql_int64);
-			/* EVIDENCE-OF: R-53367-43190 If either argument to this option is
-			 * negative, then that argument is changed to its compile-time default.
-			 *
-			 * EVIDENCE-OF: R-34993-45031 The maximum allowed mmap size will be
-			 * silently truncated if necessary so that it does not exceed the
-			 * compile-time maximum mmap size set by the SQL_MAX_MMAP_SIZE
-			 * compile-time option.
-			 */
-			if (mxMmap < 0 || mxMmap > SQL_MAX_MMAP_SIZE) {
-				mxMmap = SQL_MAX_MMAP_SIZE;
-			}
-			if (szMmap < 0)
-				szMmap = SQL_DEFAULT_MMAP_SIZE;
-			if (szMmap > mxMmap)
-				szMmap = mxMmap;
-			sqlGlobalConfig.mxMmap = mxMmap;
-			sqlGlobalConfig.szMmap = szMmap;
-			break;
-		}
-
-	case SQL_CONFIG_PMASZ:{
-			sqlGlobalConfig.szPma = va_arg(ap, unsigned int);
-			break;
-		}
-
-	case SQL_CONFIG_STMTJRNL_SPILL:{
-			sqlGlobalConfig.nStmtSpill = va_arg(ap, int);
-			break;
-		}
-
-	default:{
-			rc = SQL_ERROR;
-			break;
-		}
-	}
-	va_end(ap);
-	return rc;
-}
-
-/*
  * Set up the lookaside buffers for a database connection.
  * Return SQL_OK on success.
  * If lookaside is already active, return SQL_BUSY.
@@ -567,37 +395,6 @@ sqlErrStr(int rc)
 	return zErr;
 }
 
-#ifndef SQL_OMIT_PROGRESS_CALLBACK
-/*
- * This routine sets the progress callback for an Sqlite database to the
- * given callback function with the given argument. The progress callback will
- * be invoked every nOps opcodes.
- */
-void
-sql_progress_handler(sql * db,
-			 int nOps, int (*xProgress) (void *), void *pArg)
-{
-	if (nOps > 0) {
-		db->xProgress = xProgress;
-		db->nProgressOps = (unsigned)nOps;
-		db->pProgressArg = pArg;
-	} else {
-		db->xProgress = 0;
-		db->nProgressOps = 0;
-		db->pProgressArg = 0;
-	}
-}
-#endif
-
-/*
- * Cause any pending operation to stop at its earliest opportunity.
- */
-void
-sql_interrupt(sql * db)
-{
-	db->u1.isInterrupted = 1;
-}
-
 /*
  * This function is exactly the same as sql_create_function(), except
  * that it is designed to be called by internal code. The difference is
@@ -738,78 +535,6 @@ sql_trace_v2(sql * db,		/* Trace this connection */
 #endif				/* SQL_OMIT_TRACE */
 
 /*
- * Register a function to be invoked when a transaction commits.
- * If the invoked function returns non-zero, then the commit becomes a
- * rollback.
- */
-void *
-sql_commit_hook(sql * db,	/* Attach the hook to this database */
-		    int (*xCallback) (void *),	/* Function to invoke on each commit */
-		    void *pArg)		/* Argument to the function */
-{
-	void *pOld;
-
-	pOld = db->pCommitArg;
-	db->xCommitCallback = xCallback;
-	db->pCommitArg = pArg;
-	return pOld;
-}
-
-/*
- * Register a callback to be invoked each time a row is updated,
- * inserted or deleted using this database connection.
- */
-void *
-sql_update_hook(sql * db,	/* Attach the hook to this database */
-		    void (*xCallback) (void *, int, char const *,
-				       char const *, sql_int64),
-		    void *pArg)		/* Argument to the function */
-{
-	void *pRet;
-
-	pRet = db->pUpdateArg;
-	db->xUpdateCallback = xCallback;
-	db->pUpdateArg = pArg;
-	return pRet;
-}
-
-/*
- * Register a callback to be invoked each time a transaction is rolled
- * back by this database connection.
- */
-void *
-sql_rollback_hook(sql * db,	/* Attach the hook to this database */
-		      void (*xCallback) (void *),	/* Callback function */
-		      void *pArg)	/* Argument to the function */
-{
-	void *pRet;
-
-	pRet = db->pRollbackArg;
-	db->xRollbackCallback = xCallback;
-	db->pRollbackArg = pArg;
-	return pRet;
-}
-
-/*
- * Configure an sql_wal_hook() callback to automatically checkpoint
- * a database after committing a transaction if there are nFrame or
- * more frames in the log file. Passing zero or a negative value as the
- * nFrame parameter disables automatic checkpoints entirely.
- *
- * The callback registered by this function replaces any existing callback
- * registered using sql_wal_hook(). Likewise, registering a callback
- * using sql_wal_hook() disables the automatic checkpoint mechanism
- * configured by this function.
- */
-int
-sql_wal_autocheckpoint(sql * db, int nFrame)
-{
-	UNUSED_PARAMETER(db);
-	UNUSED_PARAMETER(nFrame);
-	return SQL_OK;
-}
-
-/*
  * This function returns true if main-memory should be used instead of
  * a temporary file for transient pager files and statement journals.
  * The value returned depends on the value of db->temp_store (runtime
@@ -848,37 +573,6 @@ sqlTempInMemory(const sql * db)
 }
 
 /*
- * Return UTF-8 encoded English language explanation of the most recent
- * error.
- */
-const char *
-sql_errmsg(sql * db)
-{
-	const char *z;
-	if (!db) {
-		return sqlErrStr(SQL_NOMEM);
-	}
-	if (!sqlSafetyCheckSickOrOk(db)) {
-		return sqlErrStr(SQL_MISUSE);
-	}
-	if (db->mallocFailed) {
-		z = sqlErrStr(SQL_NOMEM);
-	} else {
-		testcase(db->pErr == 0);
-		assert(!db->mallocFailed);
-		if (db->errCode != SQL_TARANTOOL_ERROR) {
-			z = (char *)sql_value_text(db->pErr);
-			if (z == NULL)
-				z = sqlErrStr(db->errCode);
-		} else {
-			z = diag_last_error(diag_get())->errmsg;
-		}
-		assert(z != NULL);
-	}
-	return z;
-}
-
-/*
  * Return the most recent error code generated by an sql routine. If NULL is
  * passed to this function, we assume a malloc() failed during sql_open().
  */
@@ -894,35 +588,6 @@ sql_errcode(sql * db)
 	return db->errCode & db->errMask;
 }
 
-int
-sql_extended_errcode(sql * db)
-{
-	if (db && !sqlSafetyCheckSickOrOk(db)) {
-		return SQL_MISUSE;
-	}
-	if (!db || db->mallocFailed) {
-		return SQL_NOMEM;
-	}
-	return db->errCode;
-}
-
-int
-sql_system_errno(sql * db)
-{
-	return db ? db->iSysErrno : 0;
-}
-
-/*
- * Return a string that describes the kind of error specified in the
- * argument.  For now, this simply calls the internal sqlErrStr()
- * function.
- */
-const char *
-sql_errstr(int rc)
-{
-	return sqlErrStr(rc);
-}
-
 /*
  * This array defines hard upper bounds on limit values.  The
  * initializer must be kept in sync with the SQL_LIMIT_*
@@ -1030,297 +695,6 @@ sql_limit(sql * db, int limitId, int newLimit)
 	return oldLimit;	/* IMP: R-53341-35419 */
 }
 
-/*
- * This function is used to parse both URIs and non-URI filenames passed by the
- * user to API functions sql_open() or sql_open_v2(), and for database
- * URIs specified as part of ATTACH statements.
- *
- * The first argument to this function is the name of the VFS to use (or
- * a NULL to signify the default VFS) if the URI does not contain a "vfs=xxx"
- * query parameter. The second argument contains the URI (or non-URI filename)
- * itself. When this function is called the *pFlags variable should contain
- * the default flags to open the database handle with. The value stored in
- * *pFlags may be updated before returning if the URI filename contains
- * "cache=xxx" or "mode=xxx" query parameters.
- *
- * If successful, SQL_OK is returned. In this case *ppVfs is set to point to
- * the VFS that should be used to open the database file. *pzFile is set to
- * point to a buffer containing the name of the file to open. It is the
- * responsibility of the caller to eventually call sql_free() to release
- * this buffer.
- *
- * If an error occurs, then an sql error code is returned and *pzErrMsg
- * may be set to point to a buffer containing an English language error
- * message. It is the responsibility of the caller to eventually release
- * this buffer by calling sql_free().
- */
-int
-sqlParseUri(const char *zDefaultVfs,	/* VFS to use if no "vfs=xxx" query option */
-		const char *zUri,		/* Nul-terminated URI to parse */
-		unsigned int *pFlags,		/* IN/OUT: SQL_OPEN_XXX flags */
-		sql_vfs ** ppVfs,		/* OUT: VFS to use */
-		char **pzFile,			/* OUT: Filename component of URI */
-		char **pzErrMsg)		/* OUT: Error message (if rc!=SQL_OK) */
-{
-	int rc = SQL_OK;
-	unsigned int flags = *pFlags;
-	const char *zVfs = zDefaultVfs;
-	char *zFile;
-	char c;
-	int nUri = sqlStrlen30(zUri);
-
-	assert(*pzErrMsg == 0);
-
-	if (((flags & SQL_OPEN_URI)	/* IMP: R-48725-32206 */
-	     ||sqlGlobalConfig.bOpenUri)	/* IMP: R-51689-46548 */
-	    &&nUri >= 5 && memcmp(zUri, "file:", 5) == 0	/* IMP: R-57884-37496 */
-	    ) {
-		char *zOpt;
-		int eState;	/* Parser state when parsing URI */
-		int iIn;	/* Input character index */
-		int iOut = 0;	/* Output character index */
-		u64 nByte = nUri + 2;	/* Bytes of space to allocate */
-
-		/* Make sure the SQL_OPEN_URI flag is set to indicate to the VFS xOpen
-		 * method that there may be extra parameters following the file-name.
-		 */
-		flags |= SQL_OPEN_URI;
-
-		for (iIn = 0; iIn < nUri; iIn++)
-			nByte += (zUri[iIn] == '&');
-		zFile = sql_malloc64(nByte);
-		if (!zFile)
-			return SQL_NOMEM;
-
-		iIn = 5;
-#ifdef SQL_ALLOW_URI_AUTHORITY
-		if (strncmp(zUri + 5, "///", 3) == 0) {
-			iIn = 7;
-			/* The following condition causes URIs with five leading / characters
-			 * like file://///host/path to be converted into UNCs like //host/path.
-			 * The correct URI for that UNC has only two or four leading / characters
-			 * file://host/path or file:////host/path.  But 5 leading slashes is a
-			 * common error, we are told, so we handle it as a special case.
-			 */
-			if (strncmp(zUri + 7, "///", 3) == 0) {
-				iIn++;
-			}
-		} else if (strncmp(zUri + 5, "//localhost/", 12) == 0) {
-			iIn = 16;
-		}
-#else
-		/* Discard the scheme and authority segments of the URI. */
-		if (zUri[5] == '/' && zUri[6] == '/') {
-			iIn = 7;
-			while (zUri[iIn] && zUri[iIn] != '/')
-				iIn++;
-			if (iIn != 7
-			    && (iIn != 16
-				|| memcmp("localhost", &zUri[7], 9))) {
-				*pzErrMsg =
-				    sql_mprintf
-				    ("invalid uri authority: %.*s", iIn - 7,
-				     &zUri[7]);
-				rc = SQL_ERROR;
-				goto parse_uri_out;
-			}
-		}
-#endif
-
-		/* Copy the filename and any query parameters into the zFile buffer.
-		 * Decode %HH escape codes along the way.
-		 *
-		 * Within this loop, variable eState may be set to 0, 1 or 2, depending
-		 * on the parsing context. As follows:
-		 *
-		 *   0: Parsing file-name.
-		 *   1: Parsing name section of a name=value query parameter.
-		 *   2: Parsing value section of a name=value query parameter.
-		 */
-		eState = 0;
-		while ((c = zUri[iIn]) != 0 && c != '#') {
-			iIn++;
-			if (c == '%' && sqlIsxdigit(zUri[iIn])
-			    && sqlIsxdigit(zUri[iIn + 1])
-			    ) {
-				int octet = (sqlHexToInt(zUri[iIn++]) << 4);
-				octet += sqlHexToInt(zUri[iIn++]);
-
-				assert(octet >= 0 && octet < 256);
-				if (octet == 0) {
-#ifndef SQL_ENABLE_URI_00_ERROR
-					/* This branch is taken when "%00" appears within the URI. In this
-					 * case we ignore all text in the remainder of the path, name or
-					 * value currently being parsed. So ignore the current character
-					 * and skip to the next "?", "=" or "&", as appropriate.
-					 */
-					while ((c = zUri[iIn]) != 0 && c != '#'
-					       && (eState != 0 || c != '?')
-					       && (eState != 1
-						   || (c != '=' && c != '&'))
-					       && (eState != 2 || c != '&')
-					    ) {
-						iIn++;
-					}
-					continue;
-#else
-					/* If ENABLE_URI_00_ERROR is defined, "%00" in a URI is an error. */
-					*pzErrMsg =
-					    sql_mprintf
-					    ("unexpected %%00 in uri");
-					rc = SQL_ERROR;
-					goto parse_uri_out;
-#endif
-				}
-				c = octet;
-			} else if (eState == 1 && (c == '&' || c == '=')) {
-				if (zFile[iOut - 1] == 0) {
-					/* An empty option name. Ignore this option altogether. */
-					while (zUri[iIn] && zUri[iIn] != '#'
-					       && zUri[iIn - 1] != '&')
-						iIn++;
-					continue;
-				}
-				if (c == '&') {
-					zFile[iOut++] = '\0';
-				} else {
-					eState = 2;
-				}
-				c = 0;
-			} else if ((eState == 0 && c == '?')
-				   || (eState == 2 && c == '&')) {
-				c = 0;
-				eState = 1;
-			}
-			zFile[iOut++] = c;
-		}
-		if (eState == 1)
-			zFile[iOut++] = '\0';
-		zFile[iOut++] = '\0';
-		zFile[iOut++] = '\0';
-
-		/* Check if there were any options specified that should be interpreted
-		 * here. Options that are interpreted here include "vfs" and those that
-		 * correspond to flags that may be passed to the sql_open_v2()
-		 * method.
-		 */
-		zOpt = &zFile[sqlStrlen30(zFile) + 1];
-		while (zOpt[0]) {
-			int nOpt = sqlStrlen30(zOpt);
-			char *zVal = &zOpt[nOpt + 1];
-			unsigned int nVal = sqlStrlen30(zVal);
-
-			if (nOpt == 3 && memcmp("vfs", zOpt, 3) == 0) {
-				zVfs = zVal;
-			} else {
-				struct OpenMode {
-					const char *z;
-					int mode;
-				} *aMode = 0;
-				char *zModeType = 0;
-				int mask = 0;
-				int limit = 0;
-
-				if (nOpt == 5 && memcmp("cache", zOpt, 5) == 0) {
-					static struct OpenMode aCacheMode[] = {
-						{"shared",
-						 SQL_OPEN_SHAREDCACHE},
-						{"private",
-						 SQL_OPEN_PRIVATECACHE},
-						{0, 0}
-					};
-
-					mask =
-					    SQL_OPEN_SHAREDCACHE |
-					    SQL_OPEN_PRIVATECACHE;
-					aMode = aCacheMode;
-					limit = mask;
-					zModeType = "cache";
-				}
-				if (nOpt == 4 && memcmp("mode", zOpt, 4) == 0) {
-					static struct OpenMode aOpenMode[] = {
-						{"ro", SQL_OPEN_READONLY},
-						{"rw", SQL_OPEN_READWRITE},
-						{"rwc",
-						 SQL_OPEN_READWRITE |
-						 SQL_OPEN_CREATE},
-						{"memory", SQL_OPEN_MEMORY},
-						{0, 0}
-					};
-
-					mask =
-					    SQL_OPEN_READONLY |
-					    SQL_OPEN_READWRITE |
-					    SQL_OPEN_CREATE |
-					    SQL_OPEN_MEMORY;
-					aMode = aOpenMode;
-					limit = mask & flags;
-					zModeType = "access";
-				}
-
-				if (aMode) {
-					int i;
-					int mode = 0;
-					for (i = 0; aMode[i].z; i++) {
-						const char *z = aMode[i].z;
-						if (nVal == sqlStrlen30(z)
-						    && 0 == memcmp(zVal, z,
-								   nVal)) {
-							mode = aMode[i].mode;
-							break;
-						}
-					}
-					if (mode == 0) {
-						*pzErrMsg =
-						    sql_mprintf
-						    ("no such %s mode: %s",
-						     zModeType, zVal);
-						rc = SQL_ERROR;
-						goto parse_uri_out;
-					}
-					if ((mode & ~SQL_OPEN_MEMORY) >
-					    limit) {
-						*pzErrMsg =
-						    sql_mprintf
-						    ("%s mode not allowed: %s",
-						     zModeType, zVal);
-						rc = SQL_PERM;
-						goto parse_uri_out;
-					}
-					flags = (flags & ~mask) | mode;
-				}
-			}
-
-			zOpt = &zVal[nVal + 1];
-		}
-
-	} else {
-		zFile = sql_malloc64(nUri + 2);
-		if (!zFile)
-			return SQL_NOMEM;
-		if (nUri) {
-			memcpy(zFile, zUri, nUri);
-		}
-		zFile[nUri] = '\0';
-		zFile[nUri + 1] = '\0';
-		flags &= ~SQL_OPEN_URI;
-	}
-
-	*ppVfs = sql_vfs_find(zVfs);
-	if (*ppVfs == 0) {
-		*pzErrMsg = sql_mprintf("no such vfs: %s", zVfs);
-		rc = SQL_ERROR;
-	}
- parse_uri_out:
-	if (rc != SQL_OK) {
-		sql_free(zFile);
-		zFile = 0;
-	}
-	*pFlags = flags;
-	*pzFile = zFile;
-	return rc;
-}
-
 /**
  * This routine does the work of initialization of main
  * SQL connection instance.
@@ -1389,308 +763,6 @@ opendb_out:
 }
 
 /*
- * Enable or disable the extended result codes.
- */
-int
-sql_extended_result_codes(sql * db, int onoff)
-{
-	db->errMask = onoff ? 0xffffffff : 0xff;
-	return SQL_OK;
-}
-
-/*
- * Interface to the testing logic.
- */
-int
-sql_test_control(int op, ...)
-{
-	int rc = 0;
-#ifdef SQL_UNTESTABLE
-	UNUSED_PARAMETER(op);
-#else
-	va_list ap;
-	va_start(ap, op);
-	switch (op) {
-
-		/*
-		 * Save the current state of the PRNG.
-		 */
-	case SQL_TESTCTRL_PRNG_SAVE:{
-			sqlPrngSaveState();
-			break;
-		}
-
-		/*
-		 * Restore the state of the PRNG to the last state saved using
-		 * PRNG_SAVE.  If PRNG_SAVE has never before been called, then
-		 * this verb acts like PRNG_RESET.
-		 */
-	case SQL_TESTCTRL_PRNG_RESTORE:{
-			sqlPrngRestoreState();
-			break;
-		}
-
-		/*
-		 * Reset the PRNG back to its uninitialized state.  The next call
-		 * to sql_randomness() will reseed the PRNG using a single call
-		 * to the xRandomness method of the default VFS.
-		 */
-	case SQL_TESTCTRL_PRNG_RESET:{
-			sql_randomness(0, 0);
-			break;
-		}
-
-		/*
-		 *  sql_test_control(FAULT_INSTALL, xCallback)
-		 *
-		 * Arrange to invoke xCallback() whenever sqlFaultSim() is called,
-		 * if xCallback is not NULL.
-		 *
-		 * As a test of the fault simulator mechanism itself, sqlFaultSim(0)
-		 * is called immediately after installing the new callback and the return
-		 * value from sqlFaultSim(0) becomes the return from
-		 * sql_test_control().
-		 */
-	case SQL_TESTCTRL_FAULT_INSTALL:{
-			typedef int (*TESTCALLBACKFUNC_t) (int);
-			sqlGlobalConfig.xTestCallback =
-			    va_arg(ap, TESTCALLBACKFUNC_t);
-			rc = sqlFaultSim(0);
-			break;
-		}
-
-		/*
-		 *  sql_test_control(BENIGN_MALLOC_HOOKS, xBegin, xEnd)
-		 *
-		 * Register hooks to call to indicate which malloc() failures
-		 * are benign.
-		 */
-	case SQL_TESTCTRL_BENIGN_MALLOC_HOOKS:{
-			typedef void (*void_function) (void);
-			void_function xBenignBegin;
-			void_function xBenignEnd;
-			xBenignBegin = va_arg(ap, void_function);
-			xBenignEnd = va_arg(ap, void_function);
-			sqlBenignMallocHooks(xBenignBegin, xBenignEnd);
-			break;
-		}
-
-		/*
-		 *  sql_test_control(SQL_TESTCTRL_PENDING_BYTE, unsigned int X)
-		 *
-		 * Set the PENDING byte to the value in the argument, if X>0.
-		 * Make no changes if X==0.  Return the value of the pending byte
-		 * as it existing before this routine was called.
-		 *
-		 * IMPORTANT:  Changing the PENDING byte from 0x40000000 results in
-		 * an incompatible database file format.  Changing the PENDING byte
-		 * while any database connection is open results in undefined and
-		 * deleterious behavior.
-		 */
-	case SQL_TESTCTRL_PENDING_BYTE:{
-			rc = PENDING_BYTE;
-			{
-				unsigned int newVal = va_arg(ap, unsigned int);
-				if (newVal)
-					sqlPendingByte = newVal;
-			}
-			break;
-		}
-
-		/*
-		 *  sql_test_control(SQL_TESTCTRL_ASSERT, int X)
-		 *
-		 * This action provides a run-time test to see whether or not
-		 * assert() was enabled at compile-time.  If X is true and assert()
-		 * is enabled, then the return value is true.  If X is true and
-		 * assert() is disabled, then the return value is zero.  If X is
-		 * false and assert() is enabled, then the assertion fires and the
-		 * process aborts.  If X is false and assert() is disabled, then the
-		 * return value is zero.
-		 */
-	case SQL_TESTCTRL_ASSERT:{
-			volatile int x = 0;
-			assert( /*side-effects-ok */ (x = va_arg(ap, int)) !=
-			       0);
-			rc = x;
-			break;
-		}
-
-		/*
-		 *  sql_test_control(SQL_TESTCTRL_ALWAYS, int X)
-		 *
-		 * This action provides a run-time test to see how the ALWAYS and
-		 * NEVER macros were defined at compile-time.
-		 *
-		 * The return value is ALWAYS(X).
-		 *
-		 * The recommended test is X==2.  If the return value is 2, that means
-		 * ALWAYS() and NEVER() are both no-op pass-through macros, which is the
-		 * default setting.  If the return value is 1, then ALWAYS() is either
-		 * hard-coded to true or else it asserts if its argument is false.
-		 * The first behavior (hard-coded to true) is the case if
-		 * SQL_TESTCTRL_ASSERT shows that assert() is disabled and the second
-		 * behavior (assert if the argument to ALWAYS() is false) is the case if
-		 * SQL_TESTCTRL_ASSERT shows that assert() is enabled.
-		 *
-		 * The run-time test procedure might look something like this:
-		 *
-		 *    if( sql_test_control(SQL_TESTCTRL_ALWAYS, 2)==2 ){
-		 *      // ALWAYS() and NEVER() are no-op pass-through macros
-		 *    }else if( sql_test_control(SQL_TESTCTRL_ASSERT, 1) ){
-		 *      // ALWAYS(x) asserts that x is true. NEVER(x) asserts x is false.
-		 *    }else{
-		 *      // ALWAYS(x) is a constant 1.  NEVER(x) is a constant 0.
-		 *    }
-		 */
-	case SQL_TESTCTRL_ALWAYS:{
-			int x = va_arg(ap, int);
-			rc = ALWAYS(x);
-			break;
-		}
-
-		/*
-		 *   sql_test_control(SQL_TESTCTRL_BYTEORDER);
-		 *
-		 * The integer returned reveals the byte-order of the computer on which
-		 * sql is running:
-		 *
-		 *       1     big-endian,    determined at run-time
-		 *      10     little-endian, determined at run-time
-		 *  432101     big-endian,    determined at compile-time
-		 *  123410     little-endian, determined at compile-time
-		 */
-	case SQL_TESTCTRL_BYTEORDER:{
-			rc = SQL_BYTEORDER * 100 + SQL_LITTLEENDIAN * 10 +
-			    SQL_BIGENDIAN;
-			break;
-		}
-
-		/*  sql_test_control(SQL_TESTCTRL_OPTIMIZATIONS, sql *db, int N)
-		 *
-		 * Enable or disable various optimizations for testing purposes.  The
-		 * argument N is a bitmask of optimizations to be disabled.  For normal
-		 * operation N should be 0.  The idea is that a test program (like the
-		 * SQL Logic Test or SLT test module) can run the same SQL multiple times
-		 * with various optimizations disabled to verify that the same answer
-		 * is obtained in every case.
-		 */
-	case SQL_TESTCTRL_OPTIMIZATIONS:{
-			sql *db = va_arg(ap, sql *);
-			db->dbOptFlags = (u16) (va_arg(ap, int) & 0xffff);
-			break;
-		}
-
-#ifdef SQL_N_KEYWORD
-		/* sql_test_control(SQL_TESTCTRL_ISKEYWORD, const char *zWord)
-		 *
-		 * If zWord is a keyword recognized by the parser, then return the
-		 * number of keywords.  Or if zWord is not a keyword, return 0.
-		 *
-		 * This test feature is only available in the amalgamation since
-		 * the SQL_N_KEYWORD macro is not defined in this file if sql
-		 * is built using separate source files.
-		 */
-	case SQL_TESTCTRL_ISKEYWORD:{
-			const char *zWord = va_arg(ap, const char *);
-			int n = sqlStrlen30(zWord);
-			rc = (sqlKeywordCode((u8 *) zWord, n) !=
-			      TK_ID) ? SQL_N_KEYWORD : 0;
-			break;
-		}
-#endif
-
-		/* sql_test_control(SQL_TESTCTRL_SCRATCHMALLOC, sz, &pNew, pFree);
-		 *
-		 * Pass pFree into sqlScratchFree().
-		 * If sz>0 then allocate a scratch buffer into pNew.
-		 */
-	case SQL_TESTCTRL_SCRATCHMALLOC:{
-			void *pFree, **ppNew;
-			int sz;
-			sz = va_arg(ap, int);
-			ppNew = va_arg(ap, void **);
-			pFree = va_arg(ap, void *);
-			if (sz)
-				*ppNew = sqlScratchMalloc(sz);
-			sqlScratchFree(pFree);
-			break;
-		}
-
-		/*   sql_test_control(SQL_TESTCTRL_LOCALTIME_FAULT, int onoff);
-		 *
-		 * If parameter onoff is non-zero, configure the wrappers so that all
-		 * subsequent calls to localtime() and variants fail. If onoff is zero,
-		 * undo this setting.
-		 */
-	case SQL_TESTCTRL_LOCALTIME_FAULT:{
-			sqlGlobalConfig.bLocaltimeFault = va_arg(ap, int);
-			break;
-		}
-
-		/*   sql_test_control(SQL_TESTCTRL_NEVER_CORRUPT, int);
-		 *
-		 * Set or clear a flag that indicates that the database file is always well-
-		 * formed and never corrupt.  This flag is clear by default, indicating that
-		 * database files might have arbitrary corruption.  Setting the flag during
-		 * testing causes certain assert() statements in the code to be activated
-		 * that demonstrat invariants on well-formed database files.
-		 */
-	case SQL_TESTCTRL_NEVER_CORRUPT:{
-			sqlGlobalConfig.neverCorrupt = va_arg(ap, int);
-			break;
-		}
-
-		/* Set the threshold at which OP_Once counters reset back to zero.
-		 * By default this is 0x7ffffffe (over 2 billion), but that value is
-		 * too big to test in a reasonable amount of time, so this control is
-		 * provided to set a small and easily reachable reset value.
-		 */
-	case SQL_TESTCTRL_ONCE_RESET_THRESHOLD:{
-			sqlGlobalConfig.iOnceResetThreshold =
-			    va_arg(ap, int);
-			break;
-		}
-
-		/*   sql_test_control(SQL_TESTCTRL_VDBE_COVERAGE, xCallback, ptr);
-		 *
-		 * Set the VDBE coverage callback function to xCallback with context
-		 * pointer ptr.
-		 */
-	case SQL_TESTCTRL_VDBE_COVERAGE:{
-#ifdef SQL_VDBE_COVERAGE
-			typedef void (*branch_callback) (void *, int, u8, u8);
-			sqlGlobalConfig.xVdbeBranch =
-			    va_arg(ap, branch_callback);
-			sqlGlobalConfig.pVdbeBranchArg = va_arg(ap, void *);
-#endif
-			break;
-		}
-
-		/*   sql_test_control(SQL_TESTCTRL_SORTER_MMAP, db, nMax); */
-	case SQL_TESTCTRL_SORTER_MMAP:{
-			sql *db = va_arg(ap, sql *);
-			db->nMaxSorterMmap = va_arg(ap, int);
-			break;
-		}
-
-		/*   sql_test_control(SQL_TESTCTRL_ISINIT);
-		 *
-		 * Return SQL_OK if sql has been initialized and SQL_ERROR if
-		 * not.
-		 */
-	case SQL_TESTCTRL_ISINIT:{
-			if (sqlGlobalConfig.isInit == 0)
-				rc = SQL_ERROR;
-			break;
-		}
-	}
-	va_end(ap);
-#endif				/* SQL_UNTESTABLE */
-	return rc;
-}
-
-/*
  * This is a utility routine, useful to VFS implementations, that checks
  * to see if a database file was a URI that contained a specific query
  * parameter, and if so obtains the value of the query parameter.
@@ -1716,29 +788,3 @@ sql_uri_parameter(const char *zFilename, const char *zParam)
 	}
 	return 0;
 }
-
-/*
- * Return a boolean value for a query parameter.
- */
-int
-sql_uri_boolean(const char *zFilename, const char *zParam, int bDflt)
-{
-	const char *z = sql_uri_parameter(zFilename, zParam);
-	bDflt = bDflt != 0;
-	return z ? sqlGetBoolean(z, bDflt) : bDflt;
-}
-
-/*
- * Return a 64-bit integer value for a query parameter.
- */
-sql_int64
-sql_uri_int64(const char *zFilename,	/* Filename as passed to xOpen */
-		  const char *zParam,	/* URI parameter sought */
-		  sql_int64 bDflt)	/* return if parameter is missing */
-{
-	const char *z = sql_uri_parameter(zFilename, zParam);
-	int64_t v;
-	if (z != NULL && sql_dec_or_hex_to_i64(z, &v) == 0)
-		bDflt = v;
-	return bDflt;
-}
diff --git a/src/box/sql/random.c b/src/box/sql/random.c
index 2de1890..9e1122b 100644
--- a/src/box/sql/random.c
+++ b/src/box/sql/random.c
@@ -114,9 +114,6 @@ sql_randomness(int N, void *pBuf)
  * PRNG and restore the PRNG to its saved state at a later time, or
  * to reset the PRNG to its initial state.  These routines accomplish
  * those tasks.
- *
- * The sql_test_control() interface calls these routines to
- * control the PRNG.
  */
 static SQL_WSD struct sqlPrngType sqlSavedPrng;
 void
diff --git a/src/box/sql/select.c b/src/box/sql/select.c
index b1ec8c7..e0ed5db 100644
--- a/src/box/sql/select.c
+++ b/src/box/sql/select.c
@@ -5659,8 +5659,6 @@ sqlSelect(Parse * pParse,		/* The parser context */
 		 *   (2)  The ALL keyword after SELECT is omitted.  (Applications are
 		 *        allowed to say "SELECT ALL" instead of just "SELECT" to disable
 		 *        the use of co-routines.)
-		 *   (3)  Co-routines are not disabled using sql_test_control()
-		 *        with SQL_TESTCTRL_OPTIMIZATIONS.
 		 *
 		 * TODO: Are there other reasons beside (1) to use a co-routine
 		 * implementation?
diff --git a/src/box/sql/sqlInt.h b/src/box/sql/sqlInt.h
index cfeb49c..7579e75 100644
--- a/src/box/sql/sqlInt.h
+++ b/src/box/sql/sqlInt.h
@@ -675,9 +675,6 @@ sql_column_name(sql_stmt *, int N);
 const char *
 sql_column_datatype(sql_stmt *, int N);
 
-const char *
-sql_errmsg(sql *);
-
 int
 sql_initialize(void);
 
@@ -784,9 +781,6 @@ sql_status64(int op, sql_int64 * pCurrent,
 		 sql_int64 * pHighwater,
 		 int resetFlag);
 
-int
-sql_config(int, ...);
-
 
 typedef struct sql_io_methods sql_io_methods;
 struct sql_io_methods {
@@ -836,10 +830,6 @@ sql_limit(sql *, int id, int newVal);
 #define SQL_SYNC_FULL          0x00003
 #define SQL_SYNC_DATAONLY      0x00010
 
-int
-sql_uri_boolean(const char *zFile,
-		    const char *zParam, int bDefault);
-
 extern char *
 sql_temp_directory;
 
@@ -876,9 +866,6 @@ sql_vfs_register(sql_vfs *, int makeDflt);
 #define SQL_STMTSTATUS_AUTOINDEX         3
 #define SQL_STMTSTATUS_VM_STEP           4
 
-void
-sql_interrupt(sql *);
-
 int
 sql_bind_blob(sql_stmt *, int, const void *,
 		  int n, void (*)(void *));
@@ -1507,11 +1494,7 @@ struct sql {
 #define SQL_DeferFKs       0x02000000	/* Defer all FK constraints */
 #define SQL_VdbeEQP        0x08000000	/* Debug EXPLAIN QUERY PLAN */
 
-/*
- * Bits of the sql.dbOptFlags field that are used by the
- * sql_test_control(sql_TESTCTRL_OPTIMIZATIONS,...) interface to
- * selectively disable various optimizations.
- */
+/* Bits of the sql.dbOptFlags field. */
 #define SQL_QueryFlattener 0x0001	/* Query flattening */
 #define SQL_ColumnCache    0x0002	/* Column cache */
 #define SQL_GroupByOrder   0x0004	/* GROUPBY cover of ORDERBY */
@@ -2916,24 +2899,6 @@ struct sqlConfig {
 };
 
 /*
- * This macro is used inside of assert() statements to indicate that
- * the assert is only valid on a well-formed database.  Instead of:
- *
- *     assert( X );
- *
- * One writes:
- *
- *     assert( X || CORRUPT_DB );
- *
- * CORRUPT_DB is true during normal operation.  CORRUPT_DB does not indicate
- * that the database is definitely corrupt, only that it might be corrupt.
- * For most test cases, CORRUPT_DB is set to false using a special
- * sql_test_control().  This enables assert() statements to prove
- * things that are always true for well-formed databases.
- */
-#define CORRUPT_DB  (sqlConfig.neverCorrupt==0)
-
-/*
  * Context pointer passed down through the tree-walk.
  */
 struct Walker {
@@ -3387,9 +3352,6 @@ int
 vdbe_emit_open_cursor(struct Parse *parse, int cursor, int index_id,
 		      struct space *space);
 
-int sqlParseUri(const char *, const char *, unsigned int *,
-		    sql_vfs **, char **, char **);
-
 #ifdef SQL_UNTESTABLE
 #define sqlFaultSim(X) SQL_OK
 #else
diff --git a/src/box/sql/vdbe.c b/src/box/sql/vdbe.c
index f746559..d452892 100644
--- a/src/box/sql/vdbe.c
+++ b/src/box/sql/vdbe.c
@@ -743,18 +743,6 @@ int sqlVdbeExec(Vdbe *p)
 #endif
 
 
-		/* Check to see if we need to simulate an interrupt.  This only happens
-		 * if we have a special test build.
-		 */
-#ifdef SQL_TEST
-		if (sql_interrupt_count>0) {
-			sql_interrupt_count--;
-			if (sql_interrupt_count==0) {
-				sql_interrupt(db);
-			}
-		}
-#endif
-
 		/* Sanity checking on other operands */
 #ifdef SQL_DEBUG
 		{
-- 
2.7.4

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [tarantool-patches] Re: [PATCH v1 1/3] sql: remove legacy.c
  2019-04-09 17:17 ` [tarantool-patches] [PATCH v1 1/3] sql: remove legacy.c imeevma
@ 2019-04-10  7:26   ` Konstantin Osipov
  2019-04-11  0:02   ` n.pettik
  1 sibling, 0 replies; 16+ messages in thread
From: Konstantin Osipov @ 2019-04-10  7:26 UTC (permalink / raw)
  To: tarantool-patches; +Cc: korablev

* imeevma@tarantool.org <imeevma@tarantool.org> [19/04/09 20:19]:
> The module legacy.c is not used and should be removed.

This is LGTM. Nikita?


-- 
Konstantin Osipov, Moscow, Russia, +7 903 626 22 32
http://tarantool.io - www.twitter.com/kostja_osipov

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [tarantool-patches] Re: [PATCH v1 2/3] sql: remove unused macros in SQL
  2019-04-09 17:17 ` [tarantool-patches] [PATCH v1 2/3] sql: remove unused macros in SQL imeevma
@ 2019-04-10  7:28   ` Konstantin Osipov
  2019-04-11  0:08   ` n.pettik
  2019-04-23  8:59   ` Kirill Yukhin
  2 siblings, 0 replies; 16+ messages in thread
From: Konstantin Osipov @ 2019-04-10  7:28 UTC (permalink / raw)
  To: tarantool-patches; +Cc: korablev

* imeevma@tarantool.org <imeevma@tarantool.org> [19/04/09 20:19]:
> Thise macros unused and should be removed.

LGTM.


-- 
Konstantin Osipov, Moscow, Russia, +7 903 626 22 32
http://tarantool.io - www.twitter.com/kostja_osipov

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [tarantool-patches] Re: [PATCH v1 3/3] sql: remove unused functions from main.c
  2019-04-09 17:17 ` [tarantool-patches] [PATCH v1 3/3] sql: remove unused functions from main.c imeevma
@ 2019-04-10  7:31   ` Konstantin Osipov
  2019-04-11  0:24     ` n.pettik
  2019-04-11  0:14   ` n.pettik
  1 sibling, 1 reply; 16+ messages in thread
From: Konstantin Osipov @ 2019-04-10  7:31 UTC (permalink / raw)
  To: tarantool-patches; +Cc: korablev

* imeevma@tarantool.org <imeevma@tarantool.org> [19/04/09 20:19]:
> -int
> -sql_shutdown(void)

This could be actually useful when debugging memory leaks, Nikita,
what's your take?

> -/*
> - * This API allows applications to modify the global configuration of
> - * the sql library at run-time.
> - *
> - * This routine should only be called when there are no outstanding
> - * database connections or memory allocations.  This routine is not
> - * threadsafe.  Failure to heed these warnings can lead to unpredictable
> - * behavior.
> - */
> -int
> -sql_config(int op, ...)
> -{

This is OK to remove.

> -/*
> - * Cause any pending operation to stop at its earliest opportunity.
> - */
> -void
> -sql_interrupt(sql * db)
> -{
> -	db->u1.isInterrupted = 1;
> -}

This could also be useful.

The rest of the patch is looking good to me. Let's wait for
Nikita's review. 

-- 
Konstantin Osipov, Moscow, Russia, +7 903 626 22 32
http://tarantool.io - www.twitter.com/kostja_osipov

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [tarantool-patches] Re: [PATCH v1 1/3] sql: remove legacy.c
  2019-04-09 17:17 ` [tarantool-patches] [PATCH v1 1/3] sql: remove legacy.c imeevma
  2019-04-10  7:26   ` [tarantool-patches] " Konstantin Osipov
@ 2019-04-11  0:02   ` n.pettik
  1 sibling, 0 replies; 16+ messages in thread
From: n.pettik @ 2019-04-11  0:02 UTC (permalink / raw)
  To: tarantool-patches; +Cc: Imeev Mergen


> @@ -1704,11 +1704,13 @@ sql_analysis_load(struct sql *db)
> 	info.db = db;
> 	info.stats = stats;
> 	info.index_count = 0;
> -	const char *load_stat1 =
> +	MAYBE_UNUSED const char *load_stat1 =
> 		"SELECT \"tbl\",\"idx\",\"stat\" FROM \"_sql_stat1\"";
> -	/* Load new statistics out of the _sql_stat1 table. */
> -	if (sql_exec(db, load_stat1, analysis_loader, &info, 0) != 0)
> -		goto fail;
> +	/*
> +	 * Here was loading new statistics out of the _sql_stat1
> +	 * table using analysis_loader. This part of code was
> +	 * removed due to removal of sql_exec().
> +	 */

Which mechanism will replace this functionality?
Now I don’t see any alternatives. Personally I’d
remove this function on demand: when we
introduce replacement to analysis_loader().

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [tarantool-patches] Re: [PATCH v1 2/3] sql: remove unused macros in SQL
  2019-04-09 17:17 ` [tarantool-patches] [PATCH v1 2/3] sql: remove unused macros in SQL imeevma
  2019-04-10  7:28   ` [tarantool-patches] " Konstantin Osipov
@ 2019-04-11  0:08   ` n.pettik
  2019-04-11 16:56     ` Imeev Mergen
  2019-04-12 13:08     ` Mergen Imeev
  2019-04-23  8:59   ` Kirill Yukhin
  2 siblings, 2 replies; 16+ messages in thread
From: n.pettik @ 2019-04-11  0:08 UTC (permalink / raw)
  To: tarantool-patches; +Cc: Imeev Mergen



> On 9 Apr 2019, at 20:17, imeevma@tarantool.org wrote:
> 
> Thise macros unused and should be removed.

Nit: these.

Nit: are unused.

Are you sure that you’ve removed *all* unused macros?
Otherwise, which attribute are you used to spot this group
of macros?

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [tarantool-patches] Re: [PATCH v1 3/3] sql: remove unused functions from main.c
  2019-04-09 17:17 ` [tarantool-patches] [PATCH v1 3/3] sql: remove unused functions from main.c imeevma
  2019-04-10  7:31   ` [tarantool-patches] " Konstantin Osipov
@ 2019-04-11  0:14   ` n.pettik
  1 sibling, 0 replies; 16+ messages in thread
From: n.pettik @ 2019-04-11  0:14 UTC (permalink / raw)
  To: tarantool-patches; +Cc: Imeev Mergen



> On 9 Apr 2019, at 20:17, imeevma@tarantool.org wrote:
> 
> These functions unused and should be removed.

Nit: are unused.

> Needed for #4074

Why it is ’needed for’? This removal seems to be quite optional.

Patch is OK as obvious.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [tarantool-patches] Re: [PATCH v1 3/3] sql: remove unused functions from main.c
  2019-04-10  7:31   ` [tarantool-patches] " Konstantin Osipov
@ 2019-04-11  0:24     ` n.pettik
  2019-04-11  6:36       ` Konstantin Osipov
  0 siblings, 1 reply; 16+ messages in thread
From: n.pettik @ 2019-04-11  0:24 UTC (permalink / raw)
  To: tarantool-patches; +Cc: Konstantin Osipov, Imeev Mergen



> On 10 Apr 2019, at 10:31, Konstantin Osipov <kostja@tarantool.org> wrote:
> 
> * imeevma@tarantool.org <imeevma@tarantool.org> [19/04/09 20:19]:
>> -int
>> -sql_shutdown(void)
> 
> This could be actually useful when debugging memory leaks, Nikita,
> what's your take?

I believe it is broken and useless. What is more, we are going
to completely remove SQLite's original allocators and use only
malloc and region. So, it makes no sense to leave this function.
If we may need to have smth like that someday, it will be easier
to implement it from scratch (IMHO).

>> -/*
>> - * Cause any pending operation to stop at its earliest opportunity.
>> - */
>> -void
>> -sql_interrupt(sql * db)
>> -{
>> -	db->u1.isInterrupted = 1;
>> -}
> 
> This could also be useful.

TBO I don’t understand why it could be useful and how it can
be applied to our SQL implementation at all. Furthermore,
there’s no guarantee that we haven’t removed some parts
of this functionality during previous refactorings. Let’s finish it.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [tarantool-patches] Re: [PATCH v1 3/3] sql: remove unused functions from main.c
  2019-04-11  0:24     ` n.pettik
@ 2019-04-11  6:36       ` Konstantin Osipov
  0 siblings, 0 replies; 16+ messages in thread
From: Konstantin Osipov @ 2019-04-11  6:36 UTC (permalink / raw)
  To: tarantool-patches; +Cc: Imeev Mergen

* n.pettik <korablev@tarantool.org> [19/04/11 08:09]:

OK, agree on both points.

> > * imeevma@tarantool.org <imeevma@tarantool.org> [19/04/09 20:19]:
> >> -int
> >> -sql_shutdown(void)
> > 
> > This could be actually useful when debugging memory leaks, Nikita,
> > what's your take?
> 
> I believe it is broken and useless. What is more, we are going
> to completely remove SQLite's original allocators and use only
> malloc and region. So, it makes no sense to leave this function.
> If we may need to have smth like that someday, it will be easier
> to implement it from scratch (IMHO).
> 
> >> -/*
> >> - * Cause any pending operation to stop at its earliest opportunity.
> >> - */
> >> -void
> >> -sql_interrupt(sql * db)
> >> -{
> >> -	db->u1.isInterrupted = 1;
> >> -}
> > 
> > This could also be useful.
> 
> TBO I don’t understand why it could be useful and how it can
> be applied to our SQL implementation at all. Furthermore,
> there’s no guarantee that we haven’t removed some parts
> of this functionality during previous refactorings. Let’s finish it.
> 

-- 
Konstantin Osipov, Moscow, Russia, +7 903 626 22 32
http://tarantool.io - www.twitter.com/kostja_osipov

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [tarantool-patches] Re: [PATCH v1 2/3] sql: remove unused macros in SQL
  2019-04-11  0:08   ` n.pettik
@ 2019-04-11 16:56     ` Imeev Mergen
  2019-04-12 13:08     ` Mergen Imeev
  1 sibling, 0 replies; 16+ messages in thread
From: Imeev Mergen @ 2019-04-11 16:56 UTC (permalink / raw)
  To: n.pettik, tarantool-patches

Hi! Thank you for review! My answers below.

On 4/11/19 3:08 AM, n.pettik wrote:
>
>> On 9 Apr 2019, at 20:17, imeevma@tarantool.org wrote:
>>
>> Thise macros unused and should be removed.
> Nit: these.
>
> Nit: are unused.
Thanks, will fix.
>
> Are you sure that you’ve removed *all* unused macros?
> Otherwise, which attribute are you used to spot this group
> of macros?
Definitely not all. I started with main.c. Should I remove all
unused macros or just add to the commit-message that these macros
are from main.c?

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [tarantool-patches] Re: [PATCH v1 2/3] sql: remove unused macros in SQL
  2019-04-11  0:08   ` n.pettik
  2019-04-11 16:56     ` Imeev Mergen
@ 2019-04-12 13:08     ` Mergen Imeev
  2019-04-22 15:39       ` n.pettik
  1 sibling, 1 reply; 16+ messages in thread
From: Mergen Imeev @ 2019-04-12 13:08 UTC (permalink / raw)
  To: n.pettik; +Cc: tarantool-patches

Hi! Thank you for review. I dropped first and squashed second and
third patches. New patch below.


On Thu, Apr 11, 2019 at 03:08:23AM +0300, n.pettik wrote:
> 
> 
> > On 9 Apr 2019, at 20:17, imeevma@tarantool.org wrote:
> > 
> > Thise macros unused and should be removed.
> 
> Nit: these.
> 
> Nit: are unused.
> 
Rewrote commit-message.

> Are you sure that you’ve removed *all* unused macros?
> Otherwise, which attribute are you used to spot this group
> of macros?
> 
These macros were in main.c.

New patch:

From f5b2bf849249cf395149083a6c50767a9d375a06 Mon Sep 17 00:00:00 2001
From: Mergen Imeev <imeevma@gmail.com>
Date: Sat, 6 Apr 2019 12:50:45 +0300
Subject: [PATCH] sql: remove unused code from main.c

This patch removes part of unused functions and macros from
main.c. This will facilitate the work of removing SQL error/status
codes.

Needed for #4074

diff --git a/src/box/sql/build.c b/src/box/sql/build.c
index a06ba3e..3442442 100644
--- a/src/box/sql/build.c
+++ b/src/box/sql/build.c
@@ -327,8 +327,6 @@ sqlStartTable(Parse *pParse, Token *pName, int noErr)
 		if (!noErr) {
 			diag_set(ClientError, ER_SPACE_EXISTS, zName);
 			pParse->is_aborted = true;
-		} else {
-			assert(!db->init.busy || CORRUPT_DB);
 		}
 		goto cleanup;
 	}
diff --git a/src/box/sql/expr.c b/src/box/sql/expr.c
index 6ff41a5..a95d576 100644
--- a/src/box/sql/expr.c
+++ b/src/box/sql/expr.c
@@ -3287,7 +3287,6 @@ sqlExprCodeIN(Parse * pParse,	/* Parsing and code generating context */
 	sqlDbFree(pParse->db, zAff);
 }
 
-#ifndef SQL_OMIT_FLOATING_POINT
 /*
  * Generate an instruction that will put the floating point
  * value described by z[0..n-1] into register iMem.
@@ -3309,7 +3308,6 @@ codeReal(Vdbe * v, const char *z, int negateFlag, int iMem)
 				      P4_REAL);
 	}
 }
-#endif
 
 /**
  * Generate an instruction that will put the integer describe by
@@ -3760,13 +3758,11 @@ sqlExprCodeTarget(Parse * pParse, Expr * pExpr, int target)
 			expr_code_int(pParse, pExpr, false, target);
 			return target;
 		}
-#ifndef SQL_OMIT_FLOATING_POINT
 	case TK_FLOAT:{
 			assert(!ExprHasProperty(pExpr, EP_IntValue));
 			codeReal(v, pExpr->u.zToken, 0, target);
 			return target;
 		}
-#endif
 	case TK_STRING:{
 			assert(!ExprHasProperty(pExpr, EP_IntValue));
 			sqlVdbeLoadString(v, target, pExpr->u.zToken);
@@ -3923,12 +3919,10 @@ sqlExprCodeTarget(Parse * pParse, Expr * pExpr, int target)
 			if (pLeft->op == TK_INTEGER) {
 				expr_code_int(pParse, pLeft, true, target);
 				return target;
-#ifndef SQL_OMIT_FLOATING_POINT
 			} else if (pLeft->op == TK_FLOAT) {
 				assert(!ExprHasProperty(pExpr, EP_IntValue));
 				codeReal(v, pLeft->u.zToken, 1, target);
 				return target;
-#endif
 			} else {
 				tempX.op = TK_INTEGER;
 				tempX.flags = EP_IntValue | EP_TokenOnly;
@@ -4283,7 +4277,6 @@ sqlExprCodeTarget(Parse * pParse, Expr * pExpr, int target)
 				    pExpr->space_def->fields[
 					pExpr->iColumn].name, target));
 
-#ifndef SQL_OMIT_FLOATING_POINT
 			/* If the column has type NUMBER, it may currently be stored as an
 			 * integer. Use OP_Realify to make sure it is really real.
 			 */
@@ -4291,7 +4284,6 @@ sqlExprCodeTarget(Parse * pParse, Expr * pExpr, int target)
 				pExpr->iColumn].type == FIELD_TYPE_NUMBER) {
 				sqlVdbeAddOp1(v, OP_Realify, target);
 			}
-#endif
 			break;
 		}
 
diff --git a/src/box/sql/fault.c b/src/box/sql/fault.c
index d83af36..8ee774e 100644
--- a/src/box/sql/fault.c
+++ b/src/box/sql/fault.c
@@ -65,14 +65,8 @@ static SQL_WSD struct BenignMallocHooks {
  * case where writable static data is supported, wsdHooks can refer directly
  * to the "sqlHooks" state vector declared above.
  */
-#ifdef SQL_OMIT_WSD
-#define wsdHooksInit \
-  BenignMallocHooks *x = &GLOBAL(BenignMallocHooks,sqlHooks)
-#define wsdHooks x[0]
-#else
 #define wsdHooksInit
 #define wsdHooks sqlHooks
-#endif
 
 /*
  * Register hooks to call when sqlBeginBenignMalloc() and
diff --git a/src/box/sql/func.c b/src/box/sql/func.c
index abeecef..34b6c79 100644
--- a/src/box/sql/func.c
+++ b/src/box/sql/func.c
@@ -498,7 +498,6 @@ substrFunc(sql_context * context, int argc, sql_value ** argv)
 /*
  * Implementation of the round() function
  */
-#ifndef SQL_OMIT_FLOATING_POINT
 static void
 roundFunc(sql_context * context, int argc, sql_value ** argv)
 {
@@ -535,7 +534,6 @@ roundFunc(sql_context * context, int argc, sql_value ** argv)
 	}
 	sql_result_double(context, r);
 }
-#endif
 
 /*
  * Allocate nByte bytes of space using sqlMalloc(). If the
@@ -1547,7 +1545,6 @@ totalFinalize(sql_context * context)
 {
 	SumCtx *p;
 	p = sql_aggregate_context(context, 0);
-	/* (double)0 In case of SQL_OMIT_FLOATING_POINT... */
 	sql_result_double(context, p ? p->rSum : (double)0);
 }
 
@@ -1703,11 +1700,6 @@ sql_overload_function(sql * db, const char *zName,
 {
 	int rc = SQL_OK;
 
-#ifdef SQL_ENABLE_API_ARMOR
-	if (!sqlSafetyCheckOk(db) || zName == 0 || nArg < -2) {
-		return SQL_MISUSE;
-	}
-#endif
 	if (sqlFindFunction(db, zName, nArg, 0) == 0) {
 		rc = sqlCreateFunc(db, zName, type, nArg, 0, 0,
 				       sqlInvalidFunction, 0, 0, 0);
@@ -1841,10 +1833,8 @@ sqlRegisterBuiltinFunctions(void)
 		FUNCTION(unicode, 1, 0, 0, unicodeFunc, FIELD_TYPE_STRING),
 		FUNCTION(char, -1, 0, 0, charFunc, FIELD_TYPE_STRING),
 		FUNCTION(abs, 1, 0, 0, absFunc, FIELD_TYPE_NUMBER),
-#ifndef SQL_OMIT_FLOATING_POINT
 		FUNCTION(round, 1, 0, 0, roundFunc, FIELD_TYPE_INTEGER),
 		FUNCTION(round, 2, 0, 0, roundFunc, FIELD_TYPE_INTEGER),
-#endif
 		FUNCTION_COLL(upper, 1, 0, 1, UpperICUFunc),
 		FUNCTION_COLL(lower, 1, 0, 1, LowerICUFunc),
 		FUNCTION(hex, 1, 0, 0, hexFunc, FIELD_TYPE_STRING),
diff --git a/src/box/sql/global.c b/src/box/sql/global.c
index 159b35e..9af671a 100644
--- a/src/box/sql/global.c
+++ b/src/box/sql/global.c
@@ -200,10 +200,6 @@ SQL_WSD struct sqlConfig sqlConfig = {
 	0,			/* isMallocInit */
 	0,			/* xLog */
 	0,			/* pLogArg */
-#ifdef SQL_ENABLE_SQLLOG
-	0,			/* xSqllog */
-	0,			/* pSqllogArg */
-#endif
 #ifdef SQL_VDBE_COVERAGE
 	0,			/* xVdbeBranch */
 	0,			/* pVbeBranchArg */
@@ -232,17 +228,14 @@ FuncDefHash sqlBuiltinFunctions;
  * During testing, it is often desirable to move the pending byte to
  * a different position in the file.  This allows code that has to
  * deal with the pending byte to run on files that are much smaller
- * than 1 GiB.  The sql_test_control() interface can be used to
- * move the pending byte.
+ * than 1 GiB.
  *
  * IMPORTANT:  Changing the pending byte to any value other than
  * 0x40000000 results in an incompatible database file format!
  * Changing the pending byte during operation will result in undefined
  * and incorrect behavior.
  */
-#ifndef SQL_OMIT_WSD
 int sqlPendingByte = 0x40000000;
-#endif
 
 #include "opcodes.h"
 /*
diff --git a/src/box/sql/legacy.c b/src/box/sql/legacy.c
index 599fba0..fb6891b 100644
--- a/src/box/sql/legacy.c
+++ b/src/box/sql/legacy.c
@@ -57,6 +57,7 @@ sql_exec(sql * db,	/* The database on which the SQL executes */
 	     char **pzErrMsg	/* Write error messages here */
     )
 {
+	(void)pzErrMsg;
 	int rc = SQL_OK;	/* Return code */
 	const char *zLeftover;	/* Tail of unprocessed SQL */
 	sql_stmt *pStmt = 0;	/* The current SQL statement */
@@ -169,19 +170,7 @@ sql_exec(sql * db,	/* The database on which the SQL executes */
 	sqlDbFree(db, azCols);
 
 	rc = sqlApiExit(db, rc);
-	if (rc != SQL_OK && pzErrMsg) {
-		int nErrMsg = 1 + sqlStrlen30(sql_errmsg(db));
-		*pzErrMsg = sqlMalloc(nErrMsg);
-		if (*pzErrMsg) {
-			memcpy(*pzErrMsg, sql_errmsg(db), nErrMsg);
-		} else {
-			rc = SQL_NOMEM;
-			sqlError(db, SQL_NOMEM);
-		}
-	} else if (pzErrMsg) {
-		*pzErrMsg = 0;
-	}
-
+	assert(rc == SQL_OK);
 	assert((rc & db->errMask) == rc);
 	return rc;
 }
diff --git a/src/box/sql/main.c b/src/box/sql/main.c
index 0b3bd20..fe1135a 100644
--- a/src/box/sql/main.c
+++ b/src/box/sql/main.c
@@ -40,22 +40,6 @@
 #include "version.h"
 #include "box/session.h"
 
-#ifdef SQL_ENABLE_FTS3
-#include "fts3.h"
-#endif
-#ifdef SQL_ENABLE_RTREE
-#include "rtree.h"
-#endif
-#ifdef SQL_ENABLE_ICU
-#include "sqlicu.h"
-#endif
-#ifdef SQL_ENABLE_JSON1
-int sqlJson1Init(sql *);
-#endif
-#ifdef SQL_ENABLE_FTS5
-int sqlFts5Init(sql *);
-#endif
-
 #if !defined(SQL_OMIT_TRACE) && defined(SQL_ENABLE_IOTRACE)
 /*
  * If the following function pointer is not NULL and if
@@ -89,12 +73,9 @@ char *sql_data_directory = 0;
  *
  * This routine must be called to initialize the memory allocation,
  * and VFS subsystems prior to doing any serious work with
- * sql.  But as long as you do not compile with SQL_OMIT_AUTOINIT
- * this routine will be called automatically by key routines such as
- * sql_open().
+ * sql.
  *
- * This routine is a no-op except on its very first call for the process,
- * or for the first call after a call to sql_shutdown.
+ * This routine is a no-op except on its very first call for the process.
  *
  * The first thread to call this routine runs the initialization to
  * completion.  If subsequent threads call this routine before the first
@@ -119,16 +100,6 @@ int
 sql_initialize(void)
 {
 	int rc = SQL_OK;
-#ifdef SQL_EXTRA_INIT
-	int bRunExtraInit = 0;	/* Extra initialization needed */
-#endif
-
-#ifdef SQL_OMIT_WSD
-	rc = sql_wsd_init(4096, 24);
-	if (rc != SQL_OK) {
-		return rc;
-	}
-#endif
 
 	/* If the following assert() fails on some obscure processor/compiler
 	 * combination, the work-around is to set the correct pointer
@@ -170,12 +141,6 @@ sql_initialize(void)
 	if (sqlGlobalConfig.isInit == 0
 	    && sqlGlobalConfig.inProgress == 0) {
 		sqlGlobalConfig.inProgress = 1;
-#ifdef SQL_ENABLE_SQLLOG
-		{
-			extern void sql_init_sqllog(void);
-			sql_init_sqllog();
-		}
-#endif
 		memset(&sqlBuiltinFunctions, 0,
 		       sizeof(sqlBuiltinFunctions));
 		sqlRegisterBuiltinFunctions();
@@ -184,9 +149,6 @@ sql_initialize(void)
 		}
 		if (rc == SQL_OK) {
 			sqlGlobalConfig.isInit = 1;
-#ifdef SQL_EXTRA_INIT
-			bRunExtraInit = 1;
-#endif
 		}
 		sqlGlobalConfig.inProgress = 0;
 	}
@@ -197,7 +159,6 @@ sql_initialize(void)
 	 * reason.  So we run it once during initialization.
 	 */
 #ifndef NDEBUG
-#ifndef SQL_OMIT_FLOATING_POINT
 	/* This section of code's only "output" is via assert() statements. */
 	if (rc == SQL_OK) {
 		u64 x = (((u64) 1) << 63) - 1;
@@ -208,206 +169,7 @@ sql_initialize(void)
 		assert(sqlIsNaN(y));
 	}
 #endif
-#endif
-
-	/* Do extra initialization steps requested by the SQL_EXTRA_INIT
-	 * compile-time option.
-	 */
-#ifdef SQL_EXTRA_INIT
-	if (bRunExtraInit) {
-		int SQL_EXTRA_INIT(const char *);
-		rc = SQL_EXTRA_INIT(0);
-	}
-#endif
-
-	return rc;
-}
-
-/*
- * Undo the effects of sql_initialize().  Must not be called while
- * there are outstanding database connections or memory allocations or
- * while any part of sql is otherwise in use in any thread.  This
- * routine is not threadsafe.  But it is safe to invoke this routine
- * on when sql is already shut down.  If sql is already shut down
- * when this routine is invoked, then this routine is a harmless no-op.
- */
-int
-sql_shutdown(void)
-{
-#ifdef SQL_OMIT_WSD
-	int rc = sql_wsd_init(4096, 24);
-	if (rc != SQL_OK) {
-		return rc;
-	}
-#endif
-
-	if (sqlGlobalConfig.isInit) {
-#ifdef SQL_EXTRA_SHUTDOWN
-		void SQL_EXTRA_SHUTDOWN(void);
-		SQL_EXTRA_SHUTDOWN();
-#endif
-		sql_os_end();
-		sqlGlobalConfig.isInit = 0;
-	}
-	if (sqlGlobalConfig.isMallocInit) {
-		sqlMallocEnd();
-		sqlGlobalConfig.isMallocInit = 0;
-
-#ifndef SQL_OMIT_SHUTDOWN_DIRECTORIES
-		/* The heap subsystem has now been shutdown and these values are supposed
-		 * to be NULL or point to memory that was obtained from sql_malloc(),
-		 * which would rely on that heap subsystem; therefore, make sure these
-		 * values cannot refer to heap memory that was just invalidated when the
-		 * heap subsystem was shutdown.  This is only done if the current call to
-		 * this function resulted in the heap subsystem actually being shutdown.
-		 */
-		sql_data_directory = 0;
-		sql_temp_directory = 0;
-#endif
-	}
-
-	return SQL_OK;
-}
-
-/*
- * This API allows applications to modify the global configuration of
- * the sql library at run-time.
- *
- * This routine should only be called when there are no outstanding
- * database connections or memory allocations.  This routine is not
- * threadsafe.  Failure to heed these warnings can lead to unpredictable
- * behavior.
- */
-int
-sql_config(int op, ...)
-{
-	va_list ap;
-	int rc = SQL_OK;
-
-	/* sql_config() shall return SQL_MISUSE if it is invoked while
-	 * the sql library is in use.
-	 */
-	if (sqlGlobalConfig.isInit)
-		return SQL_MISUSE;
-
-	va_start(ap, op);
-	switch (op) {
-	case SQL_CONFIG_MEMSTATUS:{
-			/* EVIDENCE-OF: R-61275-35157 The SQL_CONFIG_MEMSTATUS option takes
-			 * single argument of type int, interpreted as a boolean, which enables
-			 * or disables the collection of memory allocation statistics.
-			 */
-			sqlGlobalConfig.bMemstat = va_arg(ap, int);
-			break;
-		}
-	case SQL_CONFIG_SCRATCH:{
-			/* EVIDENCE-OF: R-08404-60887 There are three arguments to
-			 * SQL_CONFIG_SCRATCH: A pointer an 8-byte aligned memory buffer from
-			 * which the scratch allocations will be drawn, the size of each scratch
-			 * allocation (sz), and the maximum number of scratch allocations (N).
-			 */
-			sqlGlobalConfig.pScratch = va_arg(ap, void *);
-			sqlGlobalConfig.szScratch = va_arg(ap, int);
-			sqlGlobalConfig.nScratch = va_arg(ap, int);
-			break;
-		}
-
-	case SQL_CONFIG_LOOKASIDE:{
-			sqlGlobalConfig.szLookaside = va_arg(ap, int);
-			sqlGlobalConfig.nLookaside = va_arg(ap, int);
-			break;
-		}
-
-		/* Record a pointer to the logger function and its first argument.
-		 * The default is NULL.  Logging is disabled if the function pointer is
-		 * NULL.
-		 */
-	case SQL_CONFIG_LOG:{
-			typedef void (*LOGFUNC_t) (void *, int, const char *);
-			sqlGlobalConfig.xLog = va_arg(ap, LOGFUNC_t);
-			sqlGlobalConfig.pLogArg = va_arg(ap, void *);
-			break;
-		}
-
-		/* EVIDENCE-OF: R-55548-33817 The compile-time setting for URI filenames
-		 * can be changed at start-time using the
-		 * sql_config(SQL_CONFIG_URI,1) or
-		 * sql_config(SQL_CONFIG_URI,0) configuration calls.
-		 */
-	case SQL_CONFIG_URI:{
-			/* EVIDENCE-OF: R-25451-61125 The SQL_CONFIG_URI option takes a single
-			 * argument of type int. If non-zero, then URI handling is globally
-			 * enabled. If the parameter is zero, then URI handling is globally
-			 * disabled.
-			 */
-			sqlGlobalConfig.bOpenUri = va_arg(ap, int);
-			break;
-		}
-
-	case SQL_CONFIG_COVERING_INDEX_SCAN:{
-			/* EVIDENCE-OF: R-36592-02772 The SQL_CONFIG_COVERING_INDEX_SCAN
-			 * option takes a single integer argument which is interpreted as a
-			 * boolean in order to enable or disable the use of covering indices for
-			 * full table scans in the query optimizer.
-			 */
-			sqlGlobalConfig.bUseCis = va_arg(ap, int);
-			break;
-		}
-
-#ifdef SQL_ENABLE_SQLLOG
-	case SQL_CONFIG_SQLLOG:{
-			typedef void (*SQLLOGFUNC_t) (void *, sql *,
-						      const char *, int);
-			sqlGlobalConfig.xSqllog = va_arg(ap, SQLLOGFUNC_t);
-			sqlGlobalConfig.pSqllogArg = va_arg(ap, void *);
-			break;
-		}
-#endif
-
-	case SQL_CONFIG_MMAP_SIZE:{
-			/* EVIDENCE-OF: R-58063-38258 SQL_CONFIG_MMAP_SIZE takes two 64-bit
-			 * integer (sql_int64) values that are the default mmap size limit
-			 * (the default setting for PRAGMA mmap_size) and the maximum allowed
-			 * mmap size limit.
-			 */
-			sql_int64 szMmap = va_arg(ap, sql_int64);
-			sql_int64 mxMmap = va_arg(ap, sql_int64);
-			/* EVIDENCE-OF: R-53367-43190 If either argument to this option is
-			 * negative, then that argument is changed to its compile-time default.
-			 *
-			 * EVIDENCE-OF: R-34993-45031 The maximum allowed mmap size will be
-			 * silently truncated if necessary so that it does not exceed the
-			 * compile-time maximum mmap size set by the SQL_MAX_MMAP_SIZE
-			 * compile-time option.
-			 */
-			if (mxMmap < 0 || mxMmap > SQL_MAX_MMAP_SIZE) {
-				mxMmap = SQL_MAX_MMAP_SIZE;
-			}
-			if (szMmap < 0)
-				szMmap = SQL_DEFAULT_MMAP_SIZE;
-			if (szMmap > mxMmap)
-				szMmap = mxMmap;
-			sqlGlobalConfig.mxMmap = mxMmap;
-			sqlGlobalConfig.szMmap = szMmap;
-			break;
-		}
 
-	case SQL_CONFIG_PMASZ:{
-			sqlGlobalConfig.szPma = va_arg(ap, unsigned int);
-			break;
-		}
-
-	case SQL_CONFIG_STMTJRNL_SPILL:{
-			sqlGlobalConfig.nStmtSpill = va_arg(ap, int);
-			break;
-		}
-
-	default:{
-			rc = SQL_ERROR;
-			break;
-		}
-	}
-	va_end(ap);
 	return rc;
 }
 
@@ -556,13 +318,6 @@ sqlClose(sql * db, int forceZombie)
 				    "statements");
 		return SQL_BUSY;
 	}
-#ifdef SQL_ENABLE_SQLLOG
-	if (sqlGlobalConfig.xSqllog) {
-		/* Closing the handle. Fourth parameter is passed the value 2. */
-		sqlGlobalConfig.xSqllog(sqlGlobalConfig.pSqllogArg, db,
-					    0, 2);
-	}
-#endif
 
 	/* Convert the connection into a zombie and then close it.
 	 */
@@ -640,48 +395,6 @@ sqlErrStr(int rc)
 	return zErr;
 }
 
-#ifndef SQL_OMIT_PROGRESS_CALLBACK
-/*
- * This routine sets the progress callback for an Sqlite database to the
- * given callback function with the given argument. The progress callback will
- * be invoked every nOps opcodes.
- */
-void
-sql_progress_handler(sql * db,
-			 int nOps, int (*xProgress) (void *), void *pArg)
-{
-#ifdef SQL_ENABLE_API_ARMOR
-	if (!sqlSafetyCheckOk(db)) {
-		return;
-	}
-#endif
-	if (nOps > 0) {
-		db->xProgress = xProgress;
-		db->nProgressOps = (unsigned)nOps;
-		db->pProgressArg = pArg;
-	} else {
-		db->xProgress = 0;
-		db->nProgressOps = 0;
-		db->pProgressArg = 0;
-	}
-}
-#endif
-
-/*
- * Cause any pending operation to stop at its earliest opportunity.
- */
-void
-sql_interrupt(sql * db)
-{
-#ifdef SQL_ENABLE_API_ARMOR
-	if (!sqlSafetyCheckOk(db)
-	    && (db == 0 || db->magic != SQL_MAGIC_ZOMBIE)) {
-		return;
-	}
-#endif
-	db->u1.isInterrupted = 1;
-}
-
 /*
  * This function is exactly the same as sql_create_function(), except
  * that it is designed to be called by internal code. The difference is
@@ -775,11 +488,6 @@ sql_create_function_v2(sql * db,
 	int rc = SQL_ERROR;
 	FuncDestructor *pArg = 0;
 
-#ifdef SQL_ENABLE_API_ARMOR
-	if (!sqlSafetyCheckOk(db)) {
-		return SQL_MISUSE;
-	}
-#endif
 	if (xDestroy) {
 		pArg =
 		    (FuncDestructor *) sqlDbMallocZero(db,
@@ -814,11 +522,6 @@ sql_trace_v2(sql * db,		/* Trace this connection */
 		 int (*xTrace) (unsigned, void *, void *, void *),	/* Callback to invoke */
 		 void *pArg)		/* Context */
 {
-#ifdef SQL_ENABLE_API_ARMOR
-	if (!sqlSafetyCheckOk(db)) {
-		return SQL_MISUSE;
-	}
-#endif
 	if (mTrace == 0)
 		xTrace = 0;
 	if (xTrace == 0)
@@ -832,93 +535,6 @@ sql_trace_v2(sql * db,		/* Trace this connection */
 #endif				/* SQL_OMIT_TRACE */
 
 /*
- * Register a function to be invoked when a transaction commits.
- * If the invoked function returns non-zero, then the commit becomes a
- * rollback.
- */
-void *
-sql_commit_hook(sql * db,	/* Attach the hook to this database */
-		    int (*xCallback) (void *),	/* Function to invoke on each commit */
-		    void *pArg)		/* Argument to the function */
-{
-	void *pOld;
-
-#ifdef SQL_ENABLE_API_ARMOR
-	if (!sqlSafetyCheckOk(db)) {
-		return 0;
-	}
-#endif
-	pOld = db->pCommitArg;
-	db->xCommitCallback = xCallback;
-	db->pCommitArg = pArg;
-	return pOld;
-}
-
-/*
- * Register a callback to be invoked each time a row is updated,
- * inserted or deleted using this database connection.
- */
-void *
-sql_update_hook(sql * db,	/* Attach the hook to this database */
-		    void (*xCallback) (void *, int, char const *,
-				       char const *, sql_int64),
-		    void *pArg)		/* Argument to the function */
-{
-	void *pRet;
-
-#ifdef SQL_ENABLE_API_ARMOR
-	if (!sqlSafetyCheckOk(db)) {
-		return 0;
-	}
-#endif
-	pRet = db->pUpdateArg;
-	db->xUpdateCallback = xCallback;
-	db->pUpdateArg = pArg;
-	return pRet;
-}
-
-/*
- * Register a callback to be invoked each time a transaction is rolled
- * back by this database connection.
- */
-void *
-sql_rollback_hook(sql * db,	/* Attach the hook to this database */
-		      void (*xCallback) (void *),	/* Callback function */
-		      void *pArg)	/* Argument to the function */
-{
-	void *pRet;
-
-#ifdef SQL_ENABLE_API_ARMOR
-	if (!sqlSafetyCheckOk(db)) {
-		return 0;
-	}
-#endif
-	pRet = db->pRollbackArg;
-	db->xRollbackCallback = xCallback;
-	db->pRollbackArg = pArg;
-	return pRet;
-}
-
-/*
- * Configure an sql_wal_hook() callback to automatically checkpoint
- * a database after committing a transaction if there are nFrame or
- * more frames in the log file. Passing zero or a negative value as the
- * nFrame parameter disables automatic checkpoints entirely.
- *
- * The callback registered by this function replaces any existing callback
- * registered using sql_wal_hook(). Likewise, registering a callback
- * using sql_wal_hook() disables the automatic checkpoint mechanism
- * configured by this function.
- */
-int
-sql_wal_autocheckpoint(sql * db, int nFrame)
-{
-	UNUSED_PARAMETER(db);
-	UNUSED_PARAMETER(nFrame);
-	return SQL_OK;
-}
-
-/*
  * This function returns true if main-memory should be used instead of
  * a temporary file for transient pager files and statement journals.
  * The value returned depends on the value of db->temp_store (runtime
@@ -957,37 +573,6 @@ sqlTempInMemory(const sql * db)
 }
 
 /*
- * Return UTF-8 encoded English language explanation of the most recent
- * error.
- */
-const char *
-sql_errmsg(sql * db)
-{
-	const char *z;
-	if (!db) {
-		return sqlErrStr(SQL_NOMEM);
-	}
-	if (!sqlSafetyCheckSickOrOk(db)) {
-		return sqlErrStr(SQL_MISUSE);
-	}
-	if (db->mallocFailed) {
-		z = sqlErrStr(SQL_NOMEM);
-	} else {
-		testcase(db->pErr == 0);
-		assert(!db->mallocFailed);
-		if (db->errCode != SQL_TARANTOOL_ERROR) {
-			z = (char *)sql_value_text(db->pErr);
-			if (z == NULL)
-				z = sqlErrStr(db->errCode);
-		} else {
-			z = diag_last_error(diag_get())->errmsg;
-		}
-		assert(z != NULL);
-	}
-	return z;
-}
-
-/*
  * Return the most recent error code generated by an sql routine. If NULL is
  * passed to this function, we assume a malloc() failed during sql_open().
  */
@@ -1003,35 +588,6 @@ sql_errcode(sql * db)
 	return db->errCode & db->errMask;
 }
 
-int
-sql_extended_errcode(sql * db)
-{
-	if (db && !sqlSafetyCheckSickOrOk(db)) {
-		return SQL_MISUSE;
-	}
-	if (!db || db->mallocFailed) {
-		return SQL_NOMEM;
-	}
-	return db->errCode;
-}
-
-int
-sql_system_errno(sql * db)
-{
-	return db ? db->iSysErrno : 0;
-}
-
-/*
- * Return a string that describes the kind of error specified in the
- * argument.  For now, this simply calls the internal sqlErrStr()
- * function.
- */
-const char *
-sql_errstr(int rc)
-{
-	return sqlErrStr(rc);
-}
-
 /*
  * This array defines hard upper bounds on limit values.  The
  * initializer must be kept in sync with the SQL_LIMIT_*
@@ -1103,12 +659,6 @@ sql_limit(sql * db, int limitId, int newLimit)
 {
 	int oldLimit;
 
-#ifdef SQL_ENABLE_API_ARMOR
-	if (!sqlSafetyCheckOk(db)) {
-		return -1;
-	}
-#endif
-
 	/* EVIDENCE-OF: R-30189-54097 For each limit category SQL_LIMIT_NAME
 	 * there is a hard upper bound set at compile-time by a C preprocessor
 	 * macro called SQL_MAX_NAME. (The "_LIMIT_" in the name is changed to
@@ -1145,297 +695,6 @@ sql_limit(sql * db, int limitId, int newLimit)
 	return oldLimit;	/* IMP: R-53341-35419 */
 }
 
-/*
- * This function is used to parse both URIs and non-URI filenames passed by the
- * user to API functions sql_open() or sql_open_v2(), and for database
- * URIs specified as part of ATTACH statements.
- *
- * The first argument to this function is the name of the VFS to use (or
- * a NULL to signify the default VFS) if the URI does not contain a "vfs=xxx"
- * query parameter. The second argument contains the URI (or non-URI filename)
- * itself. When this function is called the *pFlags variable should contain
- * the default flags to open the database handle with. The value stored in
- * *pFlags may be updated before returning if the URI filename contains
- * "cache=xxx" or "mode=xxx" query parameters.
- *
- * If successful, SQL_OK is returned. In this case *ppVfs is set to point to
- * the VFS that should be used to open the database file. *pzFile is set to
- * point to a buffer containing the name of the file to open. It is the
- * responsibility of the caller to eventually call sql_free() to release
- * this buffer.
- *
- * If an error occurs, then an sql error code is returned and *pzErrMsg
- * may be set to point to a buffer containing an English language error
- * message. It is the responsibility of the caller to eventually release
- * this buffer by calling sql_free().
- */
-int
-sqlParseUri(const char *zDefaultVfs,	/* VFS to use if no "vfs=xxx" query option */
-		const char *zUri,		/* Nul-terminated URI to parse */
-		unsigned int *pFlags,		/* IN/OUT: SQL_OPEN_XXX flags */
-		sql_vfs ** ppVfs,		/* OUT: VFS to use */
-		char **pzFile,			/* OUT: Filename component of URI */
-		char **pzErrMsg)		/* OUT: Error message (if rc!=SQL_OK) */
-{
-	int rc = SQL_OK;
-	unsigned int flags = *pFlags;
-	const char *zVfs = zDefaultVfs;
-	char *zFile;
-	char c;
-	int nUri = sqlStrlen30(zUri);
-
-	assert(*pzErrMsg == 0);
-
-	if (((flags & SQL_OPEN_URI)	/* IMP: R-48725-32206 */
-	     ||sqlGlobalConfig.bOpenUri)	/* IMP: R-51689-46548 */
-	    &&nUri >= 5 && memcmp(zUri, "file:", 5) == 0	/* IMP: R-57884-37496 */
-	    ) {
-		char *zOpt;
-		int eState;	/* Parser state when parsing URI */
-		int iIn;	/* Input character index */
-		int iOut = 0;	/* Output character index */
-		u64 nByte = nUri + 2;	/* Bytes of space to allocate */
-
-		/* Make sure the SQL_OPEN_URI flag is set to indicate to the VFS xOpen
-		 * method that there may be extra parameters following the file-name.
-		 */
-		flags |= SQL_OPEN_URI;
-
-		for (iIn = 0; iIn < nUri; iIn++)
-			nByte += (zUri[iIn] == '&');
-		zFile = sql_malloc64(nByte);
-		if (!zFile)
-			return SQL_NOMEM;
-
-		iIn = 5;
-#ifdef SQL_ALLOW_URI_AUTHORITY
-		if (strncmp(zUri + 5, "///", 3) == 0) {
-			iIn = 7;
-			/* The following condition causes URIs with five leading / characters
-			 * like file://///host/path to be converted into UNCs like //host/path.
-			 * The correct URI for that UNC has only two or four leading / characters
-			 * file://host/path or file:////host/path.  But 5 leading slashes is a
-			 * common error, we are told, so we handle it as a special case.
-			 */
-			if (strncmp(zUri + 7, "///", 3) == 0) {
-				iIn++;
-			}
-		} else if (strncmp(zUri + 5, "//localhost/", 12) == 0) {
-			iIn = 16;
-		}
-#else
-		/* Discard the scheme and authority segments of the URI. */
-		if (zUri[5] == '/' && zUri[6] == '/') {
-			iIn = 7;
-			while (zUri[iIn] && zUri[iIn] != '/')
-				iIn++;
-			if (iIn != 7
-			    && (iIn != 16
-				|| memcmp("localhost", &zUri[7], 9))) {
-				*pzErrMsg =
-				    sql_mprintf
-				    ("invalid uri authority: %.*s", iIn - 7,
-				     &zUri[7]);
-				rc = SQL_ERROR;
-				goto parse_uri_out;
-			}
-		}
-#endif
-
-		/* Copy the filename and any query parameters into the zFile buffer.
-		 * Decode %HH escape codes along the way.
-		 *
-		 * Within this loop, variable eState may be set to 0, 1 or 2, depending
-		 * on the parsing context. As follows:
-		 *
-		 *   0: Parsing file-name.
-		 *   1: Parsing name section of a name=value query parameter.
-		 *   2: Parsing value section of a name=value query parameter.
-		 */
-		eState = 0;
-		while ((c = zUri[iIn]) != 0 && c != '#') {
-			iIn++;
-			if (c == '%' && sqlIsxdigit(zUri[iIn])
-			    && sqlIsxdigit(zUri[iIn + 1])
-			    ) {
-				int octet = (sqlHexToInt(zUri[iIn++]) << 4);
-				octet += sqlHexToInt(zUri[iIn++]);
-
-				assert(octet >= 0 && octet < 256);
-				if (octet == 0) {
-#ifndef SQL_ENABLE_URI_00_ERROR
-					/* This branch is taken when "%00" appears within the URI. In this
-					 * case we ignore all text in the remainder of the path, name or
-					 * value currently being parsed. So ignore the current character
-					 * and skip to the next "?", "=" or "&", as appropriate.
-					 */
-					while ((c = zUri[iIn]) != 0 && c != '#'
-					       && (eState != 0 || c != '?')
-					       && (eState != 1
-						   || (c != '=' && c != '&'))
-					       && (eState != 2 || c != '&')
-					    ) {
-						iIn++;
-					}
-					continue;
-#else
-					/* If ENABLE_URI_00_ERROR is defined, "%00" in a URI is an error. */
-					*pzErrMsg =
-					    sql_mprintf
-					    ("unexpected %%00 in uri");
-					rc = SQL_ERROR;
-					goto parse_uri_out;
-#endif
-				}
-				c = octet;
-			} else if (eState == 1 && (c == '&' || c == '=')) {
-				if (zFile[iOut - 1] == 0) {
-					/* An empty option name. Ignore this option altogether. */
-					while (zUri[iIn] && zUri[iIn] != '#'
-					       && zUri[iIn - 1] != '&')
-						iIn++;
-					continue;
-				}
-				if (c == '&') {
-					zFile[iOut++] = '\0';
-				} else {
-					eState = 2;
-				}
-				c = 0;
-			} else if ((eState == 0 && c == '?')
-				   || (eState == 2 && c == '&')) {
-				c = 0;
-				eState = 1;
-			}
-			zFile[iOut++] = c;
-		}
-		if (eState == 1)
-			zFile[iOut++] = '\0';
-		zFile[iOut++] = '\0';
-		zFile[iOut++] = '\0';
-
-		/* Check if there were any options specified that should be interpreted
-		 * here. Options that are interpreted here include "vfs" and those that
-		 * correspond to flags that may be passed to the sql_open_v2()
-		 * method.
-		 */
-		zOpt = &zFile[sqlStrlen30(zFile) + 1];
-		while (zOpt[0]) {
-			int nOpt = sqlStrlen30(zOpt);
-			char *zVal = &zOpt[nOpt + 1];
-			unsigned int nVal = sqlStrlen30(zVal);
-
-			if (nOpt == 3 && memcmp("vfs", zOpt, 3) == 0) {
-				zVfs = zVal;
-			} else {
-				struct OpenMode {
-					const char *z;
-					int mode;
-				} *aMode = 0;
-				char *zModeType = 0;
-				int mask = 0;
-				int limit = 0;
-
-				if (nOpt == 5 && memcmp("cache", zOpt, 5) == 0) {
-					static struct OpenMode aCacheMode[] = {
-						{"shared",
-						 SQL_OPEN_SHAREDCACHE},
-						{"private",
-						 SQL_OPEN_PRIVATECACHE},
-						{0, 0}
-					};
-
-					mask =
-					    SQL_OPEN_SHAREDCACHE |
-					    SQL_OPEN_PRIVATECACHE;
-					aMode = aCacheMode;
-					limit = mask;
-					zModeType = "cache";
-				}
-				if (nOpt == 4 && memcmp("mode", zOpt, 4) == 0) {
-					static struct OpenMode aOpenMode[] = {
-						{"ro", SQL_OPEN_READONLY},
-						{"rw", SQL_OPEN_READWRITE},
-						{"rwc",
-						 SQL_OPEN_READWRITE |
-						 SQL_OPEN_CREATE},
-						{"memory", SQL_OPEN_MEMORY},
-						{0, 0}
-					};
-
-					mask =
-					    SQL_OPEN_READONLY |
-					    SQL_OPEN_READWRITE |
-					    SQL_OPEN_CREATE |
-					    SQL_OPEN_MEMORY;
-					aMode = aOpenMode;
-					limit = mask & flags;
-					zModeType = "access";
-				}
-
-				if (aMode) {
-					int i;
-					int mode = 0;
-					for (i = 0; aMode[i].z; i++) {
-						const char *z = aMode[i].z;
-						if (nVal == sqlStrlen30(z)
-						    && 0 == memcmp(zVal, z,
-								   nVal)) {
-							mode = aMode[i].mode;
-							break;
-						}
-					}
-					if (mode == 0) {
-						*pzErrMsg =
-						    sql_mprintf
-						    ("no such %s mode: %s",
-						     zModeType, zVal);
-						rc = SQL_ERROR;
-						goto parse_uri_out;
-					}
-					if ((mode & ~SQL_OPEN_MEMORY) >
-					    limit) {
-						*pzErrMsg =
-						    sql_mprintf
-						    ("%s mode not allowed: %s",
-						     zModeType, zVal);
-						rc = SQL_PERM;
-						goto parse_uri_out;
-					}
-					flags = (flags & ~mask) | mode;
-				}
-			}
-
-			zOpt = &zVal[nVal + 1];
-		}
-
-	} else {
-		zFile = sql_malloc64(nUri + 2);
-		if (!zFile)
-			return SQL_NOMEM;
-		if (nUri) {
-			memcpy(zFile, zUri, nUri);
-		}
-		zFile[nUri] = '\0';
-		zFile[nUri + 1] = '\0';
-		flags &= ~SQL_OPEN_URI;
-	}
-
-	*ppVfs = sql_vfs_find(zVfs);
-	if (*ppVfs == 0) {
-		*pzErrMsg = sql_mprintf("no such vfs: %s", zVfs);
-		rc = SQL_ERROR;
-	}
- parse_uri_out:
-	if (rc != SQL_OK) {
-		sql_free(zFile);
-		zFile = 0;
-	}
-	*pFlags = flags;
-	*pzFile = zFile;
-	return rc;
-}
-
 /**
  * This routine does the work of initialization of main
  * SQL connection instance.
@@ -1449,15 +708,9 @@ sql_init_db(sql **out_db)
 	sql *db;
 	int rc;			/* Return code */
 
-#ifdef SQL_ENABLE_API_ARMOR
-	if (ppDb == 0)
-		return SQL_MISUSE;
-#endif
-#ifndef SQL_OMIT_AUTOINIT
 	rc = sql_initialize();
 	if (rc)
 		return rc;
-#endif
 
 	/* Allocate the sql data structure */
 	db = sqlMallocZero(sizeof(sql));
@@ -1488,54 +741,6 @@ sql_init_db(sql **out_db)
 	sqlRegisterPerConnectionBuiltinFunctions(db);
 	rc = sql_errcode(db);
 
-#ifdef SQL_ENABLE_FTS5
-	/* Register any built-in FTS5 module before loading the automatic
-	 * extensions. This allows automatic extensions to register FTS5
-	 * tokenizers and auxiliary functions.
-	 */
-	if (!db->mallocFailed && rc == SQL_OK) {
-		rc = sqlFts5Init(db);
-	}
-#endif
-
-#ifdef SQL_ENABLE_FTS1
-	if (!db->mallocFailed) {
-		extern int sqlFts1Init(sql *);
-		rc = sqlFts1Init(db);
-	}
-#endif
-
-#ifdef SQL_ENABLE_FTS2
-	if (!db->mallocFailed && rc == SQL_OK) {
-		extern int sqlFts2Init(sql *);
-		rc = sqlFts2Init(db);
-	}
-#endif
-
-#ifdef SQL_ENABLE_FTS3	/* automatically defined by SQL_ENABLE_FTS4 */
-	if (!db->mallocFailed && rc == SQL_OK) {
-		rc = sqlFts3Init(db);
-	}
-#endif
-
-#ifdef SQL_ENABLE_ICU
-	if (!db->mallocFailed && rc == SQL_OK) {
-		rc = sqlIcuInit(db);
-	}
-#endif
-
-#ifdef SQL_ENABLE_RTREE
-	if (!db->mallocFailed && rc == SQL_OK) {
-		rc = sqlRtreeInit(db);
-	}
-#endif
-
-#ifdef SQL_ENABLE_JSON1
-	if (!db->mallocFailed && rc == SQL_OK) {
-		rc = sqlJson1Init(db);
-	}
-#endif
-
 	if (rc)
 		sqlError(db, rc);
 
@@ -1553,322 +758,7 @@ opendb_out:
 		db->magic = SQL_MAGIC_SICK;
 
 	*out_db = db;
-#ifdef SQL_ENABLE_SQLLOG
-	if (sqlGlobalConfig.xSqllog) {
-		/* Opening a db handle. Fourth parameter is passed 0. */
-		void *pArg = sqlGlobalConfig.pSqllogArg;
-		sqlGlobalConfig.xSqllog(pArg, db, zFilename, 0);
-	}
-#endif
-
-	return rc;
-}
-
-/*
- * Enable or disable the extended result codes.
- */
-int
-sql_extended_result_codes(sql * db, int onoff)
-{
-#ifdef SQL_ENABLE_API_ARMOR
-	if (!sqlSafetyCheckOk(db))
-		return SQL_MISUSE;
-#endif
-	db->errMask = onoff ? 0xffffffff : 0xff;
-	return SQL_OK;
-}
-
-/*
- * Interface to the testing logic.
- */
-int
-sql_test_control(int op, ...)
-{
-	int rc = 0;
-#ifdef SQL_UNTESTABLE
-	UNUSED_PARAMETER(op);
-#else
-	va_list ap;
-	va_start(ap, op);
-	switch (op) {
-
-		/*
-		 * Save the current state of the PRNG.
-		 */
-	case SQL_TESTCTRL_PRNG_SAVE:{
-			sqlPrngSaveState();
-			break;
-		}
-
-		/*
-		 * Restore the state of the PRNG to the last state saved using
-		 * PRNG_SAVE.  If PRNG_SAVE has never before been called, then
-		 * this verb acts like PRNG_RESET.
-		 */
-	case SQL_TESTCTRL_PRNG_RESTORE:{
-			sqlPrngRestoreState();
-			break;
-		}
-
-		/*
-		 * Reset the PRNG back to its uninitialized state.  The next call
-		 * to sql_randomness() will reseed the PRNG using a single call
-		 * to the xRandomness method of the default VFS.
-		 */
-	case SQL_TESTCTRL_PRNG_RESET:{
-			sql_randomness(0, 0);
-			break;
-		}
-
-		/*
-		 *  sql_test_control(FAULT_INSTALL, xCallback)
-		 *
-		 * Arrange to invoke xCallback() whenever sqlFaultSim() is called,
-		 * if xCallback is not NULL.
-		 *
-		 * As a test of the fault simulator mechanism itself, sqlFaultSim(0)
-		 * is called immediately after installing the new callback and the return
-		 * value from sqlFaultSim(0) becomes the return from
-		 * sql_test_control().
-		 */
-	case SQL_TESTCTRL_FAULT_INSTALL:{
-			typedef int (*TESTCALLBACKFUNC_t) (int);
-			sqlGlobalConfig.xTestCallback =
-			    va_arg(ap, TESTCALLBACKFUNC_t);
-			rc = sqlFaultSim(0);
-			break;
-		}
-
-		/*
-		 *  sql_test_control(BENIGN_MALLOC_HOOKS, xBegin, xEnd)
-		 *
-		 * Register hooks to call to indicate which malloc() failures
-		 * are benign.
-		 */
-	case SQL_TESTCTRL_BENIGN_MALLOC_HOOKS:{
-			typedef void (*void_function) (void);
-			void_function xBenignBegin;
-			void_function xBenignEnd;
-			xBenignBegin = va_arg(ap, void_function);
-			xBenignEnd = va_arg(ap, void_function);
-			sqlBenignMallocHooks(xBenignBegin, xBenignEnd);
-			break;
-		}
-
-		/*
-		 *  sql_test_control(SQL_TESTCTRL_PENDING_BYTE, unsigned int X)
-		 *
-		 * Set the PENDING byte to the value in the argument, if X>0.
-		 * Make no changes if X==0.  Return the value of the pending byte
-		 * as it existing before this routine was called.
-		 *
-		 * IMPORTANT:  Changing the PENDING byte from 0x40000000 results in
-		 * an incompatible database file format.  Changing the PENDING byte
-		 * while any database connection is open results in undefined and
-		 * deleterious behavior.
-		 */
-	case SQL_TESTCTRL_PENDING_BYTE:{
-			rc = PENDING_BYTE;
-#ifndef SQL_OMIT_WSD
-			{
-				unsigned int newVal = va_arg(ap, unsigned int);
-				if (newVal)
-					sqlPendingByte = newVal;
-			}
-#endif
-			break;
-		}
-
-		/*
-		 *  sql_test_control(SQL_TESTCTRL_ASSERT, int X)
-		 *
-		 * This action provides a run-time test to see whether or not
-		 * assert() was enabled at compile-time.  If X is true and assert()
-		 * is enabled, then the return value is true.  If X is true and
-		 * assert() is disabled, then the return value is zero.  If X is
-		 * false and assert() is enabled, then the assertion fires and the
-		 * process aborts.  If X is false and assert() is disabled, then the
-		 * return value is zero.
-		 */
-	case SQL_TESTCTRL_ASSERT:{
-			volatile int x = 0;
-			assert( /*side-effects-ok */ (x = va_arg(ap, int)) !=
-			       0);
-			rc = x;
-			break;
-		}
-
-		/*
-		 *  sql_test_control(SQL_TESTCTRL_ALWAYS, int X)
-		 *
-		 * This action provides a run-time test to see how the ALWAYS and
-		 * NEVER macros were defined at compile-time.
-		 *
-		 * The return value is ALWAYS(X).
-		 *
-		 * The recommended test is X==2.  If the return value is 2, that means
-		 * ALWAYS() and NEVER() are both no-op pass-through macros, which is the
-		 * default setting.  If the return value is 1, then ALWAYS() is either
-		 * hard-coded to true or else it asserts if its argument is false.
-		 * The first behavior (hard-coded to true) is the case if
-		 * SQL_TESTCTRL_ASSERT shows that assert() is disabled and the second
-		 * behavior (assert if the argument to ALWAYS() is false) is the case if
-		 * SQL_TESTCTRL_ASSERT shows that assert() is enabled.
-		 *
-		 * The run-time test procedure might look something like this:
-		 *
-		 *    if( sql_test_control(SQL_TESTCTRL_ALWAYS, 2)==2 ){
-		 *      // ALWAYS() and NEVER() are no-op pass-through macros
-		 *    }else if( sql_test_control(SQL_TESTCTRL_ASSERT, 1) ){
-		 *      // ALWAYS(x) asserts that x is true. NEVER(x) asserts x is false.
-		 *    }else{
-		 *      // ALWAYS(x) is a constant 1.  NEVER(x) is a constant 0.
-		 *    }
-		 */
-	case SQL_TESTCTRL_ALWAYS:{
-			int x = va_arg(ap, int);
-			rc = ALWAYS(x);
-			break;
-		}
-
-		/*
-		 *   sql_test_control(SQL_TESTCTRL_BYTEORDER);
-		 *
-		 * The integer returned reveals the byte-order of the computer on which
-		 * sql is running:
-		 *
-		 *       1     big-endian,    determined at run-time
-		 *      10     little-endian, determined at run-time
-		 *  432101     big-endian,    determined at compile-time
-		 *  123410     little-endian, determined at compile-time
-		 */
-	case SQL_TESTCTRL_BYTEORDER:{
-			rc = SQL_BYTEORDER * 100 + SQL_LITTLEENDIAN * 10 +
-			    SQL_BIGENDIAN;
-			break;
-		}
-
-		/*  sql_test_control(SQL_TESTCTRL_OPTIMIZATIONS, sql *db, int N)
-		 *
-		 * Enable or disable various optimizations for testing purposes.  The
-		 * argument N is a bitmask of optimizations to be disabled.  For normal
-		 * operation N should be 0.  The idea is that a test program (like the
-		 * SQL Logic Test or SLT test module) can run the same SQL multiple times
-		 * with various optimizations disabled to verify that the same answer
-		 * is obtained in every case.
-		 */
-	case SQL_TESTCTRL_OPTIMIZATIONS:{
-			sql *db = va_arg(ap, sql *);
-			db->dbOptFlags = (u16) (va_arg(ap, int) & 0xffff);
-			break;
-		}
-
-#ifdef SQL_N_KEYWORD
-		/* sql_test_control(SQL_TESTCTRL_ISKEYWORD, const char *zWord)
-		 *
-		 * If zWord is a keyword recognized by the parser, then return the
-		 * number of keywords.  Or if zWord is not a keyword, return 0.
-		 *
-		 * This test feature is only available in the amalgamation since
-		 * the SQL_N_KEYWORD macro is not defined in this file if sql
-		 * is built using separate source files.
-		 */
-	case SQL_TESTCTRL_ISKEYWORD:{
-			const char *zWord = va_arg(ap, const char *);
-			int n = sqlStrlen30(zWord);
-			rc = (sqlKeywordCode((u8 *) zWord, n) !=
-			      TK_ID) ? SQL_N_KEYWORD : 0;
-			break;
-		}
-#endif
 
-		/* sql_test_control(SQL_TESTCTRL_SCRATCHMALLOC, sz, &pNew, pFree);
-		 *
-		 * Pass pFree into sqlScratchFree().
-		 * If sz>0 then allocate a scratch buffer into pNew.
-		 */
-	case SQL_TESTCTRL_SCRATCHMALLOC:{
-			void *pFree, **ppNew;
-			int sz;
-			sz = va_arg(ap, int);
-			ppNew = va_arg(ap, void **);
-			pFree = va_arg(ap, void *);
-			if (sz)
-				*ppNew = sqlScratchMalloc(sz);
-			sqlScratchFree(pFree);
-			break;
-		}
-
-		/*   sql_test_control(SQL_TESTCTRL_LOCALTIME_FAULT, int onoff);
-		 *
-		 * If parameter onoff is non-zero, configure the wrappers so that all
-		 * subsequent calls to localtime() and variants fail. If onoff is zero,
-		 * undo this setting.
-		 */
-	case SQL_TESTCTRL_LOCALTIME_FAULT:{
-			sqlGlobalConfig.bLocaltimeFault = va_arg(ap, int);
-			break;
-		}
-
-		/*   sql_test_control(SQL_TESTCTRL_NEVER_CORRUPT, int);
-		 *
-		 * Set or clear a flag that indicates that the database file is always well-
-		 * formed and never corrupt.  This flag is clear by default, indicating that
-		 * database files might have arbitrary corruption.  Setting the flag during
-		 * testing causes certain assert() statements in the code to be activated
-		 * that demonstrat invariants on well-formed database files.
-		 */
-	case SQL_TESTCTRL_NEVER_CORRUPT:{
-			sqlGlobalConfig.neverCorrupt = va_arg(ap, int);
-			break;
-		}
-
-		/* Set the threshold at which OP_Once counters reset back to zero.
-		 * By default this is 0x7ffffffe (over 2 billion), but that value is
-		 * too big to test in a reasonable amount of time, so this control is
-		 * provided to set a small and easily reachable reset value.
-		 */
-	case SQL_TESTCTRL_ONCE_RESET_THRESHOLD:{
-			sqlGlobalConfig.iOnceResetThreshold =
-			    va_arg(ap, int);
-			break;
-		}
-
-		/*   sql_test_control(SQL_TESTCTRL_VDBE_COVERAGE, xCallback, ptr);
-		 *
-		 * Set the VDBE coverage callback function to xCallback with context
-		 * pointer ptr.
-		 */
-	case SQL_TESTCTRL_VDBE_COVERAGE:{
-#ifdef SQL_VDBE_COVERAGE
-			typedef void (*branch_callback) (void *, int, u8, u8);
-			sqlGlobalConfig.xVdbeBranch =
-			    va_arg(ap, branch_callback);
-			sqlGlobalConfig.pVdbeBranchArg = va_arg(ap, void *);
-#endif
-			break;
-		}
-
-		/*   sql_test_control(SQL_TESTCTRL_SORTER_MMAP, db, nMax); */
-	case SQL_TESTCTRL_SORTER_MMAP:{
-			sql *db = va_arg(ap, sql *);
-			db->nMaxSorterMmap = va_arg(ap, int);
-			break;
-		}
-
-		/*   sql_test_control(SQL_TESTCTRL_ISINIT);
-		 *
-		 * Return SQL_OK if sql has been initialized and SQL_ERROR if
-		 * not.
-		 */
-	case SQL_TESTCTRL_ISINIT:{
-			if (sqlGlobalConfig.isInit == 0)
-				rc = SQL_ERROR;
-			break;
-		}
-	}
-	va_end(ap);
-#endif				/* SQL_UNTESTABLE */
 	return rc;
 }
 
@@ -1898,75 +788,3 @@ sql_uri_parameter(const char *zFilename, const char *zParam)
 	}
 	return 0;
 }
-
-/*
- * Return a boolean value for a query parameter.
- */
-int
-sql_uri_boolean(const char *zFilename, const char *zParam, int bDflt)
-{
-	const char *z = sql_uri_parameter(zFilename, zParam);
-	bDflt = bDflt != 0;
-	return z ? sqlGetBoolean(z, bDflt) : bDflt;
-}
-
-/*
- * Return a 64-bit integer value for a query parameter.
- */
-sql_int64
-sql_uri_int64(const char *zFilename,	/* Filename as passed to xOpen */
-		  const char *zParam,	/* URI parameter sought */
-		  sql_int64 bDflt)	/* return if parameter is missing */
-{
-	const char *z = sql_uri_parameter(zFilename, zParam);
-	int64_t v;
-	if (z != NULL && sql_dec_or_hex_to_i64(z, &v) == 0)
-		bDflt = v;
-	return bDflt;
-}
-
-
-#ifdef SQL_ENABLE_SNAPSHOT
-/*
- * Obtain a snapshot handle for the snapshot of database zDb currently
- * being read by handle db.
- */
-int
-sql_snapshot_get(sql * db,
-		     const char *zDb, sql_snapshot ** ppSnapshot)
-{
-	int rc = SQL_ERROR;
-	return rc;
-}
-
-/*
- * Open a read-transaction on the snapshot idendified by pSnapshot.
- */
-int
-sql_snapshot_open(sql * db,
-		      const char *zDb, sql_snapshot * pSnapshot)
-{
-	int rc = SQL_ERROR;
-	return rc;
-}
-
-/*
- * Recover as many snapshots as possible from the wal file associated with
- * schema zDb of database db.
- */
-int
-sql_snapshot_recover(sql * db, const char *zDb)
-{
-	int rc = SQL_ERROR;
-	return rc;
-}
-
-/*
- * Free a snapshot handle obtained from sql_snapshot_get().
- */
-void
-sql_snapshot_free(sql_snapshot * pSnapshot)
-{
-	sql_free(pSnapshot);
-}
-#endif				/* SQL_ENABLE_SNAPSHOT */
diff --git a/src/box/sql/malloc.c b/src/box/sql/malloc.c
index dc018fc..d6f99b4 100644
--- a/src/box/sql/malloc.c
+++ b/src/box/sql/malloc.c
@@ -185,11 +185,6 @@ sql_soft_heap_limit64(sql_int64 n)
 	sql_int64 priorLimit;
 	sql_int64 excess;
 	sql_int64 nUsed;
-#ifndef SQL_OMIT_AUTOINIT
-	int rc = sql_initialize();
-	if (rc)
-		return -1;
-#endif
 	priorLimit = mem0.alarmThreshold;
 	if (n < 0) {
 		return priorLimit;
@@ -372,20 +367,12 @@ sqlMalloc(u64 n)
 void *
 sql_malloc(int n)
 {
-#ifndef SQL_OMIT_AUTOINIT
-	if (sql_initialize())
-		return 0;
-#endif
 	return n <= 0 ? 0 : sqlMalloc(n);
 }
 
 void *
 sql_malloc64(sql_uint64 n)
 {
-#ifndef SQL_OMIT_AUTOINIT
-	if (sql_initialize())
-		return 0;
-#endif
 	return sqlMalloc(n);
 }
 
@@ -661,10 +648,6 @@ sqlRealloc(void *pOld, u64 nBytes)
 void *
 sql_realloc(void *pOld, int n)
 {
-#ifndef SQL_OMIT_AUTOINIT
-	if (sql_initialize())
-		return 0;
-#endif
 	if (n < 0)
 		n = 0;		/* IMP: R-26507-47431 */
 	return sqlRealloc(pOld, n);
@@ -673,10 +656,6 @@ sql_realloc(void *pOld, int n)
 void *
 sql_realloc64(void *pOld, sql_uint64 n)
 {
-#ifndef SQL_OMIT_AUTOINIT
-	if (sql_initialize())
-		return 0;
-#endif
 	return sqlRealloc(pOld, n);
 }
 
diff --git a/src/box/sql/os.c b/src/box/sql/os.c
index 76a15ed..eb7450b 100644
--- a/src/box/sql/os.c
+++ b/src/box/sql/os.c
@@ -213,11 +213,6 @@ sql_vfs *
 sql_vfs_find(const char *zVfs)
 {
 	sql_vfs *pVfs = 0;
-#ifndef SQL_OMIT_AUTOINIT
-	int rc = sql_initialize();
-	if (rc)
-		return 0;
-#endif
 	for (pVfs = vfsList; pVfs; pVfs = pVfs->pNext) {
 		if (zVfs == 0)
 			break;
@@ -256,15 +251,6 @@ vfsUnlink(sql_vfs * pVfs)
 int
 sql_vfs_register(sql_vfs * pVfs, int makeDflt)
 {
-#ifndef SQL_OMIT_AUTOINIT
-	int rc = sql_initialize();
-	if (rc)
-		return rc;
-#endif
-#ifdef SQL_ENABLE_API_ARMOR
-	if (pVfs == 0)
-		return SQL_MISUSE;
-#endif
 
 	vfsUnlink(pVfs);
 	if (makeDflt || vfsList == 0) {
diff --git a/src/box/sql/os_unix.c b/src/box/sql/os_unix.c
index b659985..615d539 100644
--- a/src/box/sql/os_unix.c
+++ b/src/box/sql/os_unix.c
@@ -1693,11 +1693,6 @@ getFileMode(const char *zFile,	/* File name */
  * corresponding database file and sets *pMode to this value. Whenever
  * possible, journal files are created using the same permissions
  * as the associated database file.
- *
- * If the SQL_ENABLE_8_3_NAMES option is enabled, then the
- * original filename is unavailable.  But 8_3_NAMES is only used for
- * FAT filesystems and permissions do not matter there, so just use
- * the default permissions.
  */
 static int
 findCreateFileMode(const char *zPath,	/* Path of file (possibly) being created */
diff --git a/src/box/sql/prepare.c b/src/box/sql/prepare.c
index 4ae6c13..3df6b5c 100644
--- a/src/box/sql/prepare.c
+++ b/src/box/sql/prepare.c
@@ -194,10 +194,6 @@ sqlLockAndPrepare(sql * db,		/* Database handle. */
 {
 	int rc;
 
-#ifdef SQL_ENABLE_API_ARMOR
-	if (ppStmt == 0)
-		return SQL_MISUSE;
-#endif
 	*ppStmt = 0;
 	if (!sqlSafetyCheckOk(db) || zSql == 0) {
 		return SQL_MISUSE;
diff --git a/src/box/sql/printf.c b/src/box/sql/printf.c
index 592f906..31d21db 100644
--- a/src/box/sql/printf.c
+++ b/src/box/sql/printf.c
@@ -80,12 +80,10 @@ static const et_info fmtinfo[] = {
 	{'u', 10, 0, etRADIX, 0, 0},
 	{'x', 16, 0, etRADIX, 16, 1},
 	{'X', 16, 0, etRADIX, 0, 4},
-#ifndef SQL_OMIT_FLOATING_POINT
 	{'f', 0, 1, etFLOAT, 0, 0},
 	{'e', 0, 1, etEXP, 30, 0},
 	{'E', 0, 1, etEXP, 14, 0},
 	{'G', 0, 1, etGENERIC, 14, 0},
-#endif
 	{'i', 10, 1, etRADIX, 0, 0},
 	{'n', 0, 0, etSIZE, 0, 0},
 	{'%', 0, 0, etPERCENT, 0, 0},
@@ -99,11 +97,6 @@ static const et_info fmtinfo[] = {
 };
 
 /*
- * If SQL_OMIT_FLOATING_POINT is defined, then none of the floating point
- * conversions will work.
- */
-#ifndef SQL_OMIT_FLOATING_POINT
-/*
  * "*val" is a double such that 0.1 <= *val < 10.0
  * Return the ascii code for the leading digit of *val, then
  * multiply "*val" by 10.0 to renormalize.
@@ -130,7 +123,6 @@ et_getdigit(LONGDOUBLE_TYPE * val, int *cnt)
 	*val = (*val - d) * 10.0;
 	return (char)digit;
 }
-#endif				/* SQL_OMIT_FLOATING_POINT */
 
 /*
  * Set the StrAccum object to an error mode.
@@ -213,13 +205,11 @@ sqlVXPrintf(StrAccum * pAccum,	/* Accumulate results here */
 	char *zOut;		/* Rendering buffer */
 	int nOut;		/* Size of the rendering buffer */
 	char *zExtra = 0;	/* Malloced memory used by some conversion */
-#ifndef SQL_OMIT_FLOATING_POINT
 	int exp, e2;		/* exponent of real numbers */
 	int nsd;		/* Number of significant digits returned */
 	double rounder;		/* Used for rounding floating point values */
 	etByte flag_dp;		/* True if decimal point should be shown */
 	etByte flag_rtz;	/* True if trailing zeros should be removed */
-#endif
 	PrintfArguments *pArgList = 0;	/* Arguments for SQL_PRINTF_SQLFUNC */
 	char buf[etBUFSIZE];	/* Conversion buffer */
 
@@ -499,9 +489,6 @@ sqlVXPrintf(StrAccum * pAccum,	/* Accumulate results here */
 			} else {
 				realvalue = va_arg(ap, double);
 			}
-#ifdef SQL_OMIT_FLOATING_POINT
-			length = 0;
-#else
 			if (precision < 0)
 				precision = 6;	/* Set default precision */
 			if (realvalue < 0.0) {
@@ -682,7 +669,6 @@ sqlVXPrintf(StrAccum * pAccum,	/* Accumulate results here */
 					bufpt[i++] = '0';
 				length = width;
 			}
-#endif				/* !defined(SQL_OMIT_FLOATING_POINT) */
 			break;
 		case etSIZE:
 			if (!bArgList) {
@@ -1082,16 +1068,6 @@ sql_vmprintf(const char *zFormat, va_list ap)
 	char *z;
 	char zBase[SQL_PRINT_BUF_SIZE];
 	StrAccum acc;
-
-#ifdef SQL_ENABLE_API_ARMOR
-	if (zFormat == 0) {
-		return 0;
-	}
-#endif
-#ifndef SQL_OMIT_AUTOINIT
-	if (sql_initialize())
-		return 0;
-#endif
 	sqlStrAccumInit(&acc, 0, zBase, sizeof(zBase), SQL_MAX_LENGTH);
 	sqlVXPrintf(&acc, zFormat, ap);
 	z = sqlStrAccumFinish(&acc);
@@ -1107,10 +1083,6 @@ sql_mprintf(const char *zFormat, ...)
 {
 	va_list ap;
 	char *z;
-#ifndef SQL_OMIT_AUTOINIT
-	if (sql_initialize())
-		return 0;
-#endif
 	va_start(ap, zFormat);
 	z = sql_vmprintf(zFormat, ap);
 	va_end(ap);
@@ -1136,13 +1108,6 @@ sql_vsnprintf(int n, char *zBuf, const char *zFormat, va_list ap)
 	StrAccum acc;
 	if (n <= 0)
 		return zBuf;
-#ifdef SQL_ENABLE_API_ARMOR
-	if (zBuf == 0 || zFormat == 0) {
-		if (zBuf)
-			zBuf[0] = 0;
-		return zBuf;
-	}
-#endif
 	sqlStrAccumInit(&acc, 0, zBuf, n, 0);
 	sqlVXPrintf(&acc, zFormat, ap);
 	zBuf[acc.nChar] = 0;
diff --git a/src/box/sql/random.c b/src/box/sql/random.c
index fe98e55..9e1122b 100644
--- a/src/box/sql/random.c
+++ b/src/box/sql/random.c
@@ -62,18 +62,7 @@ sql_randomness(int N, void *pBuf)
 	 * case where writable static data is supported, wsdPrng can refer directly
 	 * to the "sqlPrng" state vector declared above.
 	 */
-#ifdef SQL_OMIT_WSD
-	struct sqlPrngType *p =
-	    &GLOBAL(struct sqlPrngType, sqlPrng);
-#define wsdPrng p[0]
-#else
 #define wsdPrng sqlPrng
-#endif
-
-#ifndef SQL_OMIT_AUTOINIT
-	if (sql_initialize())
-		return;
-#endif
 
 	if (N <= 0 || pBuf == 0) {
 		wsdPrng.isInit = 0;
@@ -125,9 +114,6 @@ sql_randomness(int N, void *pBuf)
  * PRNG and restore the PRNG to its saved state at a later time, or
  * to reset the PRNG to its initial state.  These routines accomplish
  * those tasks.
- *
- * The sql_test_control() interface calls these routines to
- * control the PRNG.
  */
 static SQL_WSD struct sqlPrngType sqlSavedPrng;
 void
diff --git a/src/box/sql/select.c b/src/box/sql/select.c
index b1ec8c7..e0ed5db 100644
--- a/src/box/sql/select.c
+++ b/src/box/sql/select.c
@@ -5659,8 +5659,6 @@ sqlSelect(Parse * pParse,		/* The parser context */
 		 *   (2)  The ALL keyword after SELECT is omitted.  (Applications are
 		 *        allowed to say "SELECT ALL" instead of just "SELECT" to disable
 		 *        the use of co-routines.)
-		 *   (3)  Co-routines are not disabled using sql_test_control()
-		 *        with SQL_TESTCTRL_OPTIMIZATIONS.
 		 *
 		 * TODO: Are there other reasons beside (1) to use a co-routine
 		 * implementation?
diff --git a/src/box/sql/sqlInt.h b/src/box/sql/sqlInt.h
index b322602..828ab83 100644
--- a/src/box/sql/sqlInt.h
+++ b/src/box/sql/sqlInt.h
@@ -682,9 +682,6 @@ sql_column_name(sql_stmt *, int N);
 const char *
 sql_column_datatype(sql_stmt *, int N);
 
-const char *
-sql_errmsg(sql *);
-
 int
 sql_initialize(void);
 
@@ -791,9 +788,6 @@ sql_status64(int op, sql_int64 * pCurrent,
 		 sql_int64 * pHighwater,
 		 int resetFlag);
 
-int
-sql_config(int, ...);
-
 
 typedef struct sql_io_methods sql_io_methods;
 struct sql_io_methods {
@@ -843,10 +837,6 @@ sql_limit(sql *, int id, int newVal);
 #define SQL_SYNC_FULL          0x00003
 #define SQL_SYNC_DATAONLY      0x00010
 
-int
-sql_uri_boolean(const char *zFile,
-		    const char *zParam, int bDefault);
-
 extern char *
 sql_temp_directory;
 
@@ -883,9 +873,6 @@ sql_vfs_register(sql_vfs *, int makeDflt);
 #define SQL_STMTSTATUS_AUTOINDEX         3
 #define SQL_STMTSTATUS_VM_STEP           4
 
-void
-sql_interrupt(sql *);
-
 int
 sql_bind_blob(sql_stmt *, int, const void *,
 		  int n, void (*)(void *));
@@ -952,18 +939,6 @@ sql_bind_parameter_lindex(sql_stmt * pStmt, const char *zName,
  * If compiling for a processor that lacks floating point support,
  * substitute integer for floating-point
  */
-#ifdef SQL_OMIT_FLOATING_POINT
-#define double sql_int64
-#define float sql_int64
-#define LONGDOUBLE_TYPE sql_int64
-#ifndef SQL_BIG_DBL
-#define SQL_BIG_DBL (((sql_int64)1)<<50)
-#endif
-#define SQL_OMIT_DATETIME_FUNCS 1
-#define SQL_OMIT_TRACE 1
-#undef SQL_MIXED_ENDIAN_64BIT_FLOAT
-#undef SQL_HAVE_ISNAN
-#endif
 #ifndef SQL_BIG_DBL
 #define SQL_BIG_DBL (1e99)
 #endif
@@ -1308,30 +1283,13 @@ extern const int sqlone;
 #define SQL_DYNAMIC   ((sql_destructor_type)sqlMallocSize)
 
 /*
- * When sql_OMIT_WSD is defined, it means that the target platform does
- * not support Writable Static Data (WSD) such as global and static variables.
- * All variables must either be on the stack or dynamically allocated from
- * the heap.  When WSD is unsupported, the variable declarations scattered
- * throughout the sql code must become constants instead.  The sql_WSD
- * macro is used for this purpose.  And instead of referencing the variable
- * directly, we use its constant as a key to lookup the run-time allocated
- * buffer that holds real variable.  The constant is also the initializer
- * for the run-time allocated buffer.
- *
- * In the usual case where WSD is supported, the sql_WSD and GLOBAL
- * macros become no-ops and have zero performance impact.
- */
-#ifdef SQL_OMIT_WSD
-#define SQL_WSD const
-#define GLOBAL(t,v) (*(t*)sql_wsd_find((void*)&(v), sizeof(v)))
-#define sqlGlobalConfig GLOBAL(struct sqlConfig, sqlConfig)
-int sql_wsd_init(int N, int J);
-void *sql_wsd_find(void *K, int L);
-#else
+ * The usual case where Writable Static Data (WSD) is supported,
+ * the sql_WSD and GLOBAL macros become no-ops and have zero
+ * performance impact.
+ */
 #define SQL_WSD
 #define GLOBAL(t,v) v
 #define sqlGlobalConfig sqlConfig
-#endif
 
 /*
  * The following macros are used to suppress compiler warnings and to
@@ -1543,11 +1501,7 @@ struct sql {
 #define SQL_DeferFKs       0x02000000	/* Defer all FK constraints */
 #define SQL_VdbeEQP        0x08000000	/* Debug EXPLAIN QUERY PLAN */
 
-/*
- * Bits of the sql.dbOptFlags field that are used by the
- * sql_test_control(sql_TESTCTRL_OPTIMIZATIONS,...) interface to
- * selectively disable various optimizations.
- */
+/* Bits of the sql.dbOptFlags field. */
 #define SQL_QueryFlattener 0x0001	/* Query flattening */
 #define SQL_ColumnCache    0x0002	/* Column cache */
 #define SQL_GroupByOrder   0x0004	/* GROUPBY cover of ORDERBY */
@@ -2937,10 +2891,6 @@ struct sqlConfig {
 	int isMallocInit;	/* True after malloc is initialized */
 	void (*xLog) (void *, int, const char *);	/* Function for logging */
 	void *pLogArg;		/* First argument to xLog() */
-#ifdef SQL_ENABLE_SQLLOG
-	void (*xSqllog) (void *, sql *, const char *, int);
-	void *pSqllogArg;
-#endif
 #ifdef SQL_VDBE_COVERAGE
 	/* The following callback (if not NULL) is invoked on every VDBE branch
 	 * operation.  Set the callback using sql_TESTCTRL_VDBE_COVERAGE.
@@ -2956,24 +2906,6 @@ struct sqlConfig {
 };
 
 /*
- * This macro is used inside of assert() statements to indicate that
- * the assert is only valid on a well-formed database.  Instead of:
- *
- *     assert( X );
- *
- * One writes:
- *
- *     assert( X || CORRUPT_DB );
- *
- * CORRUPT_DB is true during normal operation.  CORRUPT_DB does not indicate
- * that the database is definitely corrupt, only that it might be corrupt.
- * For most test cases, CORRUPT_DB is set to false using a special
- * sql_test_control().  This enables assert() statements to prove
- * things that are always true for well-formed databases.
- */
-#define CORRUPT_DB  (sqlConfig.neverCorrupt==0)
-
-/*
  * Context pointer passed down through the tree-walk.
  */
 struct Walker {
@@ -3048,15 +2980,6 @@ struct TreeView {
 }
 
 /*
- * FTS4 is really an extension for FTS3.  It is enabled using the
- * sql_ENABLE_FTS3 macro.  But to avoid confusion we also call
- * the sql_ENABLE_FTS4 macro to serve as an alias for sql_ENABLE_FTS3.
- */
-#if defined(SQL_ENABLE_FTS4) && !defined(SQL_ENABLE_FTS3)
-#define SQL_ENABLE_FTS3 1
-#endif
-
-/*
  * The following macros mimic the standard library functions toupper(),
  * isspace(), isalnum(), isdigit() and isxdigit(), respectively. The
  * sql versions only work for ASCII characters, regardless of locale.
@@ -3125,11 +3048,7 @@ void sqlStatusUp(int, int);
 void sqlStatusDown(int, int);
 void sqlStatusHighwater(int, int);
 
-#ifndef SQL_OMIT_FLOATING_POINT
 int sqlIsNaN(double);
-#else
-#define sqlIsNaN(X)  0
-#endif
 
 /*
  * An instance of the following structure holds information about SQL
@@ -3440,9 +3359,6 @@ int
 vdbe_emit_open_cursor(struct Parse *parse, int cursor, int index_id,
 		      struct space *space);
 
-int sqlParseUri(const char *, const char *, unsigned int *,
-		    sql_vfs **, char **, char **);
-
 #ifdef SQL_UNTESTABLE
 #define sqlFaultSim(X) SQL_OK
 #else
@@ -4553,11 +4469,6 @@ int sqlAddInt64(i64 *, i64);
 int sqlSubInt64(i64 *, i64);
 int sqlMulInt64(i64 *, i64);
 int sqlAbsInt32(int);
-#ifdef SQL_ENABLE_8_3_NAMES
-void sqlFileSuffix3(const char *, char *);
-#else
-#define sqlFileSuffix3(X,Y)
-#endif
 u8 sqlGetBoolean(const char *z, u8);
 
 const void *sqlValueText(sql_value *);
@@ -4578,10 +4489,8 @@ extern const unsigned char sqlCtypeMap[];
 extern const Token sqlIntTokens[];
 extern SQL_WSD struct sqlConfig sqlConfig;
 extern FuncDefHash sqlBuiltinFunctions;
-#ifndef SQL_OMIT_WSD
 extern int sqlPendingByte;
 #endif
-#endif
 
 /**
  * Generate code to implement the "ALTER TABLE xxx RENAME TO yyy"
diff --git a/src/box/sql/status.c b/src/box/sql/status.c
index 2abf7a5..bc170c8 100644
--- a/src/box/sql/status.c
+++ b/src/box/sql/status.c
@@ -54,18 +54,12 @@ static SQL_WSD struct sqlStatType {
 
 
 /* The "wsdStat" macro will resolve to the status information
- * state vector.  If writable static data is unsupported on the target,
- * we have to locate the state vector at run-time.  In the more common
- * case where writable static data is supported, wsdStat can refer directly
- * to the "sqlStat" state vector declared above.
+ * state vector. In the common case where writable static data is
+ * supported, wsdStat can refer directly  to the "sqlStat" state
+ * vector declared above.
  */
-#ifdef SQL_OMIT_WSD
-#define wsdStatInit  sqlStatType *x = &GLOBAL(sqlStatType,sqlStat)
-#define wsdStat x[0]
-#else
 #define wsdStatInit
 #define wsdStat sqlStat
-#endif
 
 /*
  * Return the current value of a status parameter.
@@ -144,10 +138,6 @@ sql_status64(int op,
 	if (op < 0 || op >= ArraySize(wsdStat.nowValue)) {
 		return SQL_MISUSE;
 	}
-#ifdef SQL_ENABLE_API_ARMOR
-	if (pCurrent == 0 || pHighwater == 0)
-		return SQL_MISUSE;
-#endif
 	*pCurrent = wsdStat.nowValue[op];
 	*pHighwater = wsdStat.mxValue[op];
 	if (resetFlag) {
@@ -161,10 +151,6 @@ sql_status(int op, int *pCurrent, int *pHighwater, int resetFlag)
 {
 	sql_int64 iCur = 0, iHwtr = 0;
 	int rc;
-#ifdef SQL_ENABLE_API_ARMOR
-	if (pCurrent == 0 || pHighwater == 0)
-		return SQL_MISUSE;
-#endif
 	rc = sql_status64(op, &iCur, &iHwtr, resetFlag);
 	if (rc == 0) {
 		*pCurrent = (int)iCur;
@@ -185,11 +171,6 @@ sql_db_status(sql * db,	/* The database connection whose status is desired */
     )
 {
 	int rc = SQL_OK;	/* Return code */
-#ifdef SQL_ENABLE_API_ARMOR
-	if (!sqlSafetyCheckOk(db) || pCurrent == 0 || pHighwater == 0) {
-		return SQL_MISUSE;
-	}
-#endif
 	switch (op) {
 	case SQL_DBSTATUS_LOOKASIDE_USED:{
 			*pCurrent = db->lookaside.nOut;
diff --git a/src/box/sql/treeview.c b/src/box/sql/treeview.c
index 1fd8668..5acea58 100644
--- a/src/box/sql/treeview.c
+++ b/src/box/sql/treeview.c
@@ -349,12 +349,10 @@ sqlTreeViewExpr(TreeView * pView, const Expr * pExpr, u8 moreToFollow)
 			}
 			break;
 		}
-#ifndef SQL_OMIT_FLOATING_POINT
 	case TK_FLOAT:{
 			sqlTreeViewLine(pView, "%s", pExpr->u.zToken);
 			break;
 		}
-#endif
 	case TK_STRING:{
 			sqlTreeViewLine(pView, "%Q", pExpr->u.zToken);
 			break;
diff --git a/src/box/sql/update.c b/src/box/sql/update.c
index aeaa863..35c0019 100644
--- a/src/box/sql/update.c
+++ b/src/box/sql/update.c
@@ -58,11 +58,9 @@ sqlColumnDefault(Vdbe *v, struct space_def *def, int i, int ireg)
 		if (pValue) {
 			sqlVdbeAppendP4(v, pValue, P4_MEM);
 		}
-#ifndef SQL_OMIT_FLOATING_POINT
 		if (type == FIELD_TYPE_NUMBER) {
 			sqlVdbeAddOp1(v, OP_Realify, ireg);
 		}
-#endif
 	}
 }
 
diff --git a/src/box/sql/util.c b/src/box/sql/util.c
index 52a8663..d5c93f8 100644
--- a/src/box/sql/util.c
+++ b/src/box/sql/util.c
@@ -77,7 +77,6 @@ int
 }
 #endif
 
-#ifndef SQL_OMIT_FLOATING_POINT
 /*
  * Return true if the floating point value is Not a Number (NaN).
  *
@@ -114,7 +113,6 @@ sqlIsNaN(double x)
 	testcase(rc);
 	return rc;
 }
-#endif				/* SQL_OMIT_FLOATING_POINT */
 
 /*
  * Compute a string length that is limited to what can be stored in
@@ -413,7 +411,6 @@ sql_strnicmp(const char *zLeft, const char *zRight, int N)
 int
 sqlAtoF(const char *z, double *pResult, int length)
 {
-#ifndef SQL_OMIT_FLOATING_POINT
 	int incr = 1; // UTF-8
 	const char *zEnd = z + length;
 	/* sign * significand * (10 ^ (esign * exponent)) */
@@ -594,9 +591,6 @@ sqlAtoF(const char *z, double *pResult, int length)
 
 	/* return true if number and no extra non-whitespace chracters after */
 	return z == zEnd && nDigits > 0 && eValid && nonNum == 0;
-#else
-	return !sqlAtoi64(z, pResult, length);
-#endif				/* SQL_OMIT_FLOATING_POINT */
 }
 
 /*
@@ -1363,41 +1357,6 @@ sqlAbsInt32(int x)
 	return -x;
 }
 
-#ifdef SQL_ENABLE_8_3_NAMES
-/*
- * If SQL_ENABLE_8_3_NAMES is set at compile-time and if the database
- * filename in zBaseFilename is a URI with the "8_3_names=1" parameter and
- * if filename in z[] has a suffix (a.k.a. "extension") that is longer than
- * three characters, then shorten the suffix on z[] to be the last three
- * characters of the original suffix.
- *
- * If SQL_ENABLE_8_3_NAMES is set to 2 at compile-time, then always
- * do the suffix shortening regardless of URI parameter.
- *
- * Examples:
- *
- *     test.db-journal    =>   test.nal
- *     test.db-wal        =>   test.wal
- *     test.db-shm        =>   test.shm
- *     test.db-mj7f3319fa =>   test.9fa
- */
-void
-sqlFileSuffix3(const char *zBaseFilename, char *z)
-{
-#if SQL_ENABLE_8_3_NAMES<2
-	if (sql_uri_boolean(zBaseFilename, "8_3_names", 0))
-#endif
-	{
-		int i, sz;
-		sz = sqlStrlen30(z);
-		for (i = sz - 1; i > 0 && z[i] != '/' && z[i] != '.'; i--) {
-		}
-		if (z[i] == '.' && ALWAYS(sz > i + 4))
-			memmove(&z[i + 1], &z[sz - 3], 4);
-	}
-}
-#endif
-
 /*
  * Find (an approximate) sum of two LogEst values.  This computation is
  * not a simple "+" operator because LogEst is stored as a logarithmic
diff --git a/src/box/sql/vdbe.c b/src/box/sql/vdbe.c
index ed7bf88..d452892 100644
--- a/src/box/sql/vdbe.c
+++ b/src/box/sql/vdbe.c
@@ -530,10 +530,8 @@ memTracePrint(Mem *p)
 		printf(" si:%lld", p->u.i);
 	} else if (p->flags & MEM_Int) {
 		printf(" i:%lld", p->u.i);
-#ifndef SQL_OMIT_FLOATING_POINT
 	} else if (p->flags & MEM_Real) {
 		printf(" r:%g", p->u.r);
-#endif
 	} else {
 		char zBuf[200];
 		sqlVdbeMemPrettyPrint(p, zBuf);
@@ -745,18 +743,6 @@ int sqlVdbeExec(Vdbe *p)
 #endif
 
 
-		/* Check to see if we need to simulate an interrupt.  This only happens
-		 * if we have a special test build.
-		 */
-#ifdef SQL_TEST
-		if (sql_interrupt_count>0) {
-			sql_interrupt_count--;
-			if (sql_interrupt_count==0) {
-				sql_interrupt(db);
-			}
-		}
-#endif
-
 		/* Sanity checking on other operands */
 #ifdef SQL_DEBUG
 		{
@@ -1140,7 +1126,6 @@ case OP_Int64: {           /* out2 */
 	break;
 }
 
-#ifndef SQL_OMIT_FLOATING_POINT
 /* Opcode: Real * P2 * P4 *
  * Synopsis: r[P2]=P4
  *
@@ -1154,7 +1139,6 @@ case OP_Real: {            /* same as TK_FLOAT, out2 */
 	pOut->u.r = *pOp->p4.pReal;
 	break;
 }
-#endif
 
 /* Opcode: String8 * P2 * P4 *
  * Synopsis: r[P2]='P4'
@@ -1692,7 +1676,6 @@ case OP_Remainder: {           /* same as TK_REM, in1, in2, out3 */
 		case OP_Subtract:    rB -= rA;       break;
 		case OP_Multiply:    rB *= rA;       break;
 		case OP_Divide: {
-			/* (double)0 In case of SQL_OMIT_FLOATING_POINT... */
 			if (rA == (double)0)
 				goto division_by_zero;
 			rB /= rA;
@@ -1708,10 +1691,6 @@ case OP_Remainder: {           /* same as TK_REM, in1, in2, out3 */
 			break;
 		}
 		}
-#ifdef SQL_OMIT_FLOATING_POINT
-		pOut->u.i = rB;
-		MemSetTypeFlag(pOut, MEM_Int);
-#else
 		if (sqlIsNaN(rB)) {
 			goto arithmetic_result_is_null;
 		}
@@ -1720,7 +1699,6 @@ case OP_Remainder: {           /* same as TK_REM, in1, in2, out3 */
 		if (((type1|type2)&MEM_Real)==0 && !bIntint) {
 			mem_apply_integer_type(pOut);
 		}
-#endif
 	}
 	break;
 
@@ -2006,7 +1984,6 @@ case OP_MustBeInt: {            /* jump, in1 */
 	break;
 }
 
-#ifndef SQL_OMIT_FLOATING_POINT
 /* Opcode: Realify P1 * * * *
  *
  * If register P1 holds an integer convert it to a real value.
@@ -2023,7 +2000,6 @@ case OP_Realify: {                  /* in1 */
 	}
 	break;
 }
-#endif
 
 #ifndef SQL_OMIT_CAST
 /* Opcode: Cast P1 P2 * * *
diff --git a/src/box/sql/vdbeInt.h b/src/box/sql/vdbeInt.h
index c84f22c..577b022 100644
--- a/src/box/sql/vdbeInt.h
+++ b/src/box/sql/vdbeInt.h
@@ -481,11 +481,7 @@ void sqlVdbeMemMove(Mem *, Mem *);
 int sqlVdbeMemNulTerminate(Mem *);
 int sqlVdbeMemSetStr(Mem *, const char *, int, u8, void (*)(void *));
 void sqlVdbeMemSetInt64(Mem *, i64);
-#ifdef SQL_OMIT_FLOATING_POINT
-#define sqlVdbeMemSetDouble sqlVdbeMemSetInt64
-#else
 void sqlVdbeMemSetDouble(Mem *, double);
-#endif
 void sqlVdbeMemInit(Mem *, sql *, u32);
 void sqlVdbeMemSetNull(Mem *);
 void sqlVdbeMemSetZeroBlob(Mem *, int);
diff --git a/src/box/sql/vdbeapi.c b/src/box/sql/vdbeapi.c
index be5c9df..e6219e2 100644
--- a/src/box/sql/vdbeapi.c
+++ b/src/box/sql/vdbeapi.c
@@ -1074,11 +1074,6 @@ columnName(sql_stmt * pStmt,
 	Vdbe *p;
 	int n;
 	sql *db;
-#ifdef SQL_ENABLE_API_ARMOR
-	if (pStmt == 0) {
-		return 0;
-	}
-#endif
 	ret = 0;
 	p = (Vdbe *) pStmt;
 	db = p->db;
@@ -1576,11 +1571,6 @@ sql_stmt *
 sql_next_stmt(sql * pDb, sql_stmt * pStmt)
 {
 	sql_stmt *pNext;
-#ifdef SQL_ENABLE_API_ARMOR
-	if (!sqlSafetyCheckOk(pDb)) {
-		return 0;
-	}
-#endif
 	if (pStmt == 0) {
 		pNext = (sql_stmt *) pDb->pVdbe;
 	} else {
@@ -1597,11 +1587,6 @@ sql_stmt_status(sql_stmt * pStmt, int op, int resetFlag)
 {
 	Vdbe *pVdbe = (Vdbe *) pStmt;
 	u32 v;
-#ifdef SQL_ENABLE_API_ARMOR
-	if (!pStmt) {
-		return 0;
-	}
-#endif
 	v = pVdbe->aCounter[op];
 	if (resetFlag)
 		pVdbe->aCounter[op] = 0;
diff --git a/src/box/sql/vdbeaux.c b/src/box/sql/vdbeaux.c
index 0cc3c14..136c14e 100644
--- a/src/box/sql/vdbeaux.c
+++ b/src/box/sql/vdbeaux.c
@@ -136,7 +136,7 @@ sqlVdbeSetSql(Vdbe * p, const char *z, int n, int isPrepareV2)
 	assert(isPrepareV2 == 1 || isPrepareV2 == 0);
 	if (p == 0)
 		return;
-#if defined(SQL_OMIT_TRACE) && !defined(SQL_ENABLE_SQLLOG)
+#if defined(SQL_OMIT_TRACE)
 	if (!isPrepareV2)
 		return;
 #endif
@@ -2552,30 +2552,6 @@ sqlVdbeTransferError(Vdbe * p)
 	return rc;
 }
 
-#ifdef SQL_ENABLE_SQLLOG
-/*
- * If an SQL_CONFIG_SQLLOG hook is registered and the VM has been run,
- * invoke it.
- */
-static void
-vdbeInvokeSqllog(Vdbe * v)
-{
-	if (sqlGlobalConfig.xSqllog && v->rc == SQL_OK && v->zSql
-	    && v->pc >= 0) {
-		char *zExpanded = sqlVdbeExpandSql(v, v->zSql);
-		assert(v->db->init.busy == 0);
-		if (zExpanded) {
-			sqlGlobalConfig.xSqllog(sqlGlobalConfig.
-						    pSqllogArg, v->db,
-						    zExpanded, 1);
-			sqlDbFree(v->db, zExpanded);
-		}
-	}
-}
-#else
-#define vdbeInvokeSqllog(x)
-#endif
-
 /*
  * Clean up a VDBE after execution but do not delete the VDBE just yet.
  * Write any error messages into *pzErrMsg.  Return the result code.
@@ -2605,7 +2581,6 @@ sqlVdbeReset(Vdbe * p)
 	 * instructions yet, leave the main database error information unchanged.
 	 */
 	if (p->pc >= 0) {
-		vdbeInvokeSqllog(p);
 		sqlVdbeTransferError(p);
 		sqlDbFree(db, p->zErrMsg);
 		p->zErrMsg = 0;
@@ -3084,7 +3059,7 @@ serialGet(const unsigned char *buf,	/* Buffer to deserialize from */
 		/* EVIDENCE-OF: R-57343-49114 Value is a big-endian IEEE 754-2008 64-bit
 		 * floating point number.
 		 */
-#if !defined(NDEBUG) && !defined(SQL_OMIT_FLOATING_POINT)
+#if !defined(NDEBUG)
 		/* Verify that integers and floating point values use the same
 		 * byte order.  Or, that if SQL_MIXED_ENDIAN_64BIT_FLOAT is
 		 * defined that 64-bit floating point values really are mixed
diff --git a/src/box/sql/vdbemem.c b/src/box/sql/vdbemem.c
index 15a2f55..85fc08c 100644
--- a/src/box/sql/vdbemem.c
+++ b/src/box/sql/vdbemem.c
@@ -418,11 +418,6 @@ sqlVdbeMemRelease(Mem * p)
 static int
 doubleToInt64(double r, int64_t *i)
 {
-#ifdef SQL_OMIT_FLOATING_POINT
-	/* When floating-point is omitted, double and int64 are the same thing */
-	*i = r;
-	return 0;
-#else
 	/*
 	 * Many compilers we encounter do not define constants for the
 	 * minimum and maximum 64-bit integers, or they define them
@@ -443,7 +438,6 @@ doubleToInt64(double r, int64_t *i)
 		*i = (int64_t) r;
 		return *i != r;
 	}
-#endif
 }
 
 /*
@@ -726,7 +720,6 @@ sqlVdbeMemSetInt64(Mem * pMem, i64 val)
 	}
 }
 
-#ifndef SQL_OMIT_FLOATING_POINT
 /*
  * Delete any previous value and set the value stored in *pMem to val,
  * manifest type REAL.
@@ -740,7 +733,6 @@ sqlVdbeMemSetDouble(Mem * pMem, double val)
 		pMem->flags = MEM_Real;
 	}
 }
-#endif
 
 /*
  * Return true if the Mem object contains a TEXT or BLOB that is

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [tarantool-patches] Re: [PATCH v1 2/3] sql: remove unused macros in SQL
  2019-04-12 13:08     ` Mergen Imeev
@ 2019-04-22 15:39       ` n.pettik
  0 siblings, 0 replies; 16+ messages in thread
From: n.pettik @ 2019-04-22 15:39 UTC (permalink / raw)
  To: tarantool-patches; +Cc: Imeev Mergen

LGTM

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [tarantool-patches] Re: [PATCH v1 2/3] sql: remove unused macros in SQL
  2019-04-09 17:17 ` [tarantool-patches] [PATCH v1 2/3] sql: remove unused macros in SQL imeevma
  2019-04-10  7:28   ` [tarantool-patches] " Konstantin Osipov
  2019-04-11  0:08   ` n.pettik
@ 2019-04-23  8:59   ` Kirill Yukhin
  2 siblings, 0 replies; 16+ messages in thread
From: Kirill Yukhin @ 2019-04-23  8:59 UTC (permalink / raw)
  To: tarantool-patches; +Cc: korablev

Hello,

On 09 Apr 20:17, imeevma@tarantool.org wrote:
> Thise macros unused and should be removed.
> 
> Needed for #4074

I've checked your patch into master.

--
Regards, Kirill Yukhin

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2019-04-23  8:59 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-09 17:17 [tarantool-patches] [PATCH v1 0/3] sql: remove unused code from SQL imeevma
2019-04-09 17:17 ` [tarantool-patches] [PATCH v1 1/3] sql: remove legacy.c imeevma
2019-04-10  7:26   ` [tarantool-patches] " Konstantin Osipov
2019-04-11  0:02   ` n.pettik
2019-04-09 17:17 ` [tarantool-patches] [PATCH v1 2/3] sql: remove unused macros in SQL imeevma
2019-04-10  7:28   ` [tarantool-patches] " Konstantin Osipov
2019-04-11  0:08   ` n.pettik
2019-04-11 16:56     ` Imeev Mergen
2019-04-12 13:08     ` Mergen Imeev
2019-04-22 15:39       ` n.pettik
2019-04-23  8:59   ` Kirill Yukhin
2019-04-09 17:17 ` [tarantool-patches] [PATCH v1 3/3] sql: remove unused functions from main.c imeevma
2019-04-10  7:31   ` [tarantool-patches] " Konstantin Osipov
2019-04-11  0:24     ` n.pettik
2019-04-11  6:36       ` Konstantin Osipov
2019-04-11  0:14   ` n.pettik

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox