Home | History | Annotate | Download | only in dist

Lines Matching defs:pExpr

12350 **     then the value of the node is the value in Mem[pExpr.iTable].  Any
12624 Expr *pExpr; /* Used when p4type is P4_EXPR */
14969 ** AggInfo.pGroupBy and AggInfo.aFunc.pExpr point to fields within the
14989 Expr *pExpr; /* The original expression */
14996 Expr *pExpr; /* Expression encoding the function */
15215 Expr *pExpr; /* The parse tree for this expression */
15238 Expr *pExpr; /* The expression parse tree */
16718 SQLITE_PRIVATE char sqlite3CompareAffinity(Expr *pExpr, char aff2);
16719 SQLITE_PRIVATE int sqlite3IndexAffinityOk(Expr *pExpr, char idx_affinity);
16721 SQLITE_PRIVATE char sqlite3ExprAffinity(Expr *pExpr);
16739 SQLITE_PRIVATE CollSeq *sqlite3ExprCollSeq(Parse *pParse, Expr *pExpr);
17122 SQLITE_PRIVATE int sqlite3ExprVectorSize(Expr *pExpr);
17123 SQLITE_PRIVATE int sqlite3ExprIsVector(Expr *pExpr);
26381 SQLITE_PRIVATE void sqlite3TreeViewExpr(TreeView *pView, const Expr *pExpr, u8 moreToFollow){
26386 if( pExpr==0 ){
26391 if( pExpr->flags ){
26392 sqlite3_snprintf(sizeof(zFlgs),zFlgs," flags=0x%x",pExpr->flags);
26396 switch( pExpr->op ){
26399 pExpr->iTable, pExpr->iColumn, zFlgs);
26403 if( pExpr->iTable<0 ){
26405 sqlite3TreeViewLine(pView, "COLUMN(%d)%s", pExpr->iColumn, zFlgs);
26408 pExpr->iTable, pExpr->iColumn, zFlgs);
26413 if( pExpr->flags & EP_IntValue ){
26414 sqlite3TreeViewLine(pView, "%d", pExpr->u.iValue);
26416 sqlite3TreeViewLine(pView, "%s", pExpr->u.zToken);
26422 sqlite3TreeViewLine(pView,"%s", pExpr->u.zToken);
26427 sqlite3TreeViewLine(pView,"%Q", pExpr->u.zToken);
26436 sqlite3TreeViewLine(pView,"%s", pExpr->u.zToken);
26442 pExpr->u.zToken, pExpr->iColumn);
26446 sqlite3TreeViewLine(pView,"REGISTER(%d)", pExpr->iTable);
26450 sqlite3TreeViewLine(pView,"ID \"%w\"", pExpr->u.zToken);
26456 sqlite3TreeViewLine(pView,"CAST %Q", pExpr->u.zToken);
26457 sqlite3TreeViewExpr(pView, pExpr->pLeft, 0);
26491 sqlite3TreeViewLine(pView, "SPAN %Q", pExpr->u.zToken);
26492 sqlite3TreeViewExpr(pView, pExpr->pLeft, 0);
26497 sqlite3TreeViewLine(pView, "COLLATE %Q", pExpr->u.zToken);
26498 sqlite3TreeViewExpr(pView, pExpr->pLeft, 0);
26505 if( ExprHasProperty(pExpr, EP_TokenOnly) ){
26508 pFarg = pExpr->x.pList;
26510 if( pExpr->op==TK_AGG_FUNCTION ){
26512 pExpr->op2, pExpr->u.zToken);
26514 sqlite3TreeViewLine(pView, "FUNCTION %Q", pExpr->u.zToken);
26524 sqlite3TreeViewSelect(pView, pExpr->x.pSelect, 0);
26529 sqlite3TreeViewSelect(pView, pExpr->x.pSelect, 0);
26534 sqlite3TreeViewExpr(pView, pExpr->pLeft, 1);
26535 if( ExprHasProperty(pExpr, EP_xIsSelect) ){
26536 sqlite3TreeViewSelect(pView, pExpr->x.pSelect, 0);
26538 sqlite3TreeViewExprList(pView, pExpr->x.pList, 0, 0);
26551 ** X is stored in pExpr->pLeft.
26552 ** Y is stored in pExpr->pList->a[0].pExpr.
26553 ** Z is stored in pExpr->pList->a[1].pExpr.
26556 Expr *pX = pExpr->pLeft;
26557 Expr *pY = pExpr->x.pList->a[0].pExpr;
26558 Expr *pZ = pExpr->x.pList->a[1].pExpr;
26574 pExpr->iTable ? "NEW" : "OLD", pExpr->iColumn);
26579 sqlite3TreeViewExpr(pView, pExpr->pLeft, 1);
26580 sqlite3TreeViewExprList(pView, pExpr->x.pList, 0, 0);
26586 switch( pExpr->affinity ){
26592 sqlite3TreeViewLine(pView, "RAISE %s(%Q)", zType, pExpr->u.zToken);
26598 pExpr->iTable, pExpr->iColumn, zFlgs);
26599 sqlite3TreeViewExpr(pView, pExpr->pRight, 0);
26603 sqlite3TreeViewBareExprList(pView, pExpr->x.pList, "VECTOR");
26607 sqlite3TreeViewLine(pView, "SELECT-COLUMN %d", pExpr->iColumn);
26608 sqlite3TreeViewSelect(pView, pExpr->pLeft->x.pSelect, 0);
26612 sqlite3TreeViewLine(pView, "op=%d", pExpr->op);
26618 sqlite3TreeViewExpr(pView, pExpr->pLeft, 1);
26619 sqlite3TreeViewExpr(pView, pExpr->pRight, 0);
26622 sqlite3TreeViewExpr(pView, pExpr->pLeft, 0);
26648 sqlite3TreeViewExpr(pView, pList->a[i].pExpr, i<pList->nExpr-1);
70815 rc = sqlite3ValueFromExpr(db, pList->a[i].pExpr, enc, aff, &apVal[i]);
70875 Expr *pExpr, /* The expression to evaluate */
70888 assert( pExpr!=0 );
70889 while( (op = pExpr->op)==TK_UPLUS || op==TK_SPAN ) pExpr = pExpr->pLeft;
70890 if( NEVER(op==TK_REGISTER) ) op = pExpr->op2;
70896 assert( (pExpr->flags & EP_TokenOnly)==0 || pCtx==0 );
70899 u8 aff = sqlite3AffinityType(pExpr->u.zToken,0);
70900 rc = valueFromExpr(db, pExpr->pLeft, enc, aff, ppVal, pCtx);
70913 && (pExpr->pLeft->op==TK_INTEGER || pExpr->pLeft->op==TK_FLOAT) ){
70914 pExpr = pExpr->pLeft;
70915 op = pExpr->op;
70923 if( ExprHasProperty(pExpr, EP_IntValue) ){
70924 sqlite3VdbeMemSetInt64(pVal, (i64)pExpr->u.iValue*negInt);
70926 zVal = sqlite3MPrintf(db, "%s%s", zNeg, pExpr->u.zToken);
70941 if( SQLITE_OK==sqlite3ValueFromExpr(db,pExpr->pLeft,enc,affinity,&pVal)
70963 assert( pExpr->u.zToken[0]=='x' || pExpr->u.zToken[0]=='X' );
70964 assert( pExpr->u.zToken[1]=='\'' );
70967 zVal = &pExpr->u.zToken[2];
70977 rc = valueFromFunction(db, pExpr, enc, affinity, &pVal, pCtx);
70997 ** Create a new sqlite3_value object, containing the value of pExpr.
71008 Expr *pExpr, /* The expression to evaluate */
71013 return pExpr ? valueFromExpr(db, pExpr, enc, affinity, ppVal, 0) : 0;
71067 ** Attempt to extract a value from pExpr and use it to construct *ppVal.
71075 ** * (pExpr==0). In this case the value is assumed to be an SQL NULL,
71086 Expr *pExpr, /* The expression to extract a value from */
71096 pExpr = sqlite3ExprSkipCollate(pExpr);
71098 if( !pExpr ){
71103 }else if( pExpr->op==TK_VARIABLE
71104 || NEVER(pExpr->op==TK_REGISTER && pExpr->op2==TK_VARIABLE)
71107 int iBindVar = pExpr->iColumn;
71120 rc = valueFromExpr(db, pExpr, ENC(db), affinity, &pVal, pAlloc);
71137 ** * (pExpr==0). In this case the value is assumed to be an SQL NULL,
71144 ** Or, if pExpr is a TK_VECTOR, one field is populated for each of the
71159 ** error if a value cannot be extracted from pExpr. If an error does
71166 Expr *pExpr, /* The expression to extract a value from */
71174 if( pExpr==0 || pExpr->op!=TK_SELECT ){
71184 Expr *pElem = (pExpr ? sqlite3VectorFieldSubexpr(pExpr, i) : 0);
71198 ** Attempt to extract a value from expression pExpr using the methods
71209 Expr *pExpr, /* The expression to extract a value from */
71213 return stat4ValueFromExpr(pParse, pExpr, affinity, 0, ppVal);
72543 ** Translate the P4.pExpr value for an OP_CursorHint opcode into text
72546 static void displayP4Expr(StrAccum *p, Expr *pExpr){
72548 switch( pExpr->op ){
72550 sqlite3XPrintf(p, "%Q", pExpr->u.zToken);
72553 sqlite3XPrintf(p, "%d", pExpr->u.iValue);
72559 sqlite3XPrintf(p, "r[%d]", pExpr->iTable);
72563 if( pExpr->iColumn<0 ){
72566 sqlite3XPrintf(p, "c%d", (int)pExpr->iColumn);
72604 displayP4Expr(p, pExpr->pLeft);
72605 if( pExpr->pRight ){
72607 displayP4Expr(p, pExpr->pRight);
72642 displayP4Expr(&x, pOp->p4.pExpr);
85217 pOp->p4.pExpr, aMem);
89064 static SQLITE_NOINLINE int walkExpr(Walker *pWalker, Expr *pExpr){
89066 testcase( ExprHasProperty(pExpr, EP_TokenOnly) );
89067 testcase( ExprHasProperty(pExpr, EP_Reduced) );
89068 rc = pWalker->xExprCallback(pWalker, pExpr);
89069 if( rc || ExprHasProperty(pExpr,(EP_TokenOnly|EP_Leaf)) ){
89072 if( pExpr->pLeft && walkExpr(pWalker, pExpr->pLeft) ) return WRC_Abort;
89073 if( pExpr->pRight && walkExpr(pWalker, pExpr->pRight) ) return WRC_Abort;
89074 if( ExprHasProperty(pExpr, EP_xIsSelect) ){
89075 if( sqlite3WalkSelect(pWalker, pExpr->x.pSelect) ) return WRC_Abort;
89076 }else if( pExpr->x.pList ){
89077 if( sqlite3WalkExprList(pWalker, pExpr->x.pList) ) return WRC_Abort;
89081 SQLITE_PRIVATE int sqlite3WalkExpr(Walker *pWalker, Expr *pExpr){
89082 return pExpr ? walkExpr(pWalker,pExpr) : WRC_Continue;
89094 if( sqlite3WalkExpr(pWalker, pItem->pExpr) ) return WRC_Abort;
89209 ** Walk the expression tree pExpr and increase the aggregate function
89214 ** incrAggFunctionDepth(pExpr,n) is the main routine. incrAggDepth(..)
89217 static int incrAggDepth(Walker *pWalker, Expr *pExpr){
89218 if( pExpr->op==TK_AGG_FUNCTION ) pExpr->op2 += pWalker->u.n;
89221 static void incrAggFunctionDepth(Expr *pExpr, int N){
89227 sqlite3WalkExpr(&w, pExpr);
89232 ** Turn the pExpr expression into an alias for the iCol-th column of the
89254 Expr *pExpr, /* Transform this into an alias to the result set */
89263 pOrig = pEList->a[iCol].pExpr;
89269 if( pExpr->op==TK_COLLATE ){
89270 pDup = sqlite3ExprAddCollateString(pParse, pDup, pExpr->u.zToken);
89277 ** The pExpr->u.zToken might point into memory that will be freed by the
89281 ExprSetProperty(pExpr, EP_Static);
89282 sqlite3ExprDelete(db, pExpr);
89283 memcpy(pExpr, pDup, sizeof(*pExpr));
89284 if( !ExprHasProperty(pExpr, EP_IntValue) && pExpr->u.zToken!=0 ){
89285 assert( (pExpr->flags & (EP_Reduced|EP_TokenOnly))==0 );
89286 pExpr->u.zToken = sqlite3DbStrDup(db, pExpr->u.zToken);
89287 pExpr->flags |= EP_MemToken;
89341 ** that name in the set of source tables in pSrcList and make the pExpr
89343 ** are made to pExpr:
89345 ** pExpr->iDb Set the index in db->aDb[] of the database X
89347 ** pExpr->iTable Set to the cursor number for the table obtained
89349 ** pExpr->pTab Points to the Table structure of X.Y (even if
89351 ** pExpr->iColumn Set to the column number within the table.
89352 ** pExpr->op Set to TK_COLUMN.
89353 ** pExpr->pLeft Any expression this points to is deleted
89354 ** pExpr->pRight Any expression this points to is deleted.
89372 Expr *pExpr /* Make this EXPR node point to the selected column */
89389 assert( !ExprHasProperty(pExpr, EP_TokenOnly|EP_Reduced) );
89392 pExpr->iTable = -1;
89393 pExpr->pTab = 0;
89394 ExprSetVVAProperty(pExpr, EP_NoReduce);
89439 pExpr->iColumn = j;
89471 pExpr->iColumn = j==pTab->iPKey ? -1 : (i16)j;
89477 pExpr->iTable = pMatch->iCursor;
89478 pExpr->pTab = pMatch->pTab;
89482 ExprSetProperty(pExpr, EP_CanBeNull);
89484 pSchema = pExpr->pTab->pSchema;
89496 pExpr->iTable = 1;
89499 pExpr->iTable = 0;
89524 pExpr->affinity = SQLITE_AFF_INTEGER;
89525 }else if( pExpr->iTable==0 ){
89534 pExpr->iColumn = (i16)iCol;
89535 pExpr->pTab = pTab;
89553 pExpr->iColumn = -1;
89554 pExpr->affinity = SQLITE_AFF_INTEGER;
89564 ** In cases like this, replace pExpr with a copy of the expression that
89583 assert( pExpr->pLeft==0 && pExpr->pRight==0 );
89584 assert( pExpr->x.pList==0 );
89585 assert( pExpr->x.pSelect==0 );
89586 pOrig = pEList->a[j].pExpr;
89595 resolveAlias(pParse, pEList, j, pExpr, "", nSubquery);
89618 ** pExpr.
89623 if( cnt==0 && zTab==0 && ExprHasProperty(pExpr,EP_DblQuoted) ){
89624 pExpr->op = TK_STRING;
89625 pExpr->pTab = 0;
89653 if( pExpr->iColumn>=0 && pMatch!=0 ){
89654 int n = pExpr->iColumn;
89659 assert( pMatch->iCursor==pExpr->iTable );
89665 sqlite3ExprDelete(db, pExpr->pLeft);
89666 pExpr->pLeft = 0;
89667 sqlite3ExprDelete(db, pExpr->pRight);
89668 pExpr->pRight = 0;
89669 pExpr->op = (isTrigger ? TK_TRIGGER : TK_COLUMN);
89673 if( !ExprHasProperty(pExpr, EP_Alias) ){
89674 sqlite3AuthRead(pParse, pExpr, pSchema, pNC->pSrcList);
89759 static int resolveExprStep(Walker *pWalker, Expr *pExpr){
89768 if( ExprHasProperty(pExpr, EP_Resolved) ) return WRC_Prune;
89769 ExprSetProperty(pExpr, EP_Resolved);
89779 switch( pExpr->op ){
89791 pExpr->op = TK_COLUMN;
89792 pExpr->pTab = pItem->pTab;
89793 pExpr->iTable = pItem->iCursor;
89794 pExpr->iColumn = -1;
89795 pExpr->affinity = SQLITE_AFF_INTEGER;
89816 if( pExpr->op==TK_ID ){
89819 zColumn = pExpr->u.zToken;
89822 pRight = pExpr->pRight;
89825 zTable = pExpr->pLeft->u.zToken;
89829 zDb = pExpr->pLeft->u.zToken;
89834 return lookupName(pParse, zDb, zTable, zColumn, pNC, pExpr);
89840 ExprList *pList = pExpr->x.pList; /* The argument list */
89850 assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
89851 zId = pExpr->u.zToken;
89864 ExprSetProperty(pExpr, EP_Unlikely|EP_Skip);
89866 pExpr->iTable = exprProbability(pList->a[1].pExpr);
89867 if( pExpr->iTable<0 ){
89883 pExpr->iTable = pDef->zName[0]=='u' ? 8388608 : 125829120;
89895 pExpr->op = TK_NULL;
89904 ExprSetProperty(pExpr,EP_ConstFunc);
89934 pExpr->op = TK_AGG_FUNCTION;
89935 pExpr->op2 = 0;
89936 while( pNC2 && !sqlite3FunctionUsesThisSrc(pExpr, pNC2->pSrcList) ){
89937 pExpr->op2++;
89949 /* FIX ME: Compute pExpr->affinity based on the expected return
89956 case TK_EXISTS: testcase( pExpr->op==TK_EXISTS );
89959 testcase( pExpr->op==TK_IN );
89960 if( ExprHasProperty(pExpr, EP_xIsSelect) ){
89963 sqlite3WalkSelect(pWalker, pExpr->x.pSelect);
89966 ExprSetProperty(pExpr, EP_VarSelect);
89987 assert( pExpr->pLeft!=0 );
89988 nLeft = sqlite3ExprVectorSize(pExpr->pLeft);
89989 if( pExpr->op==TK_BETWEEN ){
89990 nRight = sqlite3ExprVectorSize(pExpr->x.pList->a[0].pExpr);
89992 nRight = sqlite3ExprVectorSize(pExpr->x.pList->a[1].pExpr);
89995 assert( pExpr->pRight!=0 );
89996 nRight = sqlite3ExprVectorSize(pExpr->pRight);
89999 testcase( pExpr->op==TK_EQ );
90000 testcase( pExpr->op==TK_NE );
90001 testcase( pExpr->op==TK_LT );
90002 testcase( pExpr->op==TK_LE );
90003 testcase( pExpr->op==TK_GT );
90004 testcase( pExpr->op==TK_GE );
90005 testcase( pExpr->op==TK_IS );
90006 testcase( pExpr->op==TK_ISNOT );
90007 testcase( pExpr->op==TK_BETWEEN );
90102 if( sqlite3ExprCompare(pEList->a[i].pExpr, pE, -1)<2 ){
90176 pE = sqlite3ExprSkipCollate(pItem->pExpr);
90200 if( pItem->pExpr==pE ){
90201 pItem->pExpr = pNew;
90203 Expr *pParent = pItem->pExpr;
90264 resolveAlias(pParse, pEList, pItem->u.x.iOrderByCol-1, pItem->pExpr,
90305 Expr *pE = pItem->pExpr;
90336 if( sqlite3ExprCompare(pE, pSelect->pEList->a[j].pExpr, -1)==0 ){
90536 if( ExprHasProperty(pItem->pExpr, EP_Agg) ){
90617 Expr *pExpr /* The expression to be analyzed. */
90622 if( pExpr==0 ) return 0;
90626 if( sqlite3ExprCheckHeight(pParse, pExpr->nHeight+pNC->pParse->nHeight) ){
90629 pParse->nHeight += pExpr->nHeight;
90641 sqlite3WalkExpr(&w, pExpr);
90643 pNC->pParse->nHeight -= pExpr->nHeight;
90646 ExprSetProperty(pExpr, EP_Error);
90649 ExprSetProperty(pExpr, EP_Agg);
90652 return ExprHasProperty(pExpr, EP_Error);
90667 if( sqlite3ResolveExprNames(pNC, pList->a[i].pExpr) ) return WRC_Abort;
90716 Expr *pExpr, /* Expression to resolve. May be NULL. */
90732 if( sqlite3ResolveExprNames(&sNC, pExpr) ) return;
90767 ** Return the 'affinity' of the expression pExpr if any.
90769 ** If pExpr is a column, a reference to a column via an 'AS' alias,
90782 SQLITE_PRIVATE char sqlite3ExprAffinity(Expr *pExpr){
90784 pExpr = sqlite3ExprSkipCollate(pExpr);
90785 if( pExpr->flags & EP_Generic ) return 0;
90786 op = pExpr->op;
90788 assert( pExpr->flags&EP_xIsSelect );
90789 return sqlite3ExprAffinity(pExpr->x.pSelect->pEList->a[0].pExpr);
90791 if( op==TK_REGISTER ) op = pExpr->op2;
90794 assert( !ExprHasProperty(pExpr, EP_IntValue) );
90795 return sqlite3AffinityType(pExpr->u.zToken, 0);
90799 return sqlite3TableColumnAffinity(pExpr->pTab, pExpr->iColumn);
90802 assert( pExpr->pLeft->flags&EP_xIsSelect );
90804 pExpr->pLeft->x.pSelect->pEList->a[pExpr->iColumn].pExpr
90807 return pExpr->affinity;
90811 ** Set the collating sequence for expression pExpr to be the collating
90816 ** and the pExpr parameter is returned unchanged.
90820 Expr *pExpr, /* Add the "COLLATE" clause to this expression */
90827 pNew->pLeft = pExpr;
90829 pExpr = pNew;
90832 return pExpr;
90834 SQLITE_PRIVATE Expr *sqlite3ExprAddCollateString(Parse *pParse, Expr *pExpr, const char *zC){
90838 return sqlite3ExprAddCollateToken(pParse, pExpr, &s, 0);
90845 SQLITE_PRIVATE Expr *sqlite3ExprSkipCollate(Expr *pExpr){
90846 while( pExpr && ExprHasProperty(pExpr, EP_Skip) ){
90847 if( ExprHasProperty(pExpr, EP_Unlikely) ){
90848 assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
90849 assert( pExpr->x.pList->nExpr>0 );
90850 assert( pExpr->op==TK_FUNCTION );
90851 pExpr = pExpr->x.pList->a[0].pExpr;
90853 assert( pExpr->op==TK_COLLATE );
90854 pExpr = pExpr->pLeft;
90857 return pExpr;
90861 ** Return the collation sequence for the expression pExpr. If
90869 SQLITE_PRIVATE CollSeq *sqlite3ExprCollSeq(Parse *pParse, Expr *pExpr){
90872 Expr *p = pExpr;
90888 /* op==TK_REGISTER && p->pTab!=0 happens when pExpr was originally
90910 if( ExprHasProperty(p->x.pList->a[i].pExpr, EP_Collate) ){
90911 pNext = p->x.pList->a[i].pExpr;
90929 ** pExpr is an operand of a comparison operator. aff2 is the
90933 SQLITE_PRIVATE char sqlite3CompareAffinity(Expr *pExpr, char aff2){
90934 char aff1 = sqlite3ExprAffinity(pExpr);
90957 ** pExpr is a comparison operator. Return the type affinity that should
90960 static char comparisonAffinity(Expr *pExpr){
90962 assert( pExpr->op==TK_EQ || pExpr->op==TK_IN || pExpr->op==TK_LT ||
90963 pExpr->op==TK_GT || pExpr->op==TK_GE || pExpr->op==TK_LE ||
90964 pExpr->op==TK_NE || pExpr->op==TK_IS || pExpr->op==TK_ISNOT );
90965 assert( pExpr->pLeft );
90966 aff = sqlite3ExprAffinity(pExpr->pLeft);
90967 if( pExpr->pRight ){
90968 aff = sqlite3CompareAffinity(pExpr->pRight, aff);
90969 }else if( ExprHasProperty(pExpr, EP_xIsSelect) ){
90970 aff = sqlite3CompareAffinity(pExpr->x.pSelect->pEList->a[0].pExpr, aff);
90978 ** pExpr is a comparison expression, eg. '=', '<', IN(...) etc.
90981 ** the comparison in pExpr.
90983 SQLITE_PRIVATE int sqlite3IndexAffinityOk(Expr *pExpr, char idx_affinity){
90984 char aff = comparisonAffinity(pExpr);
91062 ** Return true if expression pExpr is a vector, or false otherwise.
91070 SQLITE_PRIVATE int sqlite3ExprIsVector(Expr *pExpr){
91071 return sqlite3ExprVectorSize(pExpr)>1;
91080 SQLITE_PRIVATE int sqlite3ExprVectorSize(Expr *pExpr){
91081 u8 op = pExpr->op;
91082 if( op==TK_REGISTER ) op = pExpr->op2;
91084 return pExpr->x.pList->nExpr;
91086 return pExpr->x.pSelect->pEList->nExpr;
91113 return pVector->x.pSelect->pEList->a[i].pExpr;
91115 return pVector->x.pList->a[i].pExpr;
91175 if( pVector->op==TK_VECTOR ) pVector = pVector->x.pList->a[iField].pExpr;
91183 ** If expression pExpr is of type TK_SELECT, generate code to evaluate
91188 ** If pExpr is not a TK_SELECT expression, return 0.
91190 static int exprCodeSubselect(Parse *pParse, Expr *pExpr){
91193 if( pExpr->op==TK_SELECT ){
91194 reg = sqlite3CodeSubselect(pParse, pExpr, 0, 0);
91233 *ppExpr = pVector->x.pSelect->pEList->a[iField].pExpr;
91236 *ppExpr = pVector->x.pList->a[iField].pExpr;
91241 ** Expression pExpr is a comparison between two vector values. Compute
91247 ** if pExpr->op==TK_IS: op==TK_EQ and p5==SQLITE_NULLEQ
91248 ** if pExpr->op==TK_ISNOT: op==TK_NE and p5==SQLITE_NULLEQ
91249 ** otherwise: op==pExpr->op and p5==0
91253 Expr *pExpr, /* The comparison operation */
91259 Expr *pLeft = pExpr->pLeft;
91260 Expr *pRight = pExpr->pRight;
91272 assert( pExpr->op==TK_EQ || pExpr->op==TK_NE
91273 || pExpr->op==TK_IS || pExpr->op==TK_ISNOT
91274 || pExpr->op==TK_LT || pExpr->op==TK_GT
91275 || pExpr->op==TK_LE || pExpr->op==TK_GE
91277 assert( pExpr->op==op || (pExpr->op==TK_IS && op==TK_EQ)
91278 || (pExpr->op==TK_ISNOT && op==TK_NE) );
91279 assert( p5==0 || pExpr->op!=op );
91280 assert( p5==SQLITE_NULLEQ || pExpr->op==op );
91367 heightOfExpr(p->a[i].pExpr, pnHeight);
91585 ** Add pSelect to the Expr.x.pSelect field. Or, if pExpr is NULL (due
91588 SQLITE_PRIVATE void sqlite3PExprAddSelect(Parse *pParse, Expr *pExpr, Select *pSelect){
91589 if( pExpr ){
91590 pExpr->x.pSelect = pSelect;
91591 ExprSetProperty(pExpr, EP_xIsSelect|EP_Subquery);
91592 sqlite3ExprSetHeightAndFlags(pParse, pExpr);
91686 SQLITE_PRIVATE void sqlite3ExprAssignVarNumber(Parse *pParse, Expr *pExpr, u32 n){
91691 if( pExpr==0 ) return;
91692 assert( !ExprHasProperty(pExpr, EP_IntValue|EP_Reduced|EP_TokenOnly) );
91693 z = pExpr->u.zToken;
91745 pExpr->iColumn = x;
92056 Expr *pOldExpr = pOldItem->pExpr;
92058 pItem->pExpr = sqlite3ExprDup(db, pOldExpr, flags);
92061 && (pNewExpr = pItem->pExpr)!=0
92069 assert( pItem[-1].pExpr!=0 );
92070 assert( pNewExpr->iColumn==pItem[-1].pExpr->iColumn+1 );
92071 assert( pPriorSelectCol==pItem[-1].pExpr->pLeft );
92213 Expr *pExpr /* Expression to be appended. Might be NULL */
92238 pItem->pExpr = pExpr;
92244 sqlite3ExprDelete(db, pExpr);
92250 ** pColumns and pExpr form a vector assignment which is part of the SET
92264 Expr *pExpr /* Vector expression to be appended. Might be NULL */
92273 if( pExpr==0 ) goto vector_append_error;
92280 if( pExpr->op!=TK_SELECT && pColumns->nId!=(n=sqlite3ExprVectorSize(pExpr)) ){
92287 Expr *pSubExpr = sqlite3ExprForVectorField(pParse, pExpr, i);
92296 if( pExpr->op==TK_SELECT ){
92297 if( pList && pList->a[iFirst].pExpr ){
92298 Expr *pFirst = pList->a[iFirst].pExpr;
92303 pFirst->pRight = pExpr;
92304 pExpr = 0;
92313 sqlite3ExprDelete(db, pExpr);
92375 assert( db->mallocFailed || pItem->pExpr==pSpan->pExpr );
92407 sqlite3ExprDelete(db, pItem->pExpr);
92427 Expr *pExpr = pList->a[i].pExpr;
92428 assert( pExpr!=0 );
92429 m |= pExpr->flags;
92460 static int exprNodeIsConstant(Walker *pWalker, Expr *pExpr){
92465 if( pWalker->eCode==2 && ExprHasProperty(pExpr, EP_FromJoin) ){
92470 switch( pExpr->op ){
92475 if( pWalker->eCode>=4 || ExprHasProperty(pExpr,EP_ConstFunc) ){
92485 testcase( pExpr->op==TK_ID );
92486 testcase( pExpr->op==TK_COLUMN );
92487 testcase( pExpr->op==TK_AGG_FUNCTION );
92488 testcase( pExpr->op==TK_AGG_COLUMN );
92489 if( pWalker->eCode==3 && pExpr->iTable==pWalker->u.iCur ){
92500 pExpr->op = TK_NULL;
92509 testcase( pExpr->op==TK_SELECT ); /* selectNodeIsConstant will disallow */
92510 testcase( pExpr->op==TK_EXISTS ); /* selectNodeIsConstant will disallow */
92753 Expr *pRes = pEList->a[i].pExpr;
92904 if( sqlite3ExprCanBeNull(pEList->a[i].pExpr) ) break;
92922 assert( p->pEList->a[0].pExpr!=0 ); /* Because of isCandidateForInOpt(p) */
92932 if( nExpr==1 && pEList->a[0].pExpr->iColumn<0 ){
92952 int iCol = pEList->a[i].pExpr->iColumn;
92994 Expr *pRhs = pEList->a[i].pExpr;
93094 ** Argument pExpr is an (?, ?...) IN(...) expression. This
93101 static char *exprINAffinity(Parse *pParse, Expr *pExpr){
93102 Expr *pLeft = pExpr->pLeft;
93104 Select *pSelect = (pExpr->flags & EP_xIsSelect) ? pExpr->x.pSelect : 0;
93107 assert( pExpr->op==TK_IN );
93115 zRet[i] = sqlite3CompareAffinity(pSelect->pEList->a[i].pExpr, a);
93140 ** Expression pExpr is a vector that has been used in a context where
93141 ** it is not permitted. If pExpr is a sub-select vector, this routine
93150 SQLITE_PRIVATE void sqlite3VectorErrorMsg(Parse *pParse, Expr *pExpr){
93152 if( pExpr->flags & EP_xIsSelect ){
93153 sqlite3SubselectError(pParse, pExpr->x.pSelect->pEList->nExpr, 1);
93170 ** The pExpr parameter describes the expression that contains the IN
93173 ** If parameter isRowid is non-zero, then expression pExpr is guaranteed
93193 Expr *pExpr, /* The IN, SELECT, or EXISTS operator */
93213 if( !ExprHasProperty(pExpr, EP_VarSelect) ){
93221 pExpr->op==TK_IN?"LIST":"SCALAR",
93228 switch( pExpr->op ){
93231 Expr *pLeft = pExpr->pLeft; /* the LHS of the IN operator */
93251 pExpr->iTable = pParse->nTab++;
93253 pExpr->iTable, (isRowid?0:nVal));
93256 if( ExprHasProperty(pExpr, EP_xIsSelect) ){
93262 Select *pSelect = pExpr->x.pSelect;
93271 sqlite3SelectDestInit(&dest, SRT_Set, pExpr->iTable);
93272 dest.zAffSdst = exprINAffinity(pParse, pExpr);
93289 pParse, p, pEList->a[i].pExpr
93293 }else if( ALWAYS(pExpr->x.pList!=0) ){
93303 ExprList *pList = pExpr->x.pList;
93313 pKeyInfo->aColl[0] = sqlite3ExprCollSeq(pParse, pExpr->pLeft);
93321 Expr *pE2 = pItem->pExpr;
93336 sqlite3VdbeAddOp3(v, OP_InsertInt, pExpr->iTable, r2, iValToIns);
93343 sqlite3VdbeAddOp3(v, OP_Insert, pExpr->iTable, r2, r3);
93347 sqlite3VdbeAddOp4Int(v, OP_IdxInsert, pExpr->iTable, r2, r3, 1);
93380 testcase( pExpr->op==TK_EXISTS );
93381 testcase( pExpr->op==TK_SELECT );
93382 assert( pExpr->op==TK_EXISTS || pExpr->op==TK_SELECT );
93383 assert( ExprHasProperty(pExpr, EP_xIsSelect) );
93385 pSel = pExpr->x.pSelect;
93386 nReg = pExpr->op==TK_SELECT ? pSel->pEList->nExpr : 1;
93389 if( pExpr->op==TK_SELECT ){
93409 ExprSetVVAProperty(pExpr, EP_NoReduce);
93415 sqlite3SetHasNullFlag(v, pExpr->iTable, rHasNullFlag);
93477 Expr *pExpr, /* The IN expression */
93498 pLeft = pExpr->pLeft;
93499 if( sqlite3ExprCheckIN(pParse, pExpr) ) return;
93500 zAff = exprINAffinity(pParse, pExpr);
93501 nVector = sqlite3ExprVectorSize(pExpr->pLeft);
93508 ** IN_INDEX_NOOP is returned, the table opened ith cursor pExpr->iTable
93514 eType = sqlite3FindInIndex(pParse, pExpr,
93561 ExprList *pList = pExpr->x.pList;
93562 CollSeq *pColl = sqlite3ExprCollSeq(pParse, pExpr->pLeft);
93567 assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
93573 r2 = sqlite3ExprCodeTemp(pParse, pList->a[ii].pExpr, &regToFree);
93574 if( regCkNull && sqlite3ExprCanBeNull(pList->a[ii].pExpr) ){
93610 Expr *p = sqlite3VectorFieldSubexpr(pExpr->pLeft, i);
93625 sqlite3VdbeAddOp3(v, OP_SeekRowid, pExpr->iTable, destIfFalse, rLhs);
93632 sqlite3VdbeAddOp4Int(v, OP_NotFound, pExpr->iTable, destIfFalse,
93637 addrTruthOp = sqlite3VdbeAddOp4Int(v, OP_Found, pExpr->iTable, 0,
93662 addrTop = sqlite3VdbeAddOp2(v, OP_Rewind, pExpr->iTable, destIfFalse);
93677 sqlite3VdbeAddOp3(v, OP_Column, pExpr->iTable, i, r3);
93686 sqlite3VdbeAddOp2(v, OP_Next, pExpr->iTable, addrTop+1);
93734 static void codeInteger(Parse *pParse, Expr *pExpr, int negFlag, int iMem){
93736 if( pExpr->flags & EP_IntValue ){
93737 int i = pExpr->u.iValue;
93744 const char *z = pExpr->u.zToken;
93922 sqlite3ExprCodeCopy(pParse, pIdx->aColExpr->a[iIdxCol].pExpr, regOut);
94101 sqlite3ExprCodeFactorable(pParse, p->x.pList->a[i].pExpr, i+iResult);
94120 SQLITE_PRIVATE int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target){
94136 if( pExpr==0 ){
94139 op = pExpr->op;
94143 AggInfo *pAggInfo = pExpr->pAggInfo;
94144 struct AggInfo_col *pCol = &pAggInfo->aCol[pExpr->iAgg];
94156 int iTab = pExpr->iTable;
94160 return pExpr->iColumn + pParse->ckBase;
94167 return sqlite3ExprCodeGetColumn(pParse, pExpr->pTab,
94168 pExpr->iColumn, iTab, target,
94169 pExpr->op2);
94172 codeInteger(pParse, pExpr, 0, target);
94177 assert( !ExprHasProperty(pExpr, EP_IntValue) );
94178 codeReal(v, pExpr->u.zToken, 0, target);
94183 assert( !ExprHasProperty(pExpr, EP_IntValue) );
94184 sqlite3VdbeLoadString(v, target, pExpr->u.zToken);
94196 assert( !ExprHasProperty(pExpr, EP_IntValue) );
94197 assert( pExpr->u.zToken[0]=='x' || pExpr->u.zToken[0]=='X' );
94198 assert( pExpr->u.zToken[1]=='\'' );
94199 z = &pExpr->u.zToken[2];
94208 assert( !ExprHasProperty(pExpr, EP_IntValue) );
94209 assert( pExpr->u.zToken!=0 );
94210 assert( pExpr->u.zToken[0]!=0 );
94211 sqlite3VdbeAddOp2(v, OP_Variable, pExpr->iColumn, target);
94212 if( pExpr->u.zToken[1]!=0 ){
94213 const char *z = sqlite3VListNumToName(pParse->pVList, pExpr->iColumn);
94214 assert( pExpr->u.zToken[0]=='?' || strcmp(pExpr->u.zToken, z)==0 );
94221 return pExpr->iTable;
94226 inReg = sqlite3ExprCodeTarget(pParse, pExpr->pLeft, target);
94232 sqlite3AffinityType(pExpr->u.zToken, 0));
94249 Expr *pLeft = pExpr->pLeft;
94251 codeVectorCompare(pParse, pExpr, target, op, p5);
94254 r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, &regFree2);
94255 codeCompare(pParse, pLeft, pExpr->pRight, op,
94291 r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree1);
94292 r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, &regFree2);
94299 Expr *pLeft = pExpr->pLeft;
94306 assert( !ExprHasProperty(pExpr, EP_IntValue) );
94315 r2 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree2);
94325 r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree1);
94336 r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree1);
94346 AggInfo *pInfo = pExpr->pAggInfo;
94348 assert( !ExprHasProperty(pExpr, EP_IntValue) );
94349 sqlite3ErrorMsg(pParse, "misuse of aggregate: %s()", pExpr->u.zToken);
94351 return pInfo->aFunc[pExpr->iAgg].iMem;
94366 if( ConstFactorOk(pParse) && sqlite3ExprIsConstantNotJoin(pExpr) ){
94369 return sqlite3ExprCodeAtInit(pParse, pExpr, -1);
94371 assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
94372 if( ExprHasProperty(pExpr, EP_TokenOnly) ){
94375 pFarg = pExpr->x.pList;
94378 assert( !ExprHasProperty(pExpr, EP_IntValue) );
94379 zId = pExpr->u.zToken;
94398 sqlite3ExprCode(pParse, pFarg->a[0].pExpr, target);
94404 sqlite3ExprCode(pParse, pFarg->a[i].pExpr, target);
94416 return sqlite3ExprCodeTarget(pParse, pFarg->a[0].pExpr, target);
94428 aff = sqlite3ExprAffinity(pFarg->a[0].pExpr);
94436 if( i<32 && sqlite3ExprIsConstant(pFarg->a[i].pExpr) ){
94441 pColl = sqlite3ExprCollSeq(pParse, pFarg->a[i].pExpr);
94460 assert( pFarg->a[0].pExpr!=0 );
94461 exprOp = pFarg->a[0].pExpr->op;
94466 pFarg->a[0].pExpr->op2 =
94491 if( nFarg>=2 && (pExpr->flags & EP_InfixFunc) ){
94492 pDef = sqlite3VtabOverloadFunction(db, pDef, nFarg, pFarg->a[1].pExpr);
94494 pDef = sqlite3VtabOverloadFunction(db, pDef, nFarg, pFarg->a[0].pExpr);
94515 if( op==TK_SELECT && (nCol = pExpr->x.pSelect->pEList->nExpr)!=1 ){
94518 return sqlite3CodeSubselect(pParse, pExpr, 0, 0);
94524 if( pExpr->pLeft->iTable==0 ){
94525 pExpr->pLeft->iTable = sqlite3CodeSubselect(pParse, pExpr->pLeft, 0, 0);
94527 assert( pExpr->iTable==0 || pExpr->pLeft->op==TK_SELECT );
94528 if( pExpr->iTable
94529 && pExpr->iTable!=(n = sqlite3ExprVectorSize(pExpr->pLeft))
94532 pExpr->iTable, n);
94534 return pExpr->pLeft->iTable + pExpr->iColumn;
94540 sqlite3ExprCodeIN(pParse, pExpr, destIfFalse, destIfNull);
94557 ** X is stored in pExpr->pLeft.
94558 ** Y is stored in pExpr->pList->a[0].pExpr.
94559 ** Z is stored in pExpr->pList->a[1].pExpr.
94562 exprCodeBetween(pParse, pExpr, target, 0, 0);
94568 return sqlite3ExprCodeTarget(pParse, pExpr->pLeft, target);
94597 Table *pTab = pExpr->pTab;
94598 int p1 = pExpr->iTable * (pTab->nCol+1) + 1 + pExpr->iColumn;
94600 assert( pExpr->iTable==0 || pExpr->iTable==1 );
94601 assert( pExpr->iColumn>=-1 && pExpr->iColumn<pTab->nCol );
94602 assert( pTab->iPKey<0 || pExpr->iColumn!=pTab->iPKey );
94607 (pExpr->iTable ? "new" : "old"),
94608 (pExpr->iColumn<0 ? "rowid" : pExpr->pTab->aCol[pExpr->iColumn].zName),
94618 if( pExpr->iColumn>=0
94619 && pTab->aCol[pExpr->iColumn].affinity==SQLITE_AFF_REAL
94643 ** X (if it exists) is in pExpr->pLeft.
94644 ** Y is in the last element of pExpr->x.pList if pExpr->x.pList->nExpr is
94647 ** Ei is in pExpr->pList->a[i*2] and Ri is pExpr->pList->a[i*2+1].
94665 assert( !ExprHasProperty(pExpr, EP_xIsSelect) && pExpr->x.pList );
94666 assert(pExpr->x.pList->nExpr > 0);
94667 pEList = pExpr->x.pList;
94671 if( (pX = pExpr->pLeft)!=0 ){
94690 opCompare.pRight = aListelem[i].pExpr;
94692 pTest = aListelem[i].pExpr;
94697 testcase( aListelem[i+1].pExpr->op==TK_COLUMN );
94698 sqlite3ExprCode(pParse, aListelem[i+1].pExpr, target);
94705 sqlite3ExprCode(pParse, pEList->a[nExpr-1].pExpr, target);
94717 assert( pExpr->affinity==OE_Rollback
94718 || pExpr->affinity==OE_Abort
94719 || pExpr->affinity==OE_Fail
94720 || pExpr->affinity==OE_Ignore
94727 if( pExpr->affinity==OE_Abort ){
94730 assert( !ExprHasProperty(pExpr, EP_IntValue) );
94731 if( pExpr->affinity==OE_Ignore ){
94733 v, OP_Halt, SQLITE_OK, OE_Ignore, 0, pExpr->u.zToken,0);
94737 pExpr->affinity, pExpr->u.zToken, 0, 0);
94760 Expr *pExpr, /* The expression to code when the VDBE initializes */
94770 if( pItem->reusable && sqlite3ExprCompare(pItem->pExpr,pExpr,-1)==0 ){
94775 pExpr = sqlite3ExprDup(pParse->db, pExpr, 0);
94776 p = sqlite3ExprListAppend(pParse, p, pExpr);
94796 ** If pExpr is a constant, then this routine might generate this
94800 SQLITE_PRIVATE int sqlite3ExprCodeTemp(Parse *pParse, Expr *pExpr, int *pReg){
94802 pExpr = sqlite3ExprSkipCollate(pExpr);
94804 && pExpr->op!=TK_REGISTER
94805 && sqlite3ExprIsConstantNotJoin(pExpr)
94808 r2 = sqlite3ExprCodeAtInit(pParse, pExpr, -1);
94811 r2 = sqlite3ExprCodeTarget(pParse, pExpr, r1);
94823 ** Generate code that will evaluate expression pExpr and store the
94827 SQLITE_PRIVATE void sqlite3ExprCode(Parse *pParse, Expr *pExpr, int target){
94831 if( pExpr && pExpr->op==TK_REGISTER ){
94832 sqlite3VdbeAddOp2(pParse->pVdbe, OP_Copy, pExpr->iTable, target);
94834 inReg = sqlite3ExprCodeTarget(pParse, pExpr, target);
94843 ** Make a transient copy of expression pExpr and then code it using
94847 SQLITE_PRIVATE void sqlite3ExprCodeCopy(Parse *pParse, Expr *pExpr, int target){
94849 pExpr = sqlite3ExprDup(db, pExpr, 0);
94850 if( !db->mallocFailed ) sqlite3ExprCode(pParse, pExpr, target);
94851 sqlite3ExprDelete(db, pExpr);
94855 ** Generate code that will evaluate expression pExpr and store the
94860 SQLITE_PRIVATE void sqlite3ExprCodeFactorable(Parse *pParse, Expr *pExpr, int target){
94861 if( pParse->okConstFactor && sqlite3ExprIsConstant(pExpr) ){
94862 sqlite3ExprCodeAtInit(pParse, pExpr, target);
94864 sqlite3ExprCode(pParse, pExpr, target);
94880 SQLITE_PRIVATE void sqlite3ExprCodeAndCache(Parse *pParse, Expr *pExpr, int target){
94885 assert( pExpr->op!=TK_REGISTER );
94886 sqlite3ExprCode(pParse, pExpr, target);
94889 exprToRegister(pExpr, iMem);
94925 Expr *pExpr = pItem->pExpr;
94933 }else if( (flags & SQLITE_ECEL_FACTOR)!=0 && sqlite3ExprIsConstant(pExpr) ){
94934 sqlite3ExprCodeAtInit(pParse, pExpr, target+i);
94936 int inReg = sqlite3ExprCodeTarget(pParse, pExpr, target+i);
94976 Expr *pExpr, /* The BETWEEN expression */
94992 assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
94993 exprX = *pExpr->pLeft;
94999 compLeft.pRight = pExpr->x.pList->a[0].pExpr;
95002 compRight.pRight = pExpr->x.pList->a[1].pExpr;
95043 SQLITE_PRIVATE void sqlite3ExprIfTrue(Parse *pParse, Expr *pExpr, int dest, int jumpIfNull){
95052 if( NEVER(pExpr==0) ) return; /* No way this can happen */
95053 op = pExpr->op;
95058 sqlite3ExprIfFalse(pParse, pExpr->pLeft, d2,jumpIfNull^SQLITE_JUMPIFNULL);
95060 sqlite3ExprIfTrue(pParse, pExpr->pRight, dest, jumpIfNull);
95067 sqlite3ExprIfTrue(pParse, pExpr->pLeft, dest, jumpIfNull);
95069 sqlite3ExprIfTrue(pParse, pExpr->pRight, dest, jumpIfNull);
95075 sqlite3ExprIfFalse(pParse, pExpr->pLeft, dest, jumpIfNull);
95091 if( sqlite3ExprIsVector(pExpr->pLeft) ) goto default_expr;
95093 r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree1);
95094 r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, &regFree2);
95095 codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,
95115 r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree1);
95124 exprCodeBetween(pParse, pExpr, dest, sqlite3ExprIfTrue, jumpIfNull);
95131 sqlite3ExprCodeIN(pParse, pExpr, destIfFalse, destIfNull);
95139 if( exprAlwaysTrue(pExpr) ){
95141 }else if( exprAlwaysFalse(pExpr) ){
95144 r1 = sqlite3ExprCodeTemp(pParse, pExpr, &regFree1);
95166 SQLITE_PRIVATE void sqlite3ExprIfFalse(Parse *pParse, Expr *pExpr, int dest, int jumpIfNull){
95175 if( pExpr==0 ) return;
95177 /* The value of pExpr->op and op are related as follows:
95179 ** pExpr->op op
95190 ** For other values of pExpr->op, op is undefined and unused.
95195 op = ((pExpr->op+(TK_ISNULL&1))^1)-(TK_ISNULL&1);
95199 assert( pExpr->op!=TK_ISNULL || op==OP_NotNull );
95200 assert( pExpr->op!=TK_NOTNULL || op==OP_IsNull );
95201 assert( pExpr->op!=TK_NE || op==OP_Eq );
95202 assert( pExpr->op!=TK_EQ || op==OP_Ne );
95203 assert( pExpr->op!=TK_LT || op==OP_Ge );
95204 assert( pExpr->op!=TK_LE || op==OP_Gt );
95205 assert( pExpr->op!=TK_GT || op==OP_Le );
95206 assert( pExpr->op!=TK_GE || op==OP_Lt );
95208 switch( pExpr->op ){
95211 sqlite3ExprIfFalse(pParse, pExpr->pLeft, dest, jumpIfNull);
95213 sqlite3ExprIfFalse(pParse, pExpr->pRight, dest, jumpIfNull);
95220 sqlite3ExprIfTrue(pParse, pExpr->pLeft, d2, jumpIfNull^SQLITE_JUMPIFNULL);
95222 sqlite3ExprIfFalse(pParse, pExpr->pRight, dest, jumpIfNull);
95229 sqlite3ExprIfTrue(pParse, pExpr->pLeft, dest, jumpIfNull);
95234 testcase( pExpr->op==TK_IS );
95235 testcase( pExpr->op==TK_ISNOT );
95236 op = (pExpr->op==TK_IS) ? TK_NE : TK_EQ;
95245 if( sqlite3ExprIsVector(pExpr->pLeft) ) goto default_expr;
95247 r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree1);
95248 r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, &regFree2);
95249 codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,
95267 r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree1);
95276 exprCodeBetween(pParse, pExpr, dest, sqlite3ExprIfFalse, jumpIfNull);
95282 sqlite3ExprCodeIN(pParse, pExpr, dest, dest);
95285 sqlite3ExprCodeIN(pParse, pExpr, dest, destIfNull);
95293 if( exprAlwaysFalse(pExpr) ){
95295 }else if( exprAlwaysTrue(pExpr) ){
95298 r1 = sqlite3ExprCodeTemp(pParse, pExpr, &regFree1);
95312 ** Like sqlite3ExprIfFalse() except that a copy is made of pExpr before
95314 ** ensures that the original pExpr is unchanged.
95316 SQLITE_PRIVATE void sqlite3ExprIfFalseDup(Parse *pParse, Expr *pExpr, int dest,int jumpIfNull){
95318 Expr *pCopy = sqlite3ExprDup(db, pExpr, 0);
95412 Expr *pExprA = pA->a[i].pExpr;
95413 Expr *pExprB = pB->a[i].pExpr;
95486 static int exprIdxCover(Walker *pWalker, Expr *pExpr){
95487 if( pExpr->op==TK_COLUMN
95488 && pExpr->iTable==pWalker->u.pIdxCover->iCur
95489 && sqlite3ColumnOfIndex(pWalker->u.pIdxCover->pIdx, pExpr->iColumn)<0
95499 ** the expression pExpr. Return true if the index does cover the
95500 ** expression and false if the pExpr expression references table columns
95508 Expr *pExpr, /* The index to be tested */
95519 sqlite3WalkExpr(&w, pExpr);
95539 static int exprSrcCount(Walker *pWalker, Expr *pExpr){
95545 if( pExpr->op==TK_COLUMN || NEVER(pExpr->op==TK_AGG_COLUMN) ){
95551 if( pExpr->iTable==pSrc->a[i].iCursor ) break;
95563 ** Determine if any of the arguments to the pExpr Function reference
95565 ** has no arguments or has only constant arguments. Return false if pExpr
95568 SQLITE_PRIVATE int sqlite3FunctionUsesThisSrc(Expr *pExpr, SrcList *pSrcList){
95571 assert( pExpr->op==TK_AGG_FUNCTION );
95578 sqlite3WalkExprList(&w, pExpr->x.pList);
95619 static int analyzeAggregate(Walker *pWalker, Expr *pExpr){
95626 switch( pExpr->op ){
95629 testcase( pExpr->op==TK_AGG_COLUMN );
95630 testcase( pExpr->op==TK_COLUMN );
95637 assert( !ExprHasProperty(pExpr, EP_TokenOnly|EP_Reduced) );
95638 if( pExpr->iTable==pItem->iCursor ){
95639 /* If we reach this point, it means that pExpr refers to a table
95648 if( pCol->iTable==pExpr->iTable &&
95649 pCol->iColumn==pExpr->iColumn ){
95657 pCol->pTab = pExpr->pTab;
95658 pCol->iTable = pExpr->iTable;
95659 pCol->iColumn = pExpr->iColumn;
95662 pCol->pExpr = pExpr;
95669 Expr *pE = pTerm->pExpr;
95670 if( pE->op==TK_COLUMN && pE->iTable==pExpr->iTable &&
95671 pE->iColumn==pExpr->iColumn ){
95681 /* There is now an entry for pExpr in pAggInfo->aCol[] (either
95683 ** Convert the pExpr to be a TK_AGG_COLUMN referring to that
95686 ExprSetVVAProperty(pExpr, EP_NoReduce);
95687 pExpr->pAggInfo = pAggInfo;
95688 pExpr->op = TK_AGG_COLUMN;
95689 pExpr->iAgg = (i16)k;
95691 } /* endif pExpr->iTable==pItem->iCursor */
95698 && pWalker->walkerDepth==pExpr->op2
95700 /* Check to see if pExpr is a duplicate of another aggregate
95705 if( sqlite3ExprCompare(pItem->pExpr, pExpr, -1)==0 ){
95710 /* pExpr is original. Make a new entry in pAggInfo->aFunc[]
95715 assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
95717 pItem->pExpr = pExpr;
95719 assert( !ExprHasProperty(pExpr, EP_IntValue) );
95721 pExpr->u.zToken,
95722 pExpr->x.pList ? pExpr->x.pList->nExpr : 0, enc, 0);
95723 if( pExpr->flags & EP_Distinct ){
95730 /* Make pExpr point to the appropriate pAggInfo->aFunc[] entry
95732 assert( !ExprHasProperty(pExpr, EP_TokenOnly|EP_Reduced) );
95733 ExprSetVVAProperty(pExpr, EP_NoReduce);
95734 pExpr->iAgg = (i16)i;
95735 pExpr->pAggInfo = pAggInfo;
95751 ** Analyze the pExpr expression looking for aggregate functions and
95759 SQLITE_PRIVATE void sqlite3ExprAnalyzeAggregates(NameContext *pNC, Expr *pExpr){
95766 sqlite3WalkExpr(&w, pExpr);
95780 sqlite3ExprAnalyzeAggregates(pNC, pItem->pExpr);
98633 ** This only applies to the root node of pExpr, so the statement:
98639 static int resolveAttachExpr(NameContext *pName, Expr *pExpr)
98642 if( pExpr ){
98643 if( pExpr->op!=TK_ID ){
98644 rc = sqlite3ResolveExprNames(pName, pExpr);
98646 pExpr->op = TK_STRING;
99128 Expr *pExpr /* The expression to be fixed to one database */
99130 while( pExpr ){
99131 if( pExpr->op==TK_VARIABLE ){
99133 pExpr->op = TK_NULL;
99139 if( ExprHasProperty(pExpr, EP_TokenOnly|EP_Leaf) ) break;
99140 if( ExprHasProperty(pExpr, EP_xIsSelect) ){
99141 if( sqlite3FixSelect(pFix, pExpr->x.pSelect) ) return 1;
99143 if( sqlite3FixExprList(pFix, pExpr->x.pList) ) return 1;
99145 if( sqlite3FixExpr(pFix, pExpr->pRight) ){
99148 pExpr = pExpr->pLeft;
99160 if( sqlite3FixExpr(pFix, pItem->pExpr) ){
99290 ** If SQLITE_IGNORE is returned and pExpr is not NULL, then pExpr is changed
99291 ** to an SQL NULL expression. Otherwise, if pExpr is NULL, then SQLITE_IGNORE
99324 ** The pExpr should be a TK_COLUMN expression. The table referred to
99334 Expr *pExpr, /* The expression to check authorization on */
99336 SrcList *pTabList /* All table that pExpr might refer to */
99353 assert( pExpr->op==TK_COLUMN || pExpr->op==TK_TRIGGER );
99354 if( pExpr->op==TK_TRIGGER ){
99359 if( pExpr->iTable==pTabList->a[iSrc].iCursor ){
99365 iCol = pExpr->iColumn;
99379 pExpr->op = TK_NULL;
99669 sqlite3ExprCode(pParse, pEL->a[i].pExpr, pEL->a[i].u.iConstExprReg);
100679 if( !sqlite3ExprIsConstantOrFunction(pSpan->pExpr, db->init.busy) ){
100683 /* A copy of pExpr is used instead of the original, as pExpr contains
100693 x.pLeft = pSpan->pExpr;
100699 sqlite3ExprDelete(db, pSpan->pExpr);
100770 Expr *pCExpr = sqlite3ExprSkipCollate(pList->a[i].pExpr);
102551 Expr *pExpr = pList->a[i].pExpr;
102552 assert( pExpr!=0 );
102553 if( pExpr->op==TK_COLLATE ){
102554 nExtra += (1 + sqlite3Strlen30(pExpr->u.zToken));
102608 sqlite3StringToId(pListItem->pExpr);
102609 sqlite3ResolveSelfReference(pParse, pTab, NC_IdxExpr, pListItem->pExpr, 0);
102611 pCExpr = sqlite3ExprSkipCollate(pListItem->pExpr);
102640 if( pListItem->pExpr->op==TK_COLLATE ){
102642 zColl = pListItem->pExpr->u.zToken;
106994 ** pExpr points to an expression which implements a function. If
107005 SQLITE_PRIVATE int sqlite3IsLikeFunction(sqlite3 *db, Expr *pExpr, int *pIsNocase, char *aWc){
107007 if( pExpr->op!=TK_FUNCTION
107008 || !pExpr->x.pList
107009 || pExpr->x.pList->nExpr!=2
107013 assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
107014 pDef = sqlite3FindFunction(db, pExpr->u.zToken, 2, SQLITE_UTF8, 0);
107629 Expr *pExpr;
107634 pExpr = sqlite3Expr(db, TK_REGISTER, 0);
107635 if( pExpr ){
107638 pExpr->iTable = regBase + iCol + 1;
107639 pExpr->affinity = pCol->affinity;
107642 pExpr = sqlite3ExprAddCollateString(pParse, pExpr, zColl);
107644 pExpr->iTable = regBase;
107645 pExpr->affinity = SQLITE_AFF_INTEGER;
107648 return pExpr;
107661 Expr *pExpr = sqlite3Expr(db, TK_COLUMN, 0);
107662 if( pExpr ){
107663 pExpr->pTab = pTab;
107664 pExpr->iTable = iCursor;
107665 pExpr->iColumn = iCol;
107667 return pExpr;
108670 aff = sqlite3ExprAffinity(pIdx->aColExpr->a[n].pExpr);
109420 sqlite3ExprCode(pParse, pList->a[ipkColumn].pExpr, regCols);
109448 sqlite3ExprCodeAndCache(pParse, pList->a[j].pExpr, regCols+i+1);
109484 sqlite3ExprCode(pParse, pList->a[ipkColumn].pExpr, regRowid);
109553 sqlite3ExprCode(pParse, pList->a[j].pExpr, iRegStore);
109671 static int checkConstraintExprNode(Walker *pWalker, Expr *pExpr){
109672 if( pExpr->op==TK_COLUMN ){
109673 assert( pExpr->iColumn>=0 || pExpr->iColumn==-1 );
109674 if( pExpr->iColumn>=0 ){
109675 if( pWalker->u.aiCol[pExpr->iColumn]>=0 ){
109686 ** pExpr is a CHECK constraint on a row that is being UPDATE-ed. The
109690 ** Return true if CHECK constraint pExpr does not use any of the
109695 static int checkConstraintUnchanged(Expr *pExpr, int *aiChng, int chngRowid){
109701 sqlite3WalkExpr(&w, pExpr);
109911 Expr *pExpr = pCheck->a[i].pExpr;
109912 if( aiChng && checkConstraintUnchanged(pExpr, aiChng, pkChng) ) continue;
109914 sqlite3ExprIfTrue(pParse, pExpr, allOk, SQLITE_JUMPIFNULL);
110086 sqlite3ExprCodeCopy(pParse, pIdx->aColExpr->a[i].pExpr, regIdx+i);
110472 if( sqlite3ExprCompare(pSrc->aColExpr->a[i].pExpr,
110473 pDest->aColExpr->a[i].pExpr, -1)!=0 ){
110594 assert( pEList->a[0].pExpr );
110595 if( pEList->a[0].pExpr->op!=TK_ASTERISK ){
114515 sqlite3ExprIfFalse(pParse, pCheck->a[k].pExpr, addrCkFault, 0);
114517 sqlite3ExprIfTrue(pParse, pCheck->a[0].pExpr, addrCkOk,
116632 setJoinExpr(p->x.pList->a[i].pExpr, iTable);
117046 CollSeq *pColl = sqlite3ExprCollSeq(pParse, pEList->a[i].pExpr);
117365 pColl = sqlite3ExprCollSeq(pParse, pItem->pExpr);
117594 ** expression pExpr. The string may be treated as static by the caller.
117623 Expr *pExpr,
117640 assert( pExpr!=0 );
117642 switch( pExpr->op ){
117651 int iCol = pExpr->iColumn; /* Index of column in pTab */
117652 testcase( pExpr->op==TK_AGG_COLUMN );
117653 testcase( pExpr->op==TK_COLUMN );
117656 for(j=0;j<pTabList->nSrc && pTabList->a[j].iCursor!=pExpr->iTable;j++);
117686 assert( pTab && pExpr->pTab==pTab );
117701 Expr *p = pS->pEList->a[iCol].pExpr;
117744 Select *pS = pExpr->x.pSelect;
117745 Expr *p = pS->pEList->a[0].pExpr;
117746 assert( ExprHasProperty(pExpr, EP_xIsSelect) );
117784 Expr *p = pEList->a[i].pExpr;
117838 p = pEList->a[i].pExpr;
117923 p = sqlite3ExprSkipCollate(pEList->a[i].pExpr);
118016 p = a[i].pExpr;
118183 pRet = sqlite3ExprCollSeq(pParse, p->pEList->a[iCol].pExpr);
118206 Expr *pTerm = pItem->pExpr;
118214 pOrderBy->a[i].pExpr =
119392 ** Scan through the expression pExpr. Replace every reference to
119401 ** changes to pExpr so that it refers directly to the source table
119406 Expr *pExpr, /* Expr in which substitution occurs */
119411 if( pExpr==0 ) return 0;
119412 if( pExpr->op==TK_COLUMN && pExpr->iTable==iTable ){
119413 if( pExpr->iColumn<0 ){
119414 pExpr->op = TK_NULL;
119417 Expr *pCopy = pEList->a[pExpr->iColumn].pExpr;
119418 assert( pEList!=0 && pExpr->iColumn<pEList->nExpr );
119419 assert( pExpr->pLeft==0 && pExpr->pRight==0 );
119424 if( pNew && (pExpr->flags & EP_FromJoin) ){
119425 pNew->iRightJoinTable = pExpr->iRightJoinTable;
119428 sqlite3ExprDelete(db, pExpr);
119429 pExpr = pNew;
119433 pExpr->pLeft = substExpr(pParse, pExpr->pLeft, iTable, pEList);
119434 pExpr->pRight = substExpr(pParse, pExpr->pRight, iTable, pEList);
119435 if( ExprHasProperty(pExpr, EP_xIsSelect) ){
119436 substSelect(pParse, pExpr->x.pSelect, iTable, pEList, 1);
119438 substExprList(pParse, pExpr->x.pList, iTable, pEList);
119441 return pExpr;
119452 pList->a[i].pExpr = substExpr(pParse, pList->a[i].pExpr, iTable, pEList);
120136 Expr *pExpr = pAggInfo->aFunc[0].pExpr; /* Aggregate function */
120137 ExprList *pEList = pExpr->x.pList; /* Arguments to agg function */
120139 assert( pExpr->op==TK_AGG_FUNCTION );
120140 if( pEList && pEList->nExpr==1 && pEList->a[0].pExpr->op==TK_AGG_COLUMN ){
120141 const char *zFunc = pExpr->u.zToken;
120169 Expr *pExpr;
120179 pExpr = p->pEList->a[0].pExpr;
120180 assert( pTab && !pTab->pSelect && pExpr );
120183 if( pExpr->op!=TK_AGG_FUNCTION ) return 0;
120186 if( pExpr->flags&EP_Distinct ) return 0;
120253 if( a[i].pExpr->flags & EP_Collate ) break;
120536 Expr *pE, *pRight, *pExpr;
120641 pE = pEList->a[k].pExpr;
120660 pE = a[k].pExpr;
120668 pNew = sqlite3ExprListAppend(pParse, pNew, a[k].pExpr);
120675 a[k].pExpr = 0;
120748 pExpr = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight);
120751 pExpr = sqlite3PExpr(pParse, TK_DOT, pLeft, pExpr);
120758 pExpr = pRight;
120760 pNew = sqlite3ExprListAppend(pParse, pNew, pExpr);
120960 Expr *pE = pFunc->pExpr;
120984 ExprList *pList = pF->pExpr->x.pList;
120985 assert( !ExprHasProperty(pF->pExpr, EP_xIsSelect) );
121008 ExprList *pList = pF->pExpr->x.pList;
121009 assert( !ExprHasProperty(pF->pExpr, EP_xIsSelect) );
121030 pColl = sqlite3ExprCollSeq(pParse, pItem->pExpr);
121064 sqlite3ExprCode(pParse, pC->pExpr, pC->iMem);
121567 assert( !ExprHasProperty(sAggInfo.aFunc[i].pExpr, EP_xIsSelect) );
121569 sqlite3ExprAnalyzeAggList(&sNC, sAggInfo.aFunc[i].pExpr->x.pList);
121718 sqlite3ExprCode(pParse, pGroupBy->a[j].pExpr, iBMem+j);
121906 pMinMax->a[0].pExpr->op = TK_COLUMN;
123513 if( sqlite3ResolveExprNames(&sNC, pChanges->a[i].pExpr) ){
123520 pRowidExpr = pChanges->a[i].pExpr;
123532 pRowidExpr = pChanges->a[i].pExpr;
123843 sqlite3ExprCode(pParse, pChanges->a[j].pExpr, regNew+i);
124101 sqlite3ExprCode(pParse, pChanges->a[aXRef[i]].pExpr, regArg+2+i);
125552 ** second parameter (pExpr) is the first argument to this function.
125553 ** If pExpr is a column in a virtual table, then let the virtual
125567 Expr *pExpr /* First argument to the function */
125581 if( NEVER(pExpr==0) ) return pDef;
125582 if( pExpr->op!=TK_COLUMN ) return pDef;
125583 pTab = pExpr->pTab;
126019 ** categories, then eOperator==0. The WhereTerm.pExpr field is still set
126040 Expr *pExpr; /* Pointer to the subexpression that is this term */
126055 Bitmask prereqRight; /* Bitmask of tables used by pExpr->pRight */
126056 Bitmask prereqAll; /* Bitmask of tables referenced by pExpr */
126062 #define TERM_DYNAMIC 0x01 /* Need to call sqlite3ExprDelete(db, pExpr) */
126077 #define TERM_IS 0x800 /* Term.pExpr is an IS operator */
126629 && (pLevel->iLeftJoin==0 || ExprHasProperty(pTerm->pExpr, EP_FromJoin))
126732 Expr *pX = pTerm->pExpr;
126765 if( pLoop->aLTerm[i] && pLoop->aLTerm[i]->pExpr==pX ){
126771 if( ALWAYS(pLoop->aLTerm[i]) && pLoop->aLTerm[i]->pExpr==pX ) nEq++;
126786 if( pLoop->aLTerm[i]->pExpr==pX ){
126788 Expr *pNewRhs = sqlite3ExprDup(db, pOrigRhs->a[iField].pExpr, 0);
126789 Expr *pNewLhs = sqlite3ExprDup(db, pOrigLhs->a[iField].pExpr, 0);
126816 pX->pLeft = pLhs->a[0].pExpr;
126860 if( pLoop->aLTerm[i]->pExpr==pX ){
127009 if( pTerm->pExpr->flags & EP_xIsSelect ){
127017 Expr *pRight = pTerm->pExpr->pRight;
127092 static int codeCursorHintCheckExpr(Walker *pWalker, Expr *pExpr){
127095 if( pExpr->op==TK_COLUMN
127096 && pExpr->iTable==pHint->iTabCur
127097 && sqlite3ColumnOfIndex(pHint->pIdx, pExpr->iColumn)<0
127105 ** Test whether or not expression pExpr, which was part of a WHERE clause,
127119 static int codeCursorHintIsOrFunction(Walker *pWalker, Expr *pExpr){
127120 if( pExpr->op==TK_IS
127121 || pExpr->op==TK_ISNULL || pExpr->op==TK_ISNOT
127122 || pExpr->op==TK_NOTNULL || pExpr->op==TK_CASE
127125 }else if( pExpr->op==TK_FUNCTION ){
127128 if( 0==sqlite3IsLikeFunction(pWalker->pParse->db, pExpr, &d1, d2) ){
127154 static int codeCursorHintFixExpr(Walker *pWalker, Expr *pExpr){
127157 if( pExpr->op==TK_COLUMN ){
127158 if( pExpr->iTable!=pHint->iTabCur ){
127162 v, pExpr->pTab, pExpr->iTable, pExpr->iColumn, reg
127164 pExpr->op = TK_REGISTER;
127165 pExpr->iTable = reg;
127167 pExpr->iTable = pHint->iIdxCur;
127168 pExpr->iColumn = sqlite3ColumnOfIndex(pHint->pIdx, pExpr->iColumn);
127169 assert( pExpr->iColumn>=0 );
127171 }else if( pExpr->op==TK_AGG_FUNCTION ){
127173 ** be a correlated sub-query, and expression pExpr is an aggregate from
127196 Expr *pExpr = 0;
127243 Expr *pExpr = pTerm->pExpr;
127244 if( !ExprHasProperty(pExpr, EP_FromJoin)
127245 || pExpr->iRightJoinTable!=pTabItem->iCursor
127249 sqlite3WalkExpr(&sWalker, pTerm->pExpr);
127253 if( ExprHasProperty(pTerm->pExpr, EP_FromJoin) ) continue;
127265 if( sqlite3ExprContainsSubquery(pTerm->pExpr) ) continue;
127272 sqlite3WalkExpr(&sWalker, pTerm->pExpr);
127277 pExpr = sqlite3ExprAnd(db, pExpr, sqlite3ExprDup(db, pTerm->pExpr, 0));
127279 if( pExpr!=0 ){
127281 sqlite3WalkExpr(&sWalker, pExpr);
127284 (const char*)pExpr, P4_EXPR);
127363 sqlite3ExprCode(pParse, pList->a[i].pExpr, iReg+i);
127473 Expr *pRight = pTerm->pExpr->pRight;
127517 pCompare->pLeft = pTerm->pExpr->pLeft;
127550 assert( pTerm->pExpr!=0 );
127605 pX = pStart->pExpr;
127632 pX = pEnd->pExpr;
127832 Expr *pRight = pRangeStart->pExpr->pRight;
127881 Expr *pRight = pRangeEnd->pExpr->pRight;
128104 Expr *pExpr = pWC->a[iTerm].pExpr;
128106 if( ExprHasProperty(pExpr, EP_FromJoin) ) continue;
128112 pExpr = sqlite3ExprDup(db, pExpr, 0);
128113 pAndExpr = sqlite3ExprAnd(db, pAndExpr, pExpr);
128129 Expr *pOrExpr = pOrTerm->pExpr; /* Current OR clause term */
128298 pE = pTerm->pExpr;
128339 pE = pTerm->pExpr;
128350 sEAlt = *pAlt->pExpr;
128371 assert( pTerm->pExpr );
128372 sqlite3ExprIfFalse(pParse, pTerm->pExpr, addrCont, SQLITE_JUMPIFNULL);
128468 pTerm->pExpr = sqlite3ExprSkipCollate(p);
128502 static void exprCommute(Parse *pParse, Expr *pExpr){
128503 u16 expRight = (pExpr->pRight->flags & EP_Collate);
128504 u16 expLeft = (pExpr->pLeft->flags & EP_Collate);
128505 assert( allowedOp(pExpr->op) && pExpr->op!=TK_IN );
128511 pExpr->pRight->flags &= ~EP_Collate;
128512 }else if( sqlite3ExprCollSeq(pParse, pExpr->pLeft)!=0 ){
128516 pExpr->pLeft->flags |= EP_Collate;
128519 SWAP(Expr*,pExpr->pRight,pExpr->pLeft);
128520 if( pExpr->op>=TK_GT ){
128525 assert( pExpr->op>=TK_GT && pExpr->op<=TK_GE );
128526 pExpr->op = ((pExpr->op-TK_GT)^2)+TK_GT;
128573 Expr *pExpr, /* Test this expression */
128589 if( !sqlite3IsLikeFunction(db, pExpr, pnoCase, wc) ){
128595 pList = pExpr->x.pList;
128596 pLeft = pList->a[1].pExpr;
128598 pRight = sqlite3ExprSkipCollate(pList->a[0].pExpr);
128680 Expr *pExpr, /* Test this expression */
128696 if( pExpr->op!=TK_FUNCTION ){
128699 pList = pExpr->x.pList;
128703 pCol = pList->a[1].pExpr;
128708 if( sqlite3StrICmp(pExpr->u.zToken, aOp[i].zOp)==0 ){
128788 assert( pOne->pExpr->pLeft!=0 && pOne->pExpr->pRight!=0 );
128789 assert( pTwo->pExpr->pLeft!=0 && pTwo->pExpr->pRight!=0 );
128790 if( sqlite3ExprCompare(pOne->pExpr->pLeft, pTwo->pExpr->pLeft, -1) ) return;
128791 if( sqlite3ExprCompare(pOne->pExpr->pRight, pTwo->pExpr->pRight, -1) )return;
128802 pNew = sqlite3ExprDup(db, pOne->pExpr, 0);
128907 Expr *pExpr = pTerm->pExpr; /* The expression of the term */
128921 assert( pExpr->op==TK_OR );
128928 sqlite3WhereSplit(pOrWc, pExpr, TK_OR);
128955 sqlite3WhereSplit(pAndWC, pOrTerm->pExpr, TK_AND);
128960 assert( pAndTerm->pExpr );
128961 if( allowedOp(pAndTerm->pExpr->op)
129094 affRight = sqlite3ExprAffinity(pOrTerm->pExpr->pRight);
129095 affLeft = sqlite3ExprAffinity(pOrTerm->pExpr->pLeft);
129120 pDup = sqlite3ExprDup(db, pOrTerm->pExpr->pRight, 0);
129122 pLeft = pOrTerm->pExpr->pLeft;
129129 transferJoinMarkings(pNew, pExpr);
129147 ** We already know that pExpr is a binary operator where both operands are
129148 ** column references. This routine checks to see if pExpr is an equivalence
129161 static int termIsEquivalence(Parse *pParse, Expr *pExpr){
129166 if( pExpr->op!=TK_EQ && pExpr->op!=TK_IS ) return 0;
129167 if( ExprHasProperty(pExpr, EP_FromJoin) ) return 0;
129168 aff1 = sqlite3ExprAffinity(pExpr->pLeft);
129169 aff2 = sqlite3ExprAffinity(pExpr->pRight);
129175 pColl = sqlite3BinaryCompareCollSeq(pParse, pExpr->pLeft, pExpr->pRight);
129177 pColl = sqlite3ExprCollSeq(pParse, pExpr->pLeft);
129179 pColl = sqlite3ExprCollSeq(pParse, pExpr->pRight);
129211 ** Expression pExpr is one operand of a comparison operator that might
129212 ** be useful for indexing. This routine checks to see if pExpr appears
129213 ** in any index. Return TRUE (1) if pExpr is an indexed term and return
129219 ** If pExpr is a TK_COLUMN column reference, then this routine always returns
129226 Bitmask mPrereq, /* Bitmask of FROM clause terms referenced by pExpr */
129227 Expr *pExpr, /* An operand of a comparison operator */
129241 if( pExpr->op==TK_VECTOR && (op>=TK_GT && ALWAYS(op<=TK_GE)) ){
129242 pExpr = pExpr->x.pList->a[0].pExpr;
129245 if( pExpr->op==TK_COLUMN ){
129246 *piCur = pExpr->iTable;
129247 *piColumn = pExpr->iColumn;
129258 if( sqlite3ExprCompareSkip(pExpr, pIdx->aColExpr->a[i].pExpr, iCur)==0 ){
129270 ** "pExpr" field filled in. The job of this routine is to analyze the
129281 ** and the new term is marked with TERM_DYNAMIC (because it's pExpr
129294 Expr *pExpr; /* The expression to be analyzed */
129295 Bitmask prereqLeft; /* Prerequesites of the pExpr->pLeft */
129296 Bitmask prereqAll; /* Prerequesites of pExpr */
129301 int op; /* Top-level operator. pExpr->op */
129312 pExpr = pTerm->pExpr;
129313 assert( pExpr->op!=TK_AS && pExpr->op!=TK_COLLATE );
129314 prereqLeft = sqlite3WhereExprUsage(pMaskSet, pExpr->pLeft);
129315 op = pExpr->op;
129317 assert( pExpr->pRight==0 );
129318 if( sqlite3ExprCheckIN(pParse, pExpr) ) return;
129319 if( ExprHasProperty(pExpr, EP_xIsSelect) ){
129320 pTerm->prereqRight = exprSelectUsage(pMaskSet, pExpr->x.pSelect);
129322 pTerm->prereqRight = sqlite3WhereExprListUsage(pMaskSet, pExpr->x.pList);
129327 pTerm->prereqRight = sqlite3WhereExprUsage(pMaskSet, pExpr->pRight);
129329 prereqAll = sqlite3WhereExprUsage(pMaskSet, pExpr);
129330 if( ExprHasProperty(pExpr, EP_FromJoin) ){
129331 Bitmask x = sqlite3WhereGetMask(pMaskSet, pExpr->iRightJoinTable);
129346 Expr *pLeft = sqlite3ExprSkipCollate(pExpr->pLeft);
129347 Expr *pRight = sqlite3ExprSkipCollate(pExpr->pRight);
129353 pLeft = pLeft->x.pList->a[pTerm->iField-1].pExpr;
129371 pDup = sqlite3ExprDup(db, pExpr, 0);
129389 pDup = pExpr;
129418 else if( pExpr->op==TK_BETWEEN && pWC->op==TK_AND ){
129419 ExprList *pList = pExpr->x.pList;
129428 sqlite3ExprDup(db, pExpr->pLeft, 0),
129429 sqlite3ExprDup(db, pList->a[i].pExpr, 0));
129430 transferJoinMarkings(pNewExpr, pExpr);
129444 else if( pExpr->op==TK_OR ){
129466 && isLikeOrGlob(pParse, pExpr, &pStr1, &isComplete, &noCase)
129477 pLeft = pExpr->x.pList->a[1].pExpr;
129515 transferJoinMarkings(pNewExpr1, pExpr);
129523 transferJoinMarkings(pNewExpr2, pExpr);
129542 if( pWC->op==TK_AND && isMatchOfColumn(pExpr, &eOp2) ){
129548 pRight = pExpr->x.pList->a[0].pExpr;
129549 pLeft = pExpr->x.pList->a[1].pExpr;
129580 && (pExpr->op==TK_EQ || pExpr->op==TK_IS)
129581 && (nLeft = sqlite3ExprVectorSize(pExpr->pLeft))>1
129582 && sqlite3ExprVectorSize(pExpr->pRight)==nLeft
129583 && ( (pExpr->pLeft->flags & EP_xIsSelect)==0
129584 || (pExpr->pRight->flags & EP_xIsSelect)==0)
129590 Expr *pLeft = sqlite3ExprForVectorField(pParse, pExpr->pLeft, i);
129591 Expr *pRight = sqlite3ExprForVectorField(pParse, pExpr->pRight, i);
129593 pNew = sqlite3PExpr(pParse, pExpr->op, pLeft, pRight);
129594 transferJoinMarkings(pNew, pExpr);
129605 ** used by each such virtual term is pExpr (the full vector IN(...)
129611 if( pWC->op==TK_AND && pExpr->op==TK_IN && pTerm->iField==0
129612 && pExpr->pLeft->op==TK_VECTOR
129613 && pExpr->x.pSelect->pPrior==0
129616 for(i=0; i<sqlite3ExprVectorSize(pExpr->pLeft); i++){
129618 idxNew = whereClauseInsert(pWC, pExpr, TERM_VIRTUAL);
129633 if( pExpr->op==TK_NOTNULL
129634 && pExpr->pLeft->op==TK_COLUMN
129635 && pExpr->pLeft->iColumn>=0
129639 Expr *pLeft = pExpr->pLeft;
129686 ** The original WHERE clause in pExpr is unaltered. All this routine
129687 ** does is make slot[] entries point to substructure within pExpr.
129693 pExpr, u8 op){
129694 Expr *pE2 = sqlite3ExprSkipCollate(pExpr);
129698 whereClauseInsert(pWC, pExpr, 0);
129730 sqlite3ExprDelete(db, a->pExpr);
129771 mask |= sqlite3WhereExprUsage(pMaskSet, pList->a[i].pExpr);
129831 sqlite3ExprDup(pParse->db, pArgs->a[j].pExpr, 0));
130049 || sqlite3ExprCompareSkip(pTerm->pExpr->pLeft,
130051 && (pScan->iEquiv<=1 || !ExprHasProperty(pTerm->pExpr, EP_FromJoin))
130055 && (pX = sqlite3ExprSkipCollate(pTerm->pExpr->pRight))->op==TK_COLUMN
130075 pX = pTerm->pExpr;
130088 && (pX = pTerm->pExpr->pRight)->op==TK_COLUMN
130148 pScan->pIdxExpr = pIdx->aColExpr->a[j].pExpr;
130238 Expr *p = sqlite3ExprSkipCollate(pList->a[i].pExpr);
130243 CollSeq *pColl = sqlite3ExprCollSeq(pParse, pList->a[i].pExpr);
130302 Expr *p = sqlite3ExprSkipCollate(pDistinct->a[i].pExpr);
130451 if( !sqlite3IndexAffinityOk(pTerm->pExpr, aff) ) return 0;
130452 testcase( pTerm->pExpr->op==TK_IS );
130509 Expr *pExpr = pTerm->pExpr;
130510 assert( !ExprHasProperty(pExpr, EP_FromJoin) /* prereq always non-zero */
130511 || pExpr->iRightJoinTable!=pSrc->iCursor /* for the right-hand */
130515 && !ExprHasProperty(pExpr, EP_FromJoin)
130516 && sqlite3ExprIsTableConstant(pExpr, pSrc->iCursor) ){
130518 sqlite3ExprDup(pParse->db, pExpr, 0));
130579 Expr *pX = pTerm->pExpr;
130713 Expr *pExpr = pOrderBy->a[i].pExpr;
130714 if( pExpr->op!=TK_COLUMN || pExpr->iTable!=pSrc->iCursor ) break;
130778 && sqlite3ExprIsVector(pTerm->pExpr->pRight)
130788 Expr *pExpr = pOrderBy->a[i].pExpr;
130789 pIdxOrderBy[i].iColumn = pExpr->iColumn;
131137 rc = sqlite3Stat4ValueFromExpr(pParse, pLower->pExpr->pRight, aff, &p1);
131141 rc = sqlite3Stat4ValueFromExpr(pParse, pUpper->pExpr->pRight, aff, &p2);
131300 int n; /* Values extracted from pExpr */
131301 Expr *pExpr = pLower->pExpr->pRight;
131302 rc = sqlite3Stat4ProbeSetValue(pParse, p, &pRec, pExpr, nBtm, nEq, &n);
131306 if( sqlite3ExprVectorSize(pExpr)>n ) mask = (WO_LE|WO_LT);
131317 int n; /* Values extracted from pExpr */
131318 Expr *pExpr = pUpper->pExpr->pRight;
131319 rc = sqlite3Stat4ProbeSetValue(pParse, p, &pRec, pExpr, nTop, nEq, &n);
131323 if( sqlite3ExprVectorSize(pExpr)>n ) mask = (WO_LE|WO_LT);
131394 ** for that index. When pExpr==NULL that means the constraint is
131409 Expr *pExpr, /* Expression for VALUE in the x=VALUE constraint */
131438 rc = sqlite3Stat4ProbeSetValue(pParse, p, &pRec, pExpr, 1, nEq-1, &bOk);
131487 rc = whereEqualScanEst(pParse, pBuilder, pList->a[i].pExpr, &nEst);
131516 if( ExprHasProperty(pTerm->pExpr, EP_FromJoin) ) zType[2] = 'L';
131535 sqlite3TreeViewExpr(0, pTerm->pExpr, 0);
132041 Expr *pRight = pTerm->pExpr->pRight;
132042 testcase( pTerm->pExpr->op==TK_IS );
132080 int nCmp = sqlite3ExprVectorSize(pTerm->pExpr->pLeft);
132090 Expr *pLhs = pTerm->pExpr->pLeft->x.pList->a[i].pExpr;
132091 Expr *pRhs = pTerm->pExpr->pRight;
132093 pRhs = pRhs->x.pSelect->pEList->a[i].pExpr;
132095 pRhs = pRhs->x.pList->a[i].pExpr;
132223 && !ExprHasProperty(pTerm->pExpr, EP_FromJoin)
132252 Expr *pExpr = pTerm->pExpr;
132254 if( ExprHasProperty(pExpr, EP_xIsSelect) ){
132265 if( pNew->aLTerm[i] && pNew->aLTerm[i]->pExpr==pExpr ) nIn = 0;
132267 }else if( ALWAYS(pExpr->x.pList && pExpr->x.pList->nExpr) ){
132269 nIn = sqlite3LogEst(pExpr->x.pList->nExpr);
132348 && ((eOp & WO_IN)==0 || !ExprHasProperty(pTerm->pExpr, EP_xIsSelect))
132350 Expr *pExpr = pTerm->pExpr;
132355 rc = whereEqualScanEst(pParse, pBuilder, pExpr->pRight, &nOut);
132357 rc = whereInScanEst(pParse, pBuilder, pExpr->x.pList, &nOut);
132482 Expr *pExpr = sqlite3ExprSkipCollate(pOB->a[ii].pExpr);
132483 if( pExpr->op==TK_COLUMN && pExpr->iTable==iCursor ){
132484 if( pExpr->iColumn<0 ) return 1;
132486 if( pExpr->iColumn==pIndex->aiColumn[jj] ) return 1;
132491 if( sqlite3ExprCompare(pExpr,aColExpr->a[jj].pExpr,iCursor)==0 ){
132529 Expr *pExpr = pTerm->pExpr;
132530 if( sqlite3ExprImpliesExpr(pExpr, pWhere, iTab)
132531 && (!ExprHasProperty(pExpr, EP_FromJoin) || pExpr->iRightJoinTable==iTab)
132760 if( !sqlite3ExprCoveredByIndex(pTerm->pExpr, iCur, pProbe) ){
133382 pOBExpr = sqlite3ExprSkipCollate(pOrderBy->a[i].pExpr);
133398 pColl = sqlite3ExprCollSeq(pWInfo->pParse, pOrderBy->a[i].pExpr);
133401 pColl = sqlite3ExprCollSeq(pWInfo->pParse, pTerm->pExpr);
133405 testcase( pTerm->pExpr->op==TK_IS );
133459 Expr *pX = pLoop->aLTerm[j]->pExpr;
133461 if( pLoop->aLTerm[i]->pExpr==pX ){
133499 pOBExpr = sqlite3ExprSkipCollate(pOrderBy->a[i].pExpr);
133508 if( sqlite3ExprCompare(pOBExpr,pIndex->aColExpr->a[j].pExpr,iCur) ){
133513 pColl = sqlite3ExprCollSeq(pWInfo->pParse, pOrderBy->a[i].pExpr);
133559 p = pOrderBy->a[i].pExpr;
134318 if( nTabList==0 || sqlite3ExprIsConstantNotJoin(sWLB.pWC->a[ii].pExpr) ){
134319 sqlite3ExprIfFalse(pParse, sWLB.pWC->a[ii].pExpr, pWInfo->iBreak,
134466 && !ExprHasProperty(pTerm->pExpr, EP_FromJoin)
134976 pOut->pExpr = p;
134990 pLeft->pExpr = sqlite3PExpr(pParse, op, pLeft->pExpr, pRight->pExpr);
134999 pSpan->pExpr = sqlite3PExpr(pParse, TK_NOT, pSpan->pExpr, 0);
135011 pOperand->pExpr = sqlite3PExpr(pParse, op, pOperand->pExpr, 0);
135036 pOut->pExpr = sqlite3PExpr(pParse, op, pOperand->pExpr, 0);
136417 sqlite3ExprDelete(pParse->db, (yypminor->yy190).pExpr);
137249 v.pExpr = sqlite3PExpr(pParse, TK_UMINUS, yymsp[0].minor.yy190.pExpr, 0);
137273 {sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy190.pExpr);}
137346 {sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy190.pExpr);}
137500 yymsp[-2].minor.yy148 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy148, yymsp[-1].minor.yy190.pExpr);
137606 {yymsp[-1].minor.yy72 = yymsp[0].minor.yy190.pExpr;}
137634 yymsp[-3].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy148,yymsp[-1].minor.yy190.pExpr);
137640 yymsp[-1].minor.yy148 = sqlite3ExprListAppend(pParse,0,yymsp[-1].minor.yy190.pExpr); /*A-overwrites-Y*/
137657 {yymsp[-1].minor.yy354.pLimit = yymsp[0].minor.yy190.pExpr; yymsp[-1].minor.yy354.pOffset = 0;}
137660 {yymsp[-3].minor.yy354.pLimit = yymsp[-2].minor.yy190.pExpr; yymsp[-3].minor.yy354.pOffset = yymsp[0].minor.yy190.pExpr;}
137663 {yymsp[-3].minor.yy354.pOffset = yymsp[-2].minor.yy190.pExpr; yymsp[-3].minor.yy354.pLimit = yymsp[0].minor.yy190.pExpr;}
137682 yymsp[-4].minor.yy148 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy148, yymsp[0].minor.yy190.pExpr);
137688 yymsp[-6].minor.yy148 = sqlite3ExprListAppendVector(pParse, yymsp[-6].minor.yy148, yymsp[-3].minor.yy254, yymsp[0].minor.yy190.pExpr);
137693 yylhsminor.yy148 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy190.pExpr);
137700 yymsp[-4].minor.yy148 = sqlite3ExprListAppendVector(pParse, 0, yymsp[-3].minor.yy254, yymsp[0].minor.yy190.pExpr);
137725 {spanSet(&yymsp[-2].minor.yy190,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-B*/ yymsp[-2].minor.yy190.pExpr = yymsp[-1].minor.yy190.pExpr;}
137741 yymsp[-2].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp2);
137751 yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp4);
137756 yylhsminor.yy190.pExpr = sqlite3ExprAlloc(pParse->db, TK_INTEGER, &yymsp[0].minor.yy0, 1);
137759 if( yylhsminor.yy190.pExpr ) yylhsminor.yy190.pExpr->flags |= EP_Leaf|EP_Resolved;
137768 sqlite3ExprAssignVarNumber(pParse, yymsp[0].minor.yy190.pExpr, n);
137778 yymsp[0].minor.yy190.pExpr = 0;
137780 yymsp[0].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_REGISTER, 0, 0);
137781 if( yymsp[0].minor.yy190.pExpr ) sqlite3GetInt32(&t.z[1], &yymsp[0].minor.yy190.pExpr->iTable);
137788 yymsp[-2].minor.yy190.pExpr = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy190.pExpr, &yymsp[0].minor.yy0, 1);
137795 yymsp[-5].minor.yy190.pExpr = sqlite3ExprAlloc(pParse->db, TK_CAST, &yymsp[-1].minor.yy0, 1);
137796 sqlite3ExprAttachSubtrees(pParse->db, yymsp[-5].minor.yy190.pExpr, yymsp[-3].minor.yy190.pExpr, 0);
137804 yylhsminor.yy190.pExpr = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy148, &yymsp[-4].minor.yy0);
137806 if( yymsp[-2].minor.yy194==SF_Distinct && yylhsminor.yy190.pExpr ){
137807 yylhsminor.yy190.pExpr->flags |= EP_Distinct;
137814 yylhsminor.yy190.pExpr = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0);
137821 yylhsminor.yy190.pExpr = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0);
137828 ExprList *pList = sqlite3ExprListAppend(pParse, yymsp[-3].minor.yy148, yymsp[-1].minor.yy190.pExpr);
137829 yylhsminor.yy190.pExpr = sqlite3PExpr(pParse, TK_VECTOR, 0, 0);
137830 if( yylhsminor.yy190.pExpr ){
137831 yylhsminor.yy190.pExpr->x.pList = pList;
137857 pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy190.pExpr);
137858 pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy190.pExpr);
137859 yymsp[-2].minor.yy190.pExpr = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy0);
137862 if( yymsp[-2].minor.yy190.pExpr ) yymsp[-2].minor.yy190.pExpr->flags |= EP_InfixFunc;
137870 pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy190.pExpr);
137871 pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy190.pExpr);
137872 pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy190.pExpr);
137873 yymsp[-4].minor.yy190.pExpr = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy0);
137876 if( yymsp[-4].minor.yy190.pExpr ) yymsp[-4].minor.yy190.pExpr->flags |= EP_InfixFunc;
137888 binaryToUnaryIfNull(pParse, yymsp[0].minor.yy190.pExpr, yymsp[-2].minor.yy190.pExpr, TK_ISNULL);
137894 binaryToUnaryIfNull(pParse, yymsp[0].minor.yy190.pExpr, yymsp[-3].minor.yy190.pExpr, TK_NOTNULL);
137913 ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy190.pExpr);
137914 pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy190.pExpr);
137915 yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy190.pExpr, 0);
137916 if( yymsp[-4].minor.yy190.pExpr ){
137917 yymsp[-4].minor.yy190.pExpr->x.pList = pList;
137936 sqlite3ExprDelete(pParse->db, yymsp[-4].minor.yy190.pExpr);
137937 yymsp[-4].minor.yy190.pExpr = sqlite3ExprAlloc(pParse->db, TK_INTEGER,&sqlite3IntTokens[yymsp[-3].minor.yy194],1);
137955 Expr *pRHS = yymsp[-1].minor.yy148->a[0].pExpr;
137956 yymsp[-1].minor.yy148->a[0].pExpr = 0;
137964 yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, yymsp[-3].minor.yy194 ? TK_NE : TK_EQ, yymsp[-4].minor.yy190.pExpr, pRHS);
137966 yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy190.pExpr, 0);
137967 if( yymsp[-4].minor.yy190.pExpr ){
137968 yymsp[-4].minor.yy190.pExpr->x.pList = yymsp[-1].minor.yy148;
137969 sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy190.pExpr);
137981 yymsp[-2].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_SELECT, 0, 0);
137982 sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy190.pExpr, yymsp[-1].minor.yy243);
137987 yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy190.pExpr, 0);
137988 sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy190.pExpr, yymsp[-1].minor.yy243);
137998 yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy190.pExpr, 0);
137999 sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy190.pExpr, pSelect);
138008 p = yymsp[-3].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_EXISTS, 0, 0);
138015 yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy72, 0);
138016 if( yymsp[-4].minor.yy190.pExpr ){
138017 yymsp[-4].minor.yy190.pExpr->x.pList = yymsp[-1].minor.yy72 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy148,yymsp[-1].minor.yy72) : yymsp[-2].minor.yy148;
138018 sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy190.pExpr);
138027 yymsp[-4].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy148, yymsp[-2].minor.yy190.pExpr);
138028 yymsp[-4].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy148, yymsp[0].minor.yy190.pExpr);
138033 yymsp[-3].minor.yy148 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy190.pExpr);
138034 yymsp[-3].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy148, yymsp[0].minor.yy190.pExpr);
138038 {yymsp[0].minor.yy72 = yymsp[0].minor.yy190.pExpr; /*A-overwrites-X*/}
138041 {yymsp[-2].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy148,yymsp[0].minor.yy190.pExpr);}
138044 {yymsp[0].minor.yy148 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy190.pExpr); /*A-overwrites-Y*/}
138137 { yymsp[-1].minor.yy72 = yymsp[0].minor.yy190.pExpr; }
138189 yymsp[-3].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0);
138190 if( yymsp[-3].minor.yy190.pExpr ){
138191 yymsp[-3].minor.yy190.pExpr->affinity = OE_Ignore;
138198 yymsp[-5].minor.yy190.pExpr = sqlite3ExprAlloc(pParse->db, TK_RAISE, &yymsp[-1].minor.yy0, 1);
138199 if( yymsp[-5].minor.yy190.pExpr ) {
138200 yymsp[-5].minor.yy190.pExpr->affinity = (char)yymsp[-3].minor.yy194;
138217 sqlite3Attach(pParse, yymsp[-3].minor.yy190.pExpr, yymsp[-1].minor.yy190.pExpr, yymsp[0].minor.yy72);
138222 sqlite3Detach(pParse, yymsp[0].minor.yy190.pExpr);
145217 Fts3Expr *pExpr; /* Parsed MATCH query string */
146958 sqlite3Fts3ExprFree(pCsr->pExpr);
148464 sqlite3Fts3ExprFree(pCsr->pExpr);
148491 p->azColumn, p->bFts4, p->nColumn, iCol, zQuery, -1, &pCsr->pExpr,
148591 }else if( iCol==p->nColumn+2 && pCsr->pExpr ){
149252 ** by pExpr.
149267 Fts3Expr *pExpr, /* Allocate readers for this expression */
149272 if( pExpr && SQLITE_OK==*pRc ){
149273 if( pExpr->eType==FTSQUERY_PHRASE ){
149275 int nToken = pExpr->pPhrase->nToken;
149278 Fts3PhraseToken *pToken = &pExpr->pPhrase->aToken[i];
149287 assert( pExpr->pPhrase->iDoclistToken==0 );
149288 pExpr->pPhrase->iDoclistToken = -1;
149290 *pnOr += (pExpr->eType==FTSQUERY_OR);
149291 fts3EvalAllocateReaders(pCsr, pExpr->pLeft, pnToken, pnOr, pRc);
149292 fts3EvalAllocateReaders(pCsr, pExpr->pRight, pnToken, pnOr, pRc);
149925 Fts3Expr *pExpr, /* Expression to initialize phrases in */
149928 if( pExpr && SQLITE_OK==*pRc ){
149929 if( pExpr->eType==FTSQUERY_PHRASE ){
149930 int nToken = pExpr->pPhrase->nToken;
149934 if( pExpr->pPhrase->aToken[i].pDeferred==0 ) break;
149936 pExpr->bDeferred = (i==nToken);
149938 *pRc = fts3EvalPhraseStart(pCsr, 1, pExpr->pPhrase);
149940 fts3EvalStartReaders(pCsr, pExpr->pLeft, pRc);
149941 fts3EvalStartReaders(pCsr, pExpr->pRight, pRc);
149942 pExpr->bDeferred = (pExpr->pLeft->bDeferred && pExpr->pRight->bDeferred);
149979 Fts3Expr *pExpr, /* Expression to consider */
149985 if( pExpr->eType==FTSQUERY_PHRASE ){
149986 Fts3Phrase *pPhrase = pExpr->pPhrase;
149997 }else if( pExpr->eType!=FTSQUERY_NOT ){
149998 assert( pExpr->eType==FTSQUERY_OR
149999 || pExpr->eType==FTSQUERY_AND
150000 || pExpr->eType==FTSQUERY_NEAR
150002 assert( pExpr->pLeft && pExpr->pRight );
150003 if( pExpr->eType==FTSQUERY_OR ){
150004 pRoot = pExpr->pLeft;
150008 fts3EvalTokenCosts(pCsr, pRoot, pExpr->pLeft, ppTC, ppOr, pRc);
150009 if( pExpr->eType==FTSQUERY_OR ){
150010 pRoot = pExpr->pRight;
150014 fts3EvalTokenCosts(pCsr, pRoot, pExpr->pRight, ppTC, ppOr, pRc);
150214 ** the full-text query currently stored in pCsr->pExpr. To iterate through
150231 fts3EvalAllocateReaders(pCsr, pCsr->pExpr, &nToken, &nOr, &rc);
150251 fts3EvalTokenCosts(pCsr, 0, pCsr->pExpr, &pTC, &ppOr, &rc);
150267 fts3EvalStartReaders(pCsr, pCsr->pExpr, &rc);
150346 ** successful, the following variables in pExpr are set:
150381 Fts3Expr *pExpr, /* Expr. to advance to next matching row */
150386 assert( pExpr->bEof==0 );
150387 pExpr->bStart = 1;
150389 switch( pExpr->eType ){
150392 Fts3Expr *pLeft = pExpr->pLeft;
150393 Fts3Expr *pRight = pExpr->pRight;
150400 pExpr->iDocid = pRight->iDocid;
150401 pExpr->bEof = pRight->bEof;
150406 pExpr->iDocid = pLeft->iDocid;
150407 pExpr->bEof = pLeft->bEof;
150421 pExpr->iDocid = pLeft->iDocid;
150422 pExpr->bEof = (pLeft->bEof || pRight->bEof);
150423 if( pExpr->eType==FTSQUERY_NEAR && pExpr->bEof ){
150444 Fts3Expr *pLeft = pExpr->pLeft;
150445 Fts3Expr *pRight = pExpr->pRight;
150460 pExpr->bEof = (pLeft->bEof && pRight->bEof);
150463 pExpr->iDocid = pLeft->iDocid;
150465 pExpr->iDocid = pRight->iDocid;
150472 Fts3Expr *pLeft = pExpr->pLeft;
150473 Fts3Expr *pRight = pExpr->pRight;
150489 pExpr->iDocid = pLeft->iDocid;
150490 pExpr->bEof = pLeft->bEof;
150495 Fts3Phrase *pPhrase = pExpr->pPhrase;
150497 *pRc = fts3EvalPhraseNext(pCsr, pPhrase, &pExpr->bEof);
150498 pExpr->iDocid = pPhrase->doclist.iDocid;
150506 ** If *pRc is not SQLITE_OK, or if pExpr is not the root node of a NEAR
150520 static int fts3EvalNearTest(Fts3Expr *pExpr, int *pRc){
150523 /* The following block runs if pExpr is the root of a NEAR query.
150544 && pExpr->eType==FTSQUERY_NEAR
150545 && pExpr->bEof==0
150546 && (pExpr->pParent==0 || pExpr->pParent->eType!=FTSQUERY_NEAR)
150553 for(p=pExpr; p->pLeft; p=p->pLeft){
150574 aPoslist = pExpr->pRight->pPhrase->doclist.pList;
150575 nToken = pExpr->pRight->pPhrase->nToken;
150576 for(p=pExpr->pLeft; p && res; p=p->pLeft){
150608 Fts3Expr *pExpr, /* Expr to test. May or may not be root. */
150613 switch( pExpr->eType ){
150617 fts3EvalTestExpr(pCsr, pExpr->pLeft, pRc)
150618 && fts3EvalTestExpr(pCsr, pExpr->pRight, pRc)
150619 && fts3EvalNearTest(pExpr, pRc)
150638 && pExpr->eType==FTSQUERY_NEAR
150639 && (pExpr->pParent==0 || pExpr->pParent->eType!=FTSQUERY_NEAR)
150642 for(p=pExpr; p->pPhrase==0; p=p->pLeft){
150655 int bHit1 = fts3EvalTestExpr(pCsr, pExpr->pLeft, pRc);
150656 int bHit2 = fts3EvalTestExpr(pCsr, pExpr->pRight, pRc);
150663 fts3EvalTestExpr(pCsr, pExpr->pLeft, pRc)
150664 && !fts3EvalTestExpr(pCsr, pExpr->pRight, pRc)
150671 && (pExpr->iDocid==pCsr->iPrevId || pExpr->bDeferred)
150673 Fts3Phrase *pPhrase = pExpr->pPhrase;
150674 assert( pExpr->bDeferred || pPhrase->doclist.bFreeList==0 );
150675 if( pExpr->bDeferred ){
150680 pExpr->iDocid = pCsr->iPrevId;
150684 bHit = (pExpr->bEof==0 && pExpr->iDocid==pCsr->iPrevId);
150734 bMiss = (0==fts3EvalTestExpr(pCsr, pCsr->pExpr, &rc));
150745 ** Fts3Cursor.pExpr.
150749 Fts3Expr *pExpr = pCsr->pExpr;
150751 if( pExpr==0 ){
150759 fts3EvalNextRow(pCsr, pExpr, &rc);
150760 pCsr->isEof = pExpr->bEof;
150763 pCsr->iPrevId = pExpr->iDocid;
150780 ** Restart interation for expression pExpr so that the next call to
150790 Fts3Expr *pExpr,
150793 if( pExpr && *pRc==SQLITE_OK ){
150794 Fts3Phrase *pPhrase = pExpr->pPhrase;
150814 pExpr->iDocid = 0;
150815 pExpr->bEof = 0;
150816 pExpr->bStart = 0;
150818 fts3EvalRestart(pCsr, pExpr->pLeft, pRc);
150819 fts3EvalRestart(pCsr, pExpr->pRight, pRc);
150825 ** expression rooted at pExpr, the cursor iterates through all rows matched
150826 ** by pExpr, calling this function for each row. This function increments
150831 static void fts3EvalUpdateCounts(Fts3Expr *pExpr){
150832 if( pExpr ){
150833 Fts3Phrase *pPhrase = pExpr->pPhrase;
150850 pExpr->aMI[iCol*3 + 1] += iCnt;
150851 pExpr->aMI[iCol*3 + 2] += (iCnt>0);
150858 fts3EvalUpdateCounts(pExpr->pLeft);
150859 fts3EvalUpdateCounts(pExpr->pRight);
150864 ** Expression pExpr must be of type FTSQUERY_PHRASE.
150867 pExpr. If pExpr is part
150876 Fts3Expr *pExpr /* FTSQUERY_PHRASE expression */
150880 assert( pExpr->eType==FTSQUERY_PHRASE );
150881 if( pExpr->aMI==0 ){
150891 pRoot = pExpr;
150987 Fts3Expr *pExpr, /* Phrase expression */
150994 if( pExpr->bDeferred && pExpr->pParent->eType!=FTSQUERY_NEAR ){
151001 rc = fts3EvalGatherStats(pCsr, pExpr);
151003 assert( pExpr->aMI );
151005 aiOut[iCol*3 + 1] = pExpr->aMI[iCol*3 + 1];
151006 aiOut[iCol*3 + 2] = pExpr->aMI[iCol*3 + 2];
151015 ** The expression pExpr passed as the second argument to this function
151035 Fts3Expr *pExpr, /* Phrase to return doclist for */
151039 Fts3Phrase *pPhrase = pExpr->pPhrase;
151053 iDocid = pExpr->iDocid;
151055 if( iDocid!=pCsr->iPrevId || pExpr->bEof ){
151060 Fts3Expr *p; /* Used to iterate from pExpr to root */
151061 Fts3Expr *pNear; /* Most senior NEAR ancestor (or pExpr) */
151069 pNear = pExpr;
151070 for(p=pExpr->pParent; p; p=p->pParent){
152912 static char *exprToString(Fts3Expr *pExpr, char *zBuf){
152913 if( pExpr==0 ){
152916 switch( pExpr->eType ){
152918 Fts3Phrase *pPhrase = pExpr->pPhrase;
152932 zBuf = sqlite3_mprintf("%zNEAR/%d ", zBuf, pExpr->nNear);
152946 if( zBuf ) zBuf = exprToString(pExpr->pLeft, zBuf);
152949 if( zBuf ) zBuf = exprToString(pExpr->pRight, zBuf);
152982 Fts3Expr *pExpr;
153026 pTokenizer, 0, azCol, 0, nCol, nCol, zExpr, nExpr, &pExpr, &zDummy
153028 assert( rc==SQLITE_OK || pExpr==0 );
153032 pTokenizer, 0, azCol, 0, nCol, nCol, zExpr, nExpr, &pExpr
153037 sqlite3Fts3ExprFree(pExpr);
153039 }else if( rc==SQLITE_NOMEM || !(zBuf = exprToString(pExpr, 0)) ){
153046 sqlite3Fts3ExprFree(pExpr);
161268 Fts3Expr *pExpr, /* Expression to iterate phrases of */
161274 int eType = pExpr->eType; /* Type of expression node pExpr */
161277 assert( pExpr->pLeft && pExpr->pRight );
161278 rc = fts3ExprIterate2(pExpr->pLeft, piPhrase, x, pCtx);
161280 rc = fts3ExprIterate2(pExpr->pRight, piPhrase, x, pCtx);
161283 rc = x(pExpr, *piPhrase, pCtx);
161300 Fts3Expr *pExpr, /* Expression to iterate phrases of */
161305 return fts3ExprIterate2(pExpr, &iPhrase, x, pCtx);
161314 static int fts3ExprLoadDoclistsCb(Fts3Expr *pExpr, int iPhrase, void *ctx){
161316 Fts3Phrase *pPhrase = pExpr->pPhrase;
161345 rc = fts3ExprIterate(pCsr->pExpr, fts3ExprLoadDoclistsCb, (void *)&sCtx);
161351 static int fts3ExprPhraseCountCb(Fts3Expr *pExpr, int iPhrase, void *ctx){
161353 pExpr->iPhrase = iPhrase;
161356 static int fts3ExprPhraseCount(Fts3Expr *pExpr){
161358 (void)fts3ExprIterate(pExpr, fts3ExprPhraseCountCb, (void *)&nPhrase);
161488 static int fts3SnippetFindPositions(Fts3Expr *pExpr, int iPhrase, void *ctx){
161494 pPhrase->nToken = pExpr->pPhrase->nToken;
161495 rc = sqlite3Fts3EvalPhrasePoslist(p->pCsr, pExpr, p->iCol, &pCsr);
161574 rc = fts3ExprIterate(pCsr->pExpr, fts3SnippetFindPositions, (void*)&sIter);
161879 Fts3Expr *pExpr, /* Phrase expression node */
161884 Fts3Phrase *pPhrase = pExpr->pPhrase;
161890 iStart = pExpr->iPhrase * p->nCol;
161892 iStart = pExpr->iPhrase * ((p->nCol + 31) / 32);
161915 Fts3Expr *pExpr,
161918 assert( (pExpr->pLeft==0)==(pExpr->pRight==0) );
161919 if( pExpr->bEof==0 && pExpr->iDocid==p->pCursor->iPrevId ){
161920 if( pExpr->pLeft ){
161921 fts3ExprLHitGather(pExpr->pLeft, p);
161922 fts3ExprLHitGather(pExpr->pRight, p);
161924 fts3ExprLHits(pExpr, p);
161950 ** If the phrase pExpr consists entirely of deferred tokens, then all X and
161957 Fts3Expr *pExpr, /* Phrase expression node */
161963 p->pCursor, pExpr, &p->aMatchinfo[3*iPhrase*p->nCol]
161973 Fts3Expr *pExpr, /* Phrase expression node */
161984 rc = sqlite3Fts3EvalPhrasePoslist(p->pCursor, pExpr, i, &pCsr);
162083 Fts3Expr *pExpr; /* Pointer to phrase expression */
162096 Fts3Expr *pExpr, /* Phrase expression node */
162101 aIter[iPhrase].pExpr = pExpr;
162150 (void)fts3ExprIterate(pCsr->pExpr, fts3MatchinfoLcsCb, (void*)aIter);
162154 nToken -= pIter->pExpr->pPhrase->nToken;
162165 rc = sqlite3Fts3EvalPhrasePoslist(pCsr, pIt->pExpr, iCol, &pIt->pRead);
162298 fts3ExprLHitGather(pCsr->pExpr, pInfo);
162303 Fts3Expr *pExpr;
162305 pExpr = pCsr->pExpr;
162313 rc = fts3ExprIterate(pExpr, fts3ExprGlobalHitsCb,(void*)pInfo);
162317 (void)fts3ExprIterate(pExpr, fts3ExprLocalHitsCb,(void*)pInfo);
162369 pCsr->nPhrase = fts3ExprPhraseCount(pCsr->pExpr);
162445 if( !pCsr->pExpr ){
162538 static int fts3ExprTermOffsetInit(Fts3Expr *pExpr, int iPhrase, void *ctx){
162547 rc = sqlite3Fts3EvalPhrasePoslist(p->pCsr, pExpr, p->iCol, &pList);
162548 nTerm = pExpr->pPhrase->nToken;
162579 if( !pCsr->pExpr ){
162619 (void)fts3ExprIterate(pCsr->pExpr, fts3ExprTermOffsetInit, (void*)&sCtx);
162719 if( !pCsr->pExpr ){
167519 URegularExpression *pExpr = (URegularExpression *)p;
167520 uregex_close(pExpr);
167544 URegularExpression *pExpr;
167557 pExpr = sqlite3_get_auxdata(p, 0);
167558 if( !pExpr ){
167563 pExpr = uregex_open(zPattern, -1, 0, 0, &status);
167566 sqlite3_set_auxdata(p, 0, pExpr, icuRegexpDelete);
167568 assert(!pExpr);
167575 uregex_setText(pExpr, zString, -1, &status);
167582 res = uregex_matches(pExpr, 0, &status);
167593 uregex_setText(pExpr, 0, 0, &status);
182437 ** for(rc = sqlite3Fts5ExprFirst(pExpr, pIdx, bDesc);
182438 ** rc==SQLITE_OK && 0==sqlite3Fts5ExprEof(pExpr);
182439 ** rc = sqlite3Fts5ExprNext(pExpr)
182442 ** i64 iRowid = sqlite3Fts5ExprRowid(pExpr);
186047 Fts5ExprNode *pExpr; /* Result of a successful parse */
186164 sqlite3Fts5ParseNodeFree(sParse.pExpr);
186166 if( !sParse.pExpr ){
186173 pNew->pRoot = sParse.pExpr;
186182 sqlite3Fts5ParseNodeFree(sParse.pExpr);
186618 Fts5Expr *pExpr, /* Expression that pNear is a part of */
186624 if( pExpr->pConfig->eDetail!=FTS5_DETAIL_FULL ){
186674 Fts5Expr *pExpr,
186700 pExpr->pIndex, p->zTerm, (int)strlen(p->zTerm),
186702 (pExpr->bDesc ? FTS5INDEX_QUERY_DESC : 0),
186726 ** If pExpr is an ASC iterator, this function returns a value with the
186736 Fts5Expr *pExpr,
186740 assert( pExpr->bDesc==0 || pExpr->bDesc==1 );
186741 if( pExpr->bDesc==0 ){
186790 Fts5Expr *pExpr,
186796 return fts5RowidCmp(pExpr, p1->iRowid, p2->iRowid);
186811 Fts5Expr *pExpr, /* Expression pPhrase belongs to */
186820 const int bDesc = pExpr->bDesc;
186866 pNode->bNomatch = ((0==fts5ExprNearTest(&rc, pExpr, pNode)) && rc==SQLITE_OK);
186880 Fts5Expr *pExpr, /* Expression pPhrase belongs to */
186894 i64 iRowid = fts5ExprSynonymRowid(pTerm, pExpr->bDesc, 0);
186902 || (bFromValid && ii!=iFrom && (ii>iFrom)==pExpr->bDesc)
186937 rc = fts5ExprNodeTest_STRING(pExpr, pNode);
186945 Fts5Expr *pExpr, /* Expression that pNear is a part of */
186961 if( pExpr->pConfig->eDetail==FTS5_DETAIL_FULL ){
186973 Fts5Expr *pExpr,
186988 rc = fts5ExprNodeTest_TERM(pExpr, pNode);
186997 Fts5Expr *pExpr, /* Expression of which pNode is a part */
187005 int cmp = fts5NodeCompare(pExpr, pNext, pChild);
187016 Fts5Expr *pExpr,
187026 assert( p1->bEof || fts5RowidCmp(pExpr, p1->iRowid, iLast)>=0 );
187029 || (bFromValid && fts5RowidCmp(pExpr, p1->iRowid, iFrom)<0)
187031 int rc = fts5ExprNodeNext(pExpr, p1, bFromValid, iFrom);
187040 fts5ExprNodeTest_OR(pExpr, pNode);
187048 Fts5Expr *pExpr, /* Expression pPhrase belongs to */
187062 int cmp = fts5RowidCmp(pExpr, iLast, pChild->iRowid);
187065 rc = fts5ExprNodeNext(pExpr, pChild, 1, iLast);
187076 assert( pChild->bEof || fts5RowidCmp(pExpr, iLast, pChild->iRowid)<=0 );
187092 if( pAnd->bNomatch && pAnd!=pExpr->pRoot ){
187100 Fts5Expr *pExpr,
187105 int rc = fts5ExprNodeNext(pExpr, pNode->apChild[0], bFromValid, iFrom);
187107 rc = fts5ExprNodeTest_AND(pExpr, pNode);
187115 Fts5Expr *pExpr, /* Expression pPhrase belongs to */
187124 int cmp = fts5NodeCompare(pExpr, p1, p2);
187126 pExpr, p2, 1, p1->iRowid);
187127 cmp = fts5NodeCompare(pExpr, p1, p2);
187131 rc = fts5ExprNodeNext(pExpr, p1, 0, 0);
187143 Fts5Expr *pExpr,
187148 int rc = fts5ExprNodeNext(pExpr, pNode->apChild[0], bFromValid, iFrom);
187150 rc = fts5ExprNodeTest_NOT(pExpr, pNode);
187164 Fts5Expr *pExpr, /* Expression of which pNode is a part */
187172 rc = fts5ExprNodeTest_STRING(pExpr, pNode);
187177 rc = fts5ExprNodeTest_TERM(pExpr, pNode);
187182 rc = fts5ExprNodeTest_AND(pExpr, pNode);
187187 fts5ExprNodeTest_OR(pExpr, pNode);
187192 rc = fts5ExprNodeTest_NOT(pExpr, pNode);
187202 ** Set node pNode, which is part of expression pExpr, to point to the first
187208 static int fts5ExprNodeFirst(Fts5Expr *pExpr, Fts5ExprNode *pNode){
187215 rc = fts5ExprNearInitAll(pExpr, pNode);
187223 rc = fts5ExprNodeFirst(pExpr, pNode->apChild[i]);
187246 rc = fts5ExprNodeTest(pExpr, pNode);
187509 assert( pParse->pExpr==0 );
187510 pParse->pExpr = p;
187580 Fts5Expr *pExpr,
187585 Fts5ExprPhrase *pOrig; /* The phrase extracted from pExpr */
187589 pOrig = pExpr->apExprPhrase[iPhrase];
187638 pNew->pIndex = pExpr->pIndex;
187639 pNew->pConfig = pExpr->pConfig;
188063 ** Compose a tcl-readable representation of expression pExpr. Return a
188071 Fts5ExprNode *pExpr
188074 if( pExpr->eType==FTS5_STRING || pExpr->eType==FTS5_TERM ){
188075 Fts5ExprNearset *pNear = pExpr->pNear;
188123 switch( pExpr->eType ){
188127 assert( pExpr->eType==FTS5_OR );
188133 for(i=0; zRet && i<pExpr->nChild; i++){
188134 char *z = fts5ExprPrintTcl(pConfig, zNearsetCmd, pExpr->apChild[i]);
188147 static char *fts5ExprPrint(Fts5Config *pConfig, Fts5ExprNode *pExpr){
188149 if( pExpr->eType==0 ){
188152 if( pExpr->eType==FTS5_STRING || pExpr->eType==FTS5_TERM ){
188153 Fts5ExprNearset *pNear = pExpr->pNear;
188196 switch( pExpr->eType ){
188200 assert( pExpr->eType==FTS5_OR );
188205 for(i=0; i<pExpr->nChild; i++){
188206 char *z = fts5ExprPrint(pConfig, pExpr->apChild[i]);
188211 int e = pExpr->apChild[i]->eType;
188239 Fts5Expr *pExpr = 0;
188280 rc = sqlite3Fts5ExprNew(pConfig, zExpr, &pExpr, &zErr);
188284 if( pExpr->pRoot->xNext==0 ){
188287 zText = fts5ExprPrintTcl(pConfig, zNearsetCmd, pExpr->pRoot);
188289 pExpr->pRoot);
188309 sqlite3Fts5ExprFree(pExpr);
188398 ** Return the number of phrases in expression pExpr.
188400 static int sqlite3Fts5ExprPhraseCount(Fts5Expr *pExpr){
188401 return (pExpr ? pExpr->nPhrase : 0);
188405 ** Return the number of terms in the iPhrase'th phrase in pExpr.
188407 static int sqlite3Fts5ExprPhraseSize(Fts5Expr *pExpr, int iPhrase){
188408 if( iPhrase<0 || iPhrase>=pExpr->nPhrase ) return 0;
188409 return pExpr->apExprPhrase[iPhrase]->nTerm;
188416 static int sqlite3Fts5ExprPoslist(Fts5Expr *pExpr, int iPhrase, const u8 **pa){
188418 Fts5ExprPhrase *pPhrase = pExpr->apExprPhrase[iPhrase];
188420 if( pNode->bEof==0 && pNode->iRowid==pExpr->pRoot->iRowid ){
188436 static Fts5PoslistPopulator *sqlite3Fts5ExprClearPoslists(Fts5Expr *pExpr, int bLive){
188438 pRet = sqlite3_malloc(sizeof(Fts5PoslistPopulator)*pExpr->nPhrase);
188441 memset(pRet, 0, sizeof(Fts5PoslistPopulator)*pExpr->nPhrase);
188442 for(i=0; i<pExpr->nPhrase; i++){
188443 Fts5Buffer *pBuf = &pExpr->apExprPhrase[i]->poslist;
188444 Fts5ExprNode *pNode = pExpr->apExprPhrase[i]->pNode;
188445 assert( pExpr->apExprPhrase[i]->nTerm==1 );
188447 (pBuf->n==0 || pNode->iRowid!=pExpr->pRoot->iRowid || pNode->bEof)
188459 Fts5Expr *pExpr;
188485 Fts5Expr *pExpr = p->pExpr;
188492 for(i=0; i<pExpr->nPhrase; i++){
188495 for(pTerm=&pExpr->apExprPhrase[i]->aTerm[0]; pTerm; pTerm=pTerm->pSynonym){
188501 &pExpr->apExprPhrase[i]->poslist, &p->aPopulator[i].writer, p->iOff
188513 Fts5Expr *pExpr,
188520 sCtx.pExpr = pExpr;
188524 for(i=0; i<pExpr->nPhrase; i++){
188525 Fts5ExprNode *pNode = pExpr->apExprPhrase[i]->pNode;
188596 static void sqlite3Fts5ExprCheckPoslists(Fts5Expr *pExpr, i64 iRowid){
188597 fts5ExprCheckPoslists(pExpr->pRoot, iRowid);
188604 Fts5Expr *pExpr,
188609 Fts5ExprPhrase *pPhrase = pExpr->apExprPhrase[iPhrase];
188613 assert( iPhrase>=0 && iPhrase<pExpr->nPhrase );
188614 assert( pExpr->pConfig->eDetail==FTS5_DETAIL_COLUMNS );
188617 && pNode->iRowid==pExpr->pRoot->iRowid
195840 Fts5Expr *pExpr; /* Expression for MATCH queries */
196334 sqlite3Fts5ExprFree(pCsr->pExpr);
196447 i64 iRowid = sqlite3Fts5ExprRowid(pCsr->pExpr);
196449 rc = sqlite3Fts5ExprFirst(pCsr->pExpr, pTab->pIndex, iRowid, bDesc);
196450 if( rc==SQLITE_OK && iRowid!=sqlite3Fts5ExprRowid(pCsr->pExpr) ){
196456 if( sqlite3Fts5ExprEof(pCsr->pExpr) ){
196485 rc = sqlite3Fts5ExprNext(pCsr->pExpr, pCsr->iLastRowid);
196486 CsrFlagSet(pCsr, sqlite3Fts5ExprEof(pCsr->pExpr));
196554 nPhrase = sqlite3Fts5ExprPhraseCount(pCsr->pExpr);
196595 Fts5Expr *pExpr = pCsr->pExpr;
196596 rc = sqlite3Fts5ExprFirst(pExpr, pTab->pIndex, pCsr->iFirstRowid, bDesc);
196597 if( sqlite3Fts5ExprEof(pExpr) ){
196795 assert( pCsr->pExpr==0 );
196845 pCsr->pExpr = pTab->pSortCsr->pExpr;
196860 rc = sqlite3Fts5ExprNew(pConfig, zExpr, &pCsr->pExpr, pzErr);
196919 return sqlite3Fts5ExprRowid(pCsr->pExpr);
196975 assert( pCsr->pExpr );
197320 return sqlite3Fts5ExprPhraseCount(pCsr->pExpr);
197325 return sqlite3Fts5ExprPhraseSize(pCsr->pExpr, iPhrase);
197364 aPopulator = sqlite3Fts5ExprClearPoslists(pCsr->pExpr, bLive);
197371 pConfig, pCsr->pExpr, aPopulator, i, z, n
197378 sqlite3Fts5ExprCheckPoslists(pCsr->pExpr, pCsr->pSorter->iRowid);
197390 *pn = sqlite3Fts5ExprPoslist(pCsr->pExpr, iPhrase, pa);
197406 nIter = sqlite3Fts5ExprPhraseCount(pCsr->pExpr);
197724 rc = sqlite3Fts5ExprPhraseCollist(pCsr->pExpr, iPhrase, &pIter->a, &n);
197797 rc = sqlite3Fts5ExprClonePhrase(pCsr->pExpr, iPhrase, &pNew->pExpr);
197903 int nPhrase = sqlite3Fts5ExprPhraseCount(pCsr->pExpr);
197913 int nByte = sqlite3Fts5ExprPoslist(pCsr->pExpr, i, &dummy);
197921 nPoslist = sqlite3Fts5ExprPoslist(pCsr->pExpr, i, &pPoslist);
197932 rc = sqlite3Fts5ExprPhraseCollist(pCsr->pExpr, i, &dummy, &nByte);
197940 rc = sqlite3Fts5ExprPhraseCollist(pCsr->pExpr, i, &pPoslist, &nPoslist);