Tarantool development patches archive
 help / color / mirror / Atom feed
From: Stanislav Zudin <szudin@tarantool.org>
To: tarantool-patches@freelists.org, korablev@tarantool.org
Cc: Stanislav Zudin <szudin@tarantool.org>
Subject: [tarantool-patches] [PATCH 4/8] Removes unused functions and macros.
Date: Mon, 29 Apr 2019 20:26:07 +0300	[thread overview]
Message-ID: <3123e77f691f33cbb6386397cd62f562592112de.1556553117.git.szudin@tarantool.org> (raw)
In-Reply-To: <cover.1556553117.git.szudin@tarantool.org>
In-Reply-To: <cover.1556553117.git.szudin@tarantool.org>

Part of #3978
---
 extra/mkkeywordhash.c   |  8 -------
 src/box/sql/build.c     |  3 ---
 src/box/sql/expr.c      |  8 ++-----
 src/box/sql/insert.c    |  4 ----
 src/box/sql/main.c      | 50 -----------------------------------------
 src/box/sql/malloc.c    | 12 ----------
 src/box/sql/parse.y     |  5 +----
 src/box/sql/select.c    | 20 ++++-------------
 src/box/sql/sqlInt.h    | 40 ---------------------------------
 src/box/sql/treeview.c  |  4 ++--
 src/box/sql/trigger.c   |  2 --
 src/box/sql/vdbe.c      |  5 -----
 src/box/sql/vdbe.h      |  2 --
 src/box/sql/vdbeInt.h   |  2 --
 src/box/sql/vdbeapi.c   | 12 ----------
 src/box/sql/vdbeaux.c   | 38 -------------------------------
 src/box/sql/vdbesort.c  | 44 +++++++++++++++++-------------------
 src/box/sql/vdbetrace.c |  3 ---
 18 files changed, 30 insertions(+), 232 deletions(-)

diff --git a/extra/mkkeywordhash.c b/extra/mkkeywordhash.c
index 2ad74eddc..ba4932b49 100644
--- a/extra/mkkeywordhash.c
+++ b/extra/mkkeywordhash.c
@@ -60,11 +60,7 @@ struct Keyword {
 #else
 #  define AUTOINCR   0x00000010
 #endif
-#ifdef SQL_OMIT_CAST
-#  define CAST       0
-#else
 #  define CAST       0x00000020
-#endif
 #ifdef SQL_OMIT_COMPOUND_SELECT
 #  define COMPOUND   0
 #else
@@ -85,11 +81,7 @@ struct Keyword {
 #define SUBQUERY     0x00001000
 #  define TRIGGER    0x00002000
 #  define VIEW       0x00008000
-#ifdef SQL_OMIT_CTE
-#  define CTE        0
-#else
 #  define CTE        0x00040000
-#endif
 #  define RESERVED   0x00000001
 /*
 ** These are the keywords
diff --git a/src/box/sql/build.c b/src/box/sql/build.c
index 6051a2529..0cce60cb5 100644
--- a/src/box/sql/build.c
+++ b/src/box/sql/build.c
@@ -3025,7 +3025,6 @@ sqlHaltConstraint(Parse * pParse,	/* Parsing context */
 	sqlVdbeChangeP5(v, p5Errmsg);
 }
 
-#ifndef SQL_OMIT_CTE
 /*
  * This routine is invoked once per CTE by the parser while parsing a
  * WITH clause.
@@ -3106,8 +3105,6 @@ sqlWithDelete(sql * db, With * pWith)
 	}
 }
 
-#endif				/* !defined(SQL_OMIT_CTE) */
-
 int
 vdbe_emit_halt_with_presence_test(struct Parse *parser, int space_id,
 				  int index_id, int key_reg, uint32_t key_len,
diff --git a/src/box/sql/expr.c b/src/box/sql/expr.c
index ab6f9f068..0f87eba5e 100644
--- a/src/box/sql/expr.c
+++ b/src/box/sql/expr.c
@@ -1502,7 +1502,6 @@ sql_expr_dup(struct sql *db, struct Expr *p, int flags, char **buffer)
  * argument. If an OOM condition is encountered, NULL is returned
  * and the db->mallocFailed flag set.
  */
-#ifndef SQL_OMIT_CTE
 static With *
 withDup(sql * db, With * p)
 {
@@ -1525,9 +1524,6 @@ withDup(sql * db, With * p)
 	}
 	return pRet;
 }
-#else
-#define withDup(x,y) 0
-#endif
 
 /*
  * The following group of routines make deep copies of expressions,
@@ -3785,7 +3781,7 @@ sqlExprCodeTarget(Parse * pParse, Expr * pExpr, int target)
 	case TK_REGISTER:{
 			return pExpr->iTable;
 		}
-#ifndef SQL_OMIT_CAST
+
 	case TK_CAST:{
 			/* Expressions of the form:   CAST(pLeft AS token) */
 			inReg =
@@ -3799,7 +3795,7 @@ sqlExprCodeTarget(Parse * pParse, Expr * pExpr, int target)
 			sql_expr_type_cache_change(pParse, inReg, 1);
 			return inReg;
 		}
-#endif				/* SQL_OMIT_CAST */
+
 	case TK_LT:
 	case TK_LE:
 	case TK_GT:
diff --git a/src/box/sql/insert.c b/src/box/sql/insert.c
index c2aac553f..8feb8d812 100644
--- a/src/box/sql/insert.c
+++ b/src/box/sql/insert.c
@@ -335,7 +335,6 @@ sqlInsert(Parse * pParse,	/* Parser context */
 	sqlVdbeCountChanges(v);
 	sql_set_multi_write(pParse, pSelect != NULL || trigger != NULL);
 
-#ifndef SQL_OMIT_XFER_OPT
 	/* If the statement is of the form
 	 *
 	 *       INSERT INTO <table1> SELECT * FROM <table2>;
@@ -351,7 +350,6 @@ sqlInsert(Parse * pParse,	/* Parser context */
 		assert(pList == 0);
 		goto insert_end;
 	}
-#endif				/* SQL_OMIT_XFER_OPT */
 
 	/*
 	 * Allocate registers for holding the tupleid of the new
@@ -1066,7 +1064,6 @@ vdbe_emit_insertion_completion(struct Vdbe *v, struct space *space,
 	sqlVdbeChangeP5(v, pik_flags);
 }
 
-#ifndef SQL_OMIT_XFER_OPT
 /**
  * Check to see if index @src is compatible as a source of data
  * for index @dest in an insert transfer optimization. The rules
@@ -1336,4 +1333,3 @@ xferOptimization(Parse * pParse,	/* Parser context */
 		return 1;
 	}
 }
-#endif				/* SQL_OMIT_XFER_OPT */
diff --git a/src/box/sql/main.c b/src/box/sql/main.c
index a188f2e8a..c0c334f89 100644
--- a/src/box/sql/main.c
+++ b/src/box/sql/main.c
@@ -40,16 +40,6 @@
 #include "version.h"
 #include "box/session.h"
 
-#if !defined(SQL_OMIT_TRACE) && defined(SQL_ENABLE_IOTRACE)
-/*
- * If the following function pointer is not NULL and if
- * SQL_ENABLE_IOTRACE is enabled, then messages describing
- * I/O active are written using this function.  These messages
- * are intended for debugging activity only.
- */
-SQL_API void (SQL_CDECL * sqlIoTrace) (const char *, ...) = 0;
-#endif
-
 /*
  * If the following global variable points to a string which is the
  * name of a directory, then that directory will be used to store
@@ -187,7 +177,6 @@ sql_initialize(void)
 static int
 setupLookaside(sql * db, void *pBuf, int sz, int cnt)
 {
-#ifndef SQL_OMIT_LOOKASIDE
 	void *pStart;
 	if (db->lookaside.nOut) {
 		return SQL_BUSY;
@@ -241,7 +230,6 @@ setupLookaside(sql * db, void *pBuf, int sz, int cnt)
 		db->lookaside.bDisable = 1;
 		db->lookaside.bMalloced = 0;
 	}
-#endif				/* SQL_OMIT_LOOKASIDE */
 	return SQL_OK;
 }
 
@@ -513,44 +501,6 @@ sql_create_function_v2(sql * db,
 	return rc;
 }
 
-/*
- * 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
- * parameter) and the compile time value of SQL_TEMP_STORE. The
- * following table describes the relationship between these two values
- * and this functions return value.
- *
- *   SQL_TEMP_STORE     db->temp_store     Location of temporary database
- *   -----------------     --------------     ------------------------------
- *   0                     any                file      (return 0)
- *   1                     1                  file      (return 0)
- *   1                     2                  memory    (return 1)
- *   1                     0                  file      (return 0)
- *   2                     1                  file      (return 0)
- *   2                     2                  memory    (return 1)
- *   2                     0                  memory    (return 1)
- *   3                     any                memory    (return 1)
- */
-int
-sqlTempInMemory(const sql * db)
-{
-#if SQL_TEMP_STORE==1
-	return (db->temp_store == 2);
-#endif
-#if SQL_TEMP_STORE==2
-	return (db->temp_store != 1);
-#endif
-#if SQL_TEMP_STORE==3
-	UNUSED_PARAMETER(db);
-	return 1;
-#endif
-#if SQL_TEMP_STORE<1 || SQL_TEMP_STORE>3
-	UNUSED_PARAMETER(db);
-	return 0;
-#endif
-}
-
 /*
  * 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().
diff --git a/src/box/sql/malloc.c b/src/box/sql/malloc.c
index 4bb96111f..3bd2e1781 100644
--- a/src/box/sql/malloc.c
+++ b/src/box/sql/malloc.c
@@ -357,15 +357,11 @@ sql_malloc64(sql_uint64 n)
 /*
  * TRUE if p is a lookaside memory allocation from db
  */
-#ifndef SQL_OMIT_LOOKASIDE
 static int
 isLookaside(sql * db, void *p)
 {
 	return SQL_WITHIN(p, db->lookaside.pStart, db->lookaside.pEnd);
 }
-#else
-#define isLookaside(A,B) 0
-#endif
 
 /*
  * Return the size of a memory allocation previously obtained from
@@ -602,7 +598,6 @@ sqlDbMallocRaw(sql * db, u64 n)
 void *
 sqlDbMallocRawNN(sql * db, u64 n)
 {
-#ifndef SQL_OMIT_LOOKASIDE
 	LookasideSlot *pBuf;
 	assert(db != 0);
 	assert(db->pnBytesFreed == 0);
@@ -624,13 +619,6 @@ sqlDbMallocRawNN(sql * db, u64 n)
 	} else if (db->mallocFailed) {
 		return 0;
 	}
-#else
-	assert(db != 0);
-	assert(db->pnBytesFreed == 0);
-	if (db->mallocFailed) {
-		return 0;
-	}
-#endif
 	return dbMallocRawFinish(db, n);
 }
 
diff --git a/src/box/sql/parse.y b/src/box/sql/parse.y
index 3a443a068..78b3370f9 100644
--- a/src/box/sql/parse.y
+++ b/src/box/sql/parse.y
@@ -1029,7 +1029,7 @@ expr(A) ::= expr(A) COLLATE id(C). {
   A.pExpr = sqlExprAddCollateToken(pParse, A.pExpr, &C, 1);
   A.zEnd = &C.z[C.n];
 }
-%ifndef SQL_OMIT_CAST
+
 expr(A) ::= CAST(X) LP expr(E) AS typedef(T) RP(Y). {
   spanSet(&A,&X,&Y); /*A-overwrites-X*/
   A.pExpr = sql_expr_new_dequoted(pParse->db, TK_CAST, NULL);
@@ -1040,7 +1040,6 @@ expr(A) ::= CAST(X) LP expr(E) AS typedef(T) RP(Y). {
   A.pExpr->type = T.type;
   sqlExprAttachSubtrees(pParse->db, A.pExpr, E.pExpr, 0);
 }
-%endif  SQL_OMIT_CAST
 
 expr(A) ::= TRIM(X) LP trim_operands(Y) RP(E). {
   A.pExpr = sqlExprFunction(pParse, Y, &X);
@@ -1714,7 +1713,6 @@ cmd ::= ALTER TABLE fullname(X) DROP CONSTRAINT nm(Z). {
 %destructor wqlist {sqlWithDelete(pParse->db, $$);}
 
 with(A) ::= . {A = 0;}
-%ifndef SQL_OMIT_CTE
 with(A) ::= WITH wqlist(W).              { A = W; }
 with(A) ::= WITH RECURSIVE wqlist(W).    { A = W; }
 
@@ -1724,7 +1722,6 @@ wqlist(A) ::= nm(X) eidlist_opt(Y) AS LP select(Z) RP. {
 wqlist(A) ::= wqlist(A) COMMA nm(X) eidlist_opt(Y) AS LP select(Z) RP. {
   A = sqlWithAdd(pParse, A, &X, Y, Z);
 }
-%endif  SQL_OMIT_CTE
 
 ////////////////////////////// TYPE DECLARATION ///////////////////////////////
 %type typedef {struct type_def}
diff --git a/src/box/sql/select.c b/src/box/sql/select.c
index d3472a922..153997cde 100644
--- a/src/box/sql/select.c
+++ b/src/box/sql/select.c
@@ -1176,7 +1176,7 @@ selectInnerLoop(Parse * pParse,		/* The parser context */
 					  nResultCol, r1 + nPrefixReg);
 			/* Set flag to save memory allocating one by malloc. */
 			sqlVdbeChangeP5(v, 1);
-#ifndef SQL_OMIT_CTE
+
 			if (eDest == SRT_DistFifo) {
 				/* If the destination is DistFifo, then cursor (iParm+1) is open
 				 * on an ephemeral index. If the current row is already present
@@ -1192,7 +1192,7 @@ selectInnerLoop(Parse * pParse,		/* The parser context */
 						  pDest->reg_eph + 1);
 				assert(pSort == 0);
 			}
-#endif
+
 			if (pSort) {
 				pushOntoSorter(pParse, pSort, p,
 					       r1 + nPrefixReg, regResult, 1,
@@ -1295,7 +1295,6 @@ selectInnerLoop(Parse * pParse,		/* The parser context */
 			break;
 		}
 
-#ifndef SQL_OMIT_CTE
 		/* Write the results into a priority queue that is order according to
 		 * pDest->pOrderBy (in pSO).  pDest->iSDParm (in iParm) is the cursor for an
 		 * index with pSO->nExpr+2 columns.  Build a key using pSO for the first
@@ -1346,7 +1345,6 @@ selectInnerLoop(Parse * pParse,		/* The parser context */
 			sqlReleaseTempRange(pParse, r2, nKey + 2);
 			break;
 		}
-#endif				/* SQL_OMIT_CTE */
 
 		/* Discard the results.  This is used for SELECT statements inside
 		 * the body of a TRIGGER.  The purpose of such selects is to call
@@ -2303,7 +2301,6 @@ sql_multiselect_orderby_to_key_info(struct Parse *parse, struct Select *s,
 	return key_info;
 }
 
-#ifndef SQL_OMIT_CTE
 /*
  * This routine generates VDBE code to compute the content of a WITH RECURSIVE
  * query of the form:
@@ -2483,7 +2480,6 @@ generateWithRecursiveQuery(Parse * pParse,	/* Parsing context */
 	p->pOffset = pOffset;
 	return;
 }
-#endif				/* SQL_OMIT_CTE */
 
 /* Forward references */
 static int multiSelectOrderBy(Parse * pParse,	/* Parsing context */
@@ -2642,11 +2638,9 @@ multiSelect(Parse * pParse,	/* Parsing context */
 	assert(p->pEList && pPrior->pEList);
 	assert(p->pEList->nExpr == pPrior->pEList->nExpr);
 
-#ifndef SQL_OMIT_CTE
 	if (p->selFlags & SF_Recursive) {
 		generateWithRecursiveQuery(pParse, p, &dest);
 	} else
-#endif
 
 		/* Compound SELECTs that have an ORDER BY clause are handled separately.
 		 */
@@ -4534,7 +4528,6 @@ convertCompoundSelectToSubquery(Walker * pWalker, Select * p)
 	return WRC_Continue;
 }
 
-#ifndef SQL_OMIT_CTE
 /*
  * Argument pWith (which may be NULL) points to a linked list of nested
  * WITH contexts, from inner to outermost. If the table identified by
@@ -4722,9 +4715,7 @@ withExpand(Walker * pWalker, struct SrcList_item *pFrom)
 
 	return SQL_OK;
 }
-#endif
 
-#ifndef SQL_OMIT_CTE
 /*
  * If the SELECT passed as the second argument has an associated WITH
  * clause, pop it from the stack stored as part of the Parse object.
@@ -4743,9 +4734,6 @@ selectPopWith(Walker * pWalker, Select * p)
 		pParse->pWith = pWith->pOuter;
 	}
 }
-#else
-#define selectPopWith 0
-#endif
 
 /*
  * This routine is a Walker callback for "expanding" a SELECT statement.
@@ -4811,12 +4799,12 @@ selectExpander(Walker * pWalker, Select * p)
 		if (pFrom->fg.isRecursive)
 			continue;
 		assert(pFrom->space == NULL);
-#ifndef SQL_OMIT_CTE
+
 		if (withExpand(pWalker, pFrom))
 			return WRC_Abort;
 		if (pFrom->space != NULL) {
 		} else
-#endif
+
 		if (pFrom->zName == 0) {
 			Select *pSel = pFrom->pSelect;
 			/* A sub-query in the FROM clause of a SELECT */
diff --git a/src/box/sql/sqlInt.h b/src/box/sql/sqlInt.h
index 6ddc7d486..f019cd291 100644
--- a/src/box/sql/sqlInt.h
+++ b/src/box/sql/sqlInt.h
@@ -945,24 +945,6 @@ sql_bind_parameter_lindex(sql_stmt * pStmt, const char *zName,
 #define SQL_DEFAULT_RECURSIVE_TRIGGERS 0
 #endif
 
-/*
- * Provide a default value for sql_TEMP_STORE in case it is not specified
- * on the command-line
- */
-#ifndef SQL_TEMP_STORE
-#define SQL_TEMP_STORE 1
-#define SQL_TEMP_STORE_xc 1	/* Exclude from ctime.c */
-#endif
-
-/*
- * If no value has been provided for sql_MAX_WORKER_THREADS, or if
- * sql_TEMP_STORE is set to 3 (never use temporary files), set it
- * to zero.
- */
-#if SQL_TEMP_STORE==3
-#undef SQL_MAX_WORKER_THREADS
-#define SQL_MAX_WORKER_THREADS 0
-#endif
 #ifndef SQL_MAX_WORKER_THREADS
 #define SQL_MAX_WORKER_THREADS 8
 #endif
@@ -1376,7 +1358,6 @@ struct sql {
 	int iSysErrno;		/* Errno value from last system error */
 	u16 dbOptFlags;		/* Flags to enable/disable optimizations */
 	u8 enc;			/* Text encoding */
-	u8 temp_store;		/* 1: file 2: memory 0: default */
 	u8 mallocFailed;	/* True if we have seen a malloc failure */
 	u8 bBenignMalloc;	/* Do not require OOMs if true */
 	u8 dfltLockMode;	/* Default locking-mode for attached dbs */
@@ -4728,15 +4709,9 @@ collations_check_compatibility(uint32_t lhs_id, bool is_lhs_forced,
 int
 sql_binary_compare_coll_seq(Parse *parser, Expr *left, Expr *right,
 			    uint32_t *id);
-int sqlTempInMemory(const sql *);
-#ifndef SQL_OMIT_CTE
 With *sqlWithAdd(Parse *, With *, Token *, ExprList *, Select *);
 void sqlWithDelete(sql *, With *);
 void sqlWithPush(Parse *, With *, u8);
-#else
-#define sqlWithPush(x,y,z)
-#define sqlWithDelete(x,y)
-#endif
 
 /*
  * This function is called when inserting, deleting or updating a
@@ -4841,21 +4816,6 @@ int sqlExprCheckHeight(Parse *, int);
 void sqlParserTrace(FILE *, char *);
 #endif
 
-/*
- * If the sql_ENABLE IOTRACE exists then the global variable
- * sqlIoTrace is a pointer to a printf-like routine used to
- * print I/O tracing messages.
- */
-#ifdef SQL_ENABLE_IOTRACE
-#define IOTRACE(A)  if( sqlIoTrace ){ sqlIoTrace A; }
-void sqlVdbeIOTraceSql(Vdbe *);
- SQL_EXTERN void (SQL_CDECL * sqlIoTrace) (const char *,
-							       ...);
-#else
-#define IOTRACE(A)
-#define sqlVdbeIOTraceSql(X)
-#endif
-
 /*
  * These routines are available for the mem2.c debugging memory allocator
  * only.  They are used to verify that different "types" of memory
diff --git a/src/box/sql/treeview.c b/src/box/sql/treeview.c
index 5acea582a..a04597979 100644
--- a/src/box/sql/treeview.c
+++ b/src/box/sql/treeview.c
@@ -382,14 +382,14 @@ sqlTreeViewExpr(TreeView * pView, const Expr * pExpr, u8 moreToFollow)
 					    pExpr->u.zToken);
 			break;
 		}
-#ifndef SQL_OMIT_CAST
+
 	case TK_CAST:{
 			/* Expressions of the form:   CAST(pLeft AS token) */
 			sqlTreeViewLine(pView, "CAST %Q", pExpr->u.zToken);
 			sqlTreeViewExpr(pView, pExpr->pLeft, 0);
 			break;
 		}
-#endif				/* SQL_OMIT_CAST */
+
 	case TK_LT:
 		zBinOp = "LT";
 		break;
diff --git a/src/box/sql/trigger.c b/src/box/sql/trigger.c
index 14e4198a8..cca2f6079 100644
--- a/src/box/sql/trigger.c
+++ b/src/box/sql/trigger.c
@@ -772,12 +772,10 @@ sql_row_trigger_program(struct Parse *parser, struct sql_trigger *trigger,
 			     (trigger->op == TK_INSERT ? "INSERT" : ""),
 			     (trigger->op == TK_DELETE ? "DELETE" : ""),
 			      space->def->name));
-#ifndef SQL_OMIT_TRACE
 		sqlVdbeChangeP4(v, -1,
 				    sqlMPrintf(db, "-- TRIGGER %s",
 						   trigger->zName),
 				    P4_DYNAMIC);
-#endif
 
 		/*
 		 * If one was specified, code the WHEN clause. If
diff --git a/src/box/sql/vdbe.c b/src/box/sql/vdbe.c
index ce609a578..197df4bf3 100644
--- a/src/box/sql/vdbe.c
+++ b/src/box/sql/vdbe.c
@@ -659,7 +659,6 @@ int sqlVdbeExec(Vdbe *p)
 	assert(p->explain==0);
 	p->pResultSet = 0;
 	if (db->u1.isInterrupted) goto abort_due_to_interrupt;
-	sqlVdbeIOTraceSql(p);
 #ifndef SQL_OMIT_PROGRESS_CALLBACK
 	if (db->xProgress) {
 		u32 iPrior = p->aCounter[SQL_STMTSTATUS_VM_STEP];
@@ -1976,7 +1975,6 @@ case OP_Realify: {                  /* in1 */
 	break;
 }
 
-#ifndef SQL_OMIT_CAST
 /* Opcode: Cast P1 P2 * * *
  * Synopsis: type(r[P1])
  *
@@ -2006,7 +2004,6 @@ case OP_Cast: {                  /* in1 */
 	rc = SQL_TARANTOOL_ERROR;
 	goto abort_due_to_error;
 }
-#endif /* SQL_OMIT_CAST */
 
 /* Opcode: Eq P1 P2 P3 P4 P5
  * Synopsis: IF r[P3]==r[P1]
@@ -5357,7 +5354,6 @@ case OP_Init: {          /* jump */
 		break;
 	}
 
-#ifndef SQL_OMIT_TRACE
 	if ((db->mTrace & SQL_TRACE_STMT)!=0
 	    && !p->doingRerun
 	    && (zTrace = (pOp->p4.z ? pOp->p4.z : p->zSql))!=0
@@ -5373,7 +5369,6 @@ case OP_Init: {          /* jump */
 		sqlDebugPrintf("SQL-trace: %s\n", zTrace);
 	}
 #endif /* SQL_DEBUG */
-#endif /* SQL_OMIT_TRACE */
 	assert(pOp->p2>0);
 	if (pOp->p1>=sqlGlobalConfig.iOnceResetThreshold) {
 		for(i=1; i<p->nOp; i++) {
diff --git a/src/box/sql/vdbe.h b/src/box/sql/vdbe.h
index f9bb96f09..5fb9d42ca 100644
--- a/src/box/sql/vdbe.h
+++ b/src/box/sql/vdbe.h
@@ -268,9 +268,7 @@ void sqlVdbeSwap(Vdbe *, Vdbe *);
 VdbeOp *sqlVdbeTakeOpArray(Vdbe *, int *, int *);
 sql_value *sqlVdbeGetBoundValue(Vdbe *, int, u8);
 void sqlVdbeSetVarmask(Vdbe *, int);
-#ifndef SQL_OMIT_TRACE
 char *sqlVdbeExpandSql(Vdbe *, const char *);
-#endif
 int sqlMemCompare(const Mem *, const Mem *, const struct coll *);
 
 /**
diff --git a/src/box/sql/vdbeInt.h b/src/box/sql/vdbeInt.h
index a3100e513..eabec1519 100644
--- a/src/box/sql/vdbeInt.h
+++ b/src/box/sql/vdbeInt.h
@@ -425,9 +425,7 @@ struct Vdbe {
 	 */
 	uint32_t res_var_count;
 	VList *pVList;		/* Name of variables */
-#ifndef SQL_OMIT_TRACE
 	i64 startTime;		/* Time when query started - used for profiling */
-#endif
 	int nOp;		/* Number of instructions in the program */
 	u16 nResColumn;		/* Number of columns in one row of the result set */
 	u8 errorAction;		/* Recovery action to do in case of an error */
diff --git a/src/box/sql/vdbeapi.c b/src/box/sql/vdbeapi.c
index 4175f7e86..e1d100e04 100644
--- a/src/box/sql/vdbeapi.c
+++ b/src/box/sql/vdbeapi.c
@@ -66,7 +66,6 @@ vdbeSafetyNotNull(Vdbe * p)
 	}
 }
 
-#ifndef SQL_OMIT_TRACE
 /*
  * Invoke the profile callback.  This routine is only called if we already
  * know that the profile callback is defined and needs to be invoked.
@@ -98,9 +97,6 @@ invokeProfileCallback(sql * db, Vdbe * p)
  */
 #define checkProfileCallback(DB,P) \
    if( ((P)->startTime)>0 ){ invokeProfileCallback(DB,P); }
-#else
-#define checkProfileCallback(DB,P)	/*no-op */
-#endif
 
 /*
  * The following routine destroys a virtual machine that is created by
@@ -545,14 +541,12 @@ sqlStep(Vdbe * p)
 			db->u1.isInterrupted = 0;
 		}
 
-#ifndef SQL_OMIT_TRACE
 		if ((db->xProfile || (db->mTrace & SQL_TRACE_PROFILE) != 0)
 		    && !db->init.busy && p->zSql) {
 			sqlOsCurrentTimeInt64(db->pVfs, &p->startTime);
 		} else {
 			assert(p->startTime == 0);
 		}
-#endif
 
 		db->nVdbeActive++;
 		p->pc = 0;
@@ -565,11 +559,9 @@ sqlStep(Vdbe * p)
 		db->nVdbeExec--;
 	}
 
-#ifndef SQL_OMIT_TRACE
 	/* If the statement completed successfully, invoke the profile callback */
 	if (rc != SQL_ROW)
 		checkProfileCallback(db, p);
-#endif
 
 	db->errCode = rc;
 	if (SQL_NOMEM == sqlApiExit(p->db, p->rc)) {
@@ -1574,9 +1566,6 @@ sql_sql(sql_stmt * pStmt)
 char *
 sql_expanded_sql(sql_stmt * pStmt)
 {
-#ifdef SQL_OMIT_TRACE
-	return 0;
-#else
 	char *z = 0;
 	const char *zSql = sql_sql(pStmt);
 	if (zSql) {
@@ -1584,7 +1573,6 @@ sql_expanded_sql(sql_stmt * pStmt)
 		z = sqlVdbeExpandSql(p, zSql);
 	}
 	return z;
-#endif
 }
 
 #ifdef SQL_ENABLE_STMT_SCANSTATUS
diff --git a/src/box/sql/vdbeaux.c b/src/box/sql/vdbeaux.c
index 25d4cd759..2f78e19d8 100644
--- a/src/box/sql/vdbeaux.c
+++ b/src/box/sql/vdbeaux.c
@@ -137,10 +137,6 @@ sqlVdbeSetSql(Vdbe * p, const char *z, int n, int isPrepareV2)
 	assert(isPrepareV2 == 1 || isPrepareV2 == 0);
 	if (p == 0)
 		return;
-#if defined(SQL_OMIT_TRACE)
-	if (!isPrepareV2)
-		return;
-#endif
 	assert(p->zSql == 0);
 	p->zSql = sqlDbStrNDup(p->db, z, n);
 	p->isPrepareV2 = (u8) isPrepareV2;
@@ -1753,40 +1749,6 @@ sqlVdbePrintSql(Vdbe * p)
 }
 #endif
 
-#if !defined(SQL_OMIT_TRACE) && defined(SQL_ENABLE_IOTRACE)
-/*
- * Print an IOTRACE message showing SQL content.
- */
-void
-sqlVdbeIOTraceSql(Vdbe * p)
-{
-	int nOp = p->nOp;
-	VdbeOp *pOp;
-	if (sqlIoTrace == 0)
-		return;
-	if (nOp < 1)
-		return;
-	pOp = &p->aOp[0];
-	if (pOp->opcode == OP_Init && pOp->p4.z != 0) {
-		int i, j;
-		char z[1000];
-		sql_snprintf(sizeof(z), z, "%s", pOp->p4.z);
-		for (i = 0; sqlIsspace(z[i]); i++) {
-		}
-		for (j = 0; z[i]; i++) {
-			if (sqlIsspace(z[i])) {
-				if (z[i - 1] != ' ') {
-					z[j++] = ' ';
-				}
-			} else {
-				z[j++] = z[i];
-			}
-		}
-		z[j] = 0;
-		sqlIoTrace("SQL %s\n", z);
-	}
-}
-#endif				/* !SQL_OMIT_TRACE && SQL_ENABLE_IOTRACE */
 
 /* An instance of this object describes bulk memory available for use
  * by subcomponents of a prepared statement.  Space is allocated out
diff --git a/src/box/sql/vdbesort.c b/src/box/sql/vdbesort.c
index 779e83264..ddea6752c 100644
--- a/src/box/sql/vdbesort.c
+++ b/src/box/sql/vdbesort.c
@@ -894,29 +894,27 @@ sqlVdbeSorterInit(sql * db,	/* Database connection (for malloc()) */
 			pTask->pSorter = pSorter;
 		}
 
-		if (!sqlTempInMemory(db)) {
-			i64 mxCache;	/* Cache size in bytes */
-			u32 szPma = sqlGlobalConfig.szPma;
-			pSorter->mnPmaSize = szPma * pgsz;
-
-			mxCache = SQL_DEFAULT_CACHE_SIZE;
-			mxCache = mxCache * -1024;
-			mxCache = MIN(mxCache, SQL_MAX_PMASZ);
-			pSorter->mxPmaSize =
-			    MAX(pSorter->mnPmaSize, (int)mxCache);
-
-			/* EVIDENCE-OF: R-26747-61719 When the application provides any amount of
-			 * scratch memory using SQL_CONFIG_SCRATCH, sql avoids unnecessary
-			 * large heap allocations.
-			 */
-			if (sqlGlobalConfig.pScratch == 0) {
-				assert(pSorter->iMemory == 0);
-				pSorter->nMemory = pgsz;
-				pSorter->list.aMemory =
-				    (u8 *) sqlMalloc(pgsz);
-				if (!pSorter->list.aMemory)
-					rc = SQL_NOMEM;
-			}
+		i64 mxCache;	/* Cache size in bytes */
+		u32 szPma = sqlGlobalConfig.szPma;
+		pSorter->mnPmaSize = szPma * pgsz;
+
+		mxCache = SQL_DEFAULT_CACHE_SIZE;
+		mxCache = mxCache * -1024;
+		mxCache = MIN(mxCache, SQL_MAX_PMASZ);
+		pSorter->mxPmaSize =
+		    MAX(pSorter->mnPmaSize, (int)mxCache);
+
+		/* EVIDENCE-OF: R-26747-61719 When the application provides any amount of
+		 * scratch memory using SQL_CONFIG_SCRATCH, sql avoids unnecessary
+		 * large heap allocations.
+		 */
+		if (sqlGlobalConfig.pScratch == 0) {
+			assert(pSorter->iMemory == 0);
+			pSorter->nMemory = pgsz;
+			pSorter->list.aMemory =
+			    (u8 *) sqlMalloc(pgsz);
+			if (!pSorter->list.aMemory)
+				rc = SQL_NOMEM;
 		}
 
 		if (pCsr->key_def->part_count < 13
diff --git a/src/box/sql/vdbetrace.c b/src/box/sql/vdbetrace.c
index cb930538d..b86ad7b8a 100644
--- a/src/box/sql/vdbetrace.c
+++ b/src/box/sql/vdbetrace.c
@@ -39,8 +39,6 @@
 #include "sqlInt.h"
 #include "vdbeInt.h"
 
-#ifndef SQL_OMIT_TRACE
-
 /*
  * zSql is a zero-terminated string of UTF-8 SQL text.  Return the number of
  * bytes in this text up to but excluding the first character in
@@ -211,4 +209,3 @@ sqlVdbeExpandSql(Vdbe * p,	/* The prepared statement being evaluated */
 	return sqlStrAccumFinish(&out);
 }
 
-#endif				/* #ifndef SQL_OMIT_TRACE */
-- 
2.17.1

  parent reply	other threads:[~2019-04-29 17:26 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-29 17:26 [tarantool-patches] [PATCH 0/8] sql: cleanup code from obsolete macros Stanislav Zudin
2019-04-29 17:26 ` [tarantool-patches] [PATCH 1/8] " Stanislav Zudin
2019-04-29 17:26 ` [tarantool-patches] [PATCH 2/8] Removes unused functions and commented many years ago code Stanislav Zudin
2019-05-19 15:15   ` [tarantool-patches] " n.pettik
2019-05-29  8:21     ` Stanislav Zudin
2019-04-29 17:26 ` [tarantool-patches] [PATCH 3/8] Removes unused functions Stanislav Zudin
2019-04-29 17:26 ` Stanislav Zudin [this message]
2019-05-19 15:16   ` [tarantool-patches] Re: [PATCH 4/8] Removes unused functions and macros n.pettik
2019-05-29 14:01     ` Stanislav Zudin
2019-04-29 17:26 ` [tarantool-patches] [PATCH 5/8] Removes the following unused macros: SQL_ENABLE_MEMORY_MANAGEMENT SQL_ENABLE_UNKNOWN_SQL_FUNCTION SQL_SUBSTR_COMPATIBILITY SQL_ENABLE_STMT_SCANSTATUS Stanislav Zudin
2019-04-29 17:26 ` [tarantool-patches] [PATCH 6/8] Removes the following unused macros: SQL_EXPLAIN_ESTIMATED_ROWS SQL_ENABLE_COLUMN_USED_MASK SQL_DISABLE_DIRSYNC SQL_OMIT_AUTOMATIC_INDEX SQL_DEBUG_SORTER_THREADS SQL_DEFAULT_WORKER_THREADS SQL_LIMIT_WORKER_THREADS SQL_MAX_WORKER_THREADS Stanislav Zudin
2019-05-19 15:16   ` [tarantool-patches] " n.pettik
2019-05-29 14:02     ` Stanislav Zudin
2019-04-29 17:26 ` [tarantool-patches] [PATCH 7/8] Removes unused constants Stanislav Zudin
2019-04-29 17:26 ` [tarantool-patches] [PATCH 8/8] Removes the following unused macros: SQL_PRINTF_PRECISION_LIMIT SQL_OMIT_COMPOUND_SELECT SQL_POWERSAFE_OVERWRITE SQL_OMIT_PROGRESS_CALLBACK SQL_OMIT_AUTORESET SQL_OMIT_DECLTYPE SQL_ENABLE_COLUMN_METADATA SQL_TRACE_SIZE_LIMIT SQL_OMIT_LIKE_OPTIMIZATION SQL_OMIT_OR_OPTIMIZATION SQL_OMIT_BETWEEN_OPTIMIZATION Stanislav Zudin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3123e77f691f33cbb6386397cd62f562592112de.1556553117.git.szudin@tarantool.org \
    --to=szudin@tarantool.org \
    --cc=korablev@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='Re: [tarantool-patches] [PATCH 4/8] Removes unused functions and macros.' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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