From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id DDF532DD0D for ; Mon, 29 Apr 2019 13:26:22 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 2_oNLe-ZA4OK for ; Mon, 29 Apr 2019 13:26:22 -0400 (EDT) Received: from smtp39.i.mail.ru (smtp39.i.mail.ru [94.100.177.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id 72DDF2DCD2 for ; Mon, 29 Apr 2019 13:26:22 -0400 (EDT) From: Stanislav Zudin Subject: [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 Date: Mon, 29 Apr 2019 20:26:08 +0300 Message-Id: In-Reply-To: References: In-Reply-To: References: Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-Help: List-Unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-Subscribe: List-Owner: List-post: List-Archive: To: tarantool-patches@freelists.org, korablev@tarantool.org 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; /* */ -#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