Lines Matching refs:pExpr
10433 ** AggInfo.pGroupBy and AggInfo.aFunc.pExpr point to fields within the
10452 Expr *pExpr; /* The original expression */
10459 Expr *pExpr; /* Expression encoding the function */
10663 Expr *pExpr; /* The list of expressions */
10679 Expr *pExpr; /* The expression parse tree */
11863 SQLITE_PRIVATE char sqlite3CompareAffinity(Expr *pExpr, char aff2);
11864 SQLITE_PRIVATE int sqlite3IndexAffinityOk(Expr *pExpr, char idx_affinity);
11865 SQLITE_PRIVATE char sqlite3ExprAffinity(Expr *pExpr);
11875 SQLITE_PRIVATE CollSeq *sqlite3ExprCollSeq(Parse *pParse, Expr *pExpr);
59385 ** Create a new sqlite3_value object, containing the value of pExpr.
59396 Expr *pExpr, /* The expression to evaluate */
59407 if( !pExpr ){
59411 op = pExpr->op;
59418 if( op==TK_REGISTER ) op = pExpr->op2;
59420 if( NEVER(op==TK_REGISTER) ) op = pExpr->op2;
59427 && (pExpr->pLeft->op==TK_INTEGER || pExpr->pLeft->op==TK_FLOAT) ){
59428 pExpr = pExpr->pLeft;
59429 op = pExpr->op;
59437 if( ExprHasProperty(pExpr, EP_IntValue) ){
59438 sqlite3VdbeMemSetInt64(pVal, (i64)pExpr->u.iValue*negInt);
59440 zVal = sqlite3MPrintf(db, "%s%s", zNeg, pExpr->u.zToken);
59456 if( SQLITE_OK==sqlite3ValueFromExpr(db,pExpr->pLeft,enc,affinity,&pVal) ){
59475 assert( pExpr->u.zToken[0]=='x' || pExpr->u.zToken[0]=='X' );
59476 assert( pExpr->u.zToken[1]=='\'' );
59479 zVal = &pExpr->u.zToken[2];
73103 SQLITE_PRIVATE int sqlite3WalkExpr(Walker *pWalker, Expr *pExpr){
73105 if( pExpr==0 ) return WRC_Continue;
73106 testcase( ExprHasProperty(pExpr, EP_TokenOnly) );
73107 testcase( ExprHasProperty(pExpr, EP_Reduced) );
73108 rc = pWalker->xExprCallback(pWalker, pExpr);
73110 && !ExprHasAnyProperty(pExpr,EP_TokenOnly) ){
73111 if( sqlite3WalkExpr(pWalker, pExpr->pLeft) ) return WRC_Abort;
73112 if( sqlite3WalkExpr(pWalker, pExpr->pRight) ) return WRC_Abort;
73113 if( ExprHasProperty(pExpr, EP_xIsSelect) ){
73114 if( sqlite3WalkSelect(pWalker, pExpr->x.pSelect) ) return WRC_Abort;
73116 if( sqlite3WalkExprList(pWalker, pExpr->x.pList) ) return WRC_Abort;
73131 if( sqlite3WalkExpr(pWalker, pItem->pExpr) ) return WRC_Abort;
73224 ** Turn the pExpr expression into an alias for the iCol-th column of the
73254 Expr *pExpr, /* Transform this into an alias to the result set */
73262 pOrig = pEList->a[iCol].pExpr;
73288 if( pExpr->flags & EP_ExpCollate ){
73289 pDup->pColl = pExpr->pColl;
73297 ExprSetProperty(pExpr, EP_Static);
73298 sqlite3ExprDelete(db, pExpr);
73299 memcpy(pExpr, pDup, sizeof(*pExpr));
73323 ** that name in the set of source tables in pSrcList and make the pExpr
73325 ** are made to pExpr:
73327 ** pExpr->iDb Set the index in db->aDb[] of the database X
73329 ** pExpr->iTable Set to the cursor number for the table obtained
73331 ** pExpr->pTab Points to the Table structure of X.Y (even if
73333 ** pExpr->iColumn Set to the column number within the table.
73334 ** pExpr->op Set to TK_COLUMN.
73335 ** pExpr->pLeft Any expression this points to is deleted
73336 ** pExpr->pRight Any expression this points to is deleted.
73354 Expr *pExpr /* Make this EXPR node point to the selected column */
73368 assert( ~ExprHasAnyProperty(pExpr, EP_TokenOnly|EP_Reduced) );
73371 pExpr->iTable = -1;
73372 pExpr->pTab = 0;
73373 ExprSetIrreducible(pExpr);
73405 pExpr->iTable = pItem->iCursor;
73406 pExpr->pTab = pTab;
73421 pExpr->iTable = pItem->iCursor;
73422 pExpr->pTab = pTab;
73426 pExpr->iColumn = j==pTab->iPKey ? -1 : (i16)j;
73442 pExpr->iTable = 1;
73445 pExpr->iTable = 0;
73468 pExpr->affinity = SQLITE_AFF_INTEGER;
73469 }else if( pExpr->iTable==0 ){
73478 pExpr->iColumn = (i16)iCol;
73479 pExpr->pTab = pTab;
73491 pExpr->iColumn = -1; /* IMP: R-44911-55124 */
73492 pExpr->affinity = SQLITE_AFF_INTEGER;
73502 ** In cases like this, replace pExpr with a copy of the expression that
73512 assert( pExpr->pLeft==0 && pExpr->pRight==0 );
73513 assert( pExpr->x.pList==0 );
73514 assert( pExpr->x.pSelect==0 );
73515 pOrig = pEList->a[j].pExpr;
73520 resolveAlias(pParse, pEList, j, pExpr, "");
73542 ** pExpr.
73547 if( cnt==0 && zTab==0 && ExprHasProperty(pExpr,EP_DblQuoted) ){
73548 pExpr->op = TK_STRING;
73549 pExpr->pTab = 0;
73577 if( pExpr->iColumn>=0 && pMatch!=0 ){
73578 int n = pExpr->iColumn;
73583 assert( pMatch->iCursor==pExpr->iTable );
73589 sqlite3ExprDelete(db, pExpr->pLeft);
73590 pExpr->pLeft = 0;
73591 sqlite3ExprDelete(db, pExpr->pRight);
73592 pExpr->pRight = 0;
73593 pExpr->op = (isTrigger ? TK_TRIGGER : TK_COLUMN);
73597 sqlite3AuthRead(pParse, pExpr, pSchema, pNC->pSrcList);
73646 static int resolveExprStep(Walker *pWalker, Expr *pExpr){
73655 if( ExprHasAnyProperty(pExpr, EP_Resolved) ) return WRC_Prune;
73656 ExprSetProperty(pExpr, EP_Resolved);
73666 switch( pExpr->op ){
73678 pExpr->op = TK_COLUMN;
73679 pExpr->pTab = pItem->pTab;
73680 pExpr->iTable = pItem->iCursor;
73681 pExpr->iColumn = -1;
73682 pExpr->affinity = SQLITE_AFF_INTEGER;
73690 return lookupName(pParse, 0, 0, pExpr->u.zToken, pNC, pExpr);
73703 pRight = pExpr->pRight;
73706 zTable = pExpr->pLeft->u.zToken;
73710 zDb = pExpr->pLeft->u.zToken;
73714 return lookupName(pParse, zDb, zTable, zColumn, pNC, pExpr);
73721 ExprList *pList = pExpr->x.pList; /* The argument list */
73732 testcase( pExpr->op==TK_CONST_FUNC );
73733 assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
73734 zId = pExpr->u.zToken;
73756 pExpr->op = TK_NULL;
73774 pExpr->op = TK_AGG_FUNCTION;
73780 /* FIX ME: Compute pExpr->affinity based on the expected return
73787 case TK_EXISTS: testcase( pExpr->op==TK_EXISTS );
73790 testcase( pExpr->op==TK_IN );
73791 if( ExprHasProperty(pExpr, EP_xIsSelect) ){
73798 sqlite3WalkSelect(pWalker, pExpr->x.pSelect);
73801 ExprSetProperty(pExpr, EP_VarSelect);
73904 if( sqlite3ExprCompare(pEList->a[i].pExpr, pE)<2 ){
73978 pE = pItem->pExpr;
73999 pItem->pExpr = pE = sqlite3Expr(db, TK_INTEGER, 0);
74058 resolveAlias(pParse, pEList, pItem->iOrderByCol-1, pItem->pExpr, zType);
74098 Expr *pE = pItem->pExpr;
74195 Expr *pX = pEList->a[i].pExpr;
74289 if( ExprHasProperty(pItem->pExpr, EP_Agg) ){
74363 Expr *pExpr /* The expression to be analyzed. */
74368 if( pExpr==0 ) return 0;
74372 if( sqlite3ExprCheckHeight(pParse, pExpr->nHeight+pNC->pParse->nHeight) ){
74375 pParse->nHeight += pExpr->nHeight;
74384 sqlite3WalkExpr(&w, pExpr);
74386 pNC->pParse->nHeight -= pExpr->nHeight;
74389 ExprSetProperty(pExpr, EP_Error);
74392 ExprSetProperty(pExpr, EP_Agg);
74396 return ExprHasProperty(pExpr, EP_Error);
74445 ** Return the 'affinity' of the expression pExpr if any.
74447 ** If pExpr is a column, a reference to a column via an 'AS' alias,
74460 SQLITE_PRIVATE char sqlite3ExprAffinity(Expr *pExpr){
74461 int op = pExpr->op;
74463 assert( pExpr->flags&EP_xIsSelect );
74464 return sqlite3ExprAffinity(pExpr->x.pSelect->pEList->a[0].pExpr);
74468 assert( !ExprHasProperty(pExpr, EP_IntValue) );
74469 return sqlite3AffinityType(pExpr->u.zToken);
74473 && pExpr->pTab!=0
74475 /* op==TK_REGISTER && pExpr->pTab!=0 happens when pExpr was originally
74477 int j = pExpr->iColumn;
74479 assert( pExpr->pTab && j<pExpr->pTab->nCol );
74480 return pExpr->pTab->aCol[j].affinity;
74482 return pExpr->affinity;
74489 SQLITE_PRIVATE Expr *sqlite3ExprSetColl(Expr *pExpr, CollSeq *pColl){
74490 if( pExpr && pColl ){
74491 pExpr->pColl = pColl;
74492 pExpr->flags |= EP_ExpCollate;
74494 return pExpr;
74498 ** Set the collating sequence for expression pExpr to be the collating
74504 SQLITE_PRIVATE Expr *sqlite3ExprSetCollByToken(Parse *pParse, Expr *pExpr, Token *pCollName){
74510 sqlite3ExprSetColl(pExpr, pColl);
74512 return pExpr;
74516 ** Return the default collation sequence for the expression pExpr. If
74519 SQLITE_PRIVATE CollSeq *sqlite3ExprCollSeq(Parse *pParse, Expr *pExpr){
74521 Expr *p = pExpr;
74530 /* op==TK_REGISTER && p->pTab!=0 happens when pExpr was originally
74538 pExpr->pColl = pColl;
74554 ** pExpr is an operand of a comparison operator. aff2 is the
74558 SQLITE_PRIVATE char sqlite3CompareAffinity(Expr *pExpr, char aff2){
74559 char aff1 = sqlite3ExprAffinity(pExpr);
74582 ** pExpr is a comparison operator. Return the type affinity that should
74585 static char comparisonAffinity(Expr *pExpr){
74587 assert( pExpr->op==TK_EQ || pExpr->op==TK_IN || pExpr->op==TK_LT ||
74588 pExpr->op==TK_GT || pExpr->op==TK_GE || pExpr->op==TK_LE ||
74589 pExpr->op==TK_NE || pExpr->op==TK_IS || pExpr->op==TK_ISNOT );
74590 assert( pExpr->pLeft );
74591 aff = sqlite3ExprAffinity(pExpr->pLeft);
74592 if( pExpr->pRight ){
74593 aff = sqlite3CompareAffinity(pExpr->pRight, aff);
74594 }else if( ExprHasProperty(pExpr, EP_xIsSelect) ){
74595 aff = sqlite3CompareAffinity(pExpr->x.pSelect->pEList->a[0].pExpr, aff);
74603 ** pExpr is a comparison expression, eg. '=', '<', IN(...) etc.
74606 ** the comparison in pExpr.
74608 SQLITE_PRIVATE int sqlite3IndexAffinityOk(Expr *pExpr, char idx_affinity){
74609 char aff = comparisonAffinity(pExpr);
74726 heightOfExpr(p->a[i].pExpr, pnHeight);
74973 SQLITE_PRIVATE void sqlite3ExprAssignVarNumber(Parse *pParse, Expr *pExpr){
74977 if( pExpr==0 ) return;
74978 assert( !ExprHasAnyProperty(pExpr, EP_IntValue|EP_Reduced|EP_TokenOnly) );
74979 z = pExpr->u.zToken;
74985 pExpr->iColumn = (ynVar)(++pParse->nVar);
74994 pExpr->iColumn = x = (ynVar)i;
75015 pExpr->iColumn = x = (ynVar)i+1;
75019 if( x==0 ) x = pExpr->iColumn = (ynVar)(++pParse->nVar);
75295 Expr *pOldExpr = pOldItem->pExpr;
75296 pItem->pExpr = sqlite3ExprDup(db, pOldExpr, flags);
75418 Expr *pExpr /* Expression to be appended. Might be NULL */
75441 pItem->pExpr = pExpr;
75447 sqlite3ExprDelete(db, pExpr);
75495 assert( db->mallocFailed || pItem->pExpr==pSpan->pExpr );
75528 sqlite3ExprDelete(db, pItem->pExpr);
75549 static int exprNodeIsConstant(Walker *pWalker, Expr *pExpr){
75554 if( pWalker->u.i==3 && ExprHasAnyProperty(pExpr, EP_FromJoin) ){
75559 switch( pExpr->op ){
75569 testcase( pExpr->op==TK_ID );
75570 testcase( pExpr->op==TK_COLUMN );
75571 testcase( pExpr->op==TK_AGG_FUNCTION );
75572 testcase( pExpr->op==TK_AGG_COLUMN );
75576 testcase( pExpr->op==TK_SELECT ); /* selectNodeIsConstant will disallow */
75577 testcase( pExpr->op==TK_EXISTS ); /* selectNodeIsConstant will disallow */
75699 ** was computed by pExpr. If we can look at pExpr at compile-time and
75705 const Expr *pExpr, /* Only generate OP_IsNull if this expr can be NULL */
75709 if( sqlite3ExprCanBeNull(pExpr) ){
75802 if( pEList->a[0].pExpr->op!=TK_COLUMN ) return 0; /* Result is a column */
75888 Expr *pExpr; /* Expression <column> */
75894 assert( p->pEList->a[0].pExpr!=0 ); /* Because of isCandidateForInOpt(p) */
75897 pExpr = p->pEList->a[0].pExpr;
75898 iCol = pExpr->iColumn;
75925 CollSeq *pReq = sqlite3BinaryCompareCollSeq(pParse, pX->pLeft, pExpr);
75995 ** The pExpr parameter describes the expression that contains the IN
75998 ** If parameter isRowid is non-zero, then expression pExpr is guaranteed
76022 Expr *pExpr, /* The IN, SELECT, or EXISTS operator */
76042 if( !ExprHasAnyProperty(pExpr, EP_VarSelect) ){
76050 pExpr->op==TK_IN?"LIST":"SCALAR", pParse->iNextSelectId
76056 switch( pExpr->op ){
76061 Expr *pLeft = pExpr->pLeft; /* the LHS of the IN operator */
76082 pExpr->iTable = pParse->nTab++;
76083 pExpr->iTable, !isRowid);
76088 if( ExprHasProperty(pExpr, EP_xIsSelect) ){
76098 sqlite3SelectDestInit(&dest, SRT_Set, pExpr->iTable);
76100 assert( (pExpr->iTable&0x0000FFFF)==pExpr->iTable );
76101 pExpr->x.pSelect->iLimit = 0;
76102 if( sqlite3Select(pParse, pExpr->x.pSelect, &dest) ){
76105 pEList = pExpr->x.pSelect->pEList;
76107 keyInfo.aColl[0] = sqlite3BinaryCompareCollSeq(pParse, pExpr->pLeft,
76108 pEList->a[0].pExpr);
76110 }else if( ALWAYS(pExpr->x.pList!=0) ){
76119 ExprList *pList = pExpr->x.pList;
76126 keyInfo.aColl[0] = sqlite3ExprCollSeq(pParse, pExpr->pLeft);
76133 Expr *pE2 = pItem->pExpr;
76148 sqlite3VdbeAddOp3(v, OP_InsertInt, pExpr->iTable, r2, iValToIns);
76154 sqlite3VdbeAddOp3(v, OP_Insert, pExpr->iTable, r2, r3);
76158 sqlite3VdbeAddOp2(v, OP_IdxInsert, pExpr->iTable, r2);
76183 testcase( pExpr->op==TK_EXISTS );
76184 testcase( pExpr->op==TK_SELECT );
76185 assert( pExpr->op==TK_EXISTS || pExpr->op==TK_SELECT );
76187 assert( ExprHasProperty(pExpr, EP_xIsSelect) );
76188 pSel = pExpr->x.pSelect;
76190 if( pExpr->op==TK_SELECT ){
76207 ExprSetIrreducible(pExpr);
76241 Expr *pExpr, /* The IN expression */
76252 ** pExpr->iTable will contains the values that make up the RHS.
76257 eType = sqlite3FindInIndex(pParse, pExpr, &rRhsHasNull);
76263 affinity = comparisonAffinity(pExpr);
76269 sqlite3ExprCode(pParse, pExpr->pLeft, r1);
76280 sqlite3VdbeAddOp2(v, OP_Rewind, pExpr->iTable, destIfFalse);
76289 sqlite3VdbeAddOp3(v, OP_NotExists, pExpr->iTable, destIfFalse, r1);
76309 sqlite3VdbeAddOp4Int(v, OP_NotFound, pExpr->iTable, destIfFalse, r1, 1);
76322 j1 = sqlite3VdbeAddOp4Int(v, OP_Found, pExpr->iTable, 0, r1, 1);
76331 j3 = sqlite3VdbeAddOp4Int(v, OP_Found, pExpr->iTable, 0, rRhsHasNull, 1);
76395 static void codeInteger(Parse *pParse, Expr *pExpr, int negFlag, int iMem){
76397 if( pExpr->flags & EP_IntValue ){
76398 int i = pExpr->u.iValue;
76405 const char *z = pExpr->u.zToken;
76706 SQLITE_PRIVATE int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target){
76721 if( pExpr==0 ){
76724 op = pExpr->op;
76728 AggInfo *pAggInfo = pExpr->pAggInfo;
76729 struct AggInfo_col *pCol = &pAggInfo->aCol[pExpr->iAgg];
76742 if( pExpr->iTable<0 ){
76745 inReg = pExpr->iColumn + pParse->ckBase;
76747 inReg = sqlite3ExprCodeGetColumn(pParse, pExpr->pTab,
76748 pExpr->iColumn, pExpr->iTable, target);
76753 codeInteger(pParse, pExpr, 0, target);
76758 assert( !ExprHasProperty(pExpr, EP_IntValue) );
76759 codeReal(v, pExpr->u.zToken, 0, target);
76764 assert( !ExprHasProperty(pExpr, EP_IntValue) );
76765 sqlite3VdbeAddOp4(v, OP_String8, 0, target, 0, pExpr->u.zToken, 0);
76777 assert( !ExprHasProperty(pExpr, EP_IntValue) );
76778 assert( pExpr->u.zToken[0]=='x' || pExpr->u.zToken[0]=='X' );
76779 assert( pExpr->u.zToken[1]=='\'' );
76780 z = &pExpr->u.zToken[2];
76789 assert( !ExprHasProperty(pExpr, EP_IntValue) );
76790 assert( pExpr->u.zToken!=0 );
76791 assert( pExpr->u.zToken[0]!=0 );
76792 sqlite3VdbeAddOp2(v, OP_Variable, pExpr->iColumn, target);
76793 if( pExpr->u.zToken[1]!=0 ){
76794 assert( pExpr->u.zToken[0]=='?'
76795 || strcmp(pExpr->u.zToken, pParse->azVar[pExpr->iColumn-1])==0 );
76796 sqlite3VdbeChangeP4(v, -1, pParse->azVar[pExpr->iColumn-1], P4_STATIC);
76801 inReg = pExpr->iTable;
76805 inReg = sqlite3ExprCodeTarget(pParse, pExpr->pLeft, target);
76812 inReg = sqlite3ExprCodeTarget(pParse, pExpr->pLeft, target);
76813 assert( !ExprHasProperty(pExpr, EP_IntValue) );
76814 aff = sqlite3AffinityType(pExpr->u.zToken);
76854 r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, ®Free1);
76855 r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, ®Free2);
76856 codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,
76866 r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, ®Free1);
76867 r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, ®Free2);
76869 codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,
76909 r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, ®Free1);
76910 r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, ®Free2);
76917 Expr *pLeft = pExpr->pLeft;
76923 assert( !ExprHasProperty(pExpr, EP_IntValue) );
76929 r2 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, ®Free2);
76942 r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, ®Free1);
76956 r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, ®Free1);
76964 AggInfo *pInfo = pExpr->pAggInfo;
76966 assert( !ExprHasProperty(pExpr, EP_IntValue) );
76967 sqlite3ErrorMsg(pParse, "misuse of aggregate: %s()", pExpr->u.zToken);
76969 inReg = pInfo->aFunc[pExpr->iAgg].iMem;
76985 assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
76988 if( ExprHasAnyProperty(pExpr, EP_TokenOnly) ){
76991 pFarg = pExpr->x.pList;
76994 assert( !ExprHasProperty(pExpr, EP_IntValue) );
76995 zId = pExpr->u.zToken;
77010 sqlite3ExprCode(pParse, pFarg->a[0].pExpr, target);
77015 sqlite3ExprCode(pParse, pFarg->a[i].pExpr, target);
77044 if( nFarg>=2 && (pExpr->flags & EP_InfixFunc) ){
77045 pDef = sqlite3VtabOverloadFunction(db, pDef, nFarg, pFarg->a[1].pExpr);
77047 pDef = sqlite3VtabOverloadFunction(db, pDef, nFarg, pFarg->a[0].pExpr);
77051 pExpr) ){
77055 pColl = sqlite3ExprCollSeq(pParse, pFarg->a[i].pExpr);
77075 inReg = sqlite3CodeSubselect(pParse, pExpr, 0, 0);
77082 sqlite3ExprCodeIN(pParse, pExpr, destIfFalse, destIfNull);
77099 ** X is stored in pExpr->pLeft.
77100 ** Y is stored in pExpr->pList->a[0].pExpr.
77101 ** Z is stored in pExpr->pList->a[1].pExpr.
77104 Expr *pLeft = pExpr->pLeft;
77105 struct ExprList_item *pLItem = pExpr->x.pList->a;
77106 Expr *pRight = pLItem->pExpr;
77117 pRight = pLItem->pExpr;
77128 inReg = sqlite3ExprCodeTarget(pParse, pExpr->pLeft, target);
77158 Table *pTab = pExpr->pTab;
77159 int p1 = pExpr->iTable * (pTab->nCol+1) + 1 + pExpr->iColumn;
77161 assert( pExpr->iTable==0 || pExpr->iTable==1 );
77162 assert( pExpr->iColumn>=-1 && pExpr->iColumn<pTab->nCol );
77163 assert( pTab->iPKey<0 || pExpr->iColumn!=pTab->iPKey );
77168 (pExpr->iTable ? "new" : "old"),
77169 (pExpr->iColumn<0 ? "rowid" : pExpr->pTab->aCol[pExpr->iColumn].zName),
77176 if( pExpr->iColumn>=0
77177 && pTab->aCol[pExpr->iColumn].affinity==SQLITE_AFF_REAL
77197 ** X (if it exists) is in pExpr->pLeft.
77198 ** Y is in pExpr->pRight. The Y is also optional. If there is no
77201 ** Ei is in pExpr->pList->a[i*2] and Ri is pExpr->pList->a[i*2+1].
77220 assert( !ExprHasProperty(pExpr, EP_xIsSelect) && pExpr->x.pList );
77221 assert((pExpr->x.pList->nExpr % 2) == 0);
77222 assert(pExpr->x.pList->nExpr > 0);
77223 pEList = pExpr->x.pList;
77227 if( (pX = pExpr->pLeft)!=0 ){
77247 opCompare.pRight = aListelem[i].pExpr;
77249 pTest = aListelem[i].pExpr;
77254 testcase( aListelem[i+1].pExpr->op==TK_COLUMN );
77255 testcase( aListelem[i+1].pExpr->op==TK_REGISTER );
77256 sqlite3ExprCode(pParse, aListelem[i+1].pExpr, target);
77261 if( pExpr->pRight ){
77263 sqlite3ExprCode(pParse, pExpr->pRight, target);
77275 assert( pExpr->affinity==OE_Rollback
77276 || pExpr->affinity==OE_Abort
77277 || pExpr->affinity==OE_Fail
77278 || pExpr->affinity==OE_Ignore
77285 if( pExpr->affinity==OE_Abort ){
77288 assert( !ExprHasProperty(pExpr, EP_IntValue) );
77289 if( pExpr->affinity==OE_Ignore ){
77291 v, OP_Halt, SQLITE_OK, OE_Ignore, 0, pExpr->u.zToken,0);
77293 sqlite3HaltConstraint(pParse, pExpr->affinity, pExpr->u.zToken, 0);
77314 SQLITE_PRIVATE int sqlite3ExprCodeTemp(Parse *pParse, Expr *pExpr, int *pReg){
77316 int r2 = sqlite3ExprCodeTarget(pParse, pExpr, r1);
77327 ** Generate code that will evaluate expression pExpr and store the
77331 SQLITE_PRIVATE int sqlite3ExprCode(Parse *pParse, Expr *pExpr, int target){
77335 if( pExpr && pExpr->op==TK_REGISTER ){
77336 sqlite3VdbeAddOp2(pParse->pVdbe, OP_Copy, pExpr->iTable, target);
77338 inReg = sqlite3ExprCodeTarget(pParse, pExpr, target);
77359 SQLITE_PRIVATE int sqlite3ExprCodeAndCache(Parse *pParse, Expr *pExpr, int target){
77362 inReg = sqlite3ExprCode(pParse, pExpr, target);
77370 if( ALWAYS(pExpr->op!=TK_REGISTER) ){
77374 pExpr->iTable = iMem;
77375 pExpr->op2 = pExpr->op;
77376 pExpr->op = TK_REGISTER;
77385 SQLITE_PRIVATE void sqlite3ExplainExpr(Vdbe *pOut, Expr *pExpr){
77389 if( pExpr==0 ){
77392 op = pExpr->op;
77397 pExpr->iTable, pExpr->iColumn);
77401 if( pExpr->iTable<0 ){
77403 sqlite3ExplainPrintf(pOut, "COLUMN(%d)", pExpr->iColumn);
77406 pExpr->iTable, pExpr->iColumn);
77411 if( pExpr->flags & EP_IntValue ){
77412 sqlite3ExplainPrintf(pOut, "%d", pExpr->u.iValue);
77414 sqlite3ExplainPrintf(pOut, "%s", pExpr->u.zToken);
77420 sqlite3ExplainPrintf(pOut,"%s", pExpr->u.zToken);
77425 sqlite3ExplainPrintf(pOut,"%Q", pExpr->u.zToken);
77434 sqlite3ExplainPrintf(pOut,"%s", pExpr->u.zToken);
77440 pExpr->u.zToken, pExpr->iColumn);
77444 sqlite3ExplainPrintf(pOut,"REGISTER(%d)", pExpr->iTable);
77448 sqlite3ExplainExpr(pOut, pExpr->pLeft);
77455 switch( sqlite3AffinityType(pExpr->u.zToken) ){
77463 sqlite3ExplainExpr(pOut, pExpr->pLeft);
77500 if( ExprHasAnyProperty(pExpr, EP_TokenOnly) ){
77503 pFarg = pExpr->x.pList;
77507 pExpr->u.zToken);
77517 sqlite3ExplainSelect(pOut, pExpr->x.pSelect);
77523 sqlite3ExplainSelect(pOut, pExpr->x.pSelect);
77529 sqlite3ExplainExpr(pOut, pExpr->pLeft);
77531 if( ExprHasProperty(pExpr, EP_xIsSelect) ){
77532 sqlite3ExplainSelect(pOut, pExpr->x.pSelect);
77534 sqlite3ExplainExprList(pOut, pExpr->x.pList);
77548 ** X is stored in pExpr->pLeft.
77549 ** Y is stored in pExpr->pList->a[0].pExpr.
77550 ** Z is stored in pExpr->pList->a[1].pExpr.
77553 Expr *pX = pExpr->pLeft;
77554 Expr *pY = pExpr->x.pList->a[0].pExpr;
77555 Expr *pZ = pExpr->x.pList->a[1].pExpr;
77574 pExpr->iTable ? "NEW" : "OLD", pExpr->iColumn);
77579 sqlite3ExplainExpr(pOut, pExpr->pLeft);
77581 sqlite3ExplainExprList(pOut, pExpr->x.pList);
77587 switch( pExpr->affinity ){
77593 sqlite3ExplainPrintf(pOut, "RAISE-%s(%s)", zType, pExpr->u.zToken);
77600 sqlite3ExplainExpr(pOut, pExpr->pLeft);
77602 sqlite3ExplainExpr(pOut, pExpr->pRight);
77606 sqlite3ExplainExpr(pOut, pExpr->pLeft);
77622 sqlite3ExplainExpr(pOut, pList->a[0].pExpr);
77628 sqlite3ExplainExpr(pOut, pList->a[i].pExpr);
77640 ** Return TRUE if pExpr is an constant expression that is appropriate
77699 ** If pExpr is a constant expression that is appropriate for
77704 static int evalConstExpr(Walker *pWalker, Expr *pExpr){
77706 switch( pExpr->op ){
77718 ExprList *pList = pExpr->x.pList;
77719 assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
77724 if( ALWAYS(pItem->pExpr) ) pItem->pExpr->flags |= EP_FixedDest;
77730 if( isAppropriateForFactoring(pExpr) ){
77733 r2 = sqlite3ExprCodeTarget(pParse, pExpr, r1);
77735 pExpr->op2 = pExpr->op;
77736 pExpr->op = TK_REGISTER;
77737 pExpr->iTable = r2;
77744 ** Preevaluate constant subexpressions within pExpr and store the
77745 ** results in registers. Modify pExpr so that the constant subexpresions
77759 SQLITE_PRIVATE void sqlite3ExprCodeConstants(Parse *pParse, Expr *pExpr){
77766 sqlite3WalkExpr(&w, pExpr);
77789 Expr *pExpr = pItem->pExpr;
77790 int inReg = sqlite3ExprCodeTarget(pParse, pExpr, target+i);
77813 Expr *pExpr, /* The BETWEEN expression */
77824 assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
77825 exprX = *pExpr->pLeft;
77831 compLeft.pRight = pExpr->x.pList->a[0].pExpr;
77834 compRight.pRight = pExpr->x.pList->a[1].pExpr;
77869 SQLITE_PRIVATE void sqlite3ExprIfTrue(Parse *pParse, Expr *pExpr, int dest, int jumpIfNull){
77878 if( NEVER(pExpr==0) ) return; /* No way this can happen */
77879 op = pExpr->op;
77885 sqlite3ExprIfFalse(pParse, pExpr->pLeft, d2,jumpIfNull^SQLITE_JUMPIFNULL);
77886 sqlite3ExprIfTrue(pParse, pExpr->pRight, dest, jumpIfNull);
77893 sqlite3ExprIfTrue(pParse, pExpr->pLeft, dest, jumpIfNull);
77894 sqlite3ExprIfTrue(pParse, pExpr->pRight, dest, jumpIfNull);
77899 sqlite3ExprIfFalse(pParse, pExpr->pLeft, dest, jumpIfNull);
77921 r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, ®Free1);
77922 r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, ®Free2);
77923 codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,
77933 r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, ®Free1);
77934 r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, ®Free2);
77936 codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,
77948 r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, ®Free1);
77955 exprCodeBetween(pParse, pExpr, dest, 1, jumpIfNull);
77962 sqlite3ExprCodeIN(pParse, pExpr, destIfFalse, destIfNull);
77969 r1 = sqlite3ExprCodeTemp(pParse, pExpr, ®Free1);
77989 SQLITE_PRIVATE void sqlite3ExprIfFalse(Parse *pParse, Expr *pExpr, int dest, int jumpIfNull){
77998 if( pExpr==0 ) return;
78000 /* The value of pExpr->op and op are related as follows:
78002 ** pExpr->op op
78013 ** For other values of pExpr->op, op is undefined and unused.
78018 op = ((pExpr->op+(TK_ISNULL&1))^1)-(TK_ISNULL&1);
78022 assert( pExpr->op!=TK_ISNULL || op==OP_NotNull );
78023 assert( pExpr->op!=TK_NOTNULL || op==OP_IsNull );
78024 assert( pExpr->op!=TK_NE || op==OP_Eq );
78025 assert( pExpr->op!=TK_EQ || op==OP_Ne );
78026 assert( pExpr->op!=TK_LT || op==OP_Ge );
78027 assert( pExpr->op!=TK_LE || op==OP_Gt );
78028 assert( pExpr->op!=TK_GT || op==OP_Le );
78029 assert( pExpr->op!=TK_GE || op==OP_Lt );
78031 switch( pExpr->op ){
78034 sqlite3ExprIfFalse(pParse, pExpr->pLeft, dest, jumpIfNull);
78035 sqlite3ExprIfFalse(pParse, pExpr->pRight, dest, jumpIfNull);
78042 sqlite3ExprIfTrue(pParse, pExpr->pLeft, d2, jumpIfNull^SQLITE_JUMPIFNULL);
78043 sqlite3ExprIfFalse(pParse, pExpr->pRight, dest, jumpIfNull);
78050 sqlite3ExprIfTrue(pParse, pExpr->pLeft, dest, jumpIfNull);
78066 r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, ®Free1);
78067 r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, ®Free2);
78068 codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,
78076 testcase( pExpr->op==TK_IS );
78077 testcase( pExpr->op==TK_ISNOT );
78078 r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, ®Free1);
78079 r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, ®Free2);
78080 op = (pExpr->op==TK_IS) ? TK_NE : TK_EQ;
78081 codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,
78091 r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, ®Free1);
78098 exprCodeBetween(pParse, pExpr, dest, 0, jumpIfNull);
78104 sqlite3ExprCodeIN(pParse, pExpr, dest, dest);
78107 sqlite3ExprCodeIN(pParse, pExpr, dest, destIfNull);
78114 r1 = sqlite3ExprCodeTemp(pParse, pExpr, ®Free1);
78189 Expr *pExprA = pA->a[i].pExpr;
78190 Expr *pExprB = pB->a[i].pExpr;
78234 static int analyzeAggregate(Walker *pWalker, Expr *pExpr){
78241 switch( pExpr->op ){
78244 testcase( pExpr->op==TK_AGG_COLUMN );
78245 testcase( pExpr->op==TK_COLUMN );
78252 assert( !ExprHasAnyProperty(pExpr, EP_TokenOnly|EP_Reduced) );
78253 if( pExpr->iTable==pItem->iCursor ){
78254 /* If we reach this point, it means that pExpr refers to a table
78263 if( pCol->iTable==pExpr->iTable &&
78264 pCol->iColumn==pExpr->iColumn ){
78272 pCol->pTab = pExpr->pTab;
78273 pCol->iTable = pExpr->iTable;
78274 pCol->iColumn = pExpr->iColumn;
78277 pCol->pExpr = pExpr;
78284 Expr *pE = pTerm->pExpr;
78285 if( pE->op==TK_COLUMN && pE->iTable==pExpr->iTable &&
78286 pE->iColumn==pExpr->iColumn ){
78296 /* There is now an entry for pExpr in pAggInfo->aCol[] (either
78298 ** Convert the pExpr to be a TK_AGG_COLUMN referring to that
78301 ExprSetIrreducible(pExpr);
78302 pExpr->pAggInfo = pAggInfo;
78303 pExpr->op = TK_AGG_COLUMN;
78304 pExpr->iAgg = (i16)k;
78306 } /* endif pExpr->iTable==pItem->iCursor */
78315 /* Check to see if pExpr is a duplicate of another aggregate
78320 if( sqlite3ExprCompare(pItem->pExpr, pExpr)==0 ){
78325 /* pExpr is original. Make a new entry in pAggInfo->aFunc[]
78330 assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
78332 pItem->pExpr = pExpr;
78334 assert( !ExprHasProperty(pExpr, EP_IntValue) );
78336 pExpr->u.zToken, sqlite3Strlen30(pExpr->u.zToken),
78337 pExpr->x.pList ? pExpr->x.pList->nExpr : 0, enc, 0);
78338 if( pExpr->flags & EP_Distinct ){
78345 /* Make pExpr point to the appropriate pAggInfo->aFunc[] entry
78347 assert( !ExprHasAnyProperty(pExpr, EP_TokenOnly|EP_Reduced) );
78348 ExprSetIrreducible(pExpr);
78349 pExpr->iAgg = (i16)i;
78350 pExpr->pAggInfo = pAggInfo;
78377 SQLITE_PRIVATE void sqlite3ExprAnalyzeAggregates(NameContext *pNC, Expr *pExpr){
78383 sqlite3WalkExpr(&w, pExpr);
78397 sqlite3ExprAnalyzeAggregates(pNC, pItem->pExpr);
80451 ** This only applies to the root node of pExpr, so the statement:
80457 static int resolveAttachExpr(NameContext *pName, Expr *pExpr)
80460 if( pExpr ){
80461 if( pExpr->op!=TK_ID ){
80462 rc = sqlite3ResolveExprNames(pName, pExpr);
80463 if( rc==SQLITE_OK && !sqlite3ExprIsConstant(pExpr) ){
80464 sqlite3ErrorMsg(pName->pParse, "invalid name: \"%s\"", pExpr->u.zToken);
80468 pExpr->op = TK_STRING;
80928 Expr *pExpr /* The expression to be fixed to one database */
80930 while( pExpr ){
80931 if( ExprHasAnyProperty(pExpr, EP_TokenOnly) ) break;
80932 if( ExprHasProperty(pExpr, EP_xIsSelect) ){
80933 if( sqlite3FixSelect(pFix, pExpr->x.pSelect) ) return 1;
80935 if( sqlite3FixExprList(pFix, pExpr->x.pList) ) return 1;
80937 if( sqlite3FixExpr(pFix, pExpr->pRight) ){
80940 pExpr = pExpr->pLeft;
80952 if( sqlite3FixExpr(pFix, pItem->pExpr) ){
81078 ** If SQLITE_IGNORE is returned and pExpr is not NULL, then pExpr is changed
81079 ** to an SQL NULL expression. Otherwise, if pExpr is NULL, then SQLITE_IGNORE
81107 ** The pExpr should be a TK_COLUMN expression. The table referred to
81117 Expr *pExpr, /* The expression to check authorization on */
81119 SrcList *pTabList /* All table that pExpr might refer to */
81136 assert( pExpr->op==TK_COLUMN || pExpr->op==TK_TRIGGER );
81137 if( pExpr->op==TK_TRIGGER ){
81142 if( pExpr->iTable==pTabList->a[iSrc].iCursor ){
81148 iCol = pExpr->iColumn;
81162 pExpr->op = TK_NULL;
82331 if( !sqlite3ExprIsConstantOrFunction(pSpan->pExpr) ){
82335 /* A copy of pExpr is used instead of the original, as pExpr contains
82340 pCol->pDflt = sqlite3ExprDup(db, pSpan->pExpr, EXPRDUP_REDUCE);
82346 sqlite3ExprDelete(db, pSpan->pExpr);
83878 Expr *pExpr = pList->a[i].pExpr;
83879 if( pExpr ){
83880 CollSeq *pColl = pExpr->pColl;
83958 /* Justification of the ALWAYS(pListItem->pExpr->pColl): Because of
83960 ** if pListItem->pExpr is not null then either pListItem->pExpr->pColl
83963 if( pListItem->pExpr && ALWAYS(pListItem->pExpr->pColl) ){
83965 zColl = pListItem->pExpr->pColl->zName;
87641 ** pExpr points to an expression which implements a function. If
87647 SQLITE_PRIVATE int sqlite3IsLikeFunction(sqlite3 *db, Expr *pExpr, int *pIsNocase, char *aWc){
87649 if( pExpr->op!=TK_FUNCTION
87650 || !pExpr->x.pList
87651 || pExpr->x.pList->nExpr!=2
87655 assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
87656 pDef = sqlite3FindFunction(db, pExpr->u.zToken,
87657 sqlite3Strlen30(pExpr->u.zToken),
89674 if( sqlite3ResolveExprNames(&sNC, pList->a[i].pExpr) ){
89825 sqlite3ExprCode(pParse, pList->a[keyColumn].pExpr, regCols);
89854 sqlite3ExprCodeAndCache(pParse, pList->a[j].pExpr, regCols+i+1);
89892 sqlite3ExprCode(pParse, pList->a[keyColumn].pExpr, regRowid);
89959 sqlite3ExprCode(pParse, pList->a[j].pExpr, iRegStore);
90671 assert( pEList->a[0].pExpr );
90672 if( pEList->a[0].pExpr->op!=TK_ALL ){
95195 p->affinity = sqlite3CompareAffinity(pEList->a[0].pExpr, pDest->affinity);
95311 pColl = sqlite3ExprCollSeq(pParse, pItem->pExpr);
95523 ** expression pExpr. The string may be treated as static by the caller.
95541 Expr *pExpr,
95551 if( NEVER(pExpr==0) || pNC->pSrcList==0 ) return 0;
95553 switch( pExpr->op ){
95562 int iCol = pExpr->iColumn; /* Index of column in pTab */
95563 testcase( pExpr->op==TK_AGG_COLUMN );
95564 testcase( pExpr->op==TK_COLUMN );
95567 for(j=0;j<pTabList->nSrc && pTabList->a[j].iCursor!=pExpr->iTable;j++);
95597 assert( pTab && pExpr->pTab==pTab );
95609 Expr *p = pS->pEList->a[iCol].pExpr;
95642 Select *pS = pExpr->x.pSelect;
95643 Expr *p = pS->pEList->a[0].pExpr;
95644 assert( ExprHasProperty(pExpr, EP_xIsSelect) );
95679 Expr *p = pEList->a[i].pExpr;
95731 p = pEList->a[i].pExpr;
95804 p = pEList->a[i].pExpr;
95899 p = a[i].pExpr;
96051 pRet = sqlite3ExprCollSeq(pParse, p->pEList->a[iCol].pExpr);
96533 sqlite3CompareAffinity(p->pEList->a[0].pExpr, pDest->affinity);
96800 Expr *pTerm = pOrderBy->a[i].pExpr;
97049 ** Scan through the expression pExpr. Replace every reference to
97058 ** changes to pExpr so that it refers directly to the source table
97063 Expr *pExpr, /* Expr in which substitution occurs */
97067 if( pExpr==0 ) return 0;
97068 if( pExpr->op==TK_COLUMN && pExpr->iTable==iTable ){
97069 if( pExpr->iColumn<0 ){
97070 pExpr->op = TK_NULL;
97073 assert( pEList!=0 && pExpr->iColumn<pEList->nExpr );
97074 assert( pExpr->pLeft==0 && pExpr->pRight==0 );
97075 pNew = sqlite3ExprDup(db, pEList->a[pExpr->iColumn].pExpr, 0);
97076 if( pNew && pExpr->pColl ){
97077 pNew->pColl = pExpr->pColl;
97079 sqlite3ExprDelete(db, pExpr);
97080 pExpr = pNew;
97083 pExpr->pLeft = substExpr(db, pExpr->pLeft, iTable, pEList);
97084 pExpr->pRight = substExpr(db, pExpr->pRight, iTable, pEList);
97085 if( ExprHasProperty(pExpr, EP_xIsSelect) ){
97086 substSelect(db, pExpr->x.pSelect, iTable, pEList);
97088 substExprList(db, pExpr->x.pList, iTable, pEList);
97091 return pExpr;
97102 pList->a[i].pExpr = substExpr(db, pList->a[i].pExpr, iTable, pEList);
97633 Expr *pExpr;
97637 pExpr = pEList->a[0].pExpr;
97638 if( pExpr->op!=TK_AGG_FUNCTION ) return 0;
97639 if( NEVER(ExprHasProperty(pExpr, EP_xIsSelect)) ) return 0;
97640 pEList = pExpr->x.pList;
97642 if( pEList->a[0].pExpr->op!=TK_AGG_COLUMN ) return WHERE_ORDERBY_NORMAL;
97643 assert( !ExprHasProperty(pExpr, EP_IntValue) );
97644 if( sqlite3StrICmp(pExpr->u.zToken,"min")==0 ){
97646 }else if( sqlite3StrICmp(pExpr->u.zToken,"max")==0 ){
97665 Expr *pExpr;
97675 pExpr = p->pEList->a[0].pExpr;
97676 assert( pTab && !pTab->pSelect && pExpr );
97679 if( pExpr->op!=TK_AGG_FUNCTION ) return 0;
97681 if( pExpr->flags&EP_Distinct ) return 0;
97829 Expr *pE = pEList->a[k].pExpr;
97848 Expr *pE = a[k].pExpr;
97853 pNew = sqlite3ExprListAppend(pParse, pNew, a[k].pExpr);
97860 a[k].pExpr = 0;
97885 Expr *pExpr, *pRight;
97920 pExpr = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight, 0);
97926 pExpr = pRight;
97928 pNew = sqlite3ExprListAppend(pParse, pNew, pExpr);
98098 Expr *pE = pFunc->pExpr;
98122 ExprList *pList = pF->pExpr->x.pList;
98123 assert( !ExprHasProperty(pF->pExpr, EP_xIsSelect) );
98147 ExprList *pList = pF->pExpr->x.pList;
98148 assert( !ExprHasProperty(pF->pExpr, EP_xIsSelect) );
98168 pColl = sqlite3ExprCollSeq(pParse, pItem->pExpr);
98202 sqlite3ExprCode(pParse, pC->pExpr, pC->iMem);
98594 CollSeq *pColl = sqlite3ExprCollSeq(pParse, pEList->a[iExpr].pExpr);
98669 assert( !ExprHasProperty(sAggInfo.aFunc[i].pExpr, EP_xIsSelect) );
98670 sqlite3ExprAnalyzeAggList(&sNC, sAggInfo.aFunc[i].pExpr->x.pList);
98806 sqlite3ExprCode(pParse, pGroupBy->a[j].pExpr, iBMem+j);
98978 assert( !ExprHasProperty(p->pEList->a[0].pExpr, EP_xIsSelect) );
98979 pMinMax = sqlite3ExprListDup(db, p->pEList->a[0].pExpr->x.pList,0);
98983 pMinMax->a[0].pExpr->op = TK_COLUMN;
100672 if( sqlite3ResolveExprNames(&sNC, pChanges->a[i].pExpr) ){
100679 pRowidExpr = pChanges->a[i].pExpr;
100688 pRowidExpr = pChanges->a[i].pExpr;
100911 sqlite3ExprCode(pParse, pChanges->a[j].pExpr, regNew+i);
101088 Expr *pExpr; /* Temporary expression */
101108 pExpr = sqlite3ExprDup(db, pChanges->a[aXRef[i]].pExpr, 0);
101110 pExpr = sqlite3Expr(db, TK_ID, pTab->aCol[i].zName);
101112 pEList = sqlite3ExprListAppend(pParse, pEList, pExpr);
102419 ** second parameter (pExpr) is the first argument to this function.
102420 ** If pExpr is a column in a virtual table, then let the virtual
102434 Expr *pExpr /* First argument to the function */
102448 if( NEVER(pExpr==0) ) return pDef;
102449 if( pExpr->op!=TK_COLUMN ) return pDef;
102450 pTab = pExpr->pTab;
102641 ** categories, then eOperator==0. The WhereTerm.pExpr field is still set
102663 Expr *pExpr; /* Pointer to the subexpression that is this term */
102675 Bitmask prereqRight; /* Bitmask of tables used by pExpr->pRight */
102676 Bitmask prereqAll; /* Bitmask of tables referenced by pExpr */
102682 #define TERM_DYNAMIC 0x01 /* Need to call sqlite3ExprDelete(db, pExpr) */
102884 sqlite3ExprDelete(db, a->pExpr);
102938 pTerm->pExpr = p;
102955 ** The original WHERE clause in pExpr is unaltered. All this routine
102956 ** does is make slot[] entries point to substructure within pExpr.
102962 static void whereSplit(WhereClause *pWC, Expr *pExpr, int op){
102964 if( pExpr==0 ) return;
102965 if( pExpr->op!=op ){
102966 whereClauseInsert(pWC, pExpr, 0);
102968 whereSplit(pWC, pExpr->pLeft, op);
102969 whereSplit(pWC, pExpr->pRight, op);
103043 mask |= exprTableUsage(pMaskSet, pList->a[i].pExpr);
103106 static void exprCommute(Parse *pParse, Expr *pExpr){
103107 u16 expRight = (pExpr->pRight->flags & EP_ExpCollate);
103108 u16 expLeft = (pExpr->pLeft->flags & EP_ExpCollate);
103109 assert( allowedOp(pExpr->op) && pExpr->op!=TK_IN );
103110 pExpr->pRight->pColl = sqlite3ExprCollSeq(pParse, pExpr->pRight);
103111 pExpr->pLeft->pColl = sqlite3ExprCollSeq(pParse, pExpr->pLeft);
103112 SWAP(CollSeq*,pExpr->pRight->pColl,pExpr->pLeft->pColl);
103113 pExpr->pRight->flags = (pExpr->pRight->flags & ~EP_ExpCollate) | expLeft;
103114 pExpr->pLeft->flags = (pExpr->pLeft->flags & ~EP_ExpCollate) | expRight;
103115 SWAP(Expr*,pExpr->pRight,pExpr->pLeft);
103116 if( pExpr->op>=TK_GT ){
103121 assert( pExpr->op>=TK_GT && pExpr->op<=TK_GE );
103122 pExpr->op = ((pExpr->op-TK_GT)^2)+TK_GT;
103176 Expr *pX = pTerm->pExpr;
103234 Expr *pExpr, /* Test this expression */
103249 if( !sqlite3IsLikeFunction(db, pExpr, pnoCase, wc) ){
103255 pList = pExpr->x.pList;
103256 pLeft = pList->a[1].pExpr;
103264 pRight = pList->a[0].pExpr;
103328 Expr *pExpr /* Test this expression */
103332 if( pExpr->op!=TK_FUNCTION ){
103335 if( sqlite3StrICmp(pExpr->u.zToken,"match")!=0 ){
103338 pList = pExpr->x.pList;
103342 if( pList->a[1].pExpr->op != TK_COLUMN ){
103443 Expr *pExpr = pTerm->pExpr; /* The expression of the term */
103458 assert( pExpr->op==TK_OR );
103464 whereSplit(pOrWc, pExpr, TK_OR);
103491 whereSplit(pAndWC, pOrTerm->pExpr, TK_AND);
103497 assert( pAndTerm->pExpr );
103498 if( allowedOp(pAndTerm->pExpr->op) ){
103614 affRight = sqlite3ExprAffinity(pOrTerm->pExpr->pRight);
103615 affLeft = sqlite3ExprAffinity(pOrTerm->pExpr->pLeft);
103642 pDup = sqlite3ExprDup(db, pOrTerm->pExpr->pRight, 0);
103644 pLeft = pOrTerm->pExpr->pLeft;
103651 transferJoinMarkings(pNew, pExpr);
103672 ** "pExpr" field filled in. The job of this routine is to analyze the
103683 ** and the new term is marked with TERM_DYNAMIC (because it's pExpr
103695 Expr *pExpr; /* The expression to be analyzed */
103696 Bitmask prereqLeft; /* Prerequesites of the pExpr->pLeft */
103697 Bitmask prereqAll; /* Prerequesites of pExpr */
103702 int op; /* Top-level operator. pExpr->op */
103711 pExpr = pTerm->pExpr;
103712 prereqLeft = exprTableUsage(pMaskSet, pExpr->pLeft);
103713 op = pExpr->op;
103715 assert( pExpr->pRight==0 );
103716 if( ExprHasProperty(pExpr, EP_xIsSelect) ){
103717 pTerm->prereqRight = exprSelectTableUsage(pMaskSet, pExpr->x.pSelect);
103719 pTerm->prereqRight = exprListTableUsage(pMaskSet, pExpr->x.pList);
103724 pTerm->prereqRight = exprTableUsage(pMaskSet, pExpr->pRight);
103726 prereqAll = exprTableUsage(pMaskSet, pExpr);
103727 if( ExprHasProperty(pExpr, EP_FromJoin) ){
103728 Bitmask x = getMask(pMaskSet, pExpr->iRightJoinTable);
103738 Expr *pLeft = pExpr->pLeft;
103739 Expr *pRight = pExpr->pRight;
103750 pDup = sqlite3ExprDup(db, pExpr, 0);
103763 pDup = pExpr;
103793 else if( pExpr->op==TK_BETWEEN && pWC->op==TK_AND ){
103794 ExprList *pList = pExpr->x.pList;
103803 sqlite3ExprDup(db, pExpr->pLeft, 0),
103804 sqlite3ExprDup(db, pList->a[i].pExpr, 0), 0);
103819 else if( pExpr->op==TK_OR ){
103838 && isLikeOrGlob(pParse, pExpr, &pStr1, &isComplete, &noCase)
103848 pLeft = pExpr->x.pList->a[1].pExpr;
103897 if( isMatchOfColumn(pExpr) ){
103903 pRight = pExpr->x.pList->a[0].pExpr;
103904 pLeft = pExpr->x.pList->a[1].pExpr;
103938 if( pExpr->op==TK_NOTNULL
103939 && pExpr->pLeft->op==TK_COLUMN
103940 && pExpr->pLeft->iColumn>=0
103943 Expr *pLeft = pExpr->pLeft;
103986 if( (exprTableUsage(pMaskSet, pList->a[iFirst++].pExpr)&allowed)!=0 ){
104014 Expr *p = pList->a[i].pExpr;
104065 Expr *p = pDistinct->a[i].pExpr;
104069 Expr *pX = pTerm->pExpr;
104117 Expr *p = pDistinct->a[i].pExpr;
104206 Expr *pExpr; /* The expression of the ORDER BY pTerm */
104207 CollSeq *pColl; /* The collating sequence of pExpr */
104213 pExpr = pTerm->pExpr;
104214 if( pExpr->op!=TK_COLUMN || pExpr->iTable!=base ){
104219 pColl = sqlite3ExprCollSeq(pParse, pExpr);
104235 if( pExpr->iColumn!=iColumn || sqlite3StrICmp(pColl->zName, zColl) ){
104478 if( !sqlite3IndexAffinityOk(pTerm->pExpr, aff) ) return 0;
104656 Expr *pX = pTerm->pExpr;
104750 Expr *pExpr = pOrderBy->a[i].pExpr;
104751 if( pExpr->op!=TK_COLUMN || pExpr->iTable!=pSrc->iCursor ) break;
104807 Expr *pExpr = pOrderBy->a[i].pExpr;
104808 pIdxOrderBy[i].iColumn = pExpr->iColumn;
105180 ** If expression pExpr represents a literal value, set *pp to point to
105186 ** If the current parse is a recompile (sqlite3Reprepare()) and pExpr
105198 Expr *pExpr,
105202 if( pExpr->op==TK_VARIABLE
105203 || (pExpr->op==TK_REGISTER && pExpr->op2==TK_VARIABLE)
105205 int iVar = pExpr->iColumn;
105210 return sqlite3ValueFromExpr(pParse->db, pExpr, SQLITE_UTF8, aff, pp);
105273 Expr *pExpr = pLower->pExpr->pRight;
105274 rc = valueFromExpr(pParse, pExpr, aff, &pRangeVal);
105285 Expr *pExpr = pUpper->pExpr->pRight;
105286 rc = valueFromExpr(pParse, pExpr, aff, &pRangeVal);
105325 ** for that index. When pExpr==NULL that means the constraint is
105340 Expr *pExpr, /* Expression for VALUE in the x=VALUE constraint */
105351 if( pExpr ){
105352 rc = valueFromExpr(pParse, pExpr, aff, &pRhs);
105400 rc = whereEqualScanEst(pParse, p, pList->a[i].pExpr, &nEst);
105603 Expr *pExpr = pTerm->pExpr;
105605 if( ExprHasProperty(pExpr, EP_xIsSelect) ){
105609 }else if( ALWAYS(pExpr->x.pList && pExpr->x.pList->nExpr) ){
105611 nInMul *= pExpr->x.pList->nExpr;
105724 whereEqualScanEst(pParse, pProbe, pFirstTerm->pExpr->pRight, &nRow);
105727 whereInScanEst(pParse, pProbe, pFirstTerm->pExpr->x.pList, &nRow);
105979 && (pLevel->iLeftJoin==0 || ExprHasProperty(pTerm->pExpr, EP_FromJoin))
106048 Expr *pX = pTerm->pExpr;
106192 Expr *pRight = pTerm->pExpr->pRight;
106443 sqlite3ExprCode(pParse, pWC->a[iTerm].pExpr->pRight, iReg+j+1);
106477 assert( pTerm->pExpr!=0 );
106522 pX = pStart->pExpr;
106536 pX = pEnd->pExpr;
106646 /* assert( pOrderBy->a[0].pExpr->iColumn==pIdx->aiColumn[nEq] ); */
106694 Expr *pRight = pRangeStart->pExpr->pRight;
106734 Expr *pRight = pRangeEnd->pExpr->pRight;
106921 Expr *pExpr = pWC->a[iTerm].pExpr;
106922 if( ExprHasProperty(pExpr, EP_FromJoin) ) continue;
106925 pExpr = sqlite3ExprDup(pParse->db, pExpr, 0);
106926 pAndExpr = sqlite3ExprAnd(pParse->db, pAndExpr, pExpr);
106937 Expr *pOrExpr = pOrTerm->pExpr;
107018 pE = pTerm->pExpr;
107043 assert( pTerm->pExpr );
107044 sqlite3ExprIfFalse(pParse, pTerm->pExpr, addrCont, SQLITE_JUMPIFNULL);
107909 pOut->pExpr = sqlite3PExpr(pParse, op, 0, 0, pValue);
107924 pOut->pExpr = sqlite3PExpr(pParse, op, pLeft->pExpr, pRight->pExpr, 0);
107938 pOut->pExpr = sqlite3PExpr(pParse, op, pOperand->pExpr, 0, 0);
107963 pOut->pExpr = sqlite3PExpr(pParse, op, pOperand->pExpr, 0, 0);
109230 sqlite3ExprDelete(pParse->db, (yypminor->yy342).pExpr);
110074 v.pExpr = sqlite3PExpr(pParse, TK_UMINUS, yymsp[0].minor.yy342.pExpr, 0, 0);
110097 {sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy342.pExpr);}
110158 {sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy342.pExpr);}
110241 yygotominor.yy442 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy442, yymsp[-1].minor.yy342.pExpr);
110328 {yygotominor.yy122 = yymsp[0].minor.yy342.pExpr;}
110355 yygotominor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy442,yymsp[-1].minor.yy342.pExpr);
110361 yygotominor.yy442 = sqlite3ExprListAppend(pParse,0,yymsp[-1].minor.yy342.pExpr);
110376 {yygotominor.yy64.pLimit = yymsp[0].minor.yy342.pExpr; yygotominor.yy64.pOffset = 0;}
110379 {yygotominor.yy64.pLimit = yymsp[-2].minor.yy342.pExpr; yygotominor.yy64.pOffset = yymsp[0].minor.yy342.pExpr;}
110382 {yygotominor.yy64.pOffset = yymsp[-2].minor.yy342.pExpr; yygotominor.yy64.pLimit = yymsp[0].minor.yy342.pExpr;}
110399 yygotominor.yy442 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy442, yymsp[0].minor.yy342.pExpr);
110405 yygotominor.yy442 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy342.pExpr);
110461 {yygotominor.yy342.pExpr = yymsp[-1].minor.yy342.pExpr; spanSet(&yygotominor.yy342,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0);}
110476 yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp2, 0);
110486 yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp4, 0);
110497 yygotominor.yy342.pExpr = 0;
110499 yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_REGISTER, 0, 0, &yymsp[0].minor.yy0);
110500 if( yygotominor.yy342.pExpr ) sqlite3GetInt32(&yymsp[0].minor.yy0.z[1], &yygotominor.yy342.pExpr->iTable);
110508 sqlite3ExprAssignVarNumber(pParse, yygotominor.yy342.pExpr);
110514 yygotominor.yy342.pExpr = sqlite3ExprSetCollByToken(pParse, yymsp[-2].minor.yy342.pExpr, &yymsp[0].minor.yy0);
110521 yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_CAST, yymsp[-3].minor.yy342.pExpr, 0, &yymsp[-1].minor.yy0);
110530 yygotominor.yy342.pExpr = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy442, &yymsp[-4].minor.yy0);
110532 if( yymsp[-2].minor.yy392 && yygotominor.yy342.pExpr ){
110533 yygotominor.yy342.pExpr->flags |= EP_Distinct;
110539 yygotominor.yy342.pExpr = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0);
110547 yygotominor.yy342.pExpr = sqlite3ExprFunction(pParse, 0,&yymsp[0].minor.yy0);
110548 if( yygotominor.yy342.pExpr ){
110549 yygotominor.yy342.pExpr->op = TK_CONST_FUNC;
110575 pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy342.pExpr);
110576 pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy342.pExpr);
110577 yygotominor.yy342.pExpr = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy318.eOperator);
110578 if( yymsp[-1].minor.yy318.not ) yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy342.pExpr, 0, 0);
110581 if( yygotominor.yy342.pExpr ) yygotominor.yy342.pExpr->flags |= EP_InfixFunc;
110587 pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy342.pExpr);
110588 pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy342.pExpr);
110589 pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy342.pExpr);
110590 yygotominor.yy342.pExpr = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy318.eOperator);
110591 if( yymsp[-3].minor.yy318.not ) yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy342.pExpr, 0, 0);
110594 if( yygotominor.yy342.pExpr ) yygotominor.yy342.pExpr->flags |= EP_InfixFunc;
110606 binaryToUnaryIfNull(pParse, yymsp[0].minor.yy342.pExpr, yygotominor.yy342.pExpr, TK_ISNULL);
110612 binaryToUnaryIfNull(pParse, yymsp[0].minor.yy342.pExpr, yygotominor.yy342.pExpr, TK_NOTNULL);
110627 ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy342.pExpr);
110628 pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy342.pExpr);
110629 yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy342.pExpr, 0, 0);
110630 if( yygotominor.yy342.pExpr ){
110631 yygotominor.yy342.pExpr->x.pList = pList;
110635 if( yymsp[-3].minor.yy392 ) yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy342.pExpr, 0, 0);
110651 yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_INTEGER, 0, 0, &sqlite3IntTokens[yymsp[-3].minor.yy392]);
110652 sqlite3ExprDelete(pParse->db, yymsp[-4].minor.yy342.pExpr);
110654 yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy342.pExpr, 0, 0);
110655 if( yygotominor.yy342.pExpr ){
110656 yygotominor.yy342.pExpr->x.pList = yymsp[-1].minor.yy442;
110657 sqlite3ExprSetHeight(pParse, yygotominor.yy342.pExpr);
110661 if( yymsp[-3].minor.yy392 ) yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy342.pExpr, 0, 0);
110669 yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_SELECT, 0, 0, 0);
110670 if( yygotominor.yy342.pExpr ){
110671 yygotominor.yy342.pExpr->x.pSelect = yymsp[-1].minor.yy159;
110672 ExprSetProperty(yygotominor.yy342.pExpr, EP_xIsSelect);
110673 sqlite3ExprSetHeight(pParse, yygotominor.yy342.pExpr);
110683 yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy342.pExpr, 0, 0);
110684 if( yygotominor.yy342.pExpr ){
110685 yygotominor.yy342.pExpr->x.pSelect = yymsp[-1].minor.yy159;
110686 ExprSetProperty(yygotominor.yy342.pExpr, EP_xIsSelect);
110687 sqlite3ExprSetHeight(pParse, yygotominor.yy342.pExpr);
110691 if( yymsp[-3].minor.yy392 ) yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy342.pExpr, 0, 0);
110699 yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-3].minor.yy342.pExpr, 0, 0);
110700 if( yygotominor.yy342.pExpr ){
110701 yygotominor.yy342.pExpr->x.pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0,0);
110702 ExprSetProperty(yygotominor.yy342.pExpr, EP_xIsSelect);
110703 sqlite3ExprSetHeight(pParse, yygotominor.yy342.pExpr);
110707 if( yymsp[-2].minor.yy392 ) yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy342.pExpr, 0, 0);
110714 Expr *p = yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_EXISTS, 0, 0, 0);
110728 yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy122, yymsp[-1].minor.yy122, 0);
110729 if( yygotominor.yy342.pExpr ){
110730 yygotominor.yy342.pExpr->x.pList = yymsp[-2].minor.yy442;
110731 sqlite3ExprSetHeight(pParse, yygotominor.yy342.pExpr);
110741 yygotominor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy442, yymsp[-2].minor.yy342.pExpr);
110742 yygotominor.yy442 = sqlite3ExprListAppend(pParse,yygotominor.yy442, yymsp[0].minor.yy342.pExpr);
110747 yygotominor.yy442 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy342.pExpr);
110748 yygotominor.yy442 = sqlite3ExprListAppend(pParse,yygotominor.yy442, yymsp[0].minor.yy342.pExpr);
110752 {yygotominor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy442,yymsp[0].minor.yy342.pExpr);}
110755 {yygotominor.yy442 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy342.pExpr);}
110859 { yygotominor.yy122 = yymsp[0].minor.yy342.pExpr; }
110915 yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0, 0);
110916 if( yygotominor.yy342.pExpr ){
110917 yygotominor.yy342.pExpr->affinity = OE_Ignore;
110925 yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0, &yymsp[-1].minor.yy0);
110926 if( yygotominor.yy342.pExpr ) {
110927 yygotominor.yy342.pExpr->affinity = (char)yymsp[-3].minor.yy392;
110946 sqlite3Attach(pParse, yymsp[-3].minor.yy342.pExpr, yymsp[-1].minor.yy342.pExpr, yymsp[0].minor.yy122);
110951 sqlite3Detach(pParse, yymsp[0].minor.yy342.pExpr);
116690 Fts3Expr *pExpr; /* Parsed MATCH query string */
118170 sqlite3Fts3ExprFree(pCsr->pExpr);
119611 sqlite3Fts3ExprFree(pCsr->pExpr);
119633 p->azColumn, p->bHasStat, p->nColumn, iCol, zQuery, -1, &pCsr->pExpr
119733 }else if( iCol==p->nColumn+2 && pCsr->pExpr ){
120276 ** by pExpr.
120291 Fts3Expr *pExpr, /* Allocate readers for this expression */
120296 if( pExpr && SQLITE_OK==*pRc ){
120297 if( pExpr->eType==FTSQUERY_PHRASE ){
120299 int nToken = pExpr->pPhrase->nToken;
120302 Fts3PhraseToken *pToken = &pExpr->pPhrase->aToken[i];
120311 assert( pExpr->pPhrase->iDoclistToken==0 );
120312 pExpr->pPhrase->iDoclistToken = -1;
120314 *pnOr += (pExpr->eType==FTSQUERY_OR);
120315 fts3EvalAllocateReaders(pCsr, pExpr->pLeft, pnToken, pnOr, pRc);
120316 fts3EvalAllocateReaders(pCsr, pExpr->pRight, pnToken, pnOr, pRc);
120713 Fts3Expr *pExpr, /* Expression to initialize phrases in */
120717 if( pExpr && SQLITE_OK==*pRc ){
120718 if( pExpr->eType==FTSQUERY_PHRASE ){
120720 int nToken = pExpr->pPhrase->nToken;
120722 if( pExpr->pPhrase->aToken[i].pDeferred==0 ) break;
120724 pExpr->bDeferred = (i==nToken);
120725 *pRc = fts3EvalPhraseStart(pCsr, bOptOk, pExpr->pPhrase);
120727 fts3EvalStartReaders(pCsr, pExpr->pLeft, bOptOk, pRc);
120728 fts3EvalStartReaders(pCsr, pExpr->pRight, bOptOk, pRc);
120729 pExpr->bDeferred = (pExpr->pLeft->bDeferred && pExpr->pRight->bDeferred);
120766 Fts3Expr *pExpr, /* Expression to consider */
120772 if( pExpr->eType==FTSQUERY_PHRASE ){
120773 Fts3Phrase *pPhrase = pExpr->pPhrase;
120784 }else if( pExpr->eType!=FTSQUERY_NOT ){
120785 assert( pExpr->eType==FTSQUERY_OR
120786 || pExpr->eType==FTSQUERY_AND
120787 || pExpr->eType==FTSQUERY_NEAR
120789 assert( pExpr->pLeft && pExpr->pRight );
120790 if( pExpr->eType==FTSQUERY_OR ){
120791 pRoot = pExpr->pLeft;
120795 fts3EvalTokenCosts(pCsr, pRoot, pExpr->pLeft, ppTC, ppOr, pRc);
120796 if( pExpr->eType==FTSQUERY_OR ){
120797 pRoot = pExpr->pRight;
120801 fts3EvalTokenCosts(pCsr, pRoot, pExpr->pRight, ppTC, ppOr, pRc);
120997 ** the full-text query currently stored in pCsr->pExpr. To iterate through
121014 fts3EvalAllocateReaders(pCsr, pCsr->pExpr, &nToken, &nOr, &rc);
121033 fts3EvalTokenCosts(pCsr, 0, pCsr->pExpr, &pTC, &ppOr, &rc);
121048 fts3EvalStartReaders(pCsr, pCsr->pExpr, 1, &rc);
121127 ** successful, the following variables in pExpr are set:
121162 Fts3Expr *pExpr, /* Expr. to advance to next matching row */
121167 assert( pExpr->bEof==0 );
121168 pExpr->bStart = 1;
121170 switch( pExpr->eType ){
121173 Fts3Expr *pLeft = pExpr->pLeft;
121174 Fts3Expr *pRight = pExpr->pRight;
121181 pExpr->iDocid = pRight->iDocid;
121182 pExpr->bEof = pRight->bEof;
121187 pExpr->iDocid = pLeft->iDocid;
121188 pExpr->bEof = pLeft->bEof;
121202 pExpr->iDocid = pLeft->iDocid;
121203 pExpr->bEof = (pLeft->bEof || pRight->bEof);
121209 Fts3Expr *pLeft = pExpr->pLeft;
121210 Fts3Expr *pRight = pExpr->pRight;
121225 pExpr->bEof = (pLeft->bEof && pRight->bEof);
121228 pExpr->iDocid = pLeft->iDocid;
121230 pExpr->iDocid = pRight->iDocid;
121237 Fts3Expr *pLeft = pExpr->pLeft;
121238 Fts3Expr *pRight = pExpr->pRight;
121254 pExpr->iDocid = pLeft->iDocid;
121255 pExpr->bEof = pLeft->bEof;
121260 Fts3Phrase *pPhrase = pExpr->pPhrase;
121262 *pRc = fts3EvalPhraseNext(pCsr, pPhrase, &pExpr->bEof);
121263 pExpr->iDocid = pPhrase->doclist.iDocid;
121271 ** If *pRc is not SQLITE_OK, or if pExpr is not the root node of a NEAR
121285 static int fts3EvalNearTest(Fts3Expr *pExpr, int *pRc){
121288 /* The following block runs if pExpr is the root of a NEAR query.
121309 && pExpr->eType==FTSQUERY_NEAR
121310 && pExpr->bEof==0
121311 && (pExpr->pParent==0 || pExpr->pParent->eType!=FTSQUERY_NEAR)
121318 for(p=pExpr; p->pLeft; p=p->pLeft){
121336 aPoslist = pExpr->pRight->pPhrase->doclist.pList;
121337 nToken = pExpr->pRight->pPhrase->nToken;
121338 for(p=pExpr->pLeft; p && res; p=p->pLeft){
121369 Fts3Expr *pExpr, /* Expr to test. May or may not be root. */
121374 switch( pExpr->eType ){
121378 fts3EvalTestExpr(pCsr, pExpr->pLeft, pRc)
121379 && fts3EvalTestExpr(pCsr, pExpr->pRight, pRc)
121380 && fts3EvalNearTest(pExpr, pRc)
121399 && pExpr->eType==FTSQUERY_NEAR
121400 && (pExpr->pParent==0 || pExpr->pParent->eType!=FTSQUERY_NEAR)
121403 for(p=pExpr; p->pPhrase==0; p=p->pLeft){
121416 int bHit1 = fts3EvalTestExpr(pCsr, pExpr->pLeft, pRc);
121417 int bHit2 = fts3EvalTestExpr(pCsr, pExpr->pRight, pRc);
121424 fts3EvalTestExpr(pCsr, pExpr->pLeft, pRc)
121425 && !fts3EvalTestExpr(pCsr, pExpr->pRight, pRc)
121431 && (pExpr->iDocid==pCsr->iPrevId || pExpr->bDeferred)
121433 Fts3Phrase *pPhrase = pExpr->pPhrase;
121434 assert( pExpr->bDeferred || pPhrase->doclist.bFreeList==0 );
121435 if( pExpr->bDeferred ){
121440 pExpr->iDocid = pCsr->iPrevId;
121442 bHit = (pExpr->bEof==0 && pExpr->iDocid==pCsr->iPrevId);
121492 bMiss = (0==fts3EvalTestExpr(pCsr, pCsr->pExpr, &rc));
121503 ** Fts3Cursor.pExpr.
121507 Fts3Expr *pExpr = pCsr->pExpr;
121509 if( pExpr==0 ){
121517 fts3EvalNextRow(pCsr, pExpr, &rc);
121518 pCsr->isEof = pExpr->bEof;
121521 pCsr->iPrevId = pExpr->iDocid;
121528 ** Restart interation for expression pExpr so that the next call to
121538 Fts3Expr *pExpr,
121541 if( pExpr && *pRc==SQLITE_OK ){
121542 Fts3Phrase *pPhrase = pExpr->pPhrase;
121557 pExpr->iDocid = 0;
121558 pExpr->bEof = 0;
121559 pExpr->bStart = 0;
121561 fts3EvalRestart(pCsr, pExpr->pLeft, pRc);
121562 fts3EvalRestart(pCsr, pExpr->pRight, pRc);
121568 ** expression rooted at pExpr, the cursor iterates through all rows matched
121569 ** by pExpr, calling this function for each row. This function increments
121574 static void fts3EvalUpdateCounts(Fts3Expr *pExpr){
121575 if( pExpr ){
121576 Fts3Phrase *pPhrase = pExpr->pPhrase;
121593 pExpr->aMI[iCol*3 + 1] += iCnt;
121594 pExpr->aMI[iCol*3 + 2] += (iCnt>0);
121601 fts3EvalUpdateCounts(pExpr->pLeft);
121602 fts3EvalUpdateCounts(pExpr->pRight);
121607 ** Expression pExpr must be of type FTSQUERY_PHRASE.
121610 ** populates the Fts3Expr.aMI[] array for expression pExpr. If pExpr is part
121619 Fts3Expr *pExpr /* FTSQUERY_PHRASE expression */
121623 assert( pExpr->eType==FTSQUERY_PHRASE );
121624 if( pExpr->aMI==0 ){
121634 pRoot = pExpr;
121731 Fts3Expr *pExpr, /* Phrase expression */
121738 if( pExpr->bDeferred && pExpr->pParent->eType!=FTSQUERY_NEAR ){
121745 rc = fts3EvalGatherStats(pCsr, pExpr);
121747 assert( pExpr->aMI );
121749 aiOut[iCol*3 + 1] = pExpr->aMI[iCol*3 + 1];
121750 aiOut[iCol*3 + 2] = pExpr->aMI[iCol*3 + 2];
121759 ** The expression pExpr passed as the second argument to this function
121779 Fts3Expr *pExpr, /* Phrase to return doclist for */
121782 Fts3Phrase *pPhrase = pExpr->pPhrase;
121789 || pExpr->bEof
121790 || pExpr->iDocid!=pCsr->iPrevId
123207 static char *exprToString(Fts3Expr *pExpr, char *zBuf){
123208 switch( pExpr->eType ){
123210 Fts3Phrase *pPhrase = pExpr->pPhrase;
123224 zBuf = sqlite3_mprintf("%zNEAR/%d ", zBuf, pExpr->nNear);
123238 if( zBuf ) zBuf = exprToString(pExpr->pLeft, zBuf);
123241 if( zBuf ) zBuf = exprToString(pExpr->pRight, zBuf);
123274 Fts3Expr *pExpr;
123316 pTokenizer, 0, azCol, 0, nCol, nCol, zExpr, nExpr, &pExpr
123320 }else if( rc==SQLITE_NOMEM || !(zBuf = exprToString(pExpr, 0)) ){
123327 sqlite3Fts3ExprFree(pExpr);
128797 Fts3Expr *pExpr, /* Expression to iterate phrases of */
128803 int eType = pExpr->eType; /* Type of expression node pExpr */
128806 assert( pExpr->pLeft && pExpr->pRight );
128807 rc = fts3ExprIterate2(pExpr->pLeft, piPhrase, x, pCtx);
128809 rc = fts3ExprIterate2(pExpr->pRight, piPhrase, x, pCtx);
128812 rc = x(pExpr, *piPhrase, pCtx);
128829 Fts3Expr *pExpr, /* Expression to iterate phrases of */
128834 return fts3ExprIterate2(pExpr, &iPhrase, x, pCtx);
128842 static int fts3ExprLoadDoclistsCb(Fts3Expr *pExpr, int iPhrase, void *ctx){
128844 Fts3Phrase *pPhrase = pExpr->pPhrase;
128873 rc = fts3ExprIterate(pCsr->pExpr, fts3ExprLoadDoclistsCb, (void *)&sCtx);
128879 static int fts3ExprPhraseCountCb(Fts3Expr *pExpr, int iPhrase, void *ctx){
128881 UNUSED_PARAMETER(pExpr);
128885 static int fts3ExprPhraseCount(Fts3Expr *pExpr){
128887 (void)fts3ExprIterate(pExpr, fts3ExprPhraseCountCb, (void *)&nPhrase);
129017 static int fts3SnippetFindPositions(Fts3Expr *pExpr, int iPhrase, void *ctx){
129022 pPhrase->nToken = pExpr->pPhrase->nToken;
129024 pCsr = sqlite3Fts3EvalPhrasePoslist(p->pCsr, pExpr, p->iCol);
129100 (void)fts3ExprIterate(pCsr->pExpr, fts3SnippetFindPositions, (void *)&sIter);
129404 ** If the phrase pExpr consists entirely of deferred tokens, then all X and
129411 Fts3Expr *pExpr, /* Phrase expression node */
129417 p->pCursor, pExpr, &p->aMatchinfo[3*iPhrase*p->nCol]
129427 Fts3Expr *pExpr, /* Phrase expression node */
129437 pCsr = sqlite3Fts3EvalPhrasePoslist(p->pCursor, pExpr, i);
129526 Fts3Expr *pExpr; /* Pointer to phrase expression */
129539 Fts3Expr *pExpr, /* Phrase expression node */
129544 aIter[iPhrase].pExpr = pExpr;
129593 (void)fts3ExprIterate(pCsr->pExpr, fts3MatchinfoLcsCb, (void*)aIter);
129597 nToken -= pIter->pExpr->pPhrase->nToken;
129607 pIt->pRead = sqlite3Fts3EvalPhrasePoslist(pCsr, pIt->pExpr, iCol);
129736 Fts3Expr *pExpr;
129738 pExpr = pCsr->pExpr;
129746 rc = fts3ExprIterate(pExpr, fts3ExprGlobalHitsCb,(void*)pInfo);
129749 (void)fts3ExprIterate(pExpr, fts3ExprLocalHitsCb,(void*)pInfo);
129800 pCsr->nPhrase = fts3ExprPhraseCount(pCsr->pExpr);
129860 if( !pCsr->pExpr ){
129953 static int fts3ExprTermOffsetInit(Fts3Expr *pExpr, int iPhrase, void *ctx){
129961 pList = sqlite3Fts3EvalPhrasePoslist(p->pCsr, pExpr, p->iCol);
129962 nTerm = pExpr->pPhrase->nToken;
129995 if( !pCsr->pExpr ){
130033 (void)fts3ExprIterate(pCsr->pExpr, fts3ExprTermOffsetInit, (void *)&sCtx);
130143 if( !pCsr->pExpr ){
133668 URegularExpression *pExpr = (URegularExpression *)p;
133669 uregex_close(pExpr);
133693 URegularExpression *pExpr;
133706 pExpr = sqlite3_get_auxdata(p, 0);
133707 if( !pExpr ){
133712 pExpr = uregex_open(zPattern, -1, 0, 0, &status);
133715 sqlite3_set_auxdata(p, 0, pExpr, icuRegexpDelete);
133717 assert(!pExpr);
133724 uregex_setText(pExpr, zString, -1, &status);
133731 res = uregex_matches(pExpr, 0, &status);
133742 uregex_setText(pExpr, 0, 0, &status);