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 F1AFC2DD1B for ; Mon, 29 Apr 2019 13:26:25 -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 YRlt-nnnkhBc for ; Mon, 29 Apr 2019 13:26:25 -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 86BC82DBFD for ; Mon, 29 Apr 2019 13:26:25 -0400 (EDT) From: Stanislav Zudin Subject: [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 Date: Mon, 29 Apr 2019 20:26:11 +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 Closes #3978 --- extra/mkkeywordhash.c | 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(-) diff --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