* [tarantool-patches] [PATCH 1/8] sql: cleanup code from obsolete macros
2019-04-29 17:26 [tarantool-patches] [PATCH 0/8] sql: cleanup code from obsolete macros Stanislav Zudin
@ 2019-04-29 17:26 ` Stanislav Zudin
2019-04-29 17:26 ` [tarantool-patches] [PATCH 2/8] Removes unused functions and commented many years ago code Stanislav Zudin
` (6 subsequent siblings)
7 siblings, 0 replies; 15+ messages in thread
From: Stanislav Zudin @ 2019-04-29 17:26 UTC (permalink / raw)
To: tarantool-patches, korablev; +Cc: Stanislav Zudin
Removes obsolete and not applicable for the project macros.
Part of #3978
---
src/box/sql/cursor.h | 25 -------------
src/box/sql/date.c | 8 ++---
src/box/sql/expr.c | 4 +--
src/box/sql/fault.c | 3 --
src/box/sql/global.c | 6 ----
src/box/sql/random.c | 2 --
src/box/sql/sqlInt.h | 76 +++------------------------------------
src/box/sql/util.c | 86 --------------------------------------------
src/box/sql/vdbe.c | 2 +-
9 files changed, 11 insertions(+), 201 deletions(-)
diff --git a/src/box/sql/cursor.h b/src/box/sql/cursor.h
index 237411613..e5c49d736 100644
--- a/src/box/sql/cursor.h
+++ b/src/box/sql/cursor.h
@@ -101,29 +101,4 @@ int sqlCursorIsValidNN(BtCursor *);
#define CURSOR_INVALID 0
#define CURSOR_VALID 1
-/*
- * Routines to read or write a two- and four-byte big-endian integer values.
- */
-#define get2byte(x) ((x)[0]<<8 | (x)[1])
-#define put2byte(p,v) ((p)[0] = (u8)((v)>>8), (p)[1] = (u8)(v))
-#define get4byte sqlGet4byte
-#define put4byte sqlPut4byte
-
-/*
- * get2byteAligned(), unlike get2byte(), requires that its argument point to a
- * two-byte aligned address. get2bytea() is only used for accessing the
- * cell addresses in a btree header.
- */
-#if SQL_BYTEORDER==4321
-#define get2byteAligned(x) (*(u16*)(x))
-#elif SQL_BYTEORDER==1234 && !defined(SQL_DISABLE_INTRINSIC) \
- && GCC_VERSION>=4008000
-#define get2byteAligned(x) __builtin_bswap16(*(u16*)(x))
-#elif SQL_BYTEORDER==1234 && !defined(SQL_DISABLE_INTRINSIC) \
- && defined(_MSC_VER) && _MSC_VER>=1300
-#define get2byteAligned(x) _byteswap_ushort(*(u16*)(x))
-#else
-#define get2byteAligned(x) ((x)[0]<<8 | (x)[1])
-#endif
-
#endif /* SQL_CURSOR_H */
diff --git a/src/box/sql/date.c b/src/box/sql/date.c
index 07a57ab2a..26afd18d8 100644
--- a/src/box/sql/date.c
+++ b/src/box/sql/date.c
@@ -550,18 +550,18 @@ osLocaltime(time_t * t, struct tm *pTm)
#if !HAVE_LOCALTIME_R && !HAVE_LOCALTIME_S
struct tm *pX;
pX = localtime(t);
-#ifndef SQL_UNTESTABLE
+
if (sqlGlobalConfig.bLocaltimeFault)
pX = 0;
-#endif
+
if (pX)
*pTm = *pX;
rc = pX == 0;
#else
-#ifndef SQL_UNTESTABLE
+
if (sqlGlobalConfig.bLocaltimeFault)
return 1;
-#endif
+
#if HAVE_LOCALTIME_R
rc = localtime_r(t, pTm) == 0;
#else
diff --git a/src/box/sql/expr.c b/src/box/sql/expr.c
index ba7eea59d..00992388c 100644
--- a/src/box/sql/expr.c
+++ b/src/box/sql/expr.c
@@ -3603,7 +3603,7 @@ sqlExprCodeMove(Parse * pParse, int iFrom, int iTo, int nReg)
sqlExprCacheRemove(pParse, iFrom, nReg);
}
-#if defined(SQL_DEBUG) || defined(SQL_COVERAGE_TEST)
+#if defined(SQL_DEBUG)
/*
* Return true if any register in the range iFrom..iTo (inclusive)
* is used as part of the column cache.
@@ -3623,7 +3623,7 @@ usedAsColumnCache(Parse * pParse, int iFrom, int iTo)
}
return 0;
}
-#endif /* SQL_DEBUG || SQL_COVERAGE_TEST */
+#endif /* SQL_DEBUG */
/*
* Convert a scalar expression node to a TK_REGISTER referencing
diff --git a/src/box/sql/fault.c b/src/box/sql/fault.c
index 8ee774e4c..26eeaeedb 100644
--- a/src/box/sql/fault.c
+++ b/src/box/sql/fault.c
@@ -47,8 +47,6 @@
#include "sqlInt.h"
-#ifndef SQL_UNTESTABLE
-
/*
* Global variables.
*/
@@ -104,4 +102,3 @@ sqlEndBenignMalloc(void)
}
}
-#endif /* #ifndef SQL_UNTESTABLE */
diff --git a/src/box/sql/global.c b/src/box/sql/global.c
index 9af671a5e..b6a01731b 100644
--- a/src/box/sql/global.c
+++ b/src/box/sql/global.c
@@ -204,9 +204,7 @@ SQL_WSD struct sqlConfig sqlConfig = {
0, /* xVdbeBranch */
0, /* pVbeBranchArg */
#endif
-#ifndef SQL_UNTESTABLE
0, /* xTestCallback */
-#endif
0, /* bLocaltimeFault */
0x7ffffffe /* iOnceResetThreshold */
};
@@ -246,7 +244,3 @@ int sqlPendingByte = 0x40000000;
*/
const unsigned char sqlOpcodeProperty[] = OPFLG_INITIALIZER;
-/*
- * Name of the default collating sequence
- */
-const char sqlStrBINARY[] = "BINARY";
diff --git a/src/box/sql/random.c b/src/box/sql/random.c
index 9e1122b22..618cb96d6 100644
--- a/src/box/sql/random.c
+++ b/src/box/sql/random.c
@@ -108,7 +108,6 @@ sql_randomness(int N, void *pBuf)
} while (--N);
}
-#ifndef SQL_UNTESTABLE
/*
* For testing purposes, we sometimes want to preserve the state of
* PRNG and restore the PRNG to its saved state at a later time, or
@@ -132,4 +131,3 @@ sqlPrngRestoreState(void)
sizeof(sqlPrng)
);
}
-#endif /* SQL_UNTESTABLE */
diff --git a/src/box/sql/sqlInt.h b/src/box/sql/sqlInt.h
index 76ea9fb17..1691d89ca 100644
--- a/src/box/sql/sqlInt.h
+++ b/src/box/sql/sqlInt.h
@@ -228,19 +228,14 @@
* can insure that all cases are evaluated.
*
*/
-#ifdef SQL_COVERAGE_TEST
-void sqlCoverage(int);
-#define testcase(X) if( X ){ sqlCoverage(__LINE__); }
-#else
#define testcase(X)
-#endif
/*
* The TESTONLY macro is used to enclose variable declarations or
* other bits of code that are needed to support the arguments
* within testcase() and assert() macros.
*/
-#if !defined(NDEBUG) || defined(SQL_COVERAGE_TEST)
+#if !defined(NDEBUG)
#define TESTONLY(X) X
#else
#define TESTONLY(X)
@@ -270,15 +265,8 @@ void sqlCoverage(int);
* hint of unplanned behavior.
*
* In other words, ALWAYS and NEVER are added for defensive code.
- *
- * When doing coverage testing ALWAYS and NEVER are hard-coded to
- * be true and false so that the unreachable code they specify will
- * not be counted as untested code.
*/
-#if defined(SQL_COVERAGE_TEST) || defined(SQL_MUTATION_TEST)
-#define ALWAYS(X) (1)
-#define NEVER(X) (0)
-#elif !defined(NDEBUG)
+#if !defined(NDEBUG)
#define ALWAYS(X) ((X)?1:(assert(0),0))
#define NEVER(X) ((X)?(assert(0),1):0)
#else
@@ -1163,41 +1151,6 @@ typedef u64 uptr;
*/
#define SQL_WITHIN(P,S,E) (((uptr)(P)>=(uptr)(S))&&((uptr)(P)<(uptr)(E)))
-/*
- * Macros to determine whether the machine is big or little endian,
- * and whether or not that determination is run-time or compile-time.
- *
- * For best performance, an attempt is made to guess at the byte-order
- * using C-preprocessor macros. If that is unsuccessful, or if
- * -Dsql_RUNTIME_BYTEORDER=1 is set, then byte-order is determined
- * at run-time.
- */
-#if (defined(i386) || defined(__i386__) || defined(_M_IX86) || \
- defined(__x86_64) || defined(__x86_64__) || defined(_M_X64) || \
- defined(_M_AMD64) || defined(_M_ARM) || defined(__x86) || \
- defined(__arm__)) && !defined(SQL_RUNTIME_BYTEORDER)
-#define SQL_BYTEORDER 1234
-#define SQL_BIGENDIAN 0
-#define SQL_LITTLEENDIAN 1
-#endif
-#if (defined(sparc) || defined(__ppc__)) \
- && !defined(SQL_RUNTIME_BYTEORDER)
-#define SQL_BYTEORDER 4321
-#define SQL_BIGENDIAN 1
-#define SQL_LITTLEENDIAN 0
-#endif
-#if !defined(SQL_BYTEORDER)
-#ifdef SQL_AMALGAMATION
-const int sqlone = 1;
-#else
-extern const int sqlone;
-#endif
-#define SQL_BYTEORDER 0 /* 0 means "unknown at compile-time" */
-#define SQL_BIGENDIAN (*(char *)(&sqlone)==0)
-#define SQL_LITTLEENDIAN (*(char *)(&sqlone)==1)
-#define SQL_UTF16NATIVE (SQL_BIGENDIAN?SQL_UTF16BE:SQL_UTF16LE)
-#endif
-
/*
* Constants for the largest and smallest possible 64-bit signed integers.
* These macros are designed to work correctly on both 32-bit and 64-bit
@@ -2910,9 +2863,7 @@ struct sqlConfig {
void (*xVdbeBranch) (void *, int iSrcLine, u8 eThis, u8 eMx); /* Callback */
void *pVdbeBranchArg; /* 1st argument */
#endif
-#ifndef SQL_UNTESTABLE
int (*xTestCallback) (int); /* Invoked by sqlFaultSim() */
-#endif
int bLocaltimeFault; /* True to fail localtime() calls */
int iOnceResetThreshold; /* When to reset OP_Once counters */
};
@@ -3032,9 +2983,7 @@ void sqlScratchFree(void *);
void *sqlPageMalloc(int);
void sqlPageFree(void *);
void sqlMemSetDefault(void);
-#ifndef SQL_UNTESTABLE
void sqlBenignMallocHooks(void (*)(void), void (*)(void));
-#endif
int sqlHeapNearlyFull(void);
/*
@@ -3371,11 +3320,7 @@ int
vdbe_emit_open_cursor(struct Parse *parse, int cursor, int index_id,
struct space *space);
-#ifdef SQL_UNTESTABLE
-#define sqlFaultSim(X) SQL_OK
-#else
int sqlFaultSim(int);
-#endif
/**
* The parser calls this routine in order to create a new VIEW.
@@ -3677,10 +3622,8 @@ void sqlExprAnalyzeAggregates(NameContext *, Expr *);
void sqlExprAnalyzeAggList(NameContext *, ExprList *);
int sqlFunctionUsesThisSrc(Expr *, SrcList *);
Vdbe *sqlGetVdbe(Parse *);
-#ifndef SQL_UNTESTABLE
void sqlPrngSaveState(void);
void sqlPrngRestoreState(void);
-#endif
void sqlRollbackAll(Vdbe *);
/**
@@ -4493,16 +4436,14 @@ sql_value *sqlValueNew(sql *);
int sqlValueFromExpr(sql *, Expr *, enum field_type type,
sql_value **);
void sql_value_apply_type(sql_value *val, enum field_type type);
-#ifndef SQL_AMALGAMATION
+
extern const unsigned char sqlOpcodeProperty[];
-extern const char sqlStrBINARY[];
extern const unsigned char sqlUpperToLower[];
extern const unsigned char sqlCtypeMap[];
extern const Token sqlIntTokens[];
extern SQL_WSD struct sqlConfig sqlConfig;
extern FuncDefHash sqlBuiltinFunctions;
extern int sqlPendingByte;
-#endif
/**
* Generate code to implement the "ALTER TABLE xxx RENAME TO yyy"
@@ -4887,16 +4828,10 @@ fk_constraint_is_required(struct space *space, const int *changes);
/*
* The interface to the code in fault.c used for identifying "benign"
- * malloc failures. This is only present if sql_UNTESTABLE
- * is not defined.
+ * malloc failures.
*/
-#ifndef SQL_UNTESTABLE
void sqlBeginBenignMalloc(void);
void sqlEndBenignMalloc(void);
-#else
-#define sqlBeginBenignMalloc()
-#define sqlEndBenignMalloc()
-#endif
/*
* Allowed return values from sqlFindInIndex()
@@ -4922,9 +4857,6 @@ int sqlExprCheckHeight(Parse *, int);
#define sqlExprCheckHeight(x,y)
#endif
-u32 sqlGet4byte(const u8 *);
-void sqlPut4byte(u8 *, u32);
-
#ifdef SQL_DEBUG
void sqlParserTrace(FILE *, char *);
#endif
diff --git a/src/box/sql/util.c b/src/box/sql/util.c
index d5c93f8aa..4a93ddf09 100644
--- a/src/box/sql/util.c
+++ b/src/box/sql/util.c
@@ -38,25 +38,11 @@
*/
#include "sqlInt.h"
#include <stdarg.h>
-#if HAVE_ISNAN || SQL_HAVE_ISNAN
#include <math.h>
-#endif
#include "coll/coll.h"
#include <unicode/ucasemap.h>
#include "errinj.h"
-/*
- * Routine needed to support the testcase() macro.
- */
-#ifdef SQL_COVERAGE_TEST
-void
-sqlCoverage(int x)
-{
- static unsigned dummy = 0;
- dummy += (unsigned)x;
-}
-#endif
-
/*
* Give a callback to the test harness that can be used to simulate faults
* in places where it is difficult or expensive to do so purely by means
@@ -68,14 +54,12 @@ sqlCoverage(int x)
* Return whatever integer value the test callback returns, or return
* SQL_OK if no test callback is installed.
*/
-#ifndef SQL_UNTESTABLE
int
sqlFaultSim(int iTest)
{
int (*xCallback) (int) = sqlGlobalConfig.xTestCallback;
return xCallback ? xCallback(iTest) : SQL_OK;
}
-#endif
/*
* Return true if the floating point value is Not a Number (NaN).
@@ -87,30 +71,7 @@ int
sqlIsNaN(double x)
{
int rc; /* The value return */
-#if !SQL_HAVE_ISNAN && !HAVE_ISNAN
- /*
- * Systems that support the isnan() library function should probably
- * make use
- *
- * This NaN test sometimes fails if compiled on GCC with -ffast-math.
- * On the other hand, the use of -ffast-math comes with the following
- * warning:
- *
- * This option [-ffast-math] should never be turned on by any
- * -O option since it can result in incorrect output for programs
- * which depend on an exact implementation of IEEE or ISO
- * rules/specifications for math functions.
- */
-#ifdef __FAST_MATH__
-#error sql will not work correctly with the -ffast-math option of GCC.
-#endif
- volatile double y = x;
- volatile double z = y;
- rc = (y != z);
-#else /* if HAVE_ISNAN */
rc = isnan(x);
-#endif /* HAVE_ISNAN */
- testcase(rc);
return rc;
}
@@ -1123,53 +1084,6 @@ sqlVarintLen(u64 v)
return i;
}
-/*
- * Read or write a four-byte big-endian integer value.
- */
-u32
-sqlGet4byte(const u8 * p)
-{
-#if SQL_BYTEORDER==4321
- u32 x;
- memcpy(&x, p, 4);
- return x;
-#elif SQL_BYTEORDER==1234 && !defined(SQL_DISABLE_INTRINSIC) \
- && defined(__GNUC__) && GCC_VERSION>=4003000
- u32 x;
- memcpy(&x, p, 4);
- return __builtin_bswap32(x);
-#elif SQL_BYTEORDER==1234 && !defined(SQL_DISABLE_INTRINSIC) \
- && defined(_MSC_VER) && _MSC_VER>=1300
- u32 x;
- memcpy(&x, p, 4);
- return _byteswap_ulong(x);
-#else
- testcase(p[0] & 0x80);
- return ((unsigned)p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3];
-#endif
-}
-
-void
-sqlPut4byte(unsigned char *p, u32 v)
-{
-#if SQL_BYTEORDER==4321
- memcpy(p, &v, 4);
-#elif SQL_BYTEORDER==1234 && !defined(SQL_DISABLE_INTRINSIC) \
- && defined(__GNUC__) && GCC_VERSION>=4003000
- u32 x = __builtin_bswap32(v);
- memcpy(p, &x, 4);
-#elif SQL_BYTEORDER==1234 && !defined(SQL_DISABLE_INTRINSIC) \
- && defined(_MSC_VER) && _MSC_VER>=1300
- u32 x = _byteswap_ulong(v);
- memcpy(p, &x, 4);
-#else
- p[0] = (u8) (v >> 24);
- p[1] = (u8) (v >> 16);
- p[2] = (u8) (v >> 8);
- p[3] = (u8) v;
-#endif
-}
-
/*
* Translate a single byte of Hex into an integer.
* This routine only works if h really is a valid hexadecimal
diff --git a/src/box/sql/vdbe.c b/src/box/sql/vdbe.c
index 3bd82234e..ce609a578 100644
--- a/src/box/sql/vdbe.c
+++ b/src/box/sql/vdbe.c
@@ -147,7 +147,7 @@ int sql_found_count = 0;
* Test a register to see if it exceeds the current maximum blob size.
* If it does, record the new maximum blob size.
*/
-#if defined(SQL_TEST) && !defined(SQL_UNTESTABLE)
+#if defined(SQL_TEST)
# define UPDATE_MAX_BLOBSIZE(P) updateMaxBlobsize(P)
#else
# define UPDATE_MAX_BLOBSIZE(P)
--
2.17.1
^ permalink raw reply [flat|nested] 15+ messages in thread
* [tarantool-patches] [PATCH 2/8] Removes unused functions and commented many years ago code.
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 ` Stanislav Zudin
2019-05-19 15:15 ` [tarantool-patches] " n.pettik
2019-04-29 17:26 ` [tarantool-patches] [PATCH 3/8] Removes unused functions Stanislav Zudin
` (5 subsequent siblings)
7 siblings, 1 reply; 15+ messages in thread
From: Stanislav Zudin @ 2019-04-29 17:26 UTC (permalink / raw)
To: tarantool-patches, korablev; +Cc: Stanislav Zudin
Part of #3978
---
src/box/sql/expr.c | 62 ---------------------------
src/box/sql/malloc.c | 100 -------------------------------------------
src/box/sql/random.c | 24 -----------
src/box/sql/sqlInt.h | 12 ------
src/box/sql/util.c | 14 ------
5 files changed, 212 deletions(-)
diff --git a/src/box/sql/expr.c b/src/box/sql/expr.c
index 00992388c..ab6f9f068 100644
--- a/src/box/sql/expr.c
+++ b/src/box/sql/expr.c
@@ -3062,18 +3062,6 @@ sqlExprCodeIN(Parse * pParse, /* Parsing and code generating context */
assert(pParse->is_aborted || nVector == 1 || eType == IN_INDEX_EPH
|| eType == IN_INDEX_INDEX_ASC || eType == IN_INDEX_INDEX_DESC);
-#ifdef SQL_DEBUG
- /* Confirm that aiMap[] contains nVector integer values between 0 and
- * nVector-1.
- */
- /*
- for(i=0; i<nVector; i++){
- int j, cnt;
- for(cnt=j=0; j<nVector; j++) if( aiMap[j]==i ) cnt++;
- assert( cnt==1 );
- }
- */
-#endif
/* Code the LHS, the <expr> from "<expr> IN (...)". If the LHS is a
* vector, then it is stored in an array of nVector registers starting
@@ -3088,17 +3076,6 @@ sqlExprCodeIN(Parse * pParse, /* Parsing and code generating context */
rLhsOrig = exprCodeVector(pParse, pLeft, &iDummy);
/* Tarantoool: Order is always preserved. */
rLhs = rLhsOrig;
- /* for(i=0; i<nVector && aiMap[i]==i; i++){} /\* Are LHS fields reordered? *\/ */
- /* if( i==nVector ){ */
- /* /\* LHS fields are not reordered *\/ */
- /* rLhs = rLhsOrig; */
- /* }else{ */
- /* /\* Need to reorder the LHS fields according to aiMap *\/ */
- /* rLhs = sqlGetTempRange(pParse, nVector); */
- /* for(i=0; i<nVector; i++){ */
- /* sqlVdbeAddOp3(v, OP_Copy, rLhsOrig+i, rLhs+aiMap[i], 0); */
- /* } */
- /* } */
/* If sqlFindInIndex() did not find or create an index that is
* suitable for evaluating the IN operator, then evaluate using a
@@ -4495,21 +4472,6 @@ sqlExprCode(Parse * pParse, Expr * pExpr, int target)
}
}
-/*
- * Make a transient copy of expression pExpr and then code it using
- * sqlExprCode(). This routine works just like sqlExprCode()
- * except that the input expression is guaranteed to be unchanged.
- */
-void
-sqlExprCodeCopy(Parse * pParse, Expr * pExpr, int target)
-{
- sql *db = pParse->db;
- pExpr = sqlExprDup(db, pExpr, 0);
- if (!db->mallocFailed)
- sqlExprCode(pParse, pExpr, target);
- sql_expr_delete(db, pExpr, false);
-}
-
/*
* Generate code that will evaluate expression pExpr and store the
* results in register target. The results are guaranteed to appear
@@ -5623,27 +5585,3 @@ sqlClearTempRegCache(Parse * pParse)
pParse->nRangeReg = 0;
}
-/*
- * Validate that no temporary register falls within the range of
- * iFirst..iLast, inclusive. This routine is only call from within assert()
- * statements.
- */
-#ifdef SQL_DEBUG
-int
-sqlNoTempsInRange(Parse * pParse, int iFirst, int iLast)
-{
- int i;
- if (pParse->nRangeReg > 0
- && pParse->iRangeReg + pParse->nRangeReg < iLast
- && pParse->iRangeReg >= iFirst) {
- return 0;
- }
- for (i = 0; i < pParse->nTempReg; i++) {
- if (pParse->aTempReg[i] >= iFirst
- && pParse->aTempReg[i] <= iLast) {
- return 0;
- }
- }
- return 1;
-}
-#endif /* SQL_DEBUG */
diff --git a/src/box/sql/malloc.c b/src/box/sql/malloc.c
index d6f99b46e..ef10d64ae 100644
--- a/src/box/sql/malloc.c
+++ b/src/box/sql/malloc.c
@@ -376,106 +376,6 @@ sql_malloc64(sql_uint64 n)
return sqlMalloc(n);
}
-/*
- * Each thread may only have a single outstanding allocation from
- * xScratchMalloc(). We verify this constraint in the single-threaded
- * case by setting scratchAllocOut to 1 when an allocation
- * is outstanding clearing it when the allocation is freed.
- */
-#if !defined(NDEBUG)
-static int scratchAllocOut = 0;
-#endif
-
-/*
- * Allocate memory that is to be used and released right away.
- * This routine is similar to alloca() in that it is not intended
- * for situations where the memory might be held long-term. This
- * routine is intended to get memory to old large transient data
- * structures that would not normally fit on the stack of an
- * embedded processor.
- */
-void *
-sqlScratchMalloc(int n)
-{
- void *p;
- assert(n > 0);
-
- sqlStatusHighwater(SQL_STATUS_SCRATCH_SIZE, n);
- if (mem0.nScratchFree && sqlGlobalConfig.szScratch >= n) {
- p = mem0.pScratchFree;
- mem0.pScratchFree = mem0.pScratchFree->pNext;
- mem0.nScratchFree--;
- sqlStatusUp(SQL_STATUS_SCRATCH_USED, 1);
- } else {
- p = sqlMalloc(n);
- if (sqlGlobalConfig.bMemstat && p) {
- sqlStatusUp(SQL_STATUS_SCRATCH_OVERFLOW,
- sqlMallocSize(p));
- }
- sqlMemdebugSetType(p, MEMTYPE_SCRATCH);
- }
-
-#if !defined(NDEBUG)
- /* EVIDENCE-OF: R-12970-05880 sql will not use more than one scratch
- * buffers per thread.
- *
- * This can only be checked in single-threaded mode.
- */
- assert(scratchAllocOut == 0);
- if (p)
- scratchAllocOut++;
-#endif
-
- return p;
-}
-
-void
-sqlScratchFree(void *p)
-{
- if (p) {
-
-#if !defined(NDEBUG)
- /* Verify that no more than two scratch allocation per thread
- * is outstanding at one time. (This is only checked in the
- * single-threaded case since checking in the multi-threaded case
- * would be much more complicated.)
- */
- assert(scratchAllocOut >= 1 && scratchAllocOut <= 2);
- scratchAllocOut--;
-#endif
-
- if (SQL_WITHIN
- (p, sqlGlobalConfig.pScratch, mem0.pScratchEnd)) {
- /* Release memory from the SQL_CONFIG_SCRATCH allocation */
- ScratchFreeslot *pSlot;
- pSlot = (ScratchFreeslot *) p;
- pSlot->pNext = mem0.pScratchFree;
- mem0.pScratchFree = pSlot;
- mem0.nScratchFree++;
- assert(mem0.nScratchFree <=
- (u32) sqlGlobalConfig.nScratch);
- sqlStatusDown(SQL_STATUS_SCRATCH_USED, 1);
- } else {
- /* Release memory back to the heap */
- assert(sqlMemdebugHasType(p, MEMTYPE_SCRATCH));
- assert(sqlMemdebugNoType
- (p, (u8) ~ MEMTYPE_SCRATCH));
- sqlMemdebugSetType(p, MEMTYPE_HEAP);
- if (sqlGlobalConfig.bMemstat) {
- int iSize = sqlMallocSize(p);
- sqlStatusDown
- (SQL_STATUS_SCRATCH_OVERFLOW, iSize);
- sqlStatusDown(SQL_STATUS_MEMORY_USED,
- iSize);
- sqlStatusDown(SQL_STATUS_MALLOC_COUNT,
- 1);
- sql_sized_free(p);
- } else
- sql_sized_free(p);
- }
- }
-}
-
/*
* TRUE if p is a lookaside memory allocation from db
*/
diff --git a/src/box/sql/random.c b/src/box/sql/random.c
index 618cb96d6..78dc27293 100644
--- a/src/box/sql/random.c
+++ b/src/box/sql/random.c
@@ -107,27 +107,3 @@ sql_randomness(int N, void *pBuf)
*(zBuf++) = wsdPrng.s[t];
} while (--N);
}
-
-/*
- * For testing purposes, we sometimes want to preserve the state of
- * 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.
- */
-static SQL_WSD struct sqlPrngType sqlSavedPrng;
-void
-sqlPrngSaveState(void)
-{
- memcpy(&GLOBAL(struct sqlPrngType, sqlSavedPrng),
- &GLOBAL(struct sqlPrngType, sqlPrng), sizeof(sqlPrng)
- );
-}
-
-void
-sqlPrngRestoreState(void)
-{
- memcpy(&GLOBAL(struct sqlPrngType, sqlPrng),
- &GLOBAL(struct sqlPrngType, sqlSavedPrng),
- sizeof(sqlPrng)
- );
-}
diff --git a/src/box/sql/sqlInt.h b/src/box/sql/sqlInt.h
index 1691d89ca..3f3658421 100644
--- a/src/box/sql/sqlInt.h
+++ b/src/box/sql/sqlInt.h
@@ -2978,11 +2978,6 @@ void *sqlDbRealloc(sql *, void *, u64);
void sqlDbFree(sql *, void *);
int sqlMallocSize(void *);
int sqlDbMallocSize(sql *, void *);
-void *sqlScratchMalloc(int);
-void sqlScratchFree(void *);
-void *sqlPageMalloc(int);
-void sqlPageFree(void *);
-void sqlMemSetDefault(void);
void sqlBenignMallocHooks(void (*)(void), void (*)(void));
int sqlHeapNearlyFull(void);
@@ -3111,9 +3106,6 @@ void sqlReleaseTempReg(Parse *, int);
int sqlGetTempRange(Parse *, int);
void sqlReleaseTempRange(Parse *, int, int);
void sqlClearTempRegCache(Parse *);
-#ifdef SQL_DEBUG
-int sqlNoTempsInRange(Parse *, int, int);
-#endif
/**
* Construct a new expression. Memory for this node and for the
@@ -3577,7 +3569,6 @@ void sqlExprCacheRemove(Parse *, int, int);
void sqlExprCacheClear(Parse *);
void sql_expr_type_cache_change(Parse *, int, int);
void sqlExprCode(Parse *, Expr *, int);
-void sqlExprCodeCopy(Parse *, Expr *, int);
void sqlExprCodeFactorable(Parse *, Expr *, int);
void sqlExprCodeAtInit(Parse *, Expr *, int, u8);
int sqlExprCodeTemp(Parse *, Expr *, int *);
@@ -3622,8 +3613,6 @@ void sqlExprAnalyzeAggregates(NameContext *, Expr *);
void sqlExprAnalyzeAggList(NameContext *, ExprList *);
int sqlFunctionUsesThisSrc(Expr *, SrcList *);
Vdbe *sqlGetVdbe(Parse *);
-void sqlPrngSaveState(void);
-void sqlPrngRestoreState(void);
void sqlRollbackAll(Vdbe *);
/**
@@ -4423,7 +4412,6 @@ void sqlVdbeSetChanges(sql *, int);
int sqlAddInt64(i64 *, i64);
int sqlSubInt64(i64 *, i64);
int sqlMulInt64(i64 *, i64);
-int sqlAbsInt32(int);
u8 sqlGetBoolean(const char *z, u8);
const void *sqlValueText(sql_value *);
diff --git a/src/box/sql/util.c b/src/box/sql/util.c
index 4a93ddf09..687a0f30f 100644
--- a/src/box/sql/util.c
+++ b/src/box/sql/util.c
@@ -1257,20 +1257,6 @@ sqlMulInt64(i64 * pA, i64 iB)
return 0;
}
-/*
- * Compute the absolute value of a 32-bit signed integer, of possible. Or
- * if the integer has a value of -2147483648, return +2147483647
- */
-int
-sqlAbsInt32(int x)
-{
- if (x >= 0)
- return x;
- if (x == (int)0x80000000)
- return 0x7fffffff;
- return -x;
-}
-
/*
* Find (an approximate) sum of two LogEst values. This computation is
* not a simple "+" operator because LogEst is stored as a logarithmic
--
2.17.1
^ permalink raw reply [flat|nested] 15+ messages in thread
* [tarantool-patches] Re: [PATCH 2/8] Removes unused functions and commented many years ago code.
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 ` n.pettik
2019-05-29 8:21 ` Stanislav Zudin
0 siblings, 1 reply; 15+ messages in thread
From: n.pettik @ 2019-05-19 15:15 UTC (permalink / raw)
To: tarantool-patches; +Cc: szudin
> diff --git a/src/box/sql/expr.c b/src/box/sql/expr.c
> index 00992388c..ab6f9f068 100644
> --- a/src/box/sql/expr.c
> +++ b/src/box/sql/expr.c
> @@ -3062,18 +3062,6 @@ sqlExprCodeIN(Parse * pParse, /* Parsing and code generating context */
>
> assert(pParse->is_aborted || nVector == 1 || eType == IN_INDEX_EPH
> || eType == IN_INDEX_INDEX_ASC || eType == IN_INDEX_INDEX_DESC);
> -#ifdef SQL_DEBUG
SQL_DEBUG is a valid macro, why did you delete this chunk?
^ permalink raw reply [flat|nested] 15+ messages in thread
* [tarantool-patches] Re: [PATCH 2/8] Removes unused functions and commented many years ago code.
2019-05-19 15:15 ` [tarantool-patches] " n.pettik
@ 2019-05-29 8:21 ` Stanislav Zudin
0 siblings, 0 replies; 15+ messages in thread
From: Stanislav Zudin @ 2019-05-29 8:21 UTC (permalink / raw)
To: n.pettik, tarantool-patches
On 19.05.2019 18:15, n.pettik wrote:
>
>> diff --git a/src/box/sql/expr.c b/src/box/sql/expr.c
>> index 00992388c..ab6f9f068 100644
>> --- a/src/box/sql/expr.c
>> +++ b/src/box/sql/expr.c
>> @@ -3062,18 +3062,6 @@ sqlExprCodeIN(Parse * pParse, /* Parsing and code generating context */
>>
>> assert(pParse->is_aborted || nVector == 1 || eType == IN_INDEX_EPH
>> || eType == IN_INDEX_INDEX_ASC || eType == IN_INDEX_INDEX_DESC);
>> -#ifdef SQL_DEBUG
>
> SQL_DEBUG is a valid macro, why did you delete this chunk?
>
>
The SQL_DEBUG block contains code commented 24-04-2017
(commit id: c521545d70b24e8d22b06258f77865b96f80ff45).
^ permalink raw reply [flat|nested] 15+ messages in thread
* [tarantool-patches] [PATCH 3/8] Removes unused functions.
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-04-29 17:26 ` Stanislav Zudin
2019-04-29 17:26 ` [tarantool-patches] [PATCH 4/8] Removes unused functions and macros Stanislav Zudin
` (4 subsequent siblings)
7 siblings, 0 replies; 15+ messages in thread
From: Stanislav Zudin @ 2019-04-29 17:26 UTC (permalink / raw)
To: tarantool-patches, korablev; +Cc: Stanislav Zudin
Part of #3978
---
src/box/sql/hwtime.h | 63 --------------------------------------------
src/box/sql/main.c | 21 ---------------
src/box/sql/malloc.c | 48 ---------------------------------
src/box/sql/sqlInt.h | 8 ------
4 files changed, 140 deletions(-)
diff --git a/src/box/sql/hwtime.h b/src/box/sql/hwtime.h
index 278a1bf1c..f2196360b 100644
--- a/src/box/sql/hwtime.h
+++ b/src/box/sql/hwtime.h
@@ -43,34 +43,6 @@
* processor and returns that value. This can be used for high-res
* profiling.
*/
-#if (defined(__GNUC__) || defined(_MSC_VER)) && \
- (defined(i386) || defined(__i386__) || defined(_M_IX86))
-
-#if defined(__GNUC__)
-
-__inline__ sql_uint64
-sqlHwtime(void)
-{
- unsigned int lo, hi;
- __asm__ __volatile__("rdtsc":"=a"(lo), "=d"(hi));
- return (sql_uint64) hi << 32 | lo;
-}
-
-#elif defined(_MSC_VER)
-
-__declspec(naked)
-__inline sql_uint64 __cdecl
-sqlHwtime(void)
-{
- __asm {
- rdtsc ret;
- return value at EDX:EAX}
-}
-
-#endif
-
-#elif (defined(__GNUC__) && defined(__x86_64__))
-
__inline__ sql_uint64
sqlHwtime(void)
{
@@ -79,39 +51,4 @@ sqlHwtime(void)
return val;
}
-#elif (defined(__GNUC__) && defined(__ppc__))
-
-__inline__ sql_uint64
-sqlHwtime(void)
-{
- unsigned long long retval;
- unsigned long junk;
- __asm__ __volatile__("\n\
- 1: mftbu %1\n\
- mftb %L0\n\
- mftbu %0\n\
- cmpw %0,%1\n\
- bne 1b":"=r"(retval), "=r"(junk));
- return retval;
-}
-
-#else
-
-#error Need implementation of sqlHwtime() for your platform.
-
- /*
- * To compile without implementing sqlHwtime() for your platform,
- * you can remove the above #error and use the following
- * stub function. You will lose timing support for many
- * of the debugging and testing utilities, but it should at
- * least compile and run.
- */
-sql_uint64
-sqlHwtime(void)
-{
- return ((sql_uint64) 0);
-}
-
-#endif
-
#endif /* !defined(SQL_HWTIME_H) */
diff --git a/src/box/sql/main.c b/src/box/sql/main.c
index fe1135a71..a188f2e8a 100644
--- a/src/box/sql/main.c
+++ b/src/box/sql/main.c
@@ -513,27 +513,6 @@ sql_create_function_v2(sql * db,
return rc;
}
-#ifndef SQL_OMIT_TRACE
-/* Register a trace callback using the version-2 interface.
- */
-int
-sql_trace_v2(sql * db, /* Trace this connection */
- unsigned mTrace, /* Mask of events to be traced */
- int (*xTrace) (unsigned, void *, void *, void *), /* Callback to invoke */
- void *pArg) /* Context */
-{
- if (mTrace == 0)
- xTrace = 0;
- if (xTrace == 0)
- mTrace = 0;
- db->mTrace = mTrace;
- db->xTrace = xTrace;
- db->pTraceArg = pArg;
- return SQL_OK;
-}
-
-#endif /* SQL_OMIT_TRACE */
-
/*
* This function returns true if main-memory should be used instead of
* a temporary file for transient pager files and statement journals.
diff --git a/src/box/sql/malloc.c b/src/box/sql/malloc.c
index ef10d64ae..4bb96111f 100644
--- a/src/box/sql/malloc.c
+++ b/src/box/sql/malloc.c
@@ -253,15 +253,6 @@ sqlHeapNearlyFull(void)
return mem0.nearlyFull;
}
-/*
- * Deinitialize the memory allocation subsystem.
- */
-void
-sqlMallocEnd(void)
-{
- memset(&mem0, 0, sizeof(mem0));
-}
-
/*
* Return the amount of memory currently checked out.
*/
@@ -273,19 +264,6 @@ sql_memory_used(void)
return res;
}
-/*
- * Return the maximum amount of memory that has ever been
- * checked out since either the beginning of this process
- * or since the most recent reset.
- */
-sql_int64
-sql_memory_highwater(int resetFlag)
-{
- sql_int64 res, mx;
- sql_status64(SQL_STATUS_MEMORY_USED, &res, &mx, resetFlag);
- return mx;
-}
-
/*
* Trigger the alarm
*/
@@ -421,14 +399,6 @@ sqlDbMallocSize(sql * db, void *p)
return db->lookaside.sz;
}
-sql_uint64
-sql_msize(void *p)
-{
- assert(sqlMemdebugNoType(p, (u8) ~ MEMTYPE_HEAP));
- assert(sqlMemdebugHasType(p, MEMTYPE_HEAP));
- return p ? sql_sized_sizeof(p) : 0;
-}
-
/*
* Free memory previously obtained from sqlMalloc().
*/
@@ -545,14 +515,6 @@ sqlRealloc(void *pOld, u64 nBytes)
* The public interface to sqlRealloc. Make sure that the memory
* subsystem is initialized prior to invoking sqlRealloc.
*/
-void *
-sql_realloc(void *pOld, int n)
-{
- if (n < 0)
- n = 0; /* IMP: R-26507-47431 */
- return sqlRealloc(pOld, n);
-}
-
void *
sql_realloc64(void *pOld, sql_uint64 n)
{
@@ -777,16 +739,6 @@ sqlDbStrNDup(sql * db, const char *z, u64 n)
return zNew;
}
-/*
- * Free any prior content in *pz and replace it with a copy of zNew.
- */
-void
-sqlSetString(char **pz, sql * db, const char *zNew)
-{
- sqlDbFree(db, *pz);
- *pz = sqlDbStrDup(db, zNew);
-}
-
/*
* Call this routine to record the fact that an OOM (out-of-memory) error
* has happened. This routine will set db->mallocFailed, and also
diff --git a/src/box/sql/sqlInt.h b/src/box/sql/sqlInt.h
index 3f3658421..6ddc7d486 100644
--- a/src/box/sql/sqlInt.h
+++ b/src/box/sql/sqlInt.h
@@ -398,18 +398,12 @@ sql_malloc(int);
void *
sql_malloc64(sql_uint64);
-void *
-sql_realloc(void *, int);
-
void *
sql_realloc64(void *, sql_uint64);
void
sql_free(void *);
-sql_uint64
-sql_msize(void *);
-
int
sql_stricmp(const char *, const char *);
@@ -2964,7 +2958,6 @@ unsigned sqlStrlen30(const char *);
#define sqlStrNICmp sql_strnicmp
void sqlMallocInit(void);
-void sqlMallocEnd(void);
void *sqlMalloc(u64);
void *sqlMallocZero(u64);
void *sqlDbMallocZero(sql *, u64);
@@ -3035,7 +3028,6 @@ void sqlTreeViewSelect(TreeView *, const Select *, u8);
void sqlTreeViewWith(TreeView *, const With *);
#endif
-void sqlSetString(char **, sql *, const char *);
void sqlDequote(char *);
/**
--
2.17.1
^ permalink raw reply [flat|nested] 15+ messages in thread
* [tarantool-patches] [PATCH 4/8] Removes unused functions and macros.
2019-04-29 17:26 [tarantool-patches] [PATCH 0/8] sql: cleanup code from obsolete macros Stanislav Zudin
` (2 preceding siblings ...)
2019-04-29 17:26 ` [tarantool-patches] [PATCH 3/8] Removes unused functions Stanislav Zudin
@ 2019-04-29 17:26 ` Stanislav Zudin
2019-05-19 15:16 ` [tarantool-patches] " n.pettik
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
` (3 subsequent siblings)
7 siblings, 1 reply; 15+ messages in thread
From: Stanislav Zudin @ 2019-04-29 17:26 UTC (permalink / raw)
To: tarantool-patches, korablev; +Cc: Stanislav Zudin
Part of #3978
---
| 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(-)
--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
^ permalink raw reply [flat|nested] 15+ messages in thread
* [tarantool-patches] Re: [PATCH 4/8] Removes unused functions and macros.
2019-04-29 17:26 ` [tarantool-patches] [PATCH 4/8] Removes unused functions and macros Stanislav Zudin
@ 2019-05-19 15:16 ` n.pettik
2019-05-29 14:01 ` Stanislav Zudin
0 siblings, 1 reply; 15+ messages in thread
From: n.pettik @ 2019-05-19 15:16 UTC (permalink / raw)
To: tarantool-patches; +Cc: szudin
>
> 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
What about other if-def macros used in mkkeywordhash.c?
SQL_OMIT_AUTOINCREMENT - we always build with autoincement
SQL_OMIT_CONFLICT_CLAUSE - we always build with conflict clauses
SQL_OMIT_PRAGMA - pragmas are always enabled
^ permalink raw reply [flat|nested] 15+ messages in thread
* [tarantool-patches] Re: [PATCH 4/8] Removes unused functions and macros.
2019-05-19 15:16 ` [tarantool-patches] " n.pettik
@ 2019-05-29 14:01 ` Stanislav Zudin
0 siblings, 0 replies; 15+ messages in thread
From: Stanislav Zudin @ 2019-05-29 14:01 UTC (permalink / raw)
To: n.pettik, tarantool-patches
On 19.05.2019 18:16, n.pettik wrote:
>
>>
>> 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
>
> What about other if-def macros used in mkkeywordhash.c?
> SQL_OMIT_AUTOINCREMENT - we always build with autoincement
> SQL_OMIT_CONFLICT_CLAUSE - we always build with conflict clauses
> SQL_OMIT_PRAGMA - pragmas are always enabled
>
Thanks, fixed.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [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
2019-04-29 17:26 [tarantool-patches] [PATCH 0/8] sql: cleanup code from obsolete macros Stanislav Zudin
` (3 preceding siblings ...)
2019-04-29 17:26 ` [tarantool-patches] [PATCH 4/8] Removes unused functions and macros Stanislav Zudin
@ 2019-04-29 17:26 ` 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
` (2 subsequent siblings)
7 siblings, 0 replies; 15+ messages in thread
From: Stanislav Zudin @ 2019-04-29 17:26 UTC (permalink / raw)
To: tarantool-patches, korablev; +Cc: Stanislav Zudin
Part of #3978
---
src/box/sql/expr.c | 6 ----
src/box/sql/func.c | 30 -----------------
src/box/sql/malloc.c | 10 ------
src/box/sql/resolve.c | 6 +---
src/box/sql/util.c | 3 +-
src/box/sql/vdbe.c | 9 -----
src/box/sql/vdbe.h | 7 ----
src/box/sql/vdbeInt.h | 5 ---
src/box/sql/vdbeapi.c | 73 -----------------------------------------
src/box/sql/vdbeaux.c | 45 -------------------------
src/box/sql/where.c | 11 +------
src/box/sql/whereInt.h | 12 -------
src/box/sql/wherecode.c | 52 +++++------------------------
13 files changed, 11 insertions(+), 258 deletions(-)
diff --git a/src/box/sql/expr.c b/src/box/sql/expr.c
index 0f87eba5e..71d0cbf46 100644
--- a/src/box/sql/expr.c
+++ b/src/box/sql/expr.c
@@ -3965,12 +3965,6 @@ sqlExprCodeTarget(Parse * pParse, Expr * pExpr, int target)
assert(!ExprHasProperty(pExpr, EP_IntValue));
zId = pExpr->u.zToken;
pDef = sqlFindFunction(db, zId, nFarg, 0);
-#ifdef SQL_ENABLE_UNKNOWN_SQL_FUNCTION
- if (pDef == 0 && pParse->explain) {
- pDef =
- sqlFindFunction(db, "unknown", nFarg, 0);
- }
-#endif
if (pDef == 0 || pDef->xFinalize != 0) {
diag_set(ClientError, ER_NO_SUCH_FUNCTION,
zId);
diff --git a/src/box/sql/func.c b/src/box/sql/func.c
index f3790ba01..a2b5bc0b5 100644
--- a/src/box/sql/func.c
+++ b/src/box/sql/func.c
@@ -429,16 +429,6 @@ substrFunc(sql_context * context, int argc, sql_value ** argv)
if (p1 < 0)
len = sql_utf8_char_count(z, sql_value_bytes(argv[0]));
}
-#ifdef SQL_SUBSTR_COMPATIBILITY
- /* If SUBSTR_COMPATIBILITY is defined then substr(X,0,N) work the same as
- * as substr(X,1,N) - it returns the first N characters of X. This
- * is essentially a back-out of the bug-fix in check-in [5fc125d362df4b8]
- * from 2009-02-02 for compatibility of applications that exploited the
- * old buggy behavior.
- */
- if (p1 == 0)
- p1 = 1; /* <rdar://problem/6778339> */
-#endif
if (argc == 3) {
p2 = sql_value_int(argv[2]);
if (p2 < 0) {
@@ -1491,23 +1481,6 @@ trim_func_three_args(struct sql_context *context, int argc, sql_value **argv)
sql_free(char_len);
}
-#ifdef SQL_ENABLE_UNKNOWN_SQL_FUNCTION
-/*
- * The "unknown" function is automatically substituted in place of
- * any unrecognized function name when doing an EXPLAIN or EXPLAIN QUERY PLAN
- * when the SQL_ENABLE_UNKNOWN_FUNCTION compile-time option is used.
- * When the "sql" command-line shell is built using this functionality,
- * that allows an EXPLAIN or EXPLAIN QUERY PLAN for complex queries
- * involving application-defined functions to be examined in a generic
- * sql shell.
- */
-static void
-unknownFunc(sql_context * context, int argc, sql_value ** argv)
-{
- /* no-op */
-}
-#endif /*SQL_ENABLE_UNKNOWN_SQL_FUNCTION */
-
/* IMP: R-25361-16150 This function is omitted from sql by default. It
* is only available if the SQL_SOUNDEX compile-time option is used
* when sql is built.
@@ -1977,9 +1950,6 @@ sqlRegisterBuiltinFunctions(void)
FIELD_TYPE_INTEGER),
LIKEFUNC(like, 3, 1, SQL_FUNC_LIKE,
FIELD_TYPE_INTEGER),
-#ifdef SQL_ENABLE_UNKNOWN_SQL_FUNCTION
- FUNCTION(unknown, -1, 0, 0, unknownFunc, 0),
-#endif
FUNCTION(coalesce, 1, 0, 0, 0, FIELD_TYPE_SCALAR),
FUNCTION(coalesce, 0, 0, 0, 0, FIELD_TYPE_SCALAR),
FUNCTION2(coalesce, -1, 0, 0, noopFunc, SQL_FUNC_COALESCE,
diff --git a/src/box/sql/malloc.c b/src/box/sql/malloc.c
index 3bd2e1781..831be177e 100644
--- a/src/box/sql/malloc.c
+++ b/src/box/sql/malloc.c
@@ -128,16 +128,12 @@ sql_sized_realloc(void *pPrior, int nByte)
int
sql_release_memory(int n)
{
-#ifdef SQL_ENABLE_MEMORY_MANAGEMENT
- return sqlPcacheReleaseMemory(n);
-#else
/* IMPLEMENTATION-OF: R-34391-24921 The sql_release_memory() routine
* is a no-op returning zero if sql is not compiled with
* SQL_ENABLE_MEMORY_MANAGEMENT.
*/
UNUSED_PARAMETER(n);
return 0;
-#endif
}
/*
@@ -297,12 +293,6 @@ mallocWithAlarm(int n, void **pp)
}
}
p = sql_sized_malloc(nFull);
-#ifdef SQL_ENABLE_MEMORY_MANAGEMENT
- if (p == 0 && mem0.alarmThreshold > 0) {
- sqlMallocAlarm(nFull);
- p = sql_sized_malloc(nFull);
- }
-#endif
if (p) {
nFull = sqlMallocSize(p);
sqlStatusUp(SQL_STATUS_MEMORY_USED, nFull);
diff --git a/src/box/sql/resolve.c b/src/box/sql/resolve.c
index 504096e6d..1a021d4d1 100644
--- a/src/box/sql/resolve.c
+++ b/src/box/sql/resolve.c
@@ -674,11 +674,7 @@ resolveExprStep(Walker * pWalker, Expr * pExpr)
pParse->is_aborted = true;
pNC->nErr++;
is_agg = 0;
- } else if (no_such_func && pParse->db->init.busy == 0
-#ifdef SQL_ENABLE_UNKNOWN_SQL_FUNCTION
- && pParse->explain == 0
-#endif
- ) {
+ } else if (no_such_func && pParse->db->init.busy == 0) {
diag_set(ClientError, ER_NO_SUCH_FUNCTION, zId);
pParse->is_aborted = true;
pNC->nErr++;
diff --git a/src/box/sql/util.c b/src/box/sql/util.c
index 687a0f30f..31378041d 100644
--- a/src/box/sql/util.c
+++ b/src/box/sql/util.c
@@ -1337,8 +1337,7 @@ sqlLogEstToInt(LogEst x)
n -= 2;
else if (n >= 1)
n -= 1;
-#if defined(SQL_ENABLE_STMT_SCANSTATUS) || \
- defined(SQL_EXPLAIN_ESTIMATED_ROWS)
+#if defined(SQL_EXPLAIN_ESTIMATED_ROWS)
if (x > 60)
return (u64) LARGEST_INT64;
#else
diff --git a/src/box/sql/vdbe.c b/src/box/sql/vdbe.c
index 197df4bf3..624df25b8 100644
--- a/src/box/sql/vdbe.c
+++ b/src/box/sql/vdbe.c
@@ -705,9 +705,6 @@ int sqlVdbeExec(Vdbe *p)
start = sqlHwtime();
#endif
nVmStep++;
-#ifdef SQL_ENABLE_STMT_SCANSTATUS
- if (p->anExec) p->anExec[(int)(pOp-aOp)]++;
-#endif
/* Only allow tracing if SQL_DEBUG is defined.
*/
@@ -4954,9 +4951,6 @@ case OP_Program: { /* jump */
pFrame->aOp = p->aOp;
pFrame->nOp = p->nOp;
pFrame->token = pProgram->token;
-#ifdef SQL_ENABLE_STMT_SCANSTATUS
- pFrame->anExec = p->anExec;
-#endif
pEnd = &VdbeFrameMem(pFrame)[pFrame->nChildMem];
for(pMem=VdbeFrameMem(pFrame); pMem!=pEnd; pMem++) {
@@ -4986,9 +4980,6 @@ case OP_Program: { /* jump */
p->apCsr = (VdbeCursor **)&aMem[p->nMem];
p->aOp = aOp = pProgram->aOp;
p->nOp = pProgram->nOp;
-#ifdef SQL_ENABLE_STMT_SCANSTATUS
- p->anExec = 0;
-#endif
pOp = &aOp[-1];
break;
diff --git a/src/box/sql/vdbe.h b/src/box/sql/vdbe.h
index 5fb9d42ca..2a1a4402c 100644
--- a/src/box/sql/vdbe.h
+++ b/src/box/sql/vdbe.h
@@ -349,11 +349,4 @@ void sqlVdbeSetLineNumber(Vdbe *, int);
#define VdbeCoverageNeverTaken(v)
#define VDBE_OFFSET_LINENO(x) 0
#endif
-
-#ifdef SQL_ENABLE_STMT_SCANSTATUS
-void sqlVdbeScanStatus(Vdbe *, int, int, int, LogEst, const char *);
-#else
-#define sqlVdbeScanStatus(a,b,c,d,e)
-#endif
-
#endif /* SQL_VDBE_H */
diff --git a/src/box/sql/vdbeInt.h b/src/box/sql/vdbeInt.h
index eabec1519..a5933a5e7 100644
--- a/src/box/sql/vdbeInt.h
+++ b/src/box/sql/vdbeInt.h
@@ -446,11 +446,6 @@ struct Vdbe {
AuxData *pAuxData; /* Linked list of auxdata allocations */
/* Anonymous savepoint for aborts only */
Savepoint *anonymous_savepoint;
-#ifdef SQL_ENABLE_STMT_SCANSTATUS
- i64 *anExec; /* Number of times each op has been executed */
- int nScan; /* Entries in aScan[] */
- ScanStatus *aScan; /* Scan definitions for sql_stmt_scanstatus() */
-#endif
};
/*
diff --git a/src/box/sql/vdbeapi.c b/src/box/sql/vdbeapi.c
index e1d100e04..9593071f3 100644
--- a/src/box/sql/vdbeapi.c
+++ b/src/box/sql/vdbeapi.c
@@ -1575,76 +1575,3 @@ sql_expanded_sql(sql_stmt * pStmt)
return z;
}
-#ifdef SQL_ENABLE_STMT_SCANSTATUS
-/*
- * Return status data for a single loop within query pStmt.
- */
-int
-sql_stmt_scanstatus(sql_stmt * pStmt, /* Prepared statement being queried */
- int idx, /* Index of loop to report on */
- int iScanStatusOp, /* Which metric to return */
- void *pOut /* OUT: Write the answer here */
- )
-{
- Vdbe *p = (Vdbe *) pStmt;
- ScanStatus *pScan;
- if (idx < 0 || idx >= p->nScan)
- return 1;
- pScan = &p->aScan[idx];
- switch (iScanStatusOp) {
- case SQL_SCANSTAT_NLOOP:{
- *(sql_int64 *) pOut = p->anExec[pScan->addrLoop];
- break;
- }
- case SQL_SCANSTAT_NVISIT:{
- *(sql_int64 *) pOut = p->anExec[pScan->addrVisit];
- break;
- }
- case SQL_SCANSTAT_EST:{
- double r = 1.0;
- LogEst x = pScan->nEst;
- while (x < 100) {
- x += 10;
- r *= 0.5;
- }
- *(double *)pOut = r * sqlLogEstToInt(x);
- break;
- }
- case SQL_SCANSTAT_NAME:{
- *(const char **)pOut = pScan->zName;
- break;
- }
- case SQL_SCANSTAT_EXPLAIN:{
- if (pScan->addrExplain) {
- *(const char **)pOut =
- p->aOp[pScan->addrExplain].p4.z;
- } else {
- *(const char **)pOut = 0;
- }
- break;
- }
- case SQL_SCANSTAT_SELECTID:{
- if (pScan->addrExplain) {
- *(int *)pOut = p->aOp[pScan->addrExplain].p1;
- } else {
- *(int *)pOut = -1;
- }
- break;
- }
- default:{
- return 1;
- }
- }
- return 0;
-}
-
-/*
- * Zero all counters associated with the sql_stmt_scanstatus() data.
- */
-void
-sql_stmt_scanstatus_reset(sql_stmt * pStmt)
-{
- Vdbe *p = (Vdbe *) pStmt;
- memset(p->anExec, 0, p->nOp * sizeof(i64));
-}
-#endif /* SQL_ENABLE_STMT_SCANSTATUS */
diff --git a/src/box/sql/vdbeaux.c b/src/box/sql/vdbeaux.c
index 2f78e19d8..a90c492fe 100644
--- a/src/box/sql/vdbeaux.c
+++ b/src/box/sql/vdbeaux.c
@@ -743,33 +743,6 @@ sqlVdbeTakeOpArray(Vdbe * p, int *pnOp, int *pnMaxArg)
return aOp;
}
-#if defined(SQL_ENABLE_STMT_SCANSTATUS)
-/*
- * Add an entry to the array of counters managed by sql_stmt_scanstatus().
- */
-void
-sqlVdbeScanStatus(Vdbe * p, /* VM to add scanstatus() to */
- int addrExplain, /* Address of OP_Explain (or 0) */
- int addrLoop, /* Address of loop counter */
- int addrVisit, /* Address of rows visited counter */
- LogEst nEst, /* Estimated number of output rows */
- const char *zName) /* Name of table or index being scanned */
-{
- int nByte = (p->nScan + 1) * sizeof(ScanStatus);
- ScanStatus *aNew;
- aNew = (ScanStatus *) sqlDbRealloc(p->db, p->aScan, nByte);
- if (aNew) {
- ScanStatus *pNew = &aNew[p->nScan++];
- pNew->addrExplain = addrExplain;
- pNew->addrLoop = addrLoop;
- pNew->addrVisit = addrVisit;
- pNew->nEst = nEst;
- pNew->zName = sqlDbStrDup(p->db, zName);
- p->aScan = aNew;
- }
-}
-#endif
-
/*
* Change the value of the opcode, or P1, P2, P3, or P5 operands
* for a specific instruction.
@@ -1921,9 +1894,6 @@ sqlVdbeMakeReady(Vdbe * p, /* The VDBE */
p->apArg = allocSpace(&x, p->apArg, nArg * sizeof(Mem *));
p->apCsr =
allocSpace(&x, p->apCsr, nCursor * sizeof(VdbeCursor *));
-#ifdef SQL_ENABLE_STMT_SCANSTATUS
- p->anExec = allocSpace(&x, p->anExec, p->nOp * sizeof(i64));
-#endif
if (x.nNeeded == 0)
break;
x.pSpace = p->pFree = sqlDbMallocRawNN(db, x.nNeeded);
@@ -1944,9 +1914,6 @@ sqlVdbeMakeReady(Vdbe * p, /* The VDBE */
p->nMem = nMem;
initMemArray(p->aMem, nMem, db, MEM_Undefined);
memset(p->apCsr, 0, nCursor * sizeof(VdbeCursor *));
-#ifdef SQL_ENABLE_STMT_SCANSTATUS
- memset(p->anExec, 0, p->nOp * sizeof(i64));
-#endif
}
sqlVdbeRewind(p);
}
@@ -2002,9 +1969,6 @@ sqlVdbeFrameRestore(VdbeFrame * pFrame)
{
Vdbe *v = pFrame->v;
closeCursorsInFrame(v);
-#ifdef SQL_ENABLE_STMT_SCANSTATUS
- v->anExec = pFrame->anExec;
-#endif
v->aOp = pFrame->aOp;
v->nOp = pFrame->nOp;
v->aMem = pFrame->aMem;
@@ -2689,15 +2653,6 @@ sqlVdbeClearObject(sql * db, Vdbe * p)
vdbeFreeOpArray(db, p->aOp, p->nOp);
sqlDbFree(db, p->aColName);
sqlDbFree(db, p->zSql);
-#ifdef SQL_ENABLE_STMT_SCANSTATUS
- {
- int i;
- for (i = 0; i < p->nScan; i++) {
- sqlDbFree(db, p->aScan[i].zName);
- }
- sqlDbFree(db, p->aScan);
- }
-#endif
}
/*
diff --git a/src/box/sql/where.c b/src/box/sql/where.c
index 19ee2d03a..efd4f4f4b 100644
--- a/src/box/sql/where.c
+++ b/src/box/sql/where.c
@@ -4678,10 +4678,7 @@ sqlWhereBegin(Parse * pParse, /* The parser context */
*/
notReady = ~(Bitmask) 0;
for (ii = 0; ii < nTabList; ii++) {
- int addrExplain;
- int wsFlags;
pLevel = &pWInfo->a[ii];
- wsFlags = pLevel->pWLoop->wsFlags;
#ifndef SQL_OMIT_AUTOMATIC_INDEX
if ((pLevel->pWLoop->wsFlags & WHERE_AUTO_INDEX) != 0) {
constructAutomaticIndex(pParse, &pWInfo->sWC,
@@ -4691,17 +4688,11 @@ sqlWhereBegin(Parse * pParse, /* The parser context */
goto whereBeginError;
}
#endif
- addrExplain =
- sqlWhereExplainOneScan(pParse, pTabList, pLevel, ii,
+ sqlWhereExplainOneScan(pParse, pTabList, pLevel, ii,
pLevel->iFrom, wctrlFlags);
pLevel->addrBody = sqlVdbeCurrentAddr(v);
notReady = sqlWhereCodeOneLoopStart(pWInfo, ii, notReady);
pWInfo->iContinue = pLevel->addrCont;
- if ((wsFlags & WHERE_MULTI_OR) == 0
- && (wctrlFlags & WHERE_OR_SUBCLAUSE) == 0) {
- sqlWhereAddScanStatus(v, pTabList, pLevel,
- addrExplain);
- }
}
/* Done. */
diff --git a/src/box/sql/whereInt.h b/src/box/sql/whereInt.h
index 47430aef1..e39e00210 100644
--- a/src/box/sql/whereInt.h
+++ b/src/box/sql/whereInt.h
@@ -102,9 +102,6 @@ struct WhereLevel {
} u;
struct WhereLoop *pWLoop; /* The selected WhereLoop object */
Bitmask notReady; /* FROM entries not usable at this level */
-#ifdef SQL_ENABLE_STMT_SCANSTATUS
- int addrVisit; /* Address at which row is visited */
-#endif
};
/*
@@ -458,15 +455,6 @@ int sqlWhereExplainOneScan(Parse * pParse, /* Parse context */
int iFrom, /* Value for "from" column of output */
u16 wctrlFlags /* Flags passed to sqlWhereBegin() */
);
-#ifdef SQL_ENABLE_STMT_SCANSTATUS
-void sqlWhereAddScanStatus(Vdbe * v, /* Vdbe to add scanstatus entry to */
- SrcList * pSrclist, /* FROM clause pLvl reads data from */
- WhereLevel * pLvl, /* Level to add scanstatus() entry for */
- int addrExplain /* Address of OP_Explain (or 0) */
- );
-#else
-#define sqlWhereAddScanStatus(a, b, c, d) ((void)d)
-#endif
Bitmask sqlWhereCodeOneLoopStart(WhereInfo * pWInfo, /* Complete information about the WHERE clause */
int iLevel, /* Which level of pWInfo->a[] should be coded */
Bitmask notReady /* Which tables are currently available */
diff --git a/src/box/sql/wherecode.c b/src/box/sql/wherecode.c
index a453fe979..4dedb38a7 100644
--- a/src/box/sql/wherecode.c
+++ b/src/box/sql/wherecode.c
@@ -158,7 +158,7 @@ explainIndexRange(StrAccum * pStr, WhereLoop * pLoop)
/*
* This function is a no-op unless currently processing an EXPLAIN QUERY PLAN
- * command, or if either SQL_DEBUG or SQL_ENABLE_STMT_SCANSTATUS was
+ * command, or if SQL_DEBUG was
* defined at compile-time. If it is not a no-op, a single OP_Explain opcode
* is added to the output to describe the table scan strategy in pLevel.
*
@@ -174,7 +174,7 @@ sqlWhereExplainOneScan(Parse * pParse, /* Parse context */
u16 wctrlFlags) /* Flags passed to sqlWhereBegin() */
{
int ret = 0;
-#if !defined(SQL_DEBUG) && !defined(SQL_ENABLE_STMT_SCANSTATUS)
+#if !defined(SQL_DEBUG)
if (pParse->explain == 2)
#endif
{
@@ -269,34 +269,6 @@ sqlWhereExplainOneScan(Parse * pParse, /* Parse context */
return ret;
}
-#ifdef SQL_ENABLE_STMT_SCANSTATUS
-/*
- * Configure the VM passed as the first argument with an
- * sql_stmt_scanstatus() entry corresponding to the scan used to
- * implement level pLvl. Argument pSrclist is a pointer to the FROM
- * clause that the scan reads data from.
- *
- * If argument addrExplain is not 0, it must be the address of an
- * OP_Explain instruction that describes the same loop.
- */
-void
-sqlWhereAddScanStatus(Vdbe * v, /* Vdbe to add scanstatus entry to */
- SrcList * pSrclist, /* FROM clause pLvl reads data from */
- WhereLevel * pLvl, /* Level to add scanstatus() entry for */
- int addrExplain) /* Address of OP_Explain (or 0) */
-{
- const char *zObj = 0;
- WhereLoop *pLoop = pLvl->pWLoop;
- if (pLoop->pIndex != 0) {
- zObj = pLoop->pIndex->zName;
- } else {
- zObj = pSrclist->a[pLvl->iFrom].zName;
- }
- sqlVdbeScanStatus(v, addrExplain, pLvl->addrBody, pLvl->addrVisit,
- pLoop->nOut, zObj);
-}
-#endif
-
/*
* Disable a term in the WHERE clause. Except, do not disable the term
* if it controls a LEFT OUTER JOIN and it did not originate in the ON
@@ -1415,16 +1387,12 @@ sqlWhereCodeOneLoopStart(WhereInfo * pWInfo, /* Complete information about the W
|| db->mallocFailed);
if (pSubWInfo) {
WhereLoop *pSubLoop;
- int addrExplain =
- sqlWhereExplainOneScan(pParse,
- pOrTab,
- &pSubWInfo->a[0],
- iLevel,
- pLevel->iFrom,
- 0);
- sqlWhereAddScanStatus(v, pOrTab,
- &pSubWInfo->a[0],
- addrExplain);
+ sqlWhereExplainOneScan(pParse,
+ pOrTab,
+ &pSubWInfo->a[0],
+ iLevel,
+ pLevel->iFrom,
+ 0);
/* This is the sub-WHERE clause body. First skip over
* duplicate rows from prior sub-WHERE clauses, and record the
@@ -1578,10 +1546,6 @@ sqlWhereCodeOneLoopStart(WhereInfo * pWInfo, /* Complete information about the W
}
}
-#ifdef SQL_ENABLE_STMT_SCANSTATUS
- pLevel->addrVisit = sqlVdbeCurrentAddr(v);
-#endif
-
/* Insert code to test every subexpression that can be completely
* computed using the current set of tables.
*/
--
2.17.1
^ permalink raw reply [flat|nested] 15+ messages in thread
* [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
2019-04-29 17:26 [tarantool-patches] [PATCH 0/8] sql: cleanup code from obsolete macros Stanislav Zudin
` (4 preceding siblings ...)
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 ` Stanislav Zudin
2019-05-19 15:16 ` [tarantool-patches] " n.pettik
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
7 siblings, 1 reply; 15+ messages in thread
From: Stanislav Zudin @ 2019-04-29 17:26 UTC (permalink / raw)
To: tarantool-patches, korablev; +Cc: Stanislav Zudin
Part of #3978
---
src/box/sql/CMakeLists.txt | 3 -
src/box/sql/expr.c | 14 -
src/box/sql/main.c | 8 -
src/box/sql/os_unix.c | 2 -
src/box/sql/sqlInt.h | 21 +-
src/box/sql/util.c | 5 -
src/box/sql/vdbe.c | 20 --
src/box/sql/vdbeInt.h | 3 -
src/box/sql/vdbesort.c | 639 +++----------------------------------
src/box/sql/where.c | 313 ------------------
src/box/sql/wherecode.c | 8 -
11 files changed, 45 insertions(+), 991 deletions(-)
diff --git a/src/box/sql/CMakeLists.txt b/src/box/sql/CMakeLists.txt
index b9dbe141a..f988dc3e7 100644
--- a/src/box/sql/CMakeLists.txt
+++ b/src/box/sql/CMakeLists.txt
@@ -10,9 +10,6 @@ set(SQL_BIN_DIR ${CMAKE_BINARY_DIR}/src/box/sql)
include_directories(${SQL_SRC_DIR})
include_directories(${SQL_BIN_DIR})
-add_definitions(-DSQL_MAX_WORKER_THREADS=0)
-add_definitions(-DSQL_OMIT_AUTOMATIC_INDEX)
-
set(TEST_DEFINITIONS
SQL_NO_SYNC=1
SQL_TEST=1
diff --git a/src/box/sql/expr.c b/src/box/sql/expr.c
index 71d0cbf46..48d7185f3 100644
--- a/src/box/sql/expr.c
+++ b/src/box/sql/expr.c
@@ -2570,20 +2570,6 @@ sqlFindInIndex(Parse * pParse, /* Parsing context */
parts[0].sort_order;
if (prRhsHasNull) {
-#ifdef SQL_ENABLE_COLUMN_USED_MASK
- i64 mask =
- (1 << nExpr) - 1;
- sqlVdbeAddOp4Dup8(v,
- OP_ColumnsUsed,
- iTab,
- 0,
- 0,
- (u8
- *)
- &
- mask,
- P4_INT64);
-#endif
*prRhsHasNull = ++pParse->nMem;
if (nExpr == 1) {
/* Tarantool: Check for null is performed on first key of the index. */
diff --git a/src/box/sql/main.c b/src/box/sql/main.c
index c0c334f89..339b456df 100644
--- a/src/box/sql/main.c
+++ b/src/box/sql/main.c
@@ -533,7 +533,6 @@ static const int aHardLimit[] = {
SQL_MAX_ATTACHED,
SQL_MAX_LIKE_PATTERN_LENGTH,
SQL_MAX_TRIGGER_DEPTH,
- SQL_MAX_WORKER_THREADS,
};
/*
@@ -569,9 +568,6 @@ static const int aHardLimit[] = {
#if SQL_MAX_TRIGGER_DEPTH<1
#error SQL_MAX_TRIGGER_DEPTH must be at least 1
#endif
-#if SQL_MAX_WORKER_THREADS<0 || SQL_MAX_WORKER_THREADS>50
-#error SQL_MAX_WORKER_THREADS must be between 0 and 50
-#endif
/*
* Change the value of a limit. Report the old value.
@@ -607,9 +603,6 @@ sql_limit(sql * db, int limitId, int newLimit)
SQL_MAX_LIKE_PATTERN_LENGTH);
assert(aHardLimit[SQL_LIMIT_TRIGGER_DEPTH] ==
SQL_MAX_TRIGGER_DEPTH);
- assert(aHardLimit[SQL_LIMIT_WORKER_THREADS] ==
- SQL_MAX_WORKER_THREADS);
- assert(SQL_LIMIT_WORKER_THREADS == (SQL_N_LIMIT - 1));
if (limitId < 0 || limitId >= SQL_N_LIMIT) {
return -1;
@@ -652,7 +645,6 @@ sql_init_db(sql **out_db)
assert(sizeof(db->aLimit) == sizeof(aHardLimit));
memcpy(db->aLimit, aHardLimit, sizeof(db->aLimit));
- db->aLimit[SQL_LIMIT_WORKER_THREADS] = SQL_DEFAULT_WORKER_THREADS;
db->aLimit[SQL_LIMIT_COMPOUND_SELECT] = SQL_DEFAULT_COMPOUND_SELECT;
db->szMmap = sqlGlobalConfig.szMmap;
db->nMaxSorterMmap = 0x7FFFFFFF;
diff --git a/src/box/sql/os_unix.c b/src/box/sql/os_unix.c
index 615d539b5..f9969b447 100644
--- a/src/box/sql/os_unix.c
+++ b/src/box/sql/os_unix.c
@@ -1937,7 +1937,6 @@ unixDelete(sql_vfs * NotUsed, /* VFS containing this as the xDelete method */
}
return rc;
}
-#ifndef SQL_DISABLE_DIRSYNC
if ((dirSync & 1) != 0) {
int fd;
rc = openDirectory(zPath, &fd);
@@ -1953,7 +1952,6 @@ unixDelete(sql_vfs * NotUsed, /* VFS containing this as the xDelete method */
rc = SQL_OK;
}
}
-#endif
return rc;
}
diff --git a/src/box/sql/sqlInt.h b/src/box/sql/sqlInt.h
index f019cd291..4bf94fad2 100644
--- a/src/box/sql/sqlInt.h
+++ b/src/box/sql/sqlInt.h
@@ -341,7 +341,6 @@ struct sql_vfs {
#define SQL_LIMIT_ATTACHED 7
#define SQL_LIMIT_LIKE_PATTERN_LENGTH 8
#define SQL_LIMIT_TRIGGER_DEPTH 9
-#define SQL_LIMIT_WORKER_THREADS 10
enum sql_ret_code {
/** Result of a routine is ok. */
@@ -945,17 +944,6 @@ sql_bind_parameter_lindex(sql_stmt * pStmt, const char *zName,
#define SQL_DEFAULT_RECURSIVE_TRIGGERS 0
#endif
-#ifndef SQL_MAX_WORKER_THREADS
-#define SQL_MAX_WORKER_THREADS 8
-#endif
-#ifndef SQL_DEFAULT_WORKER_THREADS
-#define SQL_DEFAULT_WORKER_THREADS 0
-#endif
-#if SQL_DEFAULT_WORKER_THREADS>SQL_MAX_WORKER_THREADS
-#undef SQL_MAX_WORKER_THREADS
-#define SQL_MAX_WORKER_THREADS SQL_DEFAULT_WORKER_THREADS
-#endif
-
/**
* Default count of allowed compound selects.
*
@@ -1296,7 +1284,7 @@ typedef int VList;
* The number of different kinds of things that can be limited
* using the sql_limit() interface.
*/
-#define SQL_N_LIMIT (SQL_LIMIT_WORKER_THREADS+1)
+#define SQL_N_LIMIT (SQL_LIMIT_TRIGGER_DEPTH+1)
/*
* Lookaside malloc is a set of fixed-size buffers that can be used
@@ -4858,13 +4846,6 @@ int sqlMemdebugNoType(void *, u8);
#define MEMTYPE_SCRATCH 0x04 /* Scratch allocations */
#define MEMTYPE_PCACHE 0x08 /* Page cache allocations */
-/*
- * Threading interface
- */
-#if SQL_MAX_WORKER_THREADS>0
-int sqlThreadCreate(sqlThread **, void *(*)(void *), void *);
-int sqlThreadJoin(sqlThread *, void **);
-#endif
int sqlExprVectorSize(Expr * pExpr);
int sqlExprIsVector(Expr * pExpr);
diff --git a/src/box/sql/util.c b/src/box/sql/util.c
index 31378041d..39632e38d 100644
--- a/src/box/sql/util.c
+++ b/src/box/sql/util.c
@@ -1337,15 +1337,10 @@ sqlLogEstToInt(LogEst x)
n -= 2;
else if (n >= 1)
n -= 1;
-#if defined(SQL_EXPLAIN_ESTIMATED_ROWS)
- if (x > 60)
- return (u64) LARGEST_INT64;
-#else
/* The largest input possible to this routine is 310,
* resulting in a maximum x of 31
*/
assert(x <= 60);
-#endif
return x >= 3 ? (n + 8) << (x - 3) : (n + 8) >> (3 - x);
}
diff --git a/src/box/sql/vdbe.c b/src/box/sql/vdbe.c
index 624df25b8..738a0701b 100644
--- a/src/box/sql/vdbe.c
+++ b/src/box/sql/vdbe.c
@@ -3346,26 +3346,6 @@ case OP_Close: {
break;
}
-#ifdef SQL_ENABLE_COLUMN_USED_MASK
-/* Opcode: ColumnsUsed P1 * * P4 *
- *
- * This opcode (which only exists if sql was compiled with
- * SQL_ENABLE_COLUMN_USED_MASK) identifies which columns of the
- * table or index for cursor P1 are used. P4 is a 64-bit integer
- * (P4_INT64) in which the first 63 bits are one for each of the
- * first 63 columns of the table or index that are actually used
- * by the cursor. The high-order bit is set if any column after
- * the 64th is used.
- */
-case OP_ColumnsUsed: {
- VdbeCursor *pC;
- pC = p->apCsr[pOp->p1];
- assert(pC->eCurType==CURTYPE_TARANTOOL);
- pC->maskUsed = *(u64*)pOp->p4.pI64;
- break;
-}
-#endif
-
/* Opcode: SeekGE P1 P2 P3 P4 P5
* Synopsis: key=r[P3@P4]
*
diff --git a/src/box/sql/vdbeInt.h b/src/box/sql/vdbeInt.h
index a5933a5e7..a070e87f8 100644
--- a/src/box/sql/vdbeInt.h
+++ b/src/box/sql/vdbeInt.h
@@ -116,9 +116,6 @@ struct VdbeCursor {
const u8 *aRow; /* Data for the current row, if all on one page */
u32 payloadSize; /* Total number of bytes in the record */
u32 szRow; /* Byte available in aRow */
-#ifdef SQL_ENABLE_COLUMN_USED_MASK
- u64 maskUsed; /* Mask of columns used by this cursor */
-#endif
u32 nRowField; /* Number of fields in the current row */
/* Offsets for all fields in the record [nField+1]
* Order of fields is the same as it was passes to create table statement
diff --git a/src/box/sql/vdbesort.c b/src/box/sql/vdbesort.c
index ddea6752c..a37fbd911 100644
--- a/src/box/sql/vdbesort.c
+++ b/src/box/sql/vdbesort.c
@@ -118,11 +118,6 @@
* there are already N worker threads running, the main thread does the work
* itself.
*
- * The sorter is running in multi-threaded mode if (a) the library was built
- * with pre-processor symbol SQL_MAX_WORKER_THREADS set to a value greater
- * than zero, and (b) worker threads have been enabled at runtime by calling
- * "PRAGMA threads=N" with some value of N greater than 0.
- *
* When Rewind() is called, any data remaining in memory is flushed to a
* final PMA. So at this point the data is stored in some number of sorted
* PMAs within temporary files on disk.
@@ -159,15 +154,6 @@
#include "sqlInt.h"
#include "vdbeInt.h"
-/*
- * If SQL_DEBUG_SORTER_THREADS is defined, this module outputs various
- * messages to stderr that may be helpful in understanding the performance
- * characteristics of the sorter in multi-threaded mode.
- */
-#if 0
-#define SQL_DEBUG_SORTER_THREADS 1
-#endif
-
/*
* Hard-coded maximum amount of data to accumulate in memory before flushing
* to a level 0 PMA. The purpose of this limit is to prevent various integer
@@ -297,18 +283,14 @@ struct MergeEngine {
*
* Before a background thread is launched, variable bDone is set to 0. Then,
* right before it exits, the thread itself sets bDone to 1. This is used for
- * two purposes:
+ * the following purpose:
*
- * 1. When flushing the contents of memory to a level-0 PMA on disk, to
+ * When flushing the contents of memory to a level-0 PMA on disk, to
* attempt to select a SortSubtask for which there is not already an
* active background thread (since doing so causes the main thread
* to block until it finishes).
*
- * 2. If SQL_DEBUG_SORTER_THREADS is defined, to determine if a call
- * to sqlThreadJoin() is likely to block. Cases that are likely to
- * block provoke debugging output.
- *
- * In both cases, the effects of the main thread seeing (bDone==0) even
+ * The effects of the main thread seeing (bDone==0) even
* after the thread has finished are not dire. So we don't worry about
* memory barriers and such here.
*/
@@ -855,25 +837,6 @@ sqlVdbeSorterInit(sql * db, /* Database connection (for malloc()) */
int i; /* Used to iterate through aTask[] */
VdbeSorter *pSorter; /* The new sorter */
int rc = SQL_OK;
-#if SQL_MAX_WORKER_THREADS==0
-#define nWorker 0
-#else
- int nWorker;
-#endif
-
- /* Initialize the upper limit on the number of worker threads */
-#if SQL_MAX_WORKER_THREADS>0
- nWorker = db->aLimit[SQL_LIMIT_WORKER_THREADS];
-#endif
-
- /* Do not allow the total number of threads (main thread + all workers)
- * to exceed the maximum merge count
- */
-#if SQL_MAX_WORKER_THREADS>=SORTER_MAX_MERGE_COUNT
- if (nWorker >= SORTER_MAX_MERGE_COUNT) {
- nWorker = SORTER_MAX_MERGE_COUNT - 1;
- }
-#endif
assert(pCsr->key_def != NULL);
assert(pCsr->eCurType == CURTYPE_SORTER);
@@ -885,8 +848,8 @@ sqlVdbeSorterInit(sql * db, /* Database connection (for malloc()) */
} else {
pSorter->key_def = pCsr->key_def;
pSorter->pgsz = pgsz = 1024;
- pSorter->nTask = nWorker + 1;
- pSorter->iPrev = (u8) (nWorker - 1);
+ pSorter->nTask = 1;
+ pSorter->iPrev = (u8) (-1);
pSorter->bUseThreads = (pSorter->nTask > 1);
pSorter->db = db;
for (i = 0; i < pSorter->nTask; i++) {
@@ -927,8 +890,6 @@ sqlVdbeSorterInit(sql * db, /* Database connection (for malloc()) */
return rc;
}
-#undef nWorker /* Defined at the top of this function */
-
/*
* Free the list of sorted records starting at pRecord.
*/
@@ -951,18 +912,10 @@ static void
vdbeSortSubtaskCleanup(sql * db, SortSubtask * pTask)
{
sqlDbFree(db, pTask->pUnpacked);
-#if SQL_MAX_WORKER_THREADS>0
- /* pTask->list.aMemory can only be non-zero if it was handed memory
- * from the main thread. That only occurs SQL_MAX_WORKER_THREADS>0
- */
- if (pTask->list.aMemory) {
- sql_free(pTask->list.aMemory);
- } else
-#endif
- {
- assert(pTask->list.aMemory == 0);
- vdbeSorterRecordFree(0, pTask->list.pList);
- }
+
+ assert(pTask->list.aMemory == 0);
+ vdbeSorterRecordFree(0, pTask->list.pList);
+
if (pTask->file.pFd) {
sqlOsCloseFree(pTask->file.pFd);
}
@@ -972,116 +925,7 @@ vdbeSortSubtaskCleanup(sql * db, SortSubtask * pTask)
memset(pTask, 0, sizeof(SortSubtask));
}
-#ifdef SQL_DEBUG_SORTER_THREADS
-static void
-vdbeSorterWorkDebug(SortSubtask * pTask, const char *zEvent)
-{
- i64 t;
- int iTask = (pTask - pTask->pSorter->aTask);
- sqlOsCurrentTimeInt64(pTask->pSorter->db->pVfs, &t);
- fprintf(stderr, "%lld:%d %s\n", t, iTask, zEvent);
-}
-
-static void
-vdbeSorterRewindDebug(const char *zEvent)
-{
- i64 t;
- sqlOsCurrentTimeInt64(sql_vfs_find(0), &t);
- fprintf(stderr, "%lld:X %s\n", t, zEvent);
-}
-
-static void
-vdbeSorterPopulateDebug(SortSubtask * pTask, const char *zEvent)
-{
- i64 t;
- int iTask = (pTask - pTask->pSorter->aTask);
- sqlOsCurrentTimeInt64(pTask->pSorter->db->pVfs, &t);
- fprintf(stderr, "%lld:bg%d %s\n", t, iTask, zEvent);
-}
-
-static void
-vdbeSorterBlockDebug(SortSubtask * pTask, int bBlocked, const char *zEvent)
-{
- if (bBlocked) {
- i64 t;
- sqlOsCurrentTimeInt64(pTask->pSorter->db->pVfs, &t);
- fprintf(stderr, "%lld:main %s\n", t, zEvent);
- }
-}
-#else
-#define vdbeSorterWorkDebug(x,y)
-#define vdbeSorterRewindDebug(y)
-#define vdbeSorterPopulateDebug(x,y)
-#define vdbeSorterBlockDebug(x,y,z)
-#endif
-
-#if SQL_MAX_WORKER_THREADS>0
-/*
- * Join thread pTask->thread.
- */
-static int
-vdbeSorterJoinThread(SortSubtask * pTask)
-{
- int rc = SQL_OK;
- if (pTask->pThread) {
-#ifdef SQL_DEBUG_SORTER_THREADS
- int bDone = pTask->bDone;
-#endif
- void *pRet = SQL_INT_TO_PTR(SQL_ERROR);
- vdbeSorterBlockDebug(pTask, !bDone, "enter");
- (void)sqlThreadJoin(pTask->pThread, &pRet);
- vdbeSorterBlockDebug(pTask, !bDone, "exit");
- rc = SQL_PTR_TO_INT(pRet);
- assert(pTask->bDone == 1);
- pTask->bDone = 0;
- pTask->pThread = 0;
- }
- return rc;
-}
-
-/*
- * Launch a background thread to run xTask(pIn).
- */
-static int
-vdbeSorterCreateThread(SortSubtask * pTask, /* Thread will use this task object */
- void *(*xTask) (void *), /* Routine to run in a separate thread */
- void *pIn /* Argument passed into xTask() */
- )
-{
- assert(pTask->pThread == 0 && pTask->bDone == 0);
- return sqlThreadCreate(&pTask->pThread, xTask, pIn);
-}
-
-/*
- * Join all outstanding threads launched by SorterWrite() to create
- * level-0 PMAs.
- */
-static int
-vdbeSorterJoinAll(VdbeSorter * pSorter, int rcin)
-{
- int rc = rcin;
- int i;
-
- /* This function is always called by the main user thread.
- *
- * If this function is being called after SorterRewind() has been called,
- * it is possible that thread pSorter->aTask[pSorter->nTask-1].pThread
- * is currently attempt to join one of the other threads. To avoid a race
- * condition where this thread also attempts to join the same object, join
- * thread pSorter->aTask[pSorter->nTask-1].pThread first.
- */
- for (i = pSorter->nTask - 1; i >= 0; i--) {
- SortSubtask *pTask = &pSorter->aTask[i];
- int rc2 = vdbeSorterJoinThread(pTask);
- if (rc == SQL_OK)
- rc = rc2;
- }
- return rc;
-}
-#else
#define vdbeSorterJoinAll(x,rcin) (rcin)
-#define vdbeSorterJoinThread(pTask) SQL_OK
-#endif
/*
* Allocate a new MergeEngine object capable of handling up to
@@ -1137,15 +981,6 @@ static void
vdbeIncrFree(IncrMerger * pIncr)
{
if (pIncr) {
-#if SQL_MAX_WORKER_THREADS>0
- if (pIncr->bUseThread) {
- vdbeSorterJoinThread(pIncr->pTask);
- if (pIncr->aFile[0].pFd)
- sqlOsCloseFree(pIncr->aFile[0].pFd);
- if (pIncr->aFile[1].pFd)
- sqlOsCloseFree(pIncr->aFile[1].pFd);
- }
-#endif
vdbeMergeEngineFree(pIncr->pMerger);
sql_free(pIncr);
}
@@ -1160,13 +995,6 @@ sqlVdbeSorterReset(sql * db, VdbeSorter * pSorter)
int i;
(void)vdbeSorterJoinAll(pSorter, SQL_OK);
assert(pSorter->bUseThreads || pSorter->pReader == 0);
-#if SQL_MAX_WORKER_THREADS>0
- if (pSorter->pReader) {
- vdbePmaReaderClear(pSorter->pReader);
- sqlDbFree(db, pSorter->pReader);
- pSorter->pReader = 0;
- }
-#endif
vdbeMergeEngineFree(pSorter->pMerger);
pSorter->pMerger = 0;
for (i = 0; i < pSorter->nTask; i++) {
@@ -1516,7 +1344,6 @@ vdbeSorterListToPMA(SortSubtask * pTask, SorterList * pList)
pList->szPMA + sqlVarintLen(pList->szPMA) + pTask->file.iEof;
#endif
- vdbeSorterWorkDebug(pTask, "enter");
memset(&writer, 0, sizeof(PmaWriter));
assert(pList->szPMA > 0);
@@ -1558,7 +1385,6 @@ vdbeSorterListToPMA(SortSubtask * pTask, SorterList * pList)
rc = vdbePmaWriterFinish(&writer, &pTask->file.iEof);
}
- vdbeSorterWorkDebug(pTask, "exit");
assert(rc != SQL_OK || pList->pList == 0);
assert(rc != SQL_OK || pTask->file.iEof == iSz);
return rc;
@@ -1648,22 +1474,6 @@ vdbeMergeEngineStep(MergeEngine * pMerger, /* The merge engine to advance to the
return (rc == SQL_OK ? pTask->pUnpacked->errCode : rc);
}
-#if SQL_MAX_WORKER_THREADS>0
-/*
- * The main routine for background threads that write level-0 PMAs.
- */
-static void *
-vdbeSorterFlushThread(void *pCtx)
-{
- SortSubtask *pTask = (SortSubtask *) pCtx;
- int rc; /* Return code */
- assert(pTask->bDone == 0);
- rc = vdbeSorterListToPMA(pTask, &pTask->list);
- pTask->bDone = 1;
- return SQL_INT_TO_PTR(rc);
-}
-#endif /* SQL_MAX_WORKER_THREADS>0 */
-
/*
* Flush the current contents of VdbeSorter.list to a new PMA, possibly
* using a background thread.
@@ -1671,76 +1481,8 @@ vdbeSorterFlushThread(void *pCtx)
static int
vdbeSorterFlushPMA(VdbeSorter * pSorter)
{
-#if SQL_MAX_WORKER_THREADS==0
pSorter->bUsePMA = 1;
return vdbeSorterListToPMA(&pSorter->aTask[0], &pSorter->list);
-#else
- int rc = SQL_OK;
- int i;
- SortSubtask *pTask = 0; /* Thread context used to create new PMA */
- int nWorker = (pSorter->nTask - 1);
-
- /* Set the flag to indicate that at least one PMA has been written.
- * Or will be, anyhow.
- */
- pSorter->bUsePMA = 1;
-
- /* Select a sub-task to sort and flush the current list of in-memory
- * records to disk. If the sorter is running in multi-threaded mode,
- * round-robin between the first (pSorter->nTask-1) tasks. Except, if
- * the background thread from a sub-tasks previous turn is still running,
- * skip it. If the first (pSorter->nTask-1) sub-tasks are all still busy,
- * fall back to using the final sub-task. The first (pSorter->nTask-1)
- * sub-tasks are prefered as they use background threads - the final
- * sub-task uses the main thread.
- */
- for (i = 0; i < nWorker; i++) {
- int iTest = (pSorter->iPrev + i + 1) % nWorker;
- pTask = &pSorter->aTask[iTest];
- if (pTask->bDone) {
- rc = vdbeSorterJoinThread(pTask);
- }
- if (rc != SQL_OK || pTask->pThread == 0)
- break;
- }
-
- if (rc == SQL_OK) {
- if (i == nWorker) {
- /* Use the foreground thread for this operation */
- rc = vdbeSorterListToPMA(&pSorter->aTask[nWorker],
- &pSorter->list);
- } else {
- /* Launch a background thread for this operation */
- u8 *aMem = pTask->list.aMemory;
- void *pCtx = (void *)pTask;
-
- assert(pTask->pThread == 0 && pTask->bDone == 0);
- assert(pTask->list.pList == 0);
- assert(pTask->list.aMemory == 0
- || pSorter->list.aMemory != 0);
-
- pSorter->iPrev = (u8) (pTask - pSorter->aTask);
- pTask->list = pSorter->list;
- pSorter->list.pList = 0;
- pSorter->list.szPMA = 0;
- if (aMem) {
- pSorter->list.aMemory = aMem;
- pSorter->nMemory = sqlMallocSize(aMem);
- } else if (pSorter->list.aMemory) {
- pSorter->list.aMemory =
- sqlMalloc(pSorter->nMemory);
- if (!pSorter->list.aMemory)
- return SQL_NOMEM;
- }
-
- rc = vdbeSorterCreateThread(pTask,
- vdbeSorterFlushThread,
- pCtx);
- }
- }
-
- return rc;
-#endif /* SQL_MAX_WORKER_THREADS!=0 */
}
/*
@@ -1876,8 +1618,6 @@ vdbeIncrPopulate(IncrMerger * pIncr)
PmaWriter writer;
assert(pIncr->bEof == 0);
- vdbeSorterPopulateDebug(pTask, "enter");
-
vdbePmaWriterInit(pOut->pFd, &writer, pTask->pSorter->pgsz, iStart);
while (rc == SQL_OK) {
int dummy;
@@ -1904,36 +1644,9 @@ vdbeIncrPopulate(IncrMerger * pIncr)
rc2 = vdbePmaWriterFinish(&writer, &pOut->iEof);
if (rc == SQL_OK)
rc = rc2;
- vdbeSorterPopulateDebug(pTask, "exit");
return rc;
}
-#if SQL_MAX_WORKER_THREADS>0
-/*
- * The main routine for background threads that populate aFile[1] of
- * multi-threaded IncrMerger objects.
- */
-static void *
-vdbeIncrPopulateThread(void *pCtx)
-{
- IncrMerger *pIncr = (IncrMerger *) pCtx;
- void *pRet = SQL_INT_TO_PTR(vdbeIncrPopulate(pIncr));
- pIncr->pTask->bDone = 1;
- return pRet;
-}
-
-/*
- * Launch a background thread to populate aFile[1] of pIncr.
- */
-static int
-vdbeIncrBgPopulate(IncrMerger * pIncr)
-{
- void *p = (void *)pIncr;
- assert(pIncr->bUseThread);
- return vdbeSorterCreateThread(pIncr->pTask, vdbeIncrPopulateThread, p);
-}
-#endif
-
/*
* This function is called when the PmaReader corresponding to pIncr has
* finished reading the contents of aFile[0]. Its purpose is to "refill"
@@ -1954,33 +1667,10 @@ vdbeIncrBgPopulate(IncrMerger * pIncr)
static int
vdbeIncrSwap(IncrMerger * pIncr)
{
- int rc = SQL_OK;
-
-#if SQL_MAX_WORKER_THREADS>0
- if (pIncr->bUseThread) {
- rc = vdbeSorterJoinThread(pIncr->pTask);
-
- if (rc == SQL_OK) {
- SorterFile f0 = pIncr->aFile[0];
- pIncr->aFile[0] = pIncr->aFile[1];
- pIncr->aFile[1] = f0;
- }
-
- if (rc == SQL_OK) {
- if (pIncr->aFile[0].iEof == pIncr->iStartOff) {
- pIncr->bEof = 1;
- } else {
- rc = vdbeIncrBgPopulate(pIncr);
- }
- }
- } else
-#endif
- {
- rc = vdbeIncrPopulate(pIncr);
- pIncr->aFile[0] = pIncr->aFile[1];
- if (pIncr->aFile[0].iEof == pIncr->iStartOff) {
- pIncr->bEof = 1;
- }
+ int rc = vdbeIncrPopulate(pIncr);
+ pIncr->aFile[0] = pIncr->aFile[1];
+ if (pIncr->aFile[0].iEof == pIncr->iStartOff) {
+ pIncr->bEof = 1;
}
return rc;
@@ -2015,18 +1705,6 @@ vdbeIncrMergerNew(SortSubtask * pTask, /* The thread that will be using the new
return rc;
}
-#if SQL_MAX_WORKER_THREADS>0
-/*
- * Set the "use-threads" flag on object pIncr.
- */
-static void
-vdbeIncrMergerSetThreads(IncrMerger * pIncr)
-{
- pIncr->bUseThread = 1;
- pIncr->pTask->file2.iEof -= pIncr->mxSz;
-}
-#endif /* SQL_MAX_WORKER_THREADS>0 */
-
/*
* Recompute pMerger->aTree[iOut] by comparing the next keys on the
* two PmaReaders that feed that entry. Neither of the PmaReaders
@@ -2077,38 +1755,20 @@ vdbeMergeEngineCompare(MergeEngine * pMerger, /* Merge engine containing PmaRead
pMerger->aTree[iOut] = iRes;
}
-/*
- * Allowed values for the eMode parameter to vdbeMergeEngineInit()
- * and vdbePmaReaderIncrMergeInit().
- *
- * Only INCRINIT_NORMAL is valid in single-threaded builds (when
- * SQL_MAX_WORKER_THREADS==0). The other values are only used
- * when there exists one or more separate worker threads.
- */
-#define INCRINIT_NORMAL 0
-#define INCRINIT_TASK 1
-#define INCRINIT_ROOT 2
-
/*
* Forward reference required as the vdbeIncrMergeInit() and
* vdbePmaReaderIncrInit() routines are called mutually recursively when
* building a merge tree.
*/
-static int vdbePmaReaderIncrInit(PmaReader * pReadr, int eMode);
+static int vdbePmaReaderIncrInit(PmaReader * pReader);
/*
* Initialize the MergeEngine object passed as the second argument. Once this
* function returns, the first key of merged data may be read from the
* MergeEngine object in the usual fashion.
*
- * If argument eMode is INCRINIT_ROOT, then it is assumed that any IncrMerge
- * objects attached to the PmaReader objects that the merger reads from have
- * already been populated, but that they have not yet populated aFile[0] and
- * set the PmaReader objects up to read from it. In this case all that is
- * required is to call vdbePmaReaderNext() on each PmaReader to point it at
- * its first key.
*
- * Otherwise, if eMode is any value other than INCRINIT_ROOT, then use
+ * Use
* vdbePmaReaderIncrMergeInit() to initialize each PmaReader that feeds data
* to pMerger.
*
@@ -2116,36 +1776,19 @@ static int vdbePmaReaderIncrInit(PmaReader * pReadr, int eMode);
*/
static int
vdbeMergeEngineInit(SortSubtask * pTask, /* Thread that will run pMerger */
- MergeEngine * pMerger, /* MergeEngine to initialize */
- int eMode /* One of the INCRINIT_XXX constants */
+ MergeEngine * pMerger /* MergeEngine to initialize */
)
{
int rc = SQL_OK; /* Return code */
int i; /* For looping over PmaReader objects */
int nTree = pMerger->nTree;
- /* eMode is always INCRINIT_NORMAL in single-threaded mode */
- assert(SQL_MAX_WORKER_THREADS > 0 || eMode == INCRINIT_NORMAL);
-
/* Verify that the MergeEngine is assigned to a single thread */
assert(pMerger->pTask == 0);
pMerger->pTask = pTask;
for (i = 0; i < nTree; i++) {
- if (SQL_MAX_WORKER_THREADS > 0 && eMode == INCRINIT_ROOT) {
- /* PmaReaders should be normally initialized in order, as if they are
- * reading from the same temp file this makes for more linear file IO.
- * However, in the INCRINIT_ROOT case, if PmaReader aReadr[nTask-1] is
- * in use it will block the vdbePmaReaderNext() call while it uses
- * the main thread to fill its buffer. So calling PmaReaderNext()
- * on this PmaReader before any of the multi-threaded PmaReaders takes
- * better advantage of multi-processor hardware.
- */
- rc = vdbePmaReaderNext(&pMerger->aReadr[nTree - i - 1]);
- } else {
- rc = vdbePmaReaderIncrInit(&pMerger->aReadr[i],
- INCRINIT_NORMAL);
- }
+ rc = vdbePmaReaderIncrInit(&pMerger->aReadr[i]);
if (rc != SQL_OK)
return rc;
}
@@ -2157,50 +1800,27 @@ vdbeMergeEngineInit(SortSubtask * pTask, /* Thread that will run pMerger */
}
/*
- * The PmaReader passed as the first argument is guaranteed to be an
+ * The PmaReader is guaranteed to be an
* incremental-reader (pReadr->pIncr!=0). This function serves to open
* and/or initialize the temp file related fields of the IncrMerge
* object at (pReadr->pIncr).
*
- * If argument eMode is set to INCRINIT_NORMAL, then all PmaReaders
- * in the sub-tree headed by pReadr are also initialized. Data is then
+ * All PmaReaders
+ * in the sub-tree headed by pReadr are also initialized. Data is
* loaded into the buffers belonging to pReadr and it is set to point to
* the first key in its range.
*
- * If argument eMode is set to INCRINIT_TASK, then pReadr is guaranteed
- * to be a multi-threaded PmaReader and this function is being called in a
- * background thread. In this case all PmaReaders in the sub-tree are
- * initialized as for INCRINIT_NORMAL and the aFile[1] buffer belonging to
- * pReadr is populated. However, pReadr itself is not set up to point
- * to its first key. A call to vdbePmaReaderNext() is still required to do
- * that.
- *
- * The reason this function does not call vdbePmaReaderNext() immediately
- * in the INCRINIT_TASK case is that vdbePmaReaderNext() assumes that it has
- * to block on thread (pTask->thread) before accessing aFile[1]. But, since
- * this entire function is being run by thread (pTask->thread), that will
- * lead to the current background thread attempting to join itself.
- *
- * Finally, if argument eMode is set to INCRINIT_ROOT, it may be assumed
- * that pReadr->pIncr is a multi-threaded IncrMerge objects, and that all
- * child-trees have already been initialized using IncrInit(INCRINIT_TASK).
- * In this case vdbePmaReaderNext() is called on all child PmaReaders and
- * the current PmaReader set to point to the first key in its range.
- *
* SQL_OK is returned if successful, or an sql error code otherwise.
*/
static int
-vdbePmaReaderIncrMergeInit(PmaReader * pReadr, int eMode)
+vdbePmaReaderIncrMergeInit(PmaReader * pReadr)
{
int rc = SQL_OK;
IncrMerger *pIncr = pReadr->pIncr;
SortSubtask *pTask = pIncr->pTask;
sql *db = pTask->pSorter->db;
- /* eMode is always INCRINIT_NORMAL in single-threaded mode */
- assert(SQL_MAX_WORKER_THREADS > 0 || eMode == INCRINIT_NORMAL);
-
- rc = vdbeMergeEngineInit(pTask, pIncr->pMerger, eMode);
+ rc = vdbeMergeEngineInit(pTask, pIncr->pMerger);
/* Set up the required files for pIncr. A multi-theaded IncrMerge object
* requires two temp files to itself, whereas a single-threaded object
@@ -2208,74 +1828,27 @@ vdbePmaReaderIncrMergeInit(PmaReader * pReadr, int eMode)
*/
if (rc == SQL_OK) {
int mxSz = pIncr->mxSz;
-#if SQL_MAX_WORKER_THREADS>0
- if (pIncr->bUseThread) {
- rc = vdbeSorterOpenTempFile(db, mxSz,
- &pIncr->aFile[0].pFd);
- if (rc == SQL_OK) {
- rc = vdbeSorterOpenTempFile(db, mxSz,
- &pIncr->aFile[1].
- pFd);
- }
- } else
-#endif
- /*if( !pIncr->bUseThread ) */ {
- if (pTask->file2.pFd == 0) {
- assert(pTask->file2.iEof > 0);
- rc = vdbeSorterOpenTempFile(db,
- pTask->file2.iEof,
- &pTask->file2.pFd);
- pTask->file2.iEof = 0;
- }
- if (rc == SQL_OK) {
- pIncr->aFile[1].pFd = pTask->file2.pFd;
- pIncr->iStartOff = pTask->file2.iEof;
- pTask->file2.iEof += mxSz;
- }
- }
- }
-#if SQL_MAX_WORKER_THREADS>0
- if (rc == SQL_OK && pIncr->bUseThread) {
- /* Use the current thread to populate aFile[1], even though this
- * PmaReader is multi-threaded. If this is an INCRINIT_TASK object,
- * then this function is already running in background thread
- * pIncr->pTask->thread.
- *
- * If this is the INCRINIT_ROOT object, then it is running in the
- * main VDBE thread. But that is Ok, as that thread cannot return
- * control to the VDBE or proceed with anything useful until the
- * first results are ready from this merger object anyway.
- */
- assert(eMode == INCRINIT_ROOT || eMode == INCRINIT_TASK);
- rc = vdbeIncrPopulate(pIncr);
+ if (pTask->file2.pFd == 0) {
+ assert(pTask->file2.iEof > 0);
+ rc = vdbeSorterOpenTempFile(db,
+ pTask->file2.iEof,
+ &pTask->file2.pFd);
+ pTask->file2.iEof = 0;
+ }
+ if (rc == SQL_OK) {
+ pIncr->aFile[1].pFd = pTask->file2.pFd;
+ pIncr->iStartOff = pTask->file2.iEof;
+ pTask->file2.iEof += mxSz;
+ }
}
-#endif
- if (rc == SQL_OK
- && (SQL_MAX_WORKER_THREADS == 0 || eMode != INCRINIT_TASK)) {
+ if (rc == SQL_OK) {
rc = vdbePmaReaderNext(pReadr);
}
return rc;
}
-#if SQL_MAX_WORKER_THREADS>0
-/*
- * The main routine for vdbePmaReaderIncrMergeInit() operations run in
- * background threads.
- */
-static void *
-vdbePmaReaderBgIncrInit(void *pCtx)
-{
- PmaReader *pReader = (PmaReader *) pCtx;
- void *pRet =
- SQL_INT_TO_PTR(vdbePmaReaderIncrMergeInit(pReader, INCRINIT_TASK)
- );
- pReader->pIncr->pTask->bDone = 1;
- return pRet;
-}
-#endif
-
/*
* If the PmaReader passed as the first argument is not an incremental-reader
* (if pReadr->pIncr==0), then this function is a no-op. Otherwise, it invokes
@@ -2288,23 +1861,12 @@ vdbePmaReaderBgIncrInit(void *pCtx)
* using the current thread.
*/
static int
-vdbePmaReaderIncrInit(PmaReader * pReadr, int eMode)
+vdbePmaReaderIncrInit(PmaReader * pReadr)
{
IncrMerger *pIncr = pReadr->pIncr; /* Incremental merger */
int rc = SQL_OK; /* Return code */
if (pIncr) {
-#if SQL_MAX_WORKER_THREADS>0
- assert(pIncr->bUseThread == 0 || eMode == INCRINIT_TASK);
- if (pIncr->bUseThread) {
- void *pCtx = (void *)pReadr;
- rc = vdbeSorterCreateThread(pIncr->pTask,
- vdbePmaReaderBgIncrInit,
- pCtx);
- } else
-#endif
- {
- rc = vdbePmaReaderIncrMergeInit(pReadr, eMode);
- }
+ rc = vdbePmaReaderIncrMergeInit(pReadr);
}
return rc;
}
@@ -2451,23 +2013,10 @@ vdbeSorterMergeTreeBuild(VdbeSorter * pSorter, /* The VDBE cursor that implement
int rc = SQL_OK;
int iTask;
-#if SQL_MAX_WORKER_THREADS>0
- /* If the sorter uses more than one task, then create the top-level
- * MergeEngine here. This MergeEngine will read data from exactly
- * one PmaReader per sub-task.
- */
- assert(pSorter->bUseThreads || pSorter->nTask == 1);
- if (pSorter->nTask > 1) {
- pMain = vdbeMergeEngineNew(pSorter->nTask);
- if (pMain == 0)
- rc = SQL_NOMEM;
- }
-#endif
-
for (iTask = 0; rc == SQL_OK && iTask < pSorter->nTask; iTask++) {
SortSubtask *pTask = &pSorter->aTask[iTask];
- assert(pTask->nPMA > 0 || SQL_MAX_WORKER_THREADS > 0);
- if (SQL_MAX_WORKER_THREADS == 0 || pTask->nPMA) {
+ assert(pTask->nPMA > 0);
+ if (pTask->nPMA) {
MergeEngine *pRoot = 0; /* Root node of tree for this task */
int nDepth = vdbeSorterTreeDepth(pTask->nPMA);
i64 iReadOff = 0;
@@ -2505,18 +2054,8 @@ vdbeSorterMergeTreeBuild(VdbeSorter * pSorter, /* The VDBE cursor that implement
}
if (rc == SQL_OK) {
-#if SQL_MAX_WORKER_THREADS>0
- if (pMain != 0) {
- rc = vdbeIncrMergerNew(pTask, pRoot,
- &pMain->
- aReadr[iTask].
- pIncr);
- } else
-#endif
- {
- assert(pMain == 0);
- pMain = pRoot;
- }
+ assert(pMain == 0);
+ pMain = pRoot;
} else {
vdbeMergeEngineFree(pRoot);
}
@@ -2546,88 +2085,12 @@ vdbeSorterSetupMerge(VdbeSorter * pSorter)
int rc; /* Return code */
SortSubtask *pTask0 = &pSorter->aTask[0];
MergeEngine *pMain = 0;
-#if SQL_MAX_WORKER_THREADS
- sql *db = pTask0->pSorter->db;
- int i;
- SorterCompare xCompare = vdbeSorterGetCompare(pSorter);
- for (i = 0; i < pSorter->nTask; i++) {
- pSorter->aTask[i].xCompare = xCompare;
- }
-#endif
rc = vdbeSorterMergeTreeBuild(pSorter, &pMain);
if (rc == SQL_OK) {
-#if SQL_MAX_WORKER_THREADS
- assert(pSorter->bUseThreads == 0 || pSorter->nTask > 1);
- if (pSorter->bUseThreads) {
- int iTask;
- PmaReader *pReadr = 0;
- SortSubtask *pLast =
- &pSorter->aTask[pSorter->nTask - 1];
- rc = vdbeSortAllocUnpacked(pLast);
- if (rc == SQL_OK) {
- pReadr =
- (PmaReader *) sqlDbMallocZero(db,
- sizeof
- (PmaReader));
- pSorter->pReader = pReadr;
- if (pReadr == 0)
- rc = SQL_NOMEM;
- }
- if (rc == SQL_OK) {
- rc = vdbeIncrMergerNew(pLast, pMain,
- &pReadr->pIncr);
- if (rc == SQL_OK) {
- vdbeIncrMergerSetThreads(pReadr->pIncr);
- for (iTask = 0;
- iTask < (pSorter->nTask - 1);
- iTask++) {
- IncrMerger *pIncr;
- if ((pIncr =
- pMain->aReadr[iTask].
- pIncr)) {
- vdbeIncrMergerSetThreads
- (pIncr);
- assert(pIncr->pTask !=
- pLast);
- }
- }
- for (iTask = 0;
- rc == SQL_OK
- && iTask < pSorter->nTask;
- iTask++) {
- /* Check that:
- *
- * a) The incremental merge object is configured to use the
- * right task, and
- * b) If it is using task (nTask-1), it is configured to run
- * in single-threaded mode. This is important, as the
- * root merge (INCRINIT_ROOT) will be using the same task
- * object.
- */
- PmaReader *p =
- &pMain->aReadr[iTask];
- assert(p->pIncr == 0 || ((p->pIncr->pTask == &pSorter->aTask[iTask]) /* a */
- &&(iTask != pSorter->nTask - 1 || p->pIncr->bUseThread == 0) /* b */
- ));
- rc = vdbePmaReaderIncrInit(p,
- INCRINIT_TASK);
- }
- }
- pMain = 0;
- }
- if (rc == SQL_OK) {
- rc = vdbePmaReaderIncrMergeInit(pReadr,
- INCRINIT_ROOT);
- }
- } else
-#endif
- {
- rc = vdbeMergeEngineInit(pTask0, pMain,
- INCRINIT_NORMAL);
- pSorter->pMerger = pMain;
- pMain = 0;
- }
+ rc = vdbeMergeEngineInit(pTask0, pMain);
+ pSorter->pMerger = pMain;
+ pMain = 0;
}
if (rc != SQL_OK) {
@@ -2676,8 +2139,6 @@ sqlVdbeSorterRewind(const VdbeCursor * pCsr, int *pbEof)
/* Join all threads */
rc = vdbeSorterJoinAll(pSorter, rc);
- vdbeSorterRewindDebug("rewind");
-
/* Assuming no errors have occurred, set up a merger structure to
* incrementally read and merge all remaining PMAs.
*/
@@ -2687,7 +2148,6 @@ sqlVdbeSorterRewind(const VdbeCursor * pCsr, int *pbEof)
*pbEof = 0;
}
- vdbeSorterRewindDebug("rewinddone");
return rc;
}
@@ -2708,12 +2168,6 @@ sqlVdbeSorterNext(sql * db, const VdbeCursor * pCsr, int *pbEof)
assert(pSorter->pReader == 0 || pSorter->pMerger == 0);
assert(pSorter->bUseThreads == 0 || pSorter->pReader);
assert(pSorter->bUseThreads == 1 || pSorter->pMerger);
-#if SQL_MAX_WORKER_THREADS>0
- if (pSorter->bUseThreads) {
- rc = vdbePmaReaderNext(pSorter->pReader);
- *pbEof = (pSorter->pReader->pFd == 0);
- } else
-#endif
/*if( !pSorter->bUseThreads ) */ {
assert(pSorter->pMerger != 0);
assert(pSorter->pMerger->pTask == (&pSorter->aTask[0]));
@@ -2743,11 +2197,6 @@ vdbeSorterRowkey(const VdbeSorter * pSorter, /* Sorter object */
void *pKey;
if (pSorter->bUsePMA) {
PmaReader *pReader;
-#if SQL_MAX_WORKER_THREADS>0
- if (pSorter->bUseThreads) {
- pReader = pSorter->pReader;
- } else
-#endif
/*if( !pSorter->bUseThreads ) */ {
pReader =
&pSorter->pMerger->aReadr[pSorter->pMerger->
diff --git a/src/box/sql/where.c b/src/box/sql/where.c
index efd4f4f4b..c38b60b0f 100644
--- a/src/box/sql/where.c
+++ b/src/box/sql/where.c
@@ -684,225 +684,6 @@ translateColumnToCopy(Vdbe * v, /* The VDBE containing code to translate */
}
}
-#ifndef SQL_OMIT_AUTOMATIC_INDEX
-/*
- * Return TRUE if the WHERE clause term pTerm is of a form where it
- * could be used with an index to access pSrc, assuming an appropriate
- * index existed.
- */
-static int
-termCanDriveIndex(WhereTerm * pTerm, /* WHERE clause term to check */
- struct SrcList_item *pSrc, /* Table we are trying to access */
- Bitmask notReady /* Tables in outer loops of the join */
- )
-{
- if (pTerm->leftCursor != pSrc->iCursor)
- return 0;
- if ((pTerm->eOperator & WO_EQ) == 0)
- return 0;
- if ((pTerm->prereqRight & notReady) != 0)
- return 0;
- if (pTerm->u.leftColumn < 0)
- return 0;
- enum field_type type = pSrc->pTab->def->fields[pTerm->u.leftColumn].type;
- enum field_type expr_type = expr_cmp_mutual_type(pTerm->pExpr);
- if (!field_type1_contains_type2(expr_type, type))
- return 0;
- return 1;
-}
-#endif
-
-#ifndef SQL_OMIT_AUTOMATIC_INDEX
-/*
- * Generate code to construct the Index object for an automatic index
- * and to set up the WhereLevel object pLevel so that the code generator
- * makes use of the automatic index.
- */
-static void
-constructAutomaticIndex(Parse * pParse, /* The parsing context */
- WhereClause * pWC, /* The WHERE clause */
- struct SrcList_item *pSrc, /* The FROM clause term to get the next index */
- Bitmask notReady, /* Mask of cursors that are not available */
- WhereLevel * pLevel) /* Write new index here */
-{
- int nKeyCol; /* Number of columns in the constructed index */
- WhereTerm *pTerm; /* A single term of the WHERE clause */
- WhereTerm *pWCEnd; /* End of pWC->a[] */
- Index *pIdx; /* Object describing the transient index */
- Vdbe *v; /* Prepared statement under construction */
- int addrInit; /* Address of the initialization bypass jump */
- Table *pTable; /* The table being indexed */
- int addrTop; /* Top of the index fill loop */
- int regRecord; /* Register holding an index record */
- int n; /* Column counter */
- int i; /* Loop counter */
- int mxBitCol; /* Maximum column in pSrc->colUsed */
- struct coll *pColl; /* Collating sequence to on a column */
- WhereLoop *pLoop; /* The Loop object */
- char *zNotUsed; /* Extra space on the end of pIdx */
- Bitmask idxCols; /* Bitmap of columns used for indexing */
- Bitmask extraCols; /* Bitmap of additional columns */
- u8 sentWarning = 0; /* True if a warnning has been issued */
- int iContinue = 0; /* Jump here to skip excluded rows */
- struct SrcList_item *pTabItem; /* FROM clause term being indexed */
- int addrCounter = 0; /* Address where integer counter is initialized */
- int regBase; /* Array of registers where record is assembled */
-
- /* Generate code to skip over the creation and initialization of the
- * transient index on 2nd and subsequent iterations of the loop.
- */
- v = pParse->pVdbe;
- assert(v != 0);
- addrInit = sqlVdbeAddOp0(v, OP_Once);
- VdbeCoverage(v);
-
- /* Count the number of columns that will be added to the index
- * and used to match WHERE clause constraints
- */
- nKeyCol = 0;
- pTable = pSrc->pTab;
- pWCEnd = &pWC->a[pWC->nTerm];
- pLoop = pLevel->pWLoop;
- idxCols = 0;
- for (pTerm = pWC->a; pTerm < pWCEnd; pTerm++) {
- if (termCanDriveIndex(pTerm, pSrc, notReady)) {
- int iCol = pTerm->u.leftColumn;
- Bitmask cMask =
- iCol >= BMS ? MASKBIT(BMS - 1) : MASKBIT(iCol);
- testcase(iCol == BMS);
- testcase(iCol == BMS - 1);
- if (!sentWarning) {
- sql_log(SQL_WARNING_AUTOINDEX,
- "automatic index on %s(%s)",
- pTable->def->name,
- pTable->aCol[iCol].zName);
- sentWarning = 1;
- }
- if ((idxCols & cMask) == 0) {
- if (whereLoopResize
- (pParse->db, pLoop, nKeyCol + 1)) {
- goto end_auto_index_create;
- }
- pLoop->aLTerm[nKeyCol++] = pTerm;
- idxCols |= cMask;
- }
- }
- }
- assert(nKeyCol > 0);
- pLoop->nEq = pLoop->nLTerm = nKeyCol;
- pLoop->wsFlags = WHERE_COLUMN_EQ | WHERE_IDX_ONLY | WHERE_INDEXED
- | WHERE_AUTO_INDEX;
-
- /* Count the number of additional columns needed to create a
- * covering index. A "covering index" is an index that contains all
- * columns that are needed by the query. With a covering index, the
- * original table never needs to be accessed. Automatic indices must
- * be a covering index because the index will not be updated if the
- * original table changes and the index and table cannot both be used
- * if they go out of sync.
- */
- extraCols = pSrc->colUsed & (~idxCols | MASKBIT(BMS - 1));
- mxBitCol = MIN(BMS - 1, pTable->def->field_count);
- testcase(pTable->def->field_count == BMS - 1);
- testcase(pTable->def->field_count == BMS - 2);
- for (i = 0; i < mxBitCol; i++) {
- if (extraCols & MASKBIT(i))
- nKeyCol++;
- }
- if (pSrc->colUsed & MASKBIT(BMS - 1)) {
- nKeyCol += pTable->def->field_count - BMS + 1;
- }
-
- /* Construct the Index object to describe this index */
- pIdx = sqlDbMallocZero(pParse->db, sizeof(*pIdx));
- if (pIdx == 0)
- goto end_auto_index_create;
- pLoop->pIndex = pIdx;
- pIdx->zName = "auto-index";
- pIdx->pTable = pTable;
- n = 0;
- idxCols = 0;
- for (pTerm = pWC->a; pTerm < pWCEnd; pTerm++) {
- if (termCanDriveIndex(pTerm, pSrc, notReady)) {
- int iCol = pTerm->u.leftColumn;
- Bitmask cMask =
- iCol >= BMS ? MASKBIT(BMS - 1) : MASKBIT(iCol);
- testcase(iCol == BMS - 1);
- testcase(iCol == BMS);
- if ((idxCols & cMask) == 0) {
- Expr *pX = pTerm->pExpr;
- idxCols |= cMask;
- pIdx->aiColumn[n] = pTerm->u.leftColumn;
- n++;
- }
- }
- }
- assert((u32) n == pLoop->nEq);
-
- /* Add additional columns needed to make the automatic index into
- * a covering index
- */
- for (i = 0; i < mxBitCol; i++) {
- if (extraCols & MASKBIT(i)) {
- pIdx->aiColumn[n] = i;
- n++;
- }
- }
- if (pSrc->colUsed & MASKBIT(BMS - 1)) {
- for (i = BMS - 1; i < (int)pTable->def->field_count; i++) {
- pIdx->aiColumn[n] = i;
- n++;
- }
- }
- assert(n == nKeyCol);
- pIdx->aiColumn[n] = XN_ROWID;
-
- /* Create the automatic index */
- assert(pLevel->iIdxCur >= 0);
- pLevel->iIdxCur = pParse->nTab++;
- sqlVdbeAddOp2(v, OP_OpenAutoindex, pLevel->iIdxCur, nKeyCol + 1);
- sql_vdbe_set_p4_key_def(pParse, pIdx->key_def);
- VdbeComment((v, "for %s", pTable->def->name));
-
- /* Fill the automatic index with content */
- sqlExprCachePush(pParse);
- pTabItem = &pWC->pWInfo->pTabList->a[pLevel->iFrom];
- if (pTabItem->fg.viaCoroutine) {
- int regYield = pTabItem->regReturn;
- addrCounter = sqlVdbeAddOp2(v, OP_Integer, 0, 0);
- sqlVdbeAddOp3(v, OP_InitCoroutine, regYield, 0,
- pTabItem->addrFillSub);
- addrTop = sqlVdbeAddOp1(v, OP_Yield, regYield);
- VdbeCoverage(v);
- VdbeComment((v, "next row of \"%s\"", pTabItem->pTab->zName));
- } else {
- addrTop = sqlVdbeAddOp1(v, OP_Rewind, pLevel->iTabCur);
- VdbeCoverage(v);
- }
- regRecord = sqlGetTempReg(pParse);
- regBase = sql_generate_index_key(pParse, pIdx, pLevel->iTabCur,
- regRecord, NULL, 0);
- sqlVdbeAddOp2(v, OP_IdxInsert, pLevel->iIdxCur, regRecord);
- if (pTabItem->fg.viaCoroutine) {
- sqlVdbeChangeP2(v, addrCounter, regBase + n);
- translateColumnToCopy(v, addrTop, pLevel->iTabCur,
- pTabItem->regResult, 1);
- sqlVdbeGoto(v, addrTop);
- pTabItem->fg.viaCoroutine = 0;
- } else {
- sqlVdbeAddOp2(v, OP_Next, pLevel->iTabCur, addrTop + 1);
- VdbeCoverage(v);
- }
- sqlVdbeChangeP5(v, SQL_STMTSTATUS_AUTOINDEX);
- sqlVdbeJumpHere(v, addrTop);
- sqlReleaseTempReg(pParse, regRecord);
- sqlExprCachePop(pParse);
-
- /* Jump here when skipping the initialization */
- sqlVdbeJumpHere(v, addrInit);
-}
-#endif /* SQL_OMIT_AUTOMATIC_INDEX */
-
/*
* Estimate the location of a particular key among all keys in an
* index. Store the results in aStat as follows:
@@ -2828,61 +2609,6 @@ tnt_error:
probe = fake_index;
}
-#ifndef SQL_OMIT_AUTOMATIC_INDEX
- /* Automatic indexes */
- LogEst rSize = pTab->nRowLogEst;
- LogEst rLogSize = estLog(rSize);
- struct session *user_session = current_session();
- if (!pBuilder->pOrSet /* Not part of an OR optimization */
- && (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE) == 0 && (user_session->sql_flags & SQL_AutoIndex) != 0 && pSrc->pIBIndex == 0 /* Has no INDEXED BY clause */
- && !pSrc->fg.notIndexed /* Has no NOT INDEXED clause */
- && HasRowid(pTab) /* Not WITHOUT ROWID table. (FIXME: Why not?) */
- &&!pSrc->fg.isCorrelated /* Not a correlated subquery */
- && !pSrc->fg.isRecursive /* Not a recursive common table expression. */
- ) {
- /* Generate auto-index WhereLoops */
- WhereTerm *pTerm;
- WhereTerm *pWCEnd = pWC->a + pWC->nTerm;
- for (pTerm = pWC->a; rc == SQL_OK && pTerm < pWCEnd; pTerm++) {
- if (pTerm->prereqRight & pNew->maskSelf)
- continue;
- if (termCanDriveIndex(pTerm, pSrc, 0)) {
- pNew->nEq = 1;
- pNew->nSkip = 0;
- pNew->pIndex = 0;
- pNew->nLTerm = 1;
- pNew->aLTerm[0] = pTerm;
- /* TUNING: One-time cost for computing the automatic index is
- * estimated to be X*N*log2(N) where N is the number of rows in
- * the table being indexed and where X is 7 (LogEst=28) for normal
- * tables or 1.375 (LogEst=4) for views and subqueries. The value
- * of X is smaller for views and subqueries so that the query planner
- * will be more aggressive about generating automatic indexes for
- * those objects, since there is no opportunity to add schema
- * indexes on subqueries and views.
- */
- pNew->rSetup = rLogSize + rSize + 4;
- if (!pTab->def->opts.is_view &&
- pTab->def->id == 0)
- pNew->rSetup += 24;
- if (pNew->rSetup < 0)
- pNew->rSetup = 0;
- /* TUNING: Each index lookup yields 20 rows in the table. This
- * is more than the usual guess of 10 rows, since we have no way
- * of knowing how selective the index will ultimately be. It would
- * not be unreasonable to make this value much larger.
- */
- pNew->nOut = 43;
- assert(43 == sqlLogEst(20));
- pNew->rRun =
- sqlLogEstAdd(rLogSize, pNew->nOut);
- pNew->wsFlags = WHERE_AUTO_INDEX;
- pNew->prereq = mPrereq | pTerm->prereqRight;
- rc = whereLoopInsert(pBuilder, pNew);
- }
- }
- }
-#endif /* SQL_OMIT_AUTOMATIC_INDEX */
/*
* If there was an INDEXED BY clause, then only that one
* index is considered.
@@ -4561,12 +4287,6 @@ sqlWhereBegin(Parse * pParse, /* The parser context */
VdbeComment((v, "%s", space->def->name));
assert(pTabItem->iCursor == pLevel->iTabCur);
sqlVdbeChangeP5(v, bFordelete);
-#ifdef SQL_ENABLE_COLUMN_USED_MASK
- sqlVdbeAddOp4Dup8(v, OP_ColumnsUsed,
- pTabItem->iCursor, 0, 0,
- (const u8 *)&pTabItem->colUsed,
- P4_INT64);
-#endif
}
if (pLoop->wsFlags & WHERE_INDEXED) {
struct index_def *idx_def = pLoop->index_def;
@@ -4641,30 +4361,6 @@ sqlWhereBegin(Parse * pParse, /* The parser context */
sqlVdbeChangeP5(v, OPFLAG_SEEKEQ); /* Hint to COMDB2 */
}
VdbeComment((v, "%s", idx_def->name));
-#ifdef SQL_ENABLE_COLUMN_USED_MASK
- {
- u64 colUsed = 0;
- int ii, jj;
- for (ii = 0; ii < pIx->nColumn; ii++) {
- jj = pIx->aiColumn[ii];
- if (jj < 0)
- continue;
- if (jj > 63)
- jj = 63;
- if ((pTabItem->
- colUsed & MASKBIT(jj)) ==
- 0)
- continue;
- colUsed |=
- ((u64) 1) << (ii <
- 63 ? ii : 63);
- }
- sqlVdbeAddOp4Dup8(v, OP_ColumnsUsed,
- iIndexCur, 0, 0,
- (u8 *) & colUsed,
- P4_INT64);
- }
-#endif /* SQL_ENABLE_COLUMN_USED_MASK */
}
}
}
@@ -4679,15 +4375,6 @@ sqlWhereBegin(Parse * pParse, /* The parser context */
notReady = ~(Bitmask) 0;
for (ii = 0; ii < nTabList; ii++) {
pLevel = &pWInfo->a[ii];
-#ifndef SQL_OMIT_AUTOMATIC_INDEX
- if ((pLevel->pWLoop->wsFlags & WHERE_AUTO_INDEX) != 0) {
- constructAutomaticIndex(pParse, &pWInfo->sWC,
- &pTabList->a[pLevel->iFrom],
- notReady, pLevel);
- if (db->mallocFailed)
- goto whereBeginError;
- }
-#endif
sqlWhereExplainOneScan(pParse, pTabList, pLevel, ii,
pLevel->iFrom, wctrlFlags);
pLevel->addrBody = sqlVdbeCurrentAddr(v);
diff --git a/src/box/sql/wherecode.c b/src/box/sql/wherecode.c
index 4dedb38a7..01fa138f6 100644
--- a/src/box/sql/wherecode.c
+++ b/src/box/sql/wherecode.c
@@ -253,14 +253,6 @@ sqlWhereExplainOneScan(Parse * pParse, /* Parse context */
" USING INTEGER PRIMARY KEY (rowid%s?)",
zRangeOp);
}
-#ifdef SQL_EXPLAIN_ESTIMATED_ROWS
- if (pLoop->nOut >= 10) {
- sqlXPrintf(&str, " (~%llu rows)",
- sqlLogEstToInt(pLoop->nOut));
- } else {
- sqlStrAccumAppend(&str, " (~1 row)", 9);
- }
-#endif
zMsg = sqlStrAccumFinish(&str);
ret =
sqlVdbeAddOp4(v, OP_Explain, iId, iLevel, iFrom, zMsg,
--
2.17.1
^ permalink raw reply [flat|nested] 15+ messages in thread
* [tarantool-patches] Re: [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
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 ` n.pettik
2019-05-29 14:02 ` Stanislav Zudin
0 siblings, 1 reply; 15+ messages in thread
From: n.pettik @ 2019-05-19 15:16 UTC (permalink / raw)
To: tarantool-patches; +Cc: szudin
[-- Attachment #1: Type: text/plain, Size: 3552 bytes --]
> diff --git a/src/box/sql/CMakeLists.txt b/src/box/sql/CMakeLists.txt
> index b9dbe141a..f988dc3e7 100644
> --- a/src/box/sql/CMakeLists.txt
> +++ b/src/box/sql/CMakeLists.txt
> @@ -10,9 +10,6 @@ set(SQL_BIN_DIR ${CMAKE_BINARY_DIR}/src/box/sql)
> include_directories(${SQL_SRC_DIR})
> include_directories(${SQL_BIN_DIR})
>
> -add_definitions(-DSQL_MAX_WORKER_THREADS=0)
> -add_definitions(-DSQL_OMIT_AUTOMATIC_INDEX)
Let’s keep routines connected with automatic indexes:
we are going to re-enable it in scope of https://github.com/tarantool/tarantool/issues/2583 <https://github.com/tarantool/tarantool/issues/2583>
This code is a good point to start with reincarnation.
> -
> set(TEST_DEFINITIONS
> SQL_NO_SYNC=1
> SQL_TEST=1
>
> diff --git a/src/box/sql/sqlInt.h b/src/box/sql/sqlInt.h
> index f019cd291..4bf94fad2 100644
> --- a/src/box/sql/sqlInt.h
> +++ b/src/box/sql/sqlInt.h
>
> @@ -4858,13 +4846,6 @@ int sqlMemdebugNoType(void *, u8);
>
> -/*
> - * Threading interface
> - */
> -#if SQL_MAX_WORKER_THREADS>0
> -int sqlThreadCreate(sqlThread **, void *(*)(void *), void *);
> -int sqlThreadJoin(sqlThread *, void **);
> -#endif
Now we can remove struct sqlThread.
> diff --git a/src/box/sql/vdbesort.c b/src/box/sql/vdbesort.c
> index ddea6752c..a37fbd911 100644
> --- a/src/box/sql/vdbesort.c
> +++ b/src/box/sql/vdbesort.c
> @@ -118,11 +118,6 @@
> * there are already N worker threads running, the main thread does the work
> * itself.
> *
> - * The sorter is running in multi-threaded mode if (a) the library was built
> - * with pre-processor symbol SQL_MAX_WORKER_THREADS set to a value greater
> - * than zero, and (b) worker threads have been enabled at runtime by calling
> - * "PRAGMA threads=N" with some value of N greater than 0.
> - *
> * When Rewind() is called, any data remaining in memory is flushed to a
> * final PMA. So at this point the data is stored in some number of sorted
> * PMAs within temporary files on disk.
> @@ -159,15 +154,6 @@
> #include "sqlInt.h"
> #include "vdbeInt.h"
>
>
> /*
> * Hard-coded maximum amount of data to accumulate in memory before flushing
> * to a level 0 PMA. The purpose of this limit is to prevent various integer
> @@ -297,18 +283,14 @@ struct MergeEngine {
> *
> * Before a background thread is launched, variable bDone is set to 0. Then,
> * right before it exits, the thread itself sets bDone to 1. This is used for
> - * two purposes:
bDone member is unused now.
> @@ -885,8 +848,8 @@ sqlVdbeSorterInit(sql * db, /* Database connection (for malloc()) */
> } else {
> pSorter->key_def = pCsr->key_def;
> pSorter->pgsz = pgsz = 1024;
> - pSorter->nTask = nWorker + 1;
> - pSorter->iPrev = (u8) (nWorker - 1);
> + pSorter->nTask = 1;
nTask now always equals to 1, you can refactor code using it.
The same concerns member iPrev.
> diff --git a/src/box/sql/wherecode.c b/src/box/sql/wherecode.c
> index 4dedb38a7..01fa138f6 100644
> --- a/src/box/sql/wherecode.c
> +++ b/src/box/sql/wherecode.c
> @@ -253,14 +253,6 @@ sqlWhereExplainOneScan(Parse * pParse, /* Parse context */
> " USING INTEGER PRIMARY KEY (rowid%s?)",
> zRangeOp);
> }
> -#ifdef SQL_EXPLAIN_ESTIMATED_ROWS
> - if (pLoop->nOut >= 10) {
> - sqlXPrintf(&str, " (~%llu rows)",
> - sqlLogEstToInt(pLoop->nOut));
> - } else {
> - sqlStrAccumAppend(&str, " (~1 row)", 9);
> - }
> -#endif
We can enable this code, instead of removing it.
[-- Attachment #2: Type: text/html, Size: 7798 bytes --]
^ permalink raw reply [flat|nested] 15+ messages in thread
* [tarantool-patches] Re: [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
2019-05-19 15:16 ` [tarantool-patches] " n.pettik
@ 2019-05-29 14:02 ` Stanislav Zudin
0 siblings, 0 replies; 15+ messages in thread
From: Stanislav Zudin @ 2019-05-29 14:02 UTC (permalink / raw)
To: tarantool-patches, n.pettik
On 19.05.2019 18:16, n.pettik wrote:
>
>> diff --git a/src/box/sql/CMakeLists.txt b/src/box/sql/CMakeLists.txt
>> index b9dbe141a..f988dc3e7 100644
>> --- a/src/box/sql/CMakeLists.txt
>> +++ b/src/box/sql/CMakeLists.txt
>> @@ -10,9 +10,6 @@ set(SQL_BIN_DIR ${CMAKE_BINARY_DIR}/src/box/sql)
>> include_directories(${SQL_SRC_DIR})
>> include_directories(${SQL_BIN_DIR})
>>
>> -add_definitions(-DSQL_MAX_WORKER_THREADS=0)
>> -add_definitions(-DSQL_OMIT_AUTOMATIC_INDEX)
>
> Let’s keep routines connected with automatic indexes:
> we are going to re-enable it in scope of
> https://github.com/tarantool/tarantool/issues/2583
> This code is a good point to start with reincarnation.
The macro SQL_OMIT_AUTOMATIC_INDEX and the code enabled by this
macro returned back.
>
>> -
>> set(TEST_DEFINITIONS
>> SQL_NO_SYNC=1
>> SQL_TEST=1
>>
>> diff --git a/src/box/sql/sqlInt.h b/src/box/sql/sqlInt.h
>> index f019cd291..4bf94fad2 100644
>> --- a/src/box/sql/sqlInt.h
>> +++ b/src/box/sql/sqlInt.h
>>
>> @@ -4858,13 +4846,6 @@ int sqlMemdebugNoType(void *, u8);
>>
>> -/*
>> - * Threading interface
>> - */
>> -#if SQL_MAX_WORKER_THREADS>0
>> -int sqlThreadCreate(sqlThread **, void *(*)(void *), void *);
>> -int sqlThreadJoin(sqlThread *, void **);
>> -#endif
>
> Now we can remove struct sqlThread.
Done.
>
>> diff --git a/src/box/sql/vdbesort.c b/src/box/sql/vdbesort.c
>> index ddea6752c..a37fbd911 100644
>> --- a/src/box/sql/vdbesort.c
>> +++ b/src/box/sql/vdbesort.c
>> @@ -118,11 +118,6 @@
>> * there are already N worker threads running, the main thread does
>> the work
>> * itself.
>> *
>> - * The sorter is running in multi-threaded mode if (a) the library
>> was built
>> - * with pre-processor symbol SQL_MAX_WORKER_THREADS set to a value
>> greater
>> - * than zero, and (b) worker threads have been enabled at runtime by
>> calling
>> - * "PRAGMA threads=N" with some value of N greater than 0.
>> - *
>> * When Rewind() is called, any data remaining in memory is flushed to a
>> * final PMA. So at this point the data is stored in some number of sorted
>> * PMAs within temporary files on disk.
>> @@ -159,15 +154,6 @@
>> #include "sqlInt.h"
>> #include "vdbeInt.h"
>>
>>
>> /*
>> * Hard-coded maximum amount of data to accumulate in memory before
>> flushing
>> * to a level 0 PMA. The purpose of this limit is to prevent various
>> integer
>> @@ -297,18 +283,14 @@ struct MergeEngine {
>> *
>> * Before a background thread is launched, variable bDone is set to 0.
>> Then,
>> * right before it exits, the thread itself sets bDone to 1. This is
>> used for
>> - * two purposes:
>
> bDone member is unused now.
Done
>
>> @@ -885,8 +848,8 @@ sqlVdbeSorterInit(sql * db,/* Database connection
>> (for malloc()) */
>> } else {
>> pSorter->key_def = pCsr->key_def;
>> pSorter->pgsz = pgsz = 1024;
>> -pSorter->nTask = nWorker + 1;
>> -pSorter->iPrev = (u8) (nWorker - 1);
>> +pSorter->nTask = 1;
>
> nTask now always equals to 1, you can refactor code using it.
> The same concerns member iPrev.
>
>> diff --git a/src/box/sql/wherecode.c b/src/box/sql/wherecode.c
>> index 4dedb38a7..01fa138f6 100644
>> --- a/src/box/sql/wherecode.c
>> +++ b/src/box/sql/wherecode.c
>> @@ -253,14 +253,6 @@ sqlWhereExplainOneScan(Parse * pParse,/* Parse
>> context */
>> " USING INTEGER PRIMARY KEY (rowid%s?)",
>> zRangeOp);
>> }
>> -#ifdef SQL_EXPLAIN_ESTIMATED_ROWS
>> -if (pLoop->nOut >= 10) {
>> -sqlXPrintf(&str, " (~%llu rows)",
>> - sqlLogEstToInt(pLoop->nOut));
>> -} else {
>> -sqlStrAccumAppend(&str, " (~1 row)", 9);
>> -}
>> -#endif
>
> We can enable this code, instead of removing it.
>
Done.
See the PATCH v2 for changes.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [tarantool-patches] [PATCH 7/8] Removes unused constants
2019-04-29 17:26 [tarantool-patches] [PATCH 0/8] sql: cleanup code from obsolete macros Stanislav Zudin
` (5 preceding siblings ...)
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-04-29 17:26 ` 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
7 siblings, 0 replies; 15+ messages in thread
From: Stanislav Zudin @ 2019-04-29 17:26 UTC (permalink / raw)
To: tarantool-patches, korablev; +Cc: Stanislav Zudin
Part of #3978
---
src/box/sql/sqlInt.h | 106 -------------------------------------------
1 file changed, 106 deletions(-)
diff --git a/src/box/sql/sqlInt.h b/src/box/sql/sqlInt.h
index 4bf94fad2..4bb35ae73 100644
--- a/src/box/sql/sqlInt.h
+++ b/src/box/sql/sqlInt.h
@@ -274,12 +274,6 @@
#define NEVER(X) (X)
#endif
-/*
- * Return true (non-zero) if the input is an integer that is too large
- * to fit in 32-bits. This macro is used inside of various testcase()
- * macros to verify that we have tested sql for large-file support.
- */
-#define IS_BIG_INT(X) (((X)&~(i64)0xffffffff)!=0)
#include "hash.h"
#include "parse.h"
@@ -596,37 +590,21 @@ sql_exec(sql *, /* An open database */
#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))
-#define SQL_IOERR_FSYNC (SQL_IOERR | (4<<8))
#define SQL_IOERR_DIR_FSYNC (SQL_IOERR | (5<<8))
#define SQL_IOERR_TRUNCATE (SQL_IOERR | (6<<8))
#define SQL_IOERR_FSTAT (SQL_IOERR | (7<<8))
#define SQL_IOERR_UNLOCK (SQL_IOERR | (8<<8))
#define SQL_IOERR_RDLOCK (SQL_IOERR | (9<<8))
#define SQL_IOERR_DELETE (SQL_IOERR | (10<<8))
-#define SQL_IOERR_BLOCKED (SQL_IOERR | (11<<8))
#define SQL_IOERR_NOMEM (SQL_IOERR | (12<<8))
#define SQL_IOERR_ACCESS (SQL_IOERR | (13<<8))
-#define SQL_IOERR_CHECKRESERVEDLOCK (SQL_IOERR | (14<<8))
-#define SQL_IOERR_LOCK (SQL_IOERR | (15<<8))
#define SQL_IOERR_CLOSE (SQL_IOERR | (16<<8))
-#define SQL_IOERR_DIR_CLOSE (SQL_IOERR | (17<<8))
-#define SQL_IOERR_SHMOPEN (SQL_IOERR | (18<<8))
-#define SQL_IOERR_SHMSIZE (SQL_IOERR | (19<<8))
-#define SQL_IOERR_SHMLOCK (SQL_IOERR | (20<<8))
-#define SQL_IOERR_SHMMAP (SQL_IOERR | (21<<8))
-#define SQL_IOERR_SEEK (SQL_IOERR | (22<<8))
#define SQL_IOERR_DELETE_NOENT (SQL_IOERR | (23<<8))
-#define SQL_IOERR_MMAP (SQL_IOERR | (24<<8))
#define SQL_IOERR_GETTEMPPATH (SQL_IOERR | (25<<8))
-#define SQL_IOERR_CONVPATH (SQL_IOERR | (26<<8))
-#define SQL_IOERR_VNODE (SQL_IOERR | (27<<8))
#define SQL_CONSTRAINT_CHECK (SQL_CONSTRAINT | (1<<8))
#define SQL_CONSTRAINT_FOREIGNKEY (SQL_CONSTRAINT | (3<<8))
-#define SQL_CONSTRAINT_FUNCTION (SQL_CONSTRAINT | (4<<8))
#define SQL_CONSTRAINT_NOTNULL (SQL_CONSTRAINT | (5<<8))
-#define SQL_CONSTRAINT_PRIMARYKEY (SQL_CONSTRAINT | (6<<8))
#define SQL_CONSTRAINT_TRIGGER (SQL_CONSTRAINT | (7<<8))
-#define SQL_CONSTRAINT_UNIQUE (SQL_CONSTRAINT | (8<<8))
/**
* Subtype of a main type. Allows to do some subtype specific
@@ -673,22 +651,6 @@ sql_initialize(void);
int
sql_os_end(void);
-#define SQL_CONFIG_SCRATCH 6 /* void*, int sz, int N */
-#define SQL_CONFIG_MEMSTATUS 9 /* boolean */
-#define SQL_CONFIG_LOOKASIDE 13 /* int int */
-#define SQL_CONFIG_LOG 16 /* xFunc, void* */
-#define SQL_CONFIG_URI 17 /* int */
-#define SQL_CONFIG_COVERING_INDEX_SCAN 20 /* int */
-#define SQL_CONFIG_SQLLOG 21 /* xSqllog, void* */
-#define SQL_CONFIG_MMAP_SIZE 22 /* sql_int64, sql_int64 */
-#define SQL_CONFIG_PMASZ 24 /* unsigned int szPma */
-#define SQL_CONFIG_STMTJRNL_SPILL 25 /* int nByte */
-
-#define SQL_DBCONFIG_LOOKASIDE 1001 /* void* int int */
-#define SQL_DBCONFIG_ENABLE_FKEY 1002 /* int int* */
-#define SQL_DBCONFIG_ENABLE_TRIGGER 1003 /* int int* */
-#define SQL_DBCONFIG_NO_CKPT_ON_CLOSE 1006 /* int int* */
-
#define SQL_TRACE_STMT 0x01
#define SQL_TRACE_PROFILE 0x02
#define SQL_TRACE_ROW 0x04
@@ -697,10 +659,6 @@ sql_os_end(void);
#define SQL_DETERMINISTIC 0x800
#define SQL_STATUS_MEMORY_USED 0
-#define SQL_STATUS_PAGECACHE_USED 1
-#define SQL_STATUS_PAGECACHE_OVERFLOW 2
-#define SQL_STATUS_SCRATCH_USED 3
-#define SQL_STATUS_SCRATCH_OVERFLOW 4
#define SQL_STATUS_MALLOC_SIZE 5
#define SQL_STATUS_PARSER_STACK 6
#define SQL_STATUS_PAGECACHE_SIZE 7
@@ -733,41 +691,12 @@ sql_create_function_v2(sql * db,
#define SQL_OPEN_CREATE 0x00000004 /* Ok for sql_open_v2() */
#define SQL_OPEN_DELETEONCLOSE 0x00000008 /* VFS only */
#define SQL_OPEN_EXCLUSIVE 0x00000010 /* VFS only */
-#define SQL_OPEN_AUTOPROXY 0x00000020 /* VFS only */
#define SQL_OPEN_URI 0x00000040 /* Ok for sql_open_v2() */
-#define SQL_OPEN_MEMORY 0x00000080 /* Ok for sql_open_v2() */
#define SQL_OPEN_MAIN_DB 0x00000100 /* VFS only */
-#define SQL_OPEN_TEMP_DB 0x00000200 /* VFS only */
-#define SQL_OPEN_SHAREDCACHE 0x00020000 /* Ok for sql_open_v2() */
-#define SQL_OPEN_PRIVATECACHE 0x00040000 /* Ok for sql_open_v2() */
sql_vfs *
sql_vfs_find(const char *zVfsName);
-#define SQL_TESTCTRL_FIRST 5
-#define SQL_TESTCTRL_PRNG_SAVE 5
-#define SQL_TESTCTRL_PRNG_RESTORE 6
-#define SQL_TESTCTRL_PRNG_RESET 7
-#define SQL_TESTCTRL_BITVEC_TEST 8
-#define SQL_TESTCTRL_FAULT_INSTALL 9
-#define SQL_TESTCTRL_BENIGN_MALLOC_HOOKS 10
-#define SQL_TESTCTRL_PENDING_BYTE 11
-#define SQL_TESTCTRL_ASSERT 12
-#define SQL_TESTCTRL_ALWAYS 13
-#define SQL_TESTCTRL_RESERVE 14
-#define SQL_TESTCTRL_OPTIMIZATIONS 15
-#define SQL_TESTCTRL_ISKEYWORD 16
-#define SQL_TESTCTRL_SCRATCHMALLOC 17
-#define SQL_TESTCTRL_LOCALTIME_FAULT 18
-#define SQL_TESTCTRL_EXPLAIN_STMT 19 /* NOT USED */
-#define SQL_TESTCTRL_ONCE_RESET_THRESHOLD 19
-#define SQL_TESTCTRL_NEVER_CORRUPT 20
-#define SQL_TESTCTRL_VDBE_COVERAGE 21
-#define SQL_TESTCTRL_BYTEORDER 22
-#define SQL_TESTCTRL_ISINIT 23
-#define SQL_TESTCTRL_SORTER_MMAP 24
-#define SQL_TESTCTRL_LAST 24
-
int
sql_status64(int op, sql_int64 * pCurrent,
sql_int64 * pHighwater,
@@ -792,22 +721,13 @@ struct sql_io_methods {
};
#define SQL_FCNTL_LOCKSTATE 1
-#define SQL_FCNTL_GET_LOCKPROXYFILE 2
-#define SQL_FCNTL_SET_LOCKPROXYFILE 3
#define SQL_FCNTL_LAST_ERRNO 4
#define SQL_FCNTL_SIZE_HINT 5
#define SQL_FCNTL_CHUNK_SIZE 6
-#define SQL_FCNTL_FILE_POINTER 7
-#define SQL_FCNTL_SYNC_OMITTED 8
-#define SQL_FCNTL_OVERWRITE 10
#define SQL_FCNTL_VFSNAME 11
-#define SQL_FCNTL_POWERSAFE_OVERWRITE 12
-#define SQL_FCNTL_PRAGMA 13
#define SQL_FCNTL_TEMPFILENAME 15
#define SQL_FCNTL_MMAP_SIZE 16
-#define SQL_FCNTL_TRACE 17
#define SQL_FCNTL_HAS_MOVED 18
-#define SQL_FCNTL_SYNC 19
int
sql_os_init(void);
@@ -818,10 +738,6 @@ sql_soft_heap_limit64(sql_int64 N);
int
sql_limit(sql *, int id, int newVal);
-#define SQL_SYNC_NORMAL 0x00002
-#define SQL_SYNC_FULL 0x00003
-#define SQL_SYNC_DATAONLY 0x00010
-
extern char *
sql_temp_directory;
@@ -829,10 +745,6 @@ const char *
sql_uri_parameter(const char *zFilename,
const char *zParam);
-#define SQL_ACCESS_EXISTS 0
-#define SQL_ACCESS_READWRITE 1 /* Used by PRAGMA temp_store_directory */
-#define SQL_ACCESS_READ 2 /* Unused */
-
#define SQL_DBSTATUS_LOOKASIDE_USED 0
#define SQL_DBSTATUS_CACHE_USED 1
#define SQL_DBSTATUS_SCHEMA_USED 2
@@ -2895,16 +2807,6 @@ struct TreeView {
};
#endif /* SQL_DEBUG */
-/*
- * Assuming zIn points to the first byte of a UTF-8 character,
- * advance zIn to point to the first byte of the next UTF-8 character.
- */
-#define SQL_SKIP_UTF8(zIn) { \
- if( (*(zIn++))>=0xc0 ){ \
- while( (*zIn & 0xc0)==0x80 ){ zIn++; } \
- } \
-}
-
/*
* The following macros mimic the standard library functions toupper(),
* isspace(), isalnum(), isdigit() and isxdigit(), respectively. The
@@ -4763,12 +4665,6 @@ fk_constraint_emit_actions(struct Parse *parser, struct space *space, int reg_ol
bool
fk_constraint_is_required(struct space *space, const int *changes);
-/*
- * Available fault injectors. Should be numbered beginning with 0.
- */
-#define SQL_FAULTINJECTOR_MALLOC 0
-#define SQL_FAULTINJECTOR_COUNT 1
-
/*
* The interface to the code in fault.c used for identifying "benign"
* malloc failures.
@@ -4843,8 +4739,6 @@ int sqlMemdebugNoType(void *, u8);
#endif
#define MEMTYPE_HEAP 0x01 /* General heap allocations */
#define MEMTYPE_LOOKASIDE 0x02 /* Heap that might have been lookaside */
-#define MEMTYPE_SCRATCH 0x04 /* Scratch allocations */
-#define MEMTYPE_PCACHE 0x08 /* Page cache allocations */
int sqlExprVectorSize(Expr * pExpr);
--
2.17.1
^ permalink raw reply [flat|nested] 15+ messages in thread
* [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
2019-04-29 17:26 [tarantool-patches] [PATCH 0/8] sql: cleanup code from obsolete macros Stanislav Zudin
` (6 preceding siblings ...)
2019-04-29 17:26 ` [tarantool-patches] [PATCH 7/8] Removes unused constants Stanislav Zudin
@ 2019-04-29 17:26 ` Stanislav Zudin
7 siblings, 0 replies; 15+ messages in thread
From: Stanislav Zudin @ 2019-04-29 17:26 UTC (permalink / raw)
To: tarantool-patches, korablev; +Cc: Stanislav Zudin
Closes #3978
---
| 4 ---
src/box/sql/parse.y | 7 ++---
src/box/sql/printf.c | 10 -------
src/box/sql/select.c | 13 --------
src/box/sql/sqlInt.h | 10 -------
src/box/sql/vdbe.c | 11 ++-----
src/box/sql/vdbe.h | 6 +---
src/box/sql/vdbeapi.c | 66 +----------------------------------------
src/box/sql/vdbetrace.c | 31 -------------------
src/box/sql/wherecode.c | 5 +---
src/box/sql/whereexpr.c | 11 +------
11 files changed, 9 insertions(+), 165 deletions(-)
--git a/extra/mkkeywordhash.c b/extra/mkkeywordhash.c
index ba4932b49..5fbb82471 100644
--- a/extra/mkkeywordhash.c
+++ b/extra/mkkeywordhash.c
@@ -61,11 +61,7 @@ struct Keyword {
# define AUTOINCR 0x00000010
#endif
# define CAST 0x00000020
-#ifdef SQL_OMIT_COMPOUND_SELECT
-# define COMPOUND 0
-#else
# define COMPOUND 0x00000040
-#endif
#ifdef SQL_OMIT_CONFLICT_CLAUSE
# define CONFLICT 0
#else
diff --git a/src/box/sql/parse.y b/src/box/sql/parse.y
index 78b3370f9..3e7ffd33a 100644
--- a/src/box/sql/parse.y
+++ b/src/box/sql/parse.y
@@ -222,9 +222,6 @@ columnname(A) ::= nm(A) typedef(Y). {sqlAddColumn(pParse,&A,&Y);}
CONFLICT DEFERRED END FAIL
IGNORE INITIALLY INSTEAD NO MATCH PLAN
QUERY KEY OFFSET RAISE RELEASE REPLACE RESTRICT
-%ifdef SQL_OMIT_COMPOUND_SELECT
- INTERSECT
-%endif SQL_OMIT_COMPOUND_SELECT
RENAME CTIME_KW IF
.
%wildcard ANY.
@@ -468,7 +465,7 @@ select(A) ::= with(W) selectnowith(X). {
}
selectnowith(A) ::= oneselect(A).
-%ifndef SQL_OMIT_COMPOUND_SELECT
+
selectnowith(A) ::= selectnowith(A) multiselect_op(Y) oneselect(Z). {
Select *pRhs = Z;
Select *pLhs = A;
@@ -495,7 +492,7 @@ selectnowith(A) ::= selectnowith(A) multiselect_op(Y) oneselect(Z). {
multiselect_op(A) ::= UNION(OP). {A = @OP; /*A-overwrites-OP*/}
multiselect_op(A) ::= UNION ALL. {A = TK_ALL;}
multiselect_op(A) ::= EXCEPT|INTERSECT(OP). {A = @OP; /*A-overwrites-OP*/}
-%endif SQL_OMIT_COMPOUND_SELECT
+
oneselect(A) ::= SELECT(S) distinct(D) selcollist(W) from(X) where_opt(Y)
groupby_opt(P) having_opt(Q) orderby_opt(Z) limit_opt(L). {
#ifdef SQL_DEBUG
diff --git a/src/box/sql/printf.c b/src/box/sql/printf.c
index 31d21dbb0..a397b90d8 100644
--- a/src/box/sql/printf.c
+++ b/src/box/sql/printf.c
@@ -293,11 +293,6 @@ sqlVXPrintf(StrAccum * pAccum, /* Accumulate results here */
width = wx & 0x7fffffff;
}
assert(width >= 0);
-#ifdef SQL_PRINTF_PRECISION_LIMIT
- if (width > SQL_PRINTF_PRECISION_LIMIT) {
- width = SQL_PRINTF_PRECISION_LIMIT;
- }
-#endif
/* Get the precision */
if (c == '.') {
@@ -327,11 +322,6 @@ sqlVXPrintf(StrAccum * pAccum, /* Accumulate results here */
precision = -1;
}
assert(precision >= (-1));
-#ifdef SQL_PRINTF_PRECISION_LIMIT
- if (precision > SQL_PRINTF_PRECISION_LIMIT) {
- precision = SQL_PRINTF_PRECISION_LIMIT;
- }
-#endif
/* Get the conversion type modifier */
if (c == 'l') {
diff --git a/src/box/sql/select.c b/src/box/sql/select.c
index 153997cde..556574e10 100644
--- a/src/box/sql/select.c
+++ b/src/box/sql/select.c
@@ -1139,7 +1139,6 @@ selectInnerLoop(Parse * pParse, /* The parser context */
/* In this mode, write each query result to the key of the temporary
* table iParm.
*/
-#ifndef SQL_OMIT_COMPOUND_SELECT
case SRT_Union:{
int r1;
r1 = sqlGetTempReg(pParse);
@@ -1159,7 +1158,6 @@ selectInnerLoop(Parse * pParse, /* The parser context */
nResultCol);
break;
}
-#endif /* SQL_OMIT_COMPOUND_SELECT */
/* Store the result as data using a unique key.
*/
@@ -1517,7 +1515,6 @@ explainTempTable(Parse * pParse, const char *zUsage)
}
}
-#if !defined(SQL_OMIT_COMPOUND_SELECT)
/*
* Unless an "EXPLAIN QUERY PLAN" command is being processed, this function
* is a no-op. Otherwise, it adds a single row of output to the EQP result,
@@ -1555,10 +1552,6 @@ explainComposite(Parse * pParse, /* Parse context */
P4_DYNAMIC);
}
}
-#else
-/* No-op versions of the explainXXX() functions and macros. */
-#define explainComposite(v,w,x,y,z)
-#endif
/*
* If the inner loop was generated using a non-null pOrderBy argument,
@@ -2188,7 +2181,6 @@ computeLimitRegisters(Parse * pParse, Select * p, int iBreak)
}
}
-#ifndef SQL_OMIT_COMPOUND_SELECT
/**
* This function determines resulting collation sequence for
* @n-th column of the result set for the compound SELECT
@@ -2981,7 +2973,6 @@ multiSelect(Parse * pParse, /* Parsing context */
sql_select_delete(db, pDelete);
return rc;
}
-#endif /* SQL_OMIT_COMPOUND_SELECT */
/**
* Code an output subroutine for a coroutine implementation of a
@@ -3237,7 +3228,6 @@ generateOutputSubroutine(struct Parse *parse, struct Select *p,
* until all data is exhausted then jump to the "end" labe. AltB, AeqB,
* and AgtB jump to either L2 or to one of EofA or EofB.
*/
-#ifndef SQL_OMIT_COMPOUND_SELECT
static int
multiSelectOrderBy(Parse * pParse, /* Parsing context */
Select * p, /* The right-most of SELECTs to be coded */
@@ -3573,7 +3563,6 @@ multiSelectOrderBy(Parse * pParse, /* Parsing context */
explainComposite(pParse, p->op, iSub1, iSub2, 0);
return pParse->is_aborted;
}
-#endif
/* Forward Declarations */
static void substExprList(Parse *, ExprList *, int, ExprList *);
@@ -5570,7 +5559,6 @@ sqlSelect(Parse * pParse, /* The parser context */
if (v == 0)
goto select_end;
-#ifndef SQL_OMIT_COMPOUND_SELECT
/* Handle compound SELECT statements using the separate multiSelect()
* procedure.
*/
@@ -5591,7 +5579,6 @@ sqlSelect(Parse * pParse, /* The parser context */
#endif
return rc;
}
-#endif
/* Generate code for all sub-queries in the FROM clause
*/
diff --git a/src/box/sql/sqlInt.h b/src/box/sql/sqlInt.h
index 4bb35ae73..14d1fca82 100644
--- a/src/box/sql/sqlInt.h
+++ b/src/box/sql/sqlInt.h
@@ -168,14 +168,6 @@
#define SQL_NOINLINE
#endif
-/*
- * Powersafe overwrite is on by default. But can be turned off using
- * the -Dsql_POWERSAFE_OVERWRITE=0 command-line option.
- */
-#ifndef SQL_POWERSAFE_OVERWRITE
-#define SQL_POWERSAFE_OVERWRITE 1
-#endif
-
/*
* EVIDENCE-OF: R-25715-37072 Memory allocation statistics are enabled by
* default unless sql is compiled with sql_DEFAULT_MEMSTATUS=0 in
@@ -1293,11 +1285,9 @@ struct sql {
double notUsed1; /* Spacer */
} u1;
Lookaside lookaside; /* Lookaside malloc configuration */
-#ifndef SQL_OMIT_PROGRESS_CALLBACK
int (*xProgress) (void *); /* The progress callback */
void *pProgressArg; /* Argument to the progress callback */
unsigned nProgressOps; /* Number of opcodes for progress callback */
-#endif
Hash aFunc; /* Hash table of connection functions */
int *pnBytesFreed; /* If not NULL, increment this in DbFree() */
};
diff --git a/src/box/sql/vdbe.c b/src/box/sql/vdbe.c
index 738a0701b..50f97d684 100644
--- a/src/box/sql/vdbe.c
+++ b/src/box/sql/vdbe.c
@@ -631,9 +631,7 @@ int sqlVdbeExec(Vdbe *p)
sql *db = p->db; /* The database */
int iCompare = 0; /* Result of last comparison */
unsigned nVmStep = 0; /* Number of virtual machine steps */
-#ifndef SQL_OMIT_PROGRESS_CALLBACK
unsigned nProgressLimit = 0;/* Invoke xProgress() when nVmStep reaches this */
-#endif
Mem *aMem = p->aMem; /* Copy of p->aMem */
Mem *pIn1 = 0; /* 1st input operand */
Mem *pIn2 = 0; /* 2nd input operand */
@@ -659,13 +657,13 @@ int sqlVdbeExec(Vdbe *p)
assert(p->explain==0);
p->pResultSet = 0;
if (db->u1.isInterrupted) goto abort_due_to_interrupt;
-#ifndef SQL_OMIT_PROGRESS_CALLBACK
+
if (db->xProgress) {
u32 iPrior = p->aCounter[SQL_STMTSTATUS_VM_STEP];
assert(0 < db->nProgressOps);
nProgressLimit = db->nProgressOps - (iPrior % db->nProgressOps);
}
-#endif
+
#ifdef SQL_DEBUG
sqlBeginBenignMalloc();
if (p->pc==0
@@ -822,7 +820,7 @@ case OP_Goto: { /* jump */
*/
check_for_interrupt:
if (db->u1.isInterrupted) goto abort_due_to_interrupt;
-#ifndef SQL_OMIT_PROGRESS_CALLBACK
+
/* Call the progress callback if it is configured and the required number
* of VDBE ops have been executed (either since this invocation of
* sqlVdbeExec() or since last time the progress callback was called).
@@ -837,7 +835,6 @@ case OP_Goto: { /* jump */
goto abort_due_to_error;
}
}
-#endif
break;
}
@@ -1401,7 +1398,6 @@ case OP_ResultRow: {
assert(pOp->p1>0);
assert(pOp->p1+pOp->p2<=(p->nMem+1 - p->nCursor)+1);
-#ifndef SQL_OMIT_PROGRESS_CALLBACK
/* Run the progress counter just before returning.
*/
if (db->xProgress!=0
@@ -1411,7 +1407,6 @@ case OP_ResultRow: {
rc = SQL_INTERRUPT;
goto abort_due_to_error;
}
-#endif
/* If this statement has violated immediate foreign key constraints, do
* not return the number of rows modified. And do not RELEASE the statement
diff --git a/src/box/sql/vdbe.h b/src/box/sql/vdbe.h
index 2a1a4402c..acbe255b7 100644
--- a/src/box/sql/vdbe.h
+++ b/src/box/sql/vdbe.h
@@ -152,11 +152,7 @@ struct SubProgram {
#define COLNAME_DATABASE 2
#define COLNAME_TABLE 3
#define COLNAME_COLUMN 4
-#ifdef SQL_ENABLE_COLUMN_METADATA
-#define COLNAME_N 5 /* Number of COLNAME_xxx symbols */
-#else
-#define COLNAME_N 2 /* Store the name and decltype */
-#endif
+#define COLNAME_N 2 /* Store the name and decltype */
/*
* The following macro converts a relative address in the p2 field
diff --git a/src/box/sql/vdbeapi.c b/src/box/sql/vdbeapi.c
index 9593071f3..562441a1d 100644
--- a/src/box/sql/vdbeapi.c
+++ b/src/box/sql/vdbeapi.c
@@ -503,21 +503,9 @@ sqlStep(Vdbe * p)
*
* Nevertheless, some published applications that were originally written
* for version 3.6.23 or earlier do in fact depend on SQL_MISUSE
- * returns, and those were broken by the automatic-reset change. As a
- * a work-around, the SQL_OMIT_AUTORESET compile-time restores the
- * legacy behavior of returning SQL_MISUSE for cases where the
- * previous sql_step() returned something other than a SQL_LOCKED
- * or SQL_BUSY error.
+ * returns, and those were broken by the automatic-reset change.
*/
-#ifdef SQL_OMIT_AUTORESET
- if ((rc = p->rc & 0xff) == SQL_BUSY || rc == SQL_LOCKED) {
- sql_reset((sql_stmt *) p);
- } else {
- return SQL_MISUSE;
- }
-#else
sql_reset((sql_stmt *) p);
-#endif
}
/* Check that malloc() has not failed. If it has, return early. */
@@ -1100,16 +1088,6 @@ sql_column_datatype(sql_stmt *pStmt, int N)
COLNAME_DECLTYPE);
}
-/*
- * Constraint: If you have ENABLE_COLUMN_METADATA then you must
- * not define OMIT_DECLTYPE.
- */
-#if defined(SQL_OMIT_DECLTYPE) && defined(SQL_ENABLE_COLUMN_METADATA)
-#error "Must not define both SQL_OMIT_DECLTYPE \
- and SQL_ENABLE_COLUMN_METADATA"
-#endif
-
-#ifndef SQL_OMIT_DECLTYPE
/*
* Return the column declaration type (if applicable) of the 'i'th column
* of the result set of SQL statement pStmt.
@@ -1120,45 +1098,6 @@ sql_column_decltype(sql_stmt * pStmt, int N)
return columnName(pStmt, N, (const void *(*)(Mem *))sql_value_text,
COLNAME_DECLTYPE);
}
-#endif /* SQL_OMIT_DECLTYPE */
-
-#ifdef SQL_ENABLE_COLUMN_METADATA
-/*
- * Return the name of the database from which a result column derives.
- * NULL is returned if the result column is an expression or constant or
- * anything else which is not an unambiguous reference to a database column.
- */
-const char *
-sql_column_database_name(sql_stmt * pStmt, int N)
-{
- return columnName(pStmt, N, (const void *(*)(Mem *))sql_value_text,
- COLNAME_DATABASE);
-}
-
-/*
- * Return the name of the table from which a result column derives.
- * NULL is returned if the result column is an expression or constant or
- * anything else which is not an unambiguous reference to a database column.
- */
-const char *
-sql_column_table_name(sql_stmt * pStmt, int N)
-{
- return columnName(pStmt, N, (const void *(*)(Mem *))sql_value_text,
- COLNAME_TABLE);
-}
-
-/*
- * Return the name of the table column from which a result column derives.
- * NULL is returned if the result column is an expression or constant or
- * anything else which is not an unambiguous reference to a database column.
- */
-const char *
-sql_column_origin_name(sql_stmt * pStmt, int N)
-{
- return columnName(pStmt, N, (const void *(*)(Mem *))sql_value_text,
- COLNAME_COLUMN);
-}
-#endif /* SQL_ENABLE_COLUMN_METADATA */
/******************************* sql_bind_ **************************
*
@@ -1559,9 +1498,6 @@ sql_sql(sql_stmt * pStmt)
* bound parameters expanded. Space to hold the returned string is
* obtained from sql_malloc(). The caller is responsible for
* freeing the returned string by passing it to sql_free().
- *
- * The SQL_TRACE_SIZE_LIMIT puts an upper bound on the size of
- * expanded bound parameters.
*/
char *
sql_expanded_sql(sql_stmt * pStmt)
diff --git a/src/box/sql/vdbetrace.c b/src/box/sql/vdbetrace.c
index b86ad7b8a..f78d5b093 100644
--- a/src/box/sql/vdbetrace.c
+++ b/src/box/sql/vdbetrace.c
@@ -75,11 +75,6 @@ findNextHostParameter(const char *zSql, int *pnToken)
* then the returned string holds a copy of zRawSql with "-- " prepended
* to each line of text.
*
- * If the SQL_TRACE_SIZE_LIMIT macro is defined to an integer, then
- * then long strings and blobs are truncated to that many bytes. This
- * can be used to prevent unreasonably large trace strings when dealing
- * with large (multi-megabyte) strings and blobs.
- *
* The calling function is responsible for making sure the memory returned
* is eventually freed.
*
@@ -161,23 +156,7 @@ sqlVdbeExpandSql(Vdbe * p, /* The prepared statement being evaluated */
} else if (pVar->flags & MEM_Str) {
int nOut; /* Number of bytes of the string text to include in output */
nOut = pVar->n;
-#ifdef SQL_TRACE_SIZE_LIMIT
- if (nOut > SQL_TRACE_SIZE_LIMIT) {
- nOut = SQL_TRACE_SIZE_LIMIT;
- while (nOut < pVar->n
- && (pVar->z[nOut] & 0xc0) ==
- 0x80) {
- nOut++;
- }
- }
-#endif
sqlXPrintf(&out, "'%.*q'", nOut, pVar->z);
-#ifdef SQL_TRACE_SIZE_LIMIT
- if (nOut < pVar->n) {
- sqlXPrintf(&out, "/*+%d bytes*/",
- pVar->n - nOut);
- }
-#endif
} else if (pVar->flags & MEM_Zero) {
sqlXPrintf(&out, "zeroblob(%d)",
pVar->u.nZero);
@@ -186,21 +165,11 @@ sqlVdbeExpandSql(Vdbe * p, /* The prepared statement being evaluated */
assert(pVar->flags & MEM_Blob);
sqlStrAccumAppend(&out, "x'", 2);
nOut = pVar->n;
-#ifdef SQL_TRACE_SIZE_LIMIT
- if (nOut > SQL_TRACE_SIZE_LIMIT)
- nOut = SQL_TRACE_SIZE_LIMIT;
-#endif
for (i = 0; i < nOut; i++) {
sqlXPrintf(&out, "%02x",
pVar->z[i] & 0xff);
}
sqlStrAccumAppend(&out, "'", 1);
-#ifdef SQL_TRACE_SIZE_LIMIT
- if (nOut < pVar->n) {
- sqlXPrintf(&out, "/*+%d bytes*/",
- pVar->n - nOut);
- }
-#endif
}
}
}
diff --git a/src/box/sql/wherecode.c b/src/box/sql/wherecode.c
index 01fa138f6..0317ffd92 100644
--- a/src/box/sql/wherecode.c
+++ b/src/box/sql/wherecode.c
@@ -1211,9 +1211,7 @@ sqlWhereCodeOneLoopStart(WhereInfo * pWInfo, /* Complete information about the W
} else {
assert(pLevel->p5 == 0);
}
- } else
-#ifndef SQL_OMIT_OR_OPTIMIZATION
- if (pLoop->wsFlags & WHERE_MULTI_OR) {
+ } else if (pLoop->wsFlags & WHERE_MULTI_OR) {
/* Case 5: Two or more separately indexed terms connected by OR
*
* Example:
@@ -1512,7 +1510,6 @@ sqlWhereCodeOneLoopStart(WhereInfo * pWInfo, /* Complete information about the W
if (!untestedTerms)
disableTerm(pLevel, pTerm);
} else
-#endif /* SQL_OMIT_OR_OPTIMIZATION */
{
/* Case 6: There is no usable index. We must do a complete
diff --git a/src/box/sql/whereexpr.c b/src/box/sql/whereexpr.c
index 30017b080..d30a710bb 100644
--- a/src/box/sql/whereexpr.c
+++ b/src/box/sql/whereexpr.c
@@ -222,7 +222,6 @@ operatorMask(int op)
return c;
}
-#ifndef SQL_OMIT_LIKE_OPTIMIZATION
/**
* Check to see if the given expression is a LIKE operator that
* can be optimized using inequality constraints.
@@ -341,7 +340,6 @@ like_optimization_is_valid(Parse *pParse, Expr *pExpr, Expr **ppPrefix,
sqlValueFree(pVal);
return rc;
}
-#endif /* SQL_OMIT_LIKE_OPTIMIZATION */
/*
* If the pBase expression originated in the ON or USING clause of
@@ -451,7 +449,6 @@ whereCombineDisjuncts(SrcList * pSrc, /* the FROM clause */
exprAnalyze(pSrc, pWC, idxNew);
}
-#if !defined(SQL_OMIT_OR_OPTIMIZATION)
/*
* Analyze a term that consists of two or more OR-connected
* subterms. So in:
@@ -822,7 +819,6 @@ exprAnalyzeOrTerm(SrcList * pSrc, /* the FROM clause */
}
}
}
-#endif /* !SQL_OMIT_OR_OPTIMIZATION */
/*
* We already know that pExpr is a binary operator where both operands are
@@ -1092,7 +1088,7 @@ exprAnalyze(SrcList * pSrc, /* the FROM clause */
(operatorMask(pDup->op) + eExtraOp) & opMask;
}
}
-#ifndef SQL_OMIT_BETWEEN_OPTIMIZATION
+
/* If a term is the BETWEEN operator, create two new virtual terms
* that define the range that the BETWEEN implements. For example:
*
@@ -1133,9 +1129,7 @@ exprAnalyze(SrcList * pSrc, /* the FROM clause */
markTermAsChild(pWC, idxNew, idxTerm);
}
}
-#endif /* SQL_OMIT_BETWEEN_OPTIMIZATION */
-#if !defined(SQL_OMIT_OR_OPTIMIZATION)
/* Analyze a term that is composed of two or more subterms connected by
* an OR operator.
*/
@@ -1144,9 +1138,7 @@ exprAnalyze(SrcList * pSrc, /* the FROM clause */
exprAnalyzeOrTerm(pSrc, pWC, idxTerm);
pTerm = &pWC->a[idxTerm];
}
-#endif /* SQL_OMIT_OR_OPTIMIZATION */
-#ifndef SQL_OMIT_LIKE_OPTIMIZATION
/*
* Add constraints to reduce the search space on a LIKE
* operator.
@@ -1240,7 +1232,6 @@ exprAnalyze(SrcList * pSrc, /* the FROM clause */
markTermAsChild(pWC, idxNew2, idxTerm);
}
}
-#endif /* SQL_OMIT_LIKE_OPTIMIZATION */
/* If there is a vector == or IS term - e.g. "(a, b) == (?, ?)" - create
* new terms for each component comparison - "a = ?" and "b = ?". The
--
2.17.1
^ permalink raw reply [flat|nested] 15+ messages in thread