From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtpng3.m.smailru.net (smtpng3.m.smailru.net [94.100.177.149]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id CB34D43040D for ; Tue, 11 Aug 2020 03:34:07 +0300 (MSK) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.0 \(3594.4.19\)) From: Roman Khabibov In-Reply-To: <4241abff-452b-ba0c-841f-5adc8c3d910f@tarantool.org> Date: Tue, 11 Aug 2020 03:34:04 +0300 Content-Transfer-Encoding: quoted-printable Message-Id: <1981AD55-5001-47DB-982C-0ADD9CF64EE5@tarantool.org> References: <20200403152752.8923-1-roman.habibov@tarantool.org> <20200403152752.8923-2-roman.habibov@tarantool.org> <4241abff-452b-ba0c-841f-5adc8c3d910f@tarantool.org> Subject: Re: [Tarantool-patches] [PATCH v2 1/2] sql: rename TK_COLUMN to TK_COLUMN_NAME List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Vladislav Shpilevoy Cc: tarantool-patches@dev.tarantool.org Hi! Thanks for the review. > On Apr 25, 2020, at 01:55, Vladislav Shpilevoy = wrote: >=20 > Hi! Thanks for the patch! >=20 >> @@ -5081,7 +5081,7 @@ sqlExprCompare(Expr * pA, Expr * pB, int iTab) >> } >> return 2; >> } >> - if (pA->op !=3D TK_COLUMN && pA->op !=3D TK_AGG_COLUMN && = pA->u.zToken) { >> + if (pA->op !=3D TK_COLUMN_NAME && pA->op !=3D TK_AGG_COLUMN && = pA->u.zToken) { >=20 > 1. This is out of 80 symbols. Please, wrap the line. Fixed. >> if (pA->op =3D=3D TK_FUNCTION) { >> if (sqlStrICmp(pA->u.zToken, pB->u.zToken) !=3D = 0) >> return 2; >> @@ -5161,7 +5161,7 @@ sqlExprListCompare(ExprList * pA, ExprList * = pB, int iTab) >> * pE1: x IS NULL pE2: x IS NOT NULL Result: false >> * pE1: x IS ?2 pE2: x IS NOT NULL Reuslt: false >> * >> - * When comparing TK_COLUMN nodes between pE1 and pE2, if pE2 has >> + * When comparing TK_COLUMN_NAME nodes between pE1 and pE2, if pE2 = has >> * Expr.iTable<0 then assume a table number given by iTab. >> * >> * When in doubt, return false. Returning true might give a = performance >> @@ -5209,11 +5209,11 @@ exprSrcCount(Walker * pWalker, Expr * pExpr) >> { >> /* The NEVER() on the second term is because = sqlFunctionUsesThisSrc() >> * is always called before sqlExprAnalyzeAggregates() and so the >> - * TK_COLUMNs have not yet been converted into TK_AGG_COLUMN. = If >> + * TK_COLUMN_NAMEs have not yet been converted into = TK_AGG_COLUMN. If >=20 > 2. While you are here, please, remove the multiplied whitespace. Done. >> * sqlFunctionUsesThisSrc() is used differently in the future, = the >> * NEVER() will need to be removed. >> */ >> - if (pExpr->op =3D=3D TK_COLUMN || NEVER(pExpr->op =3D=3D = TK_AGG_COLUMN)) { >> + if (pExpr->op =3D=3D TK_COLUMN_NAME || NEVER(pExpr->op =3D=3D = TK_AGG_COLUMN)) { >> int i; >> struct SrcCount *p =3D pWalker->u.pSrcCount; >> SrcList *pSrc =3D p->pSrc; commit ee578dbfb97b09b911f169826a68aafe37d9300b Author: Roman Khabibov Date: Fri Apr 3 16:27:34 2020 +0300 sql: rename TK_COLUMN to TK_COLUMN_NAME =20 Rename TK_COLUMN used for tokens treated as a column name to TK_COLUMN_NAME. It is needed to allow the typing of COLUMN keyword in statement. =20 Needed for #3075 diff --git a/extra/addopcodes.sh b/extra/addopcodes.sh index cb6c84725..986c62683 100755 --- a/extra/addopcodes.sh +++ b/extra/addopcodes.sh @@ -39,7 +39,7 @@ extras=3D" \ END_OF_FILE \ UNCLOSED_STRING \ FUNCTION \ - COLUMN \ + COLUMN_NAME \ AGG_FUNCTION \ AGG_COLUMN \ UMINUS \ diff --git a/extra/mkkeywordhash.c b/extra/mkkeywordhash.c index dd42c8f5f..486b6b30d 100644 --- a/extra/mkkeywordhash.c +++ b/extra/mkkeywordhash.c @@ -75,10 +75,7 @@ static Keyword aKeywordTable[] =3D { { "CAST", "TK_CAST", false }, { "CHECK", "TK_CHECK", true }, { "COLLATE", "TK_COLLATE", true }, - /* gh-3075: Reserved until ALTER ADD COLUMN is implemeneted. - * Move it back to ALTER when done. - */ - /* { "COLUMN", "TK_COLUMNKW", true }, */ + { "COLUMN_NAME", "TK_COLUMN_NAME", true }, { "COLUMN", "TK_STANDARD", true }, { "COMMIT", "TK_COMMIT", true }, { "CONFLICT", "TK_CONFLICT", false }, diff --git a/src/box/sql/build.c b/src/box/sql/build.c index 8f6b403b9..619bbf8e3 100644 --- a/src/box/sql/build.c +++ b/src/box/sql/build.c @@ -2295,7 +2295,7 @@ index_fill_def(struct Parse *parse, struct index = *index, goto cleanup; =20 struct Expr *column_expr =3D sqlExprSkipCollate(expr); - if (column_expr->op !=3D TK_COLUMN) { + if (column_expr->op !=3D TK_COLUMN_NAME) { diag_set(ClientError, ER_UNSUPPORTED, = "Tarantool", "functional indexes"); goto tnt_error; diff --git a/src/box/sql/expr.c b/src/box/sql/expr.c index bc2182446..d389b3daf 100644 --- a/src/box/sql/expr.c +++ b/src/box/sql/expr.c @@ -62,7 +62,7 @@ sql_expr_type(struct Expr *pExpr) assert(!ExprHasProperty(pExpr, EP_IntValue)); return pExpr->type; case TK_AGG_COLUMN: - case TK_COLUMN: + case TK_COLUMN_NAME: case TK_TRIGGER: assert(pExpr->iColumn >=3D 0); return pExpr->space_def->fields[pExpr->iColumn].type; @@ -262,13 +262,13 @@ sql_expr_coll(Parse *parse, Expr *p, bool = *is_explicit_coll, uint32_t *coll_id, *is_explicit_coll =3D true; break; } - if ((op =3D=3D TK_AGG_COLUMN || op =3D=3D TK_COLUMN || + if ((op =3D=3D TK_AGG_COLUMN || op =3D=3D TK_COLUMN_NAME = || op =3D=3D TK_REGISTER || op =3D=3D TK_TRIGGER) && p->space_def !=3D NULL) { /* * op=3D=3DTK_REGISTER && p->space_def!=3D0 * happens when pExpr was originally - * a TK_COLUMN but was previously + * a TK_COLUMN_NAME but was previously * evaluated and cached in a register. */ int j =3D p->iColumn; @@ -2061,11 +2061,11 @@ exprNodeIsConstant(Walker * pWalker, Expr * = pExpr) return WRC_Abort; } case TK_ID: - case TK_COLUMN: + case TK_COLUMN_NAME: case TK_AGG_FUNCTION: case TK_AGG_COLUMN: testcase(pExpr->op =3D=3D TK_ID); - testcase(pExpr->op =3D=3D TK_COLUMN); + testcase(pExpr->op =3D=3D TK_COLUMN_NAME); testcase(pExpr->op =3D=3D TK_AGG_FUNCTION); testcase(pExpr->op =3D=3D TK_AGG_COLUMN); if (pWalker->eCode =3D=3D 3 && pExpr->iTable =3D=3D = pWalker->u.iCur) { @@ -2236,7 +2236,7 @@ sqlExprCanBeNull(const Expr * p) case TK_FLOAT: case TK_BLOB: return 0; - case TK_COLUMN: + case TK_COLUMN_NAME: assert(p->space_def !=3D 0); return ExprHasProperty(p, EP_CanBeNull) || (p->iColumn >=3D 0 @@ -2267,7 +2267,7 @@ sql_expr_needs_no_type_change(const struct Expr = *p, enum field_type type) return type =3D=3D FIELD_TYPE_STRING; case TK_BLOB: return type =3D=3D FIELD_TYPE_VARBINARY; - case TK_COLUMN: + case TK_COLUMN_NAME: /* p cannot be part of a CHECK constraint. */ assert(p->iTable >=3D 0); return p->iColumn < 0 && sql_type_is_numeric(type); @@ -2324,7 +2324,7 @@ isCandidateForInOpt(Expr * pX) /* All SELECT results must be columns. */ for (i =3D 0; i < pEList->nExpr; i++) { Expr *pRes =3D pEList->a[i].pExpr; - if (pRes->op !=3D TK_COLUMN) + if (pRes->op !=3D TK_COLUMN_NAME) return 0; assert(pRes->iTable =3D=3D pSrc->a[0].iCursor); /* Not a = correlated subquery */ } @@ -3707,10 +3707,10 @@ sqlExprCodeTarget(Parse * pParse, Expr * pExpr, = int target) } return target; } - /* Otherwise, fall thru into the TK_COLUMN case = */ + /* Otherwise, fall thru into the TK_COLUMN_NAME = case */ FALLTHROUGH; } - case TK_COLUMN:{ + case TK_COLUMN_NAME:{ int iTab =3D pExpr->iTable; int col =3D pExpr->iColumn; if (iTab < 0) { @@ -4102,7 +4102,7 @@ sqlExprCodeTarget(Parse * pParse, Expr * pExpr, = int target) assert(nFarg =3D=3D 1); assert(pFarg->a[0].pExpr !=3D = 0); exprOp =3D = pFarg->a[0].pExpr->op; - if (exprOp =3D=3D TK_COLUMN + if (exprOp =3D=3D TK_COLUMN_NAME || exprOp =3D=3D = TK_AGG_COLUMN) { assert(SQL_FUNC_LENGTH = =3D=3D = OPFLAG_LENGTHARG); @@ -4319,7 +4319,7 @@ sqlExprCodeTarget(Parse * pParse, Expr * pExpr, = int target) endLabel =3D sqlVdbeMakeLabel(v); if ((pX =3D pExpr->pLeft) !=3D 0) { tempX =3D *pX; - testcase(pX->op =3D=3D TK_COLUMN); + testcase(pX->op =3D=3D TK_COLUMN_NAME); exprToRegister(&tempX, exprCodeVector(pParse, = &tempX, = ®Free1)); @@ -4344,11 +4344,11 @@ sqlExprCodeTarget(Parse * pParse, Expr * pExpr, = int target) pTest =3D aListelem[i].pExpr; } nextCase =3D sqlVdbeMakeLabel(v); - testcase(pTest->op =3D=3D TK_COLUMN); + testcase(pTest->op =3D=3D = TK_COLUMN_NAME); sqlExprIfFalse(pParse, pTest, nextCase, SQL_JUMPIFNULL); testcase(aListelem[i + 1].pExpr->op =3D=3D= - TK_COLUMN); + TK_COLUMN_NAME); sqlExprCode(pParse, aListelem[i + = 1].pExpr, target); sqlVdbeGoto(v, endLabel); @@ -5081,7 +5081,8 @@ sqlExprCompare(Expr * pA, Expr * pB, int iTab) } return 2; } - if (pA->op !=3D TK_COLUMN && pA->op !=3D TK_AGG_COLUMN && = pA->u.zToken) { + if (pA->op !=3D TK_COLUMN_NAME && pA->op !=3D TK_AGG_COLUMN && + pA->u.zToken) { if (pA->op =3D=3D TK_FUNCTION) { if (sqlStrICmp(pA->u.zToken, pB->u.zToken) !=3D = 0) return 2; @@ -5161,8 +5162,8 @@ sqlExprListCompare(ExprList * pA, ExprList * pB, = int iTab) * pE1: x IS NULL pE2: x IS NOT NULL Result: false * pE1: x IS ?2 pE2: x IS NOT NULL Reuslt: false * - * When comparing TK_COLUMN nodes between pE1 and pE2, if pE2 has - * Expr.iTable<0 then assume a table number given by iTab. + * When comparing TK_COLUMN_NAME nodes between pE1 and pE2, if + * pE2 has Expr.iTable<0 then assume a table number given by iTab. * * When in doubt, return false. Returning true might give a = performance * improvement. Returning false might cause a performance reduction, = but @@ -5209,11 +5210,11 @@ exprSrcCount(Walker * pWalker, Expr * pExpr) { /* The NEVER() on the second term is because = sqlFunctionUsesThisSrc() * is always called before sqlExprAnalyzeAggregates() and so the - * TK_COLUMNs have not yet been converted into TK_AGG_COLUMN. = If + * TK_COLUMN_NAMEs have not yet been converted into = TK_AGG_COLUMN. If * sqlFunctionUsesThisSrc() is used differently in the future, = the * NEVER() will need to be removed. */ - if (pExpr->op =3D=3D TK_COLUMN || NEVER(pExpr->op =3D=3D = TK_AGG_COLUMN)) { + if (pExpr->op =3D=3D TK_COLUMN_NAME || NEVER(pExpr->op =3D=3D = TK_AGG_COLUMN)) { int i; struct SrcCount *p =3D pWalker->u.pSrcCount; SrcList *pSrc =3D p->pSrc; @@ -5299,9 +5300,9 @@ analyzeAggregate(Walker * pWalker, Expr * pExpr) =20 switch (pExpr->op) { case TK_AGG_COLUMN: - case TK_COLUMN:{ + case TK_COLUMN_NAME:{ testcase(pExpr->op =3D=3D TK_AGG_COLUMN); - testcase(pExpr->op =3D=3D TK_COLUMN); + testcase(pExpr->op =3D=3D TK_COLUMN_NAME); /* Check to see if the column is in one of the = tables in the FROM * clause of the aggregate query */ @@ -5370,7 +5371,7 @@ analyzeAggregate(Walker * pWalker, Expr * pExpr) = if (pE-> = op = =3D=3D - = TK_COLUMN + = TK_COLUMN_NAME = && = pE-> = iTable diff --git a/src/box/sql/fk_constraint.c b/src/box/sql/fk_constraint.c index 482220a95..3f3625ad5 100644 --- a/src/box/sql/fk_constraint.c +++ b/src/box/sql/fk_constraint.c @@ -338,7 +338,7 @@ static struct Expr * sql_expr_new_column_by_cursor(struct sql *db, struct space_def *def, int cursor, int column) { - struct Expr *expr =3D sql_expr_new_anon(db, TK_COLUMN); + struct Expr *expr =3D sql_expr_new_anon(db, TK_COLUMN_NAME); if (expr =3D=3D NULL) return NULL; expr->space_def =3D def; diff --git a/src/box/sql/resolve.c b/src/box/sql/resolve.c index 6f625dc18..5fe8ee3f6 100644 --- a/src/box/sql/resolve.c +++ b/src/box/sql/resolve.c @@ -189,7 +189,7 @@ sqlMatchSpanName(const char *zSpan, * pExpr->space_def Points to the space_def structure of X.Y * (even if X and/or Y are implied.) * pExpr->iColumn Set to the column number within the table. - * pExpr->op Set to TK_COLUMN. + * pExpr->op Set to TK_COLUMN_NAME. * pExpr->pLeft Any expression this points to is deleted * pExpr->pRight Any expression this points to is deleted. * @@ -461,7 +461,7 @@ lookupName(Parse * pParse, /* The parsing context = */ pExpr->pLeft =3D 0; sql_expr_delete(db, pExpr->pRight, false); pExpr->pRight =3D 0; - pExpr->op =3D (isTrigger ? TK_TRIGGER : TK_COLUMN); + pExpr->op =3D (isTrigger ? TK_TRIGGER : TK_COLUMN_NAME); lookupname_end: if (cnt =3D=3D 1) { assert(pNC !=3D 0); @@ -485,7 +485,7 @@ struct Expr * sql_expr_new_column(struct sql *db, struct SrcList *src_list, int = src_idx, int column) { - struct Expr *expr =3D sql_expr_new_anon(db, TK_COLUMN); + struct Expr *expr =3D sql_expr_new_anon(db, TK_COLUMN_NAME); if (expr =3D=3D NULL) return NULL; struct SrcList_item *item =3D &src_list->a[src_idx]; @@ -518,7 +518,7 @@ exprProbability(Expr * p) /* * This routine is callback for sqlWalkExpr(). * - * Resolve symbolic names into TK_COLUMN operators for the current + * Resolve symbolic names into TK_COLUMN_NAME operators for the current * node in the expression tree. Return 0 to continue the search down * the tree or 2 to abort the tree walk. * @@ -1451,7 +1451,7 @@ resolveSelectStep(Walker * pWalker, Select * p) * * The node at the root of the subtree is modified as follows: * - * Expr.op Changed to TK_COLUMN + * Expr.op Changed to TK_COLUMN_NAME * Expr.pTab Points to the Table object for X.Y * Expr.iColumn The column index in X.Y. -1 for the rowid. * Expr.iTable The VDBE cursor number for X.Y diff --git a/src/box/sql/select.c b/src/box/sql/select.c index b0554a172..80fbf69e0 100644 --- a/src/box/sql/select.c +++ b/src/box/sql/select.c @@ -1817,7 +1817,7 @@ generate_column_metadata(struct Parse *pParse, = struct SrcList *pTabList, vdbe_metadata_set_col_nullability(v, i, -1); const char *colname =3D pEList->a[i].zName; const char *span =3D pEList->a[i].zSpan; - if (p->op =3D=3D TK_COLUMN || p->op =3D=3D = TK_AGG_COLUMN) { + if (p->op =3D=3D TK_COLUMN_NAME || p->op =3D=3D = TK_AGG_COLUMN) { char *zCol; int iCol =3D p->iColumn; for (j =3D 0; ALWAYS(j < pTabList->nSrc); j++) { @@ -1939,7 +1939,7 @@ sqlColumnsFromExprList(Parse * parse, ExprList * = expr_list, pColExpr =3D pColExpr->pRight; assert(pColExpr !=3D 0); } - if (pColExpr->op =3D=3D TK_COLUMN + if (pColExpr->op =3D=3D TK_COLUMN_NAME && ALWAYS(pColExpr->space_def !=3D NULL)) { /* For columns use the column name name = */ int iCol =3D pColExpr->iColumn; @@ -3653,7 +3653,7 @@ substExpr(Parse * pParse, /* Report errors here */ sql *db =3D pParse->db; if (pExpr =3D=3D 0) return 0; - if (pExpr->op =3D=3D TK_COLUMN && pExpr->iTable =3D=3D iTable) { + if (pExpr->op =3D=3D TK_COLUMN_NAME && pExpr->iTable =3D=3D = iTable) { if (pExpr->iColumn < 0) { pExpr->op =3D TK_NULL; } else { @@ -6044,7 +6044,7 @@ sqlSelect(Parse * pParse, /* The parser = context */ /* Create a label to jump to when we want to abort the = query */ addrEnd =3D sqlVdbeMakeLabel(v); =20 - /* Convert TK_COLUMN nodes into TK_AGG_COLUMN and make = entries in + /* Convert TK_COLUMN_NAME nodes into TK_AGG_COLUMN and = make entries in * sAggInfo for all TK_AGG_FUNCTION nodes in expressions = of the * SELECT statement. */ @@ -6416,7 +6416,7 @@ sqlSelect(Parse * pParse, /* The parser = context */ flag !=3D WHERE_ORDERBY_MIN ? = 1 : 0; pMinMax->a[0].pExpr->op = =3D - TK_COLUMN; + TK_COLUMN_NAME; } } =20 diff --git a/src/box/sql/sqlInt.h b/src/box/sql/sqlInt.h index adf90d824..beb83ce95 100644 --- a/src/box/sql/sqlInt.h +++ b/src/box/sql/sqlInt.h @@ -1517,7 +1517,7 @@ typedef int ynVar; * valid. * * An expression of the form ID or ID.ID refers to a column in a table. - * For such expressions, Expr.op is set to TK_COLUMN and Expr.iTable is + * For such expressions, Expr.op is set to TK_COLUMN_NAME and = Expr.iTable is * the integer cursor number of a VDBE cursor pointing to that table = and * Expr.iColumn is the column number for the specific column. If the * expression is used as a result in an aggregate SELECT, then the @@ -1587,20 +1587,20 @@ struct Expr { #if SQL_MAX_EXPR_DEPTH>0 int nHeight; /* Height of the tree headed by this = node */ #endif - int iTable; /* TK_COLUMN: cursor number of table = holding column + int iTable; /* TK_COLUMN_NAME: cursor number of = table holding column * TK_REGISTER: register number * TK_TRIGGER: 1 -> new, 0 -> old * EP_Unlikely: 134217728 times = likelihood * TK_SELECT: 1st register of result = vector */ - ynVar iColumn; /* TK_COLUMN: column index. + ynVar iColumn; /* TK_COLUMN_NAME: column index. * TK_VARIABLE: variable number (always = >=3D 1). * TK_SELECT_COLUMN: column of the = result vector */ i16 iAgg; /* Which entry in pAggInfo->aCol[] or = ->aFunc[] */ i16 iRightJoinTable; /* If EP_FromJoin, the right table of = the join */ u8 op2; /* TK_REGISTER: original value of = Expr.op - * TK_COLUMN: the value of p5 for = OP_Column + * TK_COLUMN_NAME: the value of p5 for = OP_Column * TK_AGG_FUNCTION: nesting depth */ AggInfo *pAggInfo; /* Used by TK_AGG_COLUMN and = TK_AGG_FUNCTION */ diff --git a/src/box/sql/treeview.c b/src/box/sql/treeview.c index a04597979..ea26fcf6d 100644 --- a/src/box/sql/treeview.c +++ b/src/box/sql/treeview.c @@ -327,7 +327,7 @@ sqlTreeViewExpr(TreeView * pView, const Expr * = pExpr, u8 moreToFollow) zFlgs); break; } - case TK_COLUMN:{ + case TK_COLUMN_NAME:{ if (pExpr->iTable < 0) { /* This only happens when coding check = constraints */ sqlTreeViewLine(pView, "COLUMN(%d)%s", diff --git a/src/box/sql/where.c b/src/box/sql/where.c index e9e936856..77f863b0e 100644 --- a/src/box/sql/where.c +++ b/src/box/sql/where.c @@ -276,7 +276,7 @@ whereScanNext(WhereScan * pScan) = sqlExprSkipCollate(pTerm-> = pExpr-> = pRight))-> - op =3D=3D TK_COLUMN) { + op =3D=3D TK_COLUMN_NAME) { int j; for (j =3D 0; j < = pScan->nEquiv; j++) { if = (pScan->aiCur[j] =3D=3D pX->iTable @@ -319,7 +319,7 @@ whereScanNext(WhereScan * pScan) } } if ((pTerm->eOperator & = WO_EQ) !=3D 0 - && (pX =3D = pTerm->pExpr->pRight)->op =3D=3D TK_COLUMN + && (pX =3D = pTerm->pExpr->pRight)->op =3D=3D TK_COLUMN_NAME && pX->iTable =3D=3D = pScan->aiCur[0] && pX->iColumn =3D=3D = pScan->aiColumn[0]) { continue; @@ -555,7 +555,7 @@ findIndexCol(Parse * pParse, /* Parse context = */ struct key_part *part_to_match =3D = &idx_def->key_def->parts[iCol]; for (int i =3D 0; i < pList->nExpr; i++) { Expr *p =3D sqlExprSkipCollate(pList->a[i].pExpr); - if (p->op =3D=3D TK_COLUMN && p->iTable =3D=3D iBase && + if (p->op =3D=3D TK_COLUMN_NAME && p->iTable =3D=3D = iBase && p->iColumn =3D=3D (int) part_to_match->fieldno) { bool is_found; uint32_t id; @@ -601,7 +601,8 @@ isDistinctRedundant(Parse * pParse, /* = Parsing context */ */ for (int i =3D 0; i < pDistinct->nExpr; i++) { Expr *p =3D sqlExprSkipCollate(pDistinct->a[i].pExpr); - if (p->op =3D=3D TK_COLUMN && p->iTable =3D=3D iBase && = p->iColumn < 0) + if (p->op =3D=3D TK_COLUMN_NAME && p->iTable =3D=3D = iBase && + p->iColumn < 0) return 1; } if (space =3D=3D NULL) @@ -2245,7 +2246,7 @@ whereRangeVectorLen(Parse * pParse, /* = Parsing context */ * leftmost index column. */ struct key_part *parts =3D idx_def->key_def->parts; - if (pLhs->op !=3D TK_COLUMN || pLhs->iTable !=3D iCur || + if (pLhs->op !=3D TK_COLUMN_NAME || pLhs->iTable !=3D = iCur || pLhs->iColumn !=3D (int)parts[i + nEq].fieldno || parts[i + nEq].sort_order !=3D = parts[nEq].sort_order) break; @@ -2677,7 +2678,7 @@ indexMightHelpWithOrderBy(WhereLoopBuilder * = pBuilder, return 0; for (ii =3D 0; ii < pOB->nExpr; ii++) { Expr *pExpr =3D sqlExprSkipCollate(pOB->a[ii].pExpr); - if (pExpr->op =3D=3D TK_COLUMN && pExpr->iTable =3D=3D = iCursor) { + if (pExpr->op =3D=3D TK_COLUMN_NAME && pExpr->iTable =3D=3D= iCursor) { if (pExpr->iColumn < 0) return 1; for (jj =3D 0; jj < part_count; jj++) { @@ -3213,7 +3214,7 @@ wherePathSatisfiesOrderBy(WhereInfo * pWInfo, = /* The WHERE clause */ if (MASKBIT(i) & obSat) continue; pOBExpr =3D = sqlExprSkipCollate(pOrderBy->a[i].pExpr); - if (pOBExpr->op !=3D TK_COLUMN) + if (pOBExpr->op !=3D TK_COLUMN_NAME) continue; if (pOBExpr->iTable !=3D iCur) continue; @@ -3361,7 +3362,8 @@ wherePathSatisfiesOrderBy(WhereInfo * pWInfo, = /* The WHERE clause */ if ((wctrlFlags & (WHERE_GROUPBY = | WHERE_DISTINCTBY)) =3D=3D 0) bOnce =3D 0; if (iColumn >=3D (-1)) { - if (pOBExpr->op !=3D = TK_COLUMN) + if (pOBExpr->op !=3D + TK_COLUMN_NAME) continue; if (pOBExpr->iTable !=3D = iCur) continue; diff --git a/src/box/sql/whereexpr.c b/src/box/sql/whereexpr.c index d9b5c78f5..c2ce4339f 100644 --- a/src/box/sql/whereexpr.c +++ b/src/box/sql/whereexpr.c @@ -279,7 +279,7 @@ like_optimization_is_valid(Parse *pParse, Expr = *pExpr, Expr **ppPrefix, pList =3D pExpr->x.pList; pLeft =3D pList->a[1].pExpr; /* Value might be numeric */ - if (pLeft->op !=3D TK_COLUMN || + if (pLeft->op !=3D TK_COLUMN_NAME || sql_expr_type(pLeft) !=3D FIELD_TYPE_STRING) { /* IMP: R-02065-49465 The left-hand side of the * LIKE operator must be the name of an indexed @@ -928,7 +928,7 @@ exprSelectUsage(WhereMaskSet * pMaskSet, Select * = pS) * number of the table that is indexed and *piColumn to the column = number * of the column that is indexed. * - * If pExpr is a TK_COLUMN column reference, then this routine always = returns + * If pExpr is a TK_COLUMN_NAME column reference, then this routine = always returns * true even if that particular column is not indexed, because the = column * might be added to an automatic index later. */ @@ -950,7 +950,7 @@ exprMightBeIndexed(int op, /* The specific = comparison operator */ pExpr =3D pExpr->x.pList->a[0].pExpr; } =20 - if (pExpr->op =3D=3D TK_COLUMN) { + if (pExpr->op =3D=3D TK_COLUMN_NAME) { *piCur =3D pExpr->iTable; *piColumn =3D pExpr->iColumn; return 1; @@ -1272,7 +1272,7 @@ exprAnalyze(SrcList * pSrc, /* the FROM = clause */ * Note that the virtual term must be tagged with TERM_VNULL. */ if (pExpr->op =3D=3D TK_NOTNULL - && pExpr->pLeft->op =3D=3D TK_COLUMN + && pExpr->pLeft->op =3D=3D TK_COLUMN_NAME && pExpr->pLeft->iColumn >=3D 0) { Expr *pNewExpr; Expr *pLeft =3D pExpr->pLeft; @@ -1397,7 +1397,7 @@ sqlWhereExprUsage(WhereMaskSet * pMaskSet, Expr * = p) Bitmask mask; if (p =3D=3D 0) return 0; - if (p->op =3D=3D TK_COLUMN) { + if (p->op =3D=3D TK_COLUMN_NAME) { mask =3D sqlWhereGetMask(pMaskSet, p->iTable); return mask; } @@ -1475,7 +1475,7 @@ sqlWhereTabFuncArgs(Parse * pParse, /* = Parsing context */ * unused. */ assert(k < (int)space_def->field_count); - pColRef =3D sql_expr_new_anon(pParse->db, TK_COLUMN); + pColRef =3D sql_expr_new_anon(pParse->db, = TK_COLUMN_NAME); if (pColRef =3D=3D NULL) { pParse->is_aborted =3D true; return;