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);
59357 ** Create a new sqlite3_value object, containing the value of pExpr.
59368 Expr *pExpr, /* The expression to evaluate */
59379 if( !pExpr ){
59383 op = pExpr->op;
59390 if( op==TK_REGISTER ) op = pExpr->op2;
59392 if( NEVER(op==TK_REGISTER) ) op = pExpr->op2;
59399 && (pExpr->pLeft->op==TK_INTEGER || pExpr->pLeft->op==TK_FLOAT) ){
59400 pExpr = pExpr->pLeft;
59401 op = pExpr->op;
59409 if( ExprHasProperty(pExpr, EP_IntValue) ){
59410 sqlite3VdbeMemSetInt64(pVal, (i64)pExpr->u.iValue*negInt);
59412 zVal = sqlite3MPrintf(db, "%s%s", zNeg, pExpr->u.zToken);
59428 if( SQLITE_OK==sqlite3ValueFromExpr(db,pExpr->pLeft,enc,affinity,&pVal) ){
59447 assert( pExpr->u.zToken[0]=='x' || pExpr->u.zToken[0]=='X' );
59448 assert( pExpr->u.zToken[1]=='\'' );
59451 zVal = &pExpr->u.zToken[2];
73067 SQLITE_PRIVATE int sqlite3WalkExpr(Walker *pWalker, Expr *pExpr){
73069 if( pExpr==0 ) return WRC_Continue;
73070 testcase( ExprHasProperty(pExpr, EP_TokenOnly) );
73071 testcase( ExprHasProperty(pExpr, EP_Reduced) );
73072 rc = pWalker->xExprCallback(pWalker, pExpr);
73074 && !ExprHasAnyProperty(pExpr,EP_TokenOnly) ){
73075 if( sqlite3WalkExpr(pWalker, pExpr->pLeft) ) return WRC_Abort;
73076 if( sqlite3WalkExpr(pWalker, pExpr->pRight) ) return WRC_Abort;
73077 if( ExprHasProperty(pExpr, EP_xIsSelect) ){
73078 if( sqlite3WalkSelect(pWalker, pExpr->x.pSelect) ) return WRC_Abort;
73080 if( sqlite3WalkExprList(pWalker, pExpr->x.pList) ) return WRC_Abort;
73095 if( sqlite3WalkExpr(pWalker, pItem->pExpr) ) return WRC_Abort;
73188 ** Turn the pExpr expression into an alias for the iCol-th column of the
73218 Expr *pExpr, /* Transform this into an alias to the result set */
73226 pOrig = pEList->a[iCol].pExpr;
73252 if( pExpr->flags & EP_ExpCollate ){
73253 pDup->pColl = pExpr->pColl;
73261 ExprSetProperty(pExpr, EP_Static);
73262 sqlite3ExprDelete(db, pExpr);
73263 memcpy(pExpr, pDup, sizeof(*pExpr));
73287 ** that name in the set of source tables in pSrcList and make the pExpr
73289 ** are made to pExpr:
73291 ** pExpr->iDb Set the index in db->aDb[] of the database X
73293 ** pExpr->iTable Set to the cursor number for the table obtained
73295 ** pExpr->pTab Points to the Table structure of X.Y (even if
73297 ** pExpr->iColumn Set to the column number within the table.
73298 ** pExpr->op Set to TK_COLUMN.
73299 ** pExpr->pLeft Any expression this points to is deleted
73300 ** pExpr->pRight Any expression this points to is deleted.
73318 Expr *pExpr /* Make this EXPR node point to the selected column */
73332 assert( ~ExprHasAnyProperty(pExpr, EP_TokenOnly|EP_Reduced) );
73335 pExpr->iTable = -1;
73336 pExpr->pTab = 0;
73337 ExprSetIrreducible(pExpr);
73369 pExpr->iTable = pItem->iCursor;
73370 pExpr->pTab = pTab;
73385 pExpr->iTable = pItem->iCursor;
73386 pExpr->pTab = pTab;
73390 pExpr->iColumn = j==pTab->iPKey ? -1 : (i16)j;
73406 pExpr->iTable = 1;
73409 pExpr->iTable = 0;
73432 pExpr->affinity = SQLITE_AFF_INTEGER;
73433 }else if( pExpr->iTable==0 ){
73442 pExpr->iColumn = (i16)iCol;
73443 pExpr->pTab = pTab;
73455 pExpr->iColumn = -1; /* IMP: R-44911-55124 */
73456 pExpr->affinity = SQLITE_AFF_INTEGER;
73466 ** In cases like this, replace pExpr with a copy of the expression that
73476 assert( pExpr->pLeft==0 && pExpr->pRight==0 );
73477 assert( pExpr->x.pList==0 );
73478 assert( pExpr->x.pSelect==0 );
73479 pOrig = pEList->a[j].pExpr;
73484 resolveAlias(pParse, pEList, j, pExpr, "");
73506 ** pExpr.
73511 if( cnt==0 && zTab==0 && ExprHasProperty(pExpr,EP_DblQuoted) ){
73512 pExpr->op = TK_STRING;
73513 pExpr->pTab = 0;
73541 if( pExpr->iColumn>=0 && pMatch!=0 ){
73542 int n = pExpr->iColumn;
73547 assert( pMatch->iCursor==pExpr->iTable );
73553 sqlite3ExprDelete(db, pExpr->pLeft);
73554 pExpr->pLeft = 0;
73555 sqlite3ExprDelete(db, pExpr->pRight);
73556 pExpr->pRight = 0;
73557 pExpr->op = (isTrigger ? TK_TRIGGER : TK_COLUMN);
73561 sqlite3AuthRead(pParse, pExpr, pSchema, pNC->pSrcList);
73610 static int resolveExprStep(Walker *pWalker, Expr *pExpr){
73619 if( ExprHasAnyProperty(pExpr, EP_Resolved) ) return WRC_Prune;
73620 ExprSetProperty(pExpr, EP_Resolved);
73630 switch( pExpr->op ){
73642 pExpr->op = TK_COLUMN;
73643 pExpr->pTab = pItem->pTab;
73644 pExpr->iTable = pItem->iCursor;
73645 pExpr->iColumn = -1;
73646 pExpr->affinity = SQLITE_AFF_INTEGER;
73654 return lookupName(pParse, 0, 0, pExpr->u.zToken, pNC, pExpr);
73667 pRight = pExpr->pRight;
73670 zTable = pExpr->pLeft->u.zToken;
73674 zDb = pExpr->pLeft->u.zToken;
73678 return lookupName(pParse, zDb, zTable, zColumn, pNC, pExpr);
73685 ExprList *pList = pExpr->x.pList; /* The argument list */
73696 testcase( pExpr->op==TK_CONST_FUNC );
73697 assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
73698 zId = pExpr->u.zToken;
73720 pExpr->op = TK_NULL;
73738 pExpr->op = TK_AGG_FUNCTION;
73744 /* FIX ME: Compute pExpr->affinity based on the expected return
73751 case TK_EXISTS: testcase( pExpr->op==TK_EXISTS );
73754 testcase( pExpr->op==TK_IN );
73755 if( ExprHasProperty(pExpr, EP_xIsSelect) ){
73762 sqlite3WalkSelect(pWalker, pExpr->x.pSelect);
73765 ExprSetProperty(pExpr, EP_VarSelect);
73868 if( sqlite3ExprCompare(pEList->a[i].pExpr, pE)<2 ){
73942 pE = pItem->pExpr;
73963 pItem->pExpr = pE = sqlite3Expr(db, TK_INTEGER, 0);
74022 resolveAlias(pParse, pEList, pItem->iOrderByCol-1, pItem->pExpr, zType);
74062 Expr *pE = pItem->pExpr;
74159 Expr *pX = pEList->a[i].pExpr;
74253 if( ExprHasProperty(pItem->pExpr, EP_Agg) ){
74327 Expr *pExpr /* The expression to be analyzed. */
74332 if( pExpr==0 ) return 0;
74336 if( sqlite3ExprCheckHeight(pParse, pExpr->nHeight+pNC->pParse->nHeight) ){
74339 pParse->nHeight += pExpr->nHeight;
74348 sqlite3WalkExpr(&w, pExpr);
74350 pNC->pParse->nHeight -= pExpr->nHeight;
74353 ExprSetProperty(pExpr, EP_Error);
74356 ExprSetProperty(pExpr, EP_Agg);
74360 return ExprHasProperty(pExpr, EP_Error);
74409 ** Return the 'affinity' of the expression pExpr if any.
74411 ** If pExpr is a column, a reference to a column via an 'AS' alias,
74424 SQLITE_PRIVATE char sqlite3ExprAffinity(Expr *pExpr){
74425 int op = pExpr->op;
74427 assert( pExpr->flags&EP_xIsSelect );
74428 return sqlite3ExprAffinity(pExpr->x.pSelect->pEList->a[0].pExpr);
74432 assert( !ExprHasProperty(pExpr, EP_IntValue) );
74433 return sqlite3AffinityType(pExpr->u.zToken);
74437 && pExpr->pTab!=0
74439 /* op==TK_REGISTER && pExpr->pTab!=0 happens when pExpr was originally
74441 int j = pExpr->iColumn;
74443 assert( pExpr->pTab && j<pExpr->pTab->nCol );
74444 return pExpr->pTab->aCol[j].affinity;
74446 return pExpr->affinity;
74453 SQLITE_PRIVATE Expr *sqlite3ExprSetColl(Expr *pExpr, CollSeq *pColl){
74454 if( pExpr && pColl ){
74455 pExpr->pColl = pColl;
74456 pExpr->flags |= EP_ExpCollate;
74458 return pExpr;
74462 ** Set the collating sequence for expression pExpr to be the collating
74468 SQLITE_PRIVATE Expr *sqlite3ExprSetCollByToken(Parse *pParse, Expr *pExpr, Token *pCollName){
74474 sqlite3ExprSetColl(pExpr, pColl);
74476 return pExpr;
74480 ** Return the default collation sequence for the expression pExpr. If
74483 SQLITE_PRIVATE CollSeq *sqlite3ExprCollSeq(Parse *pParse, Expr *pExpr){
74485 Expr *p = pExpr;
74494 /* op==TK_REGISTER && p->pTab!=0 happens when pExpr was originally
74502 pExpr->pColl = pColl;
74518 ** pExpr is an operand of a comparison operator. aff2 is the
74522 SQLITE_PRIVATE char sqlite3CompareAffinity(Expr *pExpr, char aff2){
74523 char aff1 = sqlite3ExprAffinity(pExpr);
74546 ** pExpr is a comparison operator. Return the type affinity that should
74549 static char comparisonAffinity(Expr *pExpr){
74551 assert( pExpr->op==TK_EQ || pExpr->op==TK_IN || pExpr->op==TK_LT ||
74552 pExpr->op==TK_GT || pExpr->op==TK_GE || pExpr->op==TK_LE ||
74553 pExpr->op==TK_NE || pExpr->op==TK_IS || pExpr->op==TK_ISNOT );
74554 assert( pExpr->pLeft );
74555 aff = sqlite3ExprAffinity(pExpr->pLeft);
74556 if( pExpr->pRight ){
74557 aff = sqlite3CompareAffinity(pExpr->pRight, aff);
74558 }else if( ExprHasProperty(pExpr, EP_xIsSelect) ){
74559 aff = sqlite3CompareAffinity(pExpr->x.pSelect->pEList->a[0].pExpr, aff);
74567 ** pExpr is a comparison expression, eg. '=', '<', IN(...) etc.
74570 ** the comparison in pExpr.
74572 SQLITE_PRIVATE int sqlite3IndexAffinityOk(Expr *pExpr, char idx_affinity){
74573 char aff = comparisonAffinity(pExpr);
74690 heightOfExpr(p->a[i].pExpr, pnHeight);
74937 SQLITE_PRIVATE void sqlite3ExprAssignVarNumber(Parse *pParse, Expr *pExpr){
74941 if( pExpr==0 ) return;
74942 assert( !ExprHasAnyProperty(pExpr, EP_IntValue|EP_Reduced|EP_TokenOnly) );
74943 z = pExpr->u.zToken;
74949 pExpr->iColumn = (ynVar)(++pParse->nVar);
74958 pExpr->iColumn = x = (ynVar)i;
74979 pExpr->iColumn = x = (ynVar)i+1;
74983 if( x==0 ) x = pExpr->iColumn = (ynVar)(++pParse->nVar);
75259 Expr *pOldExpr = pOldItem->pExpr;
75260 pItem->pExpr = sqlite3ExprDup(db, pOldExpr, flags);
75382 Expr *pExpr /* Expression to be appended. Might be NULL */
75405 pItem->pExpr = pExpr;
75411 sqlite3ExprDelete(db, pExpr);
75459 assert( db->mallocFailed || pItem->pExpr==pSpan->pExpr );
75492 sqlite3ExprDelete(db, pItem->pExpr);
75513 static int exprNodeIsConstant(Walker *pWalker, Expr *pExpr){
75518 if( pWalker->u.i==3 && ExprHasAnyProperty(pExpr, EP_FromJoin) ){
75523 switch( pExpr->op ){
75533 testcase( pExpr->op==TK_ID );
75534 testcase( pExpr->op==TK_COLUMN );
75535 testcase( pExpr->op==TK_AGG_FUNCTION );
75536 testcase( pExpr->op==TK_AGG_COLUMN );
75540 testcase( pExpr->op==TK_SELECT ); /* selectNodeIsConstant will disallow */
75541 testcase( pExpr->op==TK_EXISTS ); /* selectNodeIsConstant will disallow */
75663 ** was computed by pExpr. If we can look at pExpr at compile-time and
75669 const Expr *pExpr, /* Only generate OP_IsNull if this expr can be NULL */
75673 if( sqlite3ExprCanBeNull(pExpr) ){
75766 if( pEList->a[0].pExpr->op!=TK_COLUMN ) return 0; /* Result is a column */
75852 Expr *pExpr; /* Expression <column> */
75858 assert( p->pEList->a[0].pExpr!=0 ); /* Because of isCandidateForInOpt(p) */
75861 pExpr = p->pEList->a[0].pExpr;
75862 iCol = pExpr->iColumn;
75889 CollSeq *pReq = sqlite3BinaryCompareCollSeq(pParse, pX->pLeft, pExpr);
75959 ** The pExpr parameter describes the expression that contains the IN
75962 ** If parameter isRowid is non-zero, then expression pExpr is guaranteed
75986 Expr *pExpr, /* The IN, SELECT, or EXISTS operator */
76006 if( !ExprHasAnyProperty(pExpr, EP_VarSelect) ){
76014 pExpr->op==TK_IN?"LIST":"SCALAR", pParse->iNextSelectId
76020 switch( pExpr->op ){
76025 Expr *pLeft = pExpr->pLeft; /* the LHS of the IN operator */
76046 pExpr->iTable = pParse->nTab++;
76047 addr = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, pExpr->iTable, !isRowid);
76052 if( ExprHasProperty(pExpr, EP_xIsSelect) ){
76062 sqlite3SelectDestInit(&dest, SRT_Set, pExpr->iTable);
76064 assert( (pExpr->iTable&0x0000FFFF)==pExpr->iTable );
76065 pExpr->x.pSelect->iLimit = 0;
76066 if( sqlite3Select(pParse, pExpr->x.pSelect, &dest) ){
76069 pEList = pExpr->x.pSelect->pEList;
76071 keyInfo.aColl[0] = sqlite3BinaryCompareCollSeq(pParse, pExpr->pLeft,
76072 pEList->a[0].pExpr);
76074 }else if( ALWAYS(pExpr->x.pList!=0) ){
76083 ExprList *pList = pExpr->x.pList;
76090 keyInfo.aColl[0] = sqlite3ExprCollSeq(pParse, pExpr->pLeft);
76097 Expr *pE2 = pItem->pExpr;
76112 sqlite3VdbeAddOp3(v, OP_InsertInt, pExpr->iTable, r2, iValToIns);
76118 sqlite3VdbeAddOp3(v, OP_Insert, pExpr->iTable, r2, r3);
76122 sqlite3VdbeAddOp2(v, OP_IdxInsert, pExpr->iTable, r2);
76147 testcase( pExpr->op==TK_EXISTS );
76148 testcase( pExpr->op==TK_SELECT );
76149 assert( pExpr->op==TK_EXISTS || pExpr->op==TK_SELECT );
76151 assert( ExprHasProperty(pExpr, EP_xIsSelect) );
76152 pSel = pExpr->x.pSelect;
76154 if( pExpr->op==TK_SELECT ){
76171 ExprSetIrreducible(pExpr);
76205 Expr *pExpr, /* The IN expression */
76216 ** pExpr->iTable will contains the values that make up the RHS.
76221 eType = sqlite3FindInIndex(pParse, pExpr, &rRhsHasNull);
76227 affinity = comparisonAffinity(pExpr);
76233 sqlite3ExprCode(pParse, pExpr->pLeft, r1);
76244 sqlite3VdbeAddOp2(v, OP_Rewind, pExpr->iTable, destIfFalse);
76253 sqlite3VdbeAddOp3(v, OP_NotExists, pExpr->iTable, destIfFalse, r1);
76273 sqlite3VdbeAddOp4Int(v, OP_NotFound, pExpr->iTable, destIfFalse, r1, 1);
76286 j1 = sqlite3VdbeAddOp4Int(v, OP_Found, pExpr->iTable, 0, r1, 1);
76295 j3 = sqlite3VdbeAddOp4Int(v, OP_Found, pExpr->iTable, 0, rRhsHasNull, 1);
76359 static void codeInteger(Parse *pParse, Expr *pExpr, int negFlag, int iMem){
76361 if( pExpr->flags & EP_IntValue ){
76362 int i = pExpr->u.iValue;
76369 const char *z = pExpr->u.zToken;
76670 SQLITE_PRIVATE int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target){
76685 if( pExpr==0 ){
76688 op = pExpr->op;
76692 AggInfo *pAggInfo = pExpr->pAggInfo;
76693 struct AggInfo_col *pCol = &pAggInfo->aCol[pExpr->iAgg];
76706 if( pExpr->iTable<0 ){
76709 inReg = pExpr->iColumn + pParse->ckBase;
76711 inReg = sqlite3ExprCodeGetColumn(pParse, pExpr->pTab,
76712 pExpr->iColumn, pExpr->iTable, target);
76717 codeInteger(pParse, pExpr, 0, target);
76722 assert( !ExprHasProperty(pExpr, EP_IntValue) );
76723 codeReal(v, pExpr->u.zToken, 0, target);
76728 assert( !ExprHasProperty(pExpr, EP_IntValue) );
76729 sqlite3VdbeAddOp4(v, OP_String8, 0, target, 0, pExpr->u.zToken, 0);
76741 assert( !ExprHasProperty(pExpr, EP_IntValue) );
76742 assert( pExpr->u.zToken[0]=='x' || pExpr->u.zToken[0]=='X' );
76743 assert( pExpr->u.zToken[1]=='\'' );
76744 z = &pExpr->u.zToken[2];
76753 assert( !ExprHasProperty(pExpr, EP_IntValue) );
76754 assert( pExpr->u.zToken!=0 );
76755 assert( pExpr->u.zToken[0]!=0 );
76756 sqlite3VdbeAddOp2(v, OP_Variable, pExpr->iColumn, target);
76757 if( pExpr->u.zToken[1]!=0 ){
76758 assert( pExpr->u.zToken[0]=='?'
76759 || strcmp(pExpr->u.zToken, pParse->azVar[pExpr->iColumn-1])==0 );
76760 sqlite3VdbeChangeP4(v, -1, pParse->azVar[pExpr->iColumn-1], P4_STATIC);
76765 inReg = pExpr->iTable;
76769 inReg = sqlite3ExprCodeTarget(pParse, pExpr->pLeft, target);
76776 inReg = sqlite3ExprCodeTarget(pParse, pExpr->pLeft, target);
76777 assert( !ExprHasProperty(pExpr, EP_IntValue) );
76778 aff = sqlite3AffinityType(pExpr->u.zToken);
76818 r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, ®Free1);
76819 r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, ®Free2);
76820 codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,
76830 r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, ®Free1);
76831 r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, ®Free2);
76833 codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,
76873 r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, ®Free1);
76874 r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, ®Free2);
76881 Expr *pLeft = pExpr->pLeft;
76887 assert( !ExprHasProperty(pExpr, EP_IntValue) );
76893 r2 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, ®Free2);
76906 r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, ®Free1);
76920 r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, ®Free1);
76928 AggInfo *pInfo = pExpr->pAggInfo;
76930 assert( !ExprHasProperty(pExpr, EP_IntValue) );
76931 sqlite3ErrorMsg(pParse, "misuse of aggregate: %s()", pExpr->u.zToken);
76933 inReg = pInfo->aFunc[pExpr->iAgg].iMem;
76949 assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
76952 if( ExprHasAnyProperty(pExpr, EP_TokenOnly) ){
76955 pFarg = pExpr->x.pList;
76958 assert( !ExprHasProperty(pExpr, EP_IntValue) );
76959 zId = pExpr->u.zToken;
76974 sqlite3ExprCode(pParse, pFarg->a[0].pExpr, target);
76979 sqlite3ExprCode(pParse, pFarg->a[i].pExpr, target);
77008 if( nFarg>=2 && (pExpr->flags & EP_InfixFunc) ){
77009 pDef = sqlite3VtabOverloadFunction(db, pDef, nFarg, pFarg->a[1].pExpr);
77011 pDef = sqlite3VtabOverloadFunction(db, pDef, nFarg, pFarg->a[0].pExpr);
77015 if( i<32 && sqlite3ExprIsConstant(pFarg->a[i].pExpr) ){
77019 pColl = sqlite3ExprCollSeq(pParse, pFarg->a[i].pExpr);
77039 inReg = sqlite3CodeSubselect(pParse, pExpr, 0, 0);
77046 sqlite3ExprCodeIN(pParse, pExpr, destIfFalse, destIfNull);
77063 ** X is stored in pExpr->pLeft.
77064 ** Y is stored in pExpr->pList->a[0].pExpr.
77065 ** Z is stored in pExpr->pList->a[1].pExpr.
77068 Expr *pLeft = pExpr->pLeft;
77069 struct ExprList_item *pLItem = pExpr->x.pList->a;
77070 Expr *pRight = pLItem->pExpr;
77081 pRight = pLItem->pExpr;
77092 inReg = sqlite3ExprCodeTarget(pParse, pExpr->pLeft, target);
77122 Table *pTab = pExpr->pTab;
77123 int p1 = pExpr->iTable * (pTab->nCol+1) + 1 + pExpr->iColumn;
77125 assert( pExpr->iTable==0 || pExpr->iTable==1 );
77126 assert( pExpr->iColumn>=-1 && pExpr->iColumn<pTab->nCol );
77127 assert( pTab->iPKey<0 || pExpr->iColumn!=pTab->iPKey );
77132 (pExpr->iTable ? "new" : "old"),
77133 (pExpr->iColumn<0 ? "rowid" : pExpr->pTab->aCol[pExpr->iColumn].zName),
77140 if( pExpr->iColumn>=0
77141 && pTab->aCol[pExpr->iColumn].affinity==SQLITE_AFF_REAL
77161 ** X (if it exists) is in pExpr->pLeft.
77162 ** Y is in pExpr->pRight. The Y is also optional. If there is no
77165 ** Ei is in pExpr->pList->a[i*2] and Ri is pExpr->pList->a[i*2+1].
77184 assert( !ExprHasProperty(pExpr, EP_xIsSelect) && pExpr->x.pList );
77185 assert((pExpr->x.pList->nExpr % 2) == 0);
77186 assert(pExpr->x.pList->nExpr > 0);
77187 pEList = pExpr->x.pList;
77191 if( (pX = pExpr->pLeft)!=0 ){
77211 opCompare.pRight = aListelem[i].pExpr;
77213 pTest = aListelem[i].pExpr;
77218 testcase( aListelem[i+1].pExpr->op==TK_COLUMN );
77219 testcase( aListelem[i+1].pExpr->op==TK_REGISTER );
77220 sqlite3ExprCode(pParse, aListelem[i+1].pExpr, target);
77225 if( pExpr->pRight ){
77227 sqlite3ExprCode(pParse, pExpr->pRight, target);
77239 assert( pExpr->affinity==OE_Rollback
77240 || pExpr->affinity==OE_Abort
77241 || pExpr->affinity==OE_Fail
77242 || pExpr->affinity==OE_Ignore
77249 if( pExpr->affinity==OE_Abort ){
77252 assert( !ExprHasProperty(pExpr, EP_IntValue) );
77253 if( pExpr->affinity==OE_Ignore ){
77255 v, OP_Halt, SQLITE_OK, OE_Ignore, 0, pExpr->u.zToken,0);
77257 sqlite3HaltConstraint(pParse, pExpr->affinity, pExpr->u.zToken, 0);
77278 SQLITE_PRIVATE int sqlite3ExprCodeTemp(Parse *pParse, Expr *pExpr, int *pReg){
77280 int r2 = sqlite3ExprCodeTarget(pParse, pExpr, r1);
77291 ** Generate code that will evaluate expression pExpr and store the
77295 SQLITE_PRIVATE int sqlite3ExprCode(Parse *pParse, Expr *pExpr, int target){
77299 if( pExpr && pExpr->op==TK_REGISTER ){
77300 sqlite3VdbeAddOp2(pParse->pVdbe, OP_Copy, pExpr->iTable, target);
77302 inReg = sqlite3ExprCodeTarget(pParse, pExpr, target);
77323 SQLITE_PRIVATE int sqlite3ExprCodeAndCache(Parse *pParse, Expr *pExpr, int target){
77326 inReg = sqlite3ExprCode(pParse, pExpr, target);
77334 if( ALWAYS(pExpr->op!=TK_REGISTER) ){
77338 pExpr->iTable = iMem;
77339 pExpr->op2 = pExpr->op;
77340 pExpr->op = TK_REGISTER;
77349 SQLITE_PRIVATE void sqlite3ExplainExpr(Vdbe *pOut, Expr *pExpr){
77353 if( pExpr==0 ){
77356 op = pExpr->op;
77361 pExpr->iTable, pExpr->iColumn);
77365 if( pExpr->iTable<0 ){
77367 sqlite3ExplainPrintf(pOut, "COLUMN(%d)", pExpr->iColumn);
77370 pExpr->iTable, pExpr->iColumn);
77375 if( pExpr->flags & EP_IntValue ){
77376 sqlite3ExplainPrintf(pOut, "%d", pExpr->u.iValue);
77378 sqlite3ExplainPrintf(pOut, "%s", pExpr->u.zToken);
77384 sqlite3ExplainPrintf(pOut,"%s", pExpr->u.zToken);
77389 sqlite3ExplainPrintf(pOut,"%Q", pExpr->u.zToken);
77398 sqlite3ExplainPrintf(pOut,"%s", pExpr->u.zToken);
77404 pExpr->u.zToken, pExpr->iColumn);
77408 sqlite3ExplainPrintf(pOut,"REGISTER(%d)", pExpr->iTable);
77412 sqlite3ExplainExpr(pOut, pExpr->pLeft);
77419 switch( sqlite3AffinityType(pExpr->u.zToken) ){
77427 sqlite3ExplainExpr(pOut, pExpr->pLeft);
77464 if( ExprHasAnyProperty(pExpr, EP_TokenOnly) ){
77467 pFarg = pExpr->x.pList;
77471 pExpr->u.zToken);
77481 sqlite3ExplainSelect(pOut, pExpr->x.pSelect);
77487 sqlite3ExplainSelect(pOut, pExpr->x.pSelect);
77493 sqlite3ExplainExpr(pOut, pExpr->pLeft);
77495 if( ExprHasProperty(pExpr, EP_xIsSelect) ){
77496 sqlite3ExplainSelect(pOut, pExpr->x.pSelect);
77498 sqlite3ExplainExprList(pOut, pExpr->x.pList);
77512 ** X is stored in pExpr->pLeft.
77513 ** Y is stored in pExpr->pList->a[0].pExpr.
77514 ** Z is stored in pExpr->pList->a[1].pExpr.
77517 Expr *pX = pExpr->pLeft;
77518 Expr *pY = pExpr->x.pList->a[0].pExpr;
77519 Expr *pZ = pExpr->x.pList->a[1].pExpr;
77538 pExpr->iTable ? "NEW" : "OLD", pExpr->iColumn);
77543 sqlite3ExplainExpr(pOut, pExpr->pLeft);
77545 sqlite3ExplainExprList(pOut, pExpr->x.pList);
77551 switch( pExpr->affinity ){
77557 sqlite3ExplainPrintf(pOut, "RAISE-%s(%s)", zType, pExpr->u.zToken);
77564 sqlite3ExplainExpr(pOut, pExpr->pLeft);
77566 sqlite3ExplainExpr(pOut, pExpr->pRight);
77570 sqlite3ExplainExpr(pOut, pExpr->pLeft);
77586 sqlite3ExplainExpr(pOut, pList->a[0].pExpr);
77592 sqlite3ExplainExpr(pOut, pList->a[i].pExpr);
77604 ** Return TRUE if pExpr is an constant expression that is appropriate
77663 ** If pExpr is a constant expression that is appropriate for
77668 static int evalConstExpr(Walker *pWalker, Expr *pExpr){
77670 switch( pExpr->op ){
77682 ExprList *pList = pExpr->x.pList;
77683 assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
77688 if( ALWAYS(pItem->pExpr) ) pItem->pExpr->flags |= EP_FixedDest;
77694 if( isAppropriateForFactoring(pExpr) ){
77697 r2 = sqlite3ExprCodeTarget(pParse, pExpr, r1);
77699 pExpr->op2 = pExpr->op;
77700 pExpr->op = TK_REGISTER;
77701 pExpr->iTable = r2;
77708 ** Preevaluate constant subexpressions within pExpr and store the
77709 ** results in registers. Modify pExpr so that the constant subexpresions
77723 SQLITE_PRIVATE void sqlite3ExprCodeConstants(Parse *pParse, Expr *pExpr){
77730 sqlite3WalkExpr(&w, pExpr);
77753 Expr *pExpr = pItem->pExpr;
77754 int inReg = sqlite3ExprCodeTarget(pParse, pExpr, target+i);
77777 Expr *pExpr, /* The BETWEEN expression */
77788 assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
77789 exprX = *pExpr->pLeft;
77795 compLeft.pRight = pExpr->x.pList->a[0].pExpr;
77798 compRight.pRight = pExpr->x.pList->a[1].pExpr;
77833 SQLITE_PRIVATE void sqlite3ExprIfTrue(Parse *pParse, Expr *pExpr, int dest, int jumpIfNull){
77842 if( NEVER(pExpr==0) ) return; /* No way this can happen */
77843 op = pExpr->op;
77849 sqlite3ExprIfFalse(pParse, pExpr->pLeft, d2,jumpIfNull^SQLITE_JUMPIFNULL);
77850 sqlite3ExprIfTrue(pParse, pExpr->pRight, dest, jumpIfNull);
77857 sqlite3ExprIfTrue(pParse, pExpr->pLeft, dest, jumpIfNull);
77858 sqlite3ExprIfTrue(pParse, pExpr->pRight, dest, jumpIfNull);
77863 sqlite3ExprIfFalse(pParse, pExpr->pLeft, dest, jumpIfNull);
77885 r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, ®Free1);
77886 r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, ®Free2);
77887 codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,
77897 r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, ®Free1);
77898 r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, ®Free2);
77900 codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,
77912 r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, ®Free1);
77919 exprCodeBetween(pParse, pExpr, dest, 1, jumpIfNull);
77926 sqlite3ExprCodeIN(pParse, pExpr, destIfFalse, destIfNull);
77933 r1 = sqlite3ExprCodeTemp(pParse, pExpr, ®Free1);
77953 SQLITE_PRIVATE void sqlite3ExprIfFalse(Parse *pParse, Expr *pExpr, int dest, int jumpIfNull){
77962 if( pExpr==0 ) return;
77964 /* The value of pExpr->op and op are related as follows:
77966 ** pExpr->op op
77977 ** For other values of pExpr->op, op is undefined and unused.
77982 op = ((pExpr->op+(TK_ISNULL&1))^1)-(TK_ISNULL&1);
77986 assert( pExpr->op!=TK_ISNULL || op==OP_NotNull );
77987 assert( pExpr->op!=TK_NOTNULL || op==OP_IsNull );
77988 assert( pExpr->op!=TK_NE || op==OP_Eq );
77989 assert( pExpr->op!=TK_EQ || op==OP_Ne );
77990 assert( pExpr->op!=TK_LT || op==OP_Ge );
77991 assert( pExpr->op!=TK_LE || op==OP_Gt );
77992 assert( pExpr->op!=TK_GT || op==OP_Le );
77993 assert( pExpr->op!=TK_GE || op==OP_Lt );
77995 switch( pExpr->op ){
77998 sqlite3ExprIfFalse(pParse, pExpr->pLeft, dest, jumpIfNull);
77999 sqlite3ExprIfFalse(pParse, pExpr->pRight, dest, jumpIfNull);
78006 sqlite3ExprIfTrue(pParse, pExpr->pLeft, d2, jumpIfNull^SQLITE_JUMPIFNULL);
78007 sqlite3ExprIfFalse(pParse, pExpr->pRight, dest, jumpIfNull);
78014 sqlite3ExprIfTrue(pParse, pExpr->pLeft, dest, jumpIfNull);
78030 r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, ®Free1);
78031 r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, ®Free2);
78032 codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,
78040 testcase( pExpr->op==TK_IS );
78041 testcase( pExpr->op==TK_ISNOT );
78042 r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, ®Free1);
78043 r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, ®Free2);
78044 op = (pExpr->op==TK_IS) ? TK_NE : TK_EQ;
78045 codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,
78055 r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, ®Free1);
78062 exprCodeBetween(pParse, pExpr, dest, 0, jumpIfNull);
78068 sqlite3ExprCodeIN(pParse, pExpr, dest, dest);
78071 sqlite3ExprCodeIN(pParse, pExpr, dest, destIfNull);
78078 r1 = sqlite3ExprCodeTemp(pParse, pExpr, ®Free1);
78153 Expr *pExprA = pA->a[i].pExpr;
78154 Expr *pExprB = pB->a[i].pExpr;
78198 static int analyzeAggregate(Walker *pWalker, Expr *pExpr){
78205 switch( pExpr->op ){
78208 testcase( pExpr->op==TK_AGG_COLUMN );
78209 testcase( pExpr->op==TK_COLUMN );
78216 assert( !ExprHasAnyProperty(pExpr, EP_TokenOnly|EP_Reduced) );
78217 if( pExpr->iTable==pItem->iCursor ){
78218 /* If we reach this point, it means that pExpr refers to a table
78227 if( pCol->iTable==pExpr->iTable &&
78228 pCol->iColumn==pExpr->iColumn ){
78236 pCol->pTab = pExpr->pTab;
78237 pCol->iTable = pExpr->iTable;
78238 pCol->iColumn = pExpr->iColumn;
78241 pCol->pExpr = pExpr;
78248 Expr *pE = pTerm->pExpr;
78249 if( pE->op==TK_COLUMN && pE->iTable==pExpr->iTable &&
78250 pE->iColumn==pExpr->iColumn ){
78260 /* There is now an entry for pExpr in pAggInfo->aCol[] (either
78262 ** Convert the pExpr to be a TK_AGG_COLUMN referring to that
78265 ExprSetIrreducible(pExpr);
78266 pExpr->pAggInfo = pAggInfo;
78267 pExpr->op = TK_AGG_COLUMN;
78268 pExpr->iAgg = (i16)k;
78270 } /* endif pExpr->iTable==pItem->iCursor */
78279 /* Check to see if pExpr is a duplicate of another aggregate
78284 if( sqlite3ExprCompare(pItem->pExpr, pExpr)==0 ){
78289 /* pExpr is original. Make a new entry in pAggInfo->aFunc[]
78294 assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
78296 pItem->pExpr = pExpr;
78298 assert( !ExprHasProperty(pExpr, EP_IntValue) );
78300 pExpr->u.zToken, sqlite3Strlen30(pExpr->u.zToken),
78301 pExpr->x.pList ? pExpr->x.pList->nExpr : 0, enc, 0);
78302 if( pExpr->flags & EP_Distinct ){
78309 /* Make pExpr point to the appropriate pAggInfo->aFunc[] entry
78311 assert( !ExprHasAnyProperty(pExpr, EP_TokenOnly|EP_Reduced) );
78312 ExprSetIrreducible(pExpr);
78313 pExpr->iAgg = (i16)i;
78314 pExpr->pAggInfo = pAggInfo;
78341 SQLITE_PRIVATE void sqlite3ExprAnalyzeAggregates(NameContext *pNC, Expr *pExpr){
78347 sqlite3WalkExpr(&w, pExpr);
78361 sqlite3ExprAnalyzeAggregates(pNC, pItem->pExpr);
80415 ** This only applies to the root node of pExpr, so the statement:
80421 static int resolveAttachExpr(NameContext *pName, Expr *pExpr)
80424 if( pExpr ){
80425 if( pExpr->op!=TK_ID ){
80426 rc = sqlite3ResolveExprNames(pName, pExpr);
80427 if( rc==SQLITE_OK && !sqlite3ExprIsConstant(pExpr) ){
80428 sqlite3ErrorMsg(pName->pParse, "invalid name: \"%s\"", pExpr->u.zToken);
80432 pExpr->op = TK_STRING;
80892 Expr *pExpr /* The expression to be fixed to one database */
80894 while( pExpr ){
80895 if( ExprHasAnyProperty(pExpr, EP_TokenOnly) ) break;
80896 if( ExprHasProperty(pExpr, EP_xIsSelect) ){
80897 if( sqlite3FixSelect(pFix, pExpr->x.pSelect) ) return 1;
80899 if( sqlite3FixExprList(pFix, pExpr->x.pList) ) return 1;
80901 if( sqlite3FixExpr(pFix, pExpr->pRight) ){
80904 pExpr = pExpr->pLeft;
80916 if( sqlite3FixExpr(pFix, pItem->pExpr) ){
81042 ** If SQLITE_IGNORE is returned and pExpr is not NULL, then pExpr is changed
81043 ** to an SQL NULL expression. Otherwise, if pExpr is NULL, then SQLITE_IGNORE
81071 ** The pExpr should be a TK_COLUMN expression. The table referred to
81081 Expr *pExpr, /* The expression to check authorization on */
81083 SrcList *pTabList /* All table that pExpr might refer to */
81100 assert( pExpr->op==TK_COLUMN || pExpr->op==TK_TRIGGER );
81101 if( pExpr->op==TK_TRIGGER ){
81106 if( pExpr->iTable==pTabList->a[iSrc].iCursor ){
81112 iCol = pExpr->iColumn;
81126 pExpr->op = TK_NULL;
82295 if( !sqlite3ExprIsConstantOrFunction(pSpan->pExpr) ){
82299 /* A copy of pExpr is used instead of the original, as pExpr contains
82304 pCol->pDflt = sqlite3ExprDup(db, pSpan->pExpr, EXPRDUP_REDUCE);
82310 sqlite3ExprDelete(db, pSpan->pExpr);
83842 Expr *pExpr = pList->a[i].pExpr;
83843 if( pExpr ){
83844 CollSeq *pColl = pExpr->pColl;
83922 /* Justification of the ALWAYS(pListItem->pExpr->pColl): Because of
83924 ** if pListItem->pExpr is not null then either pListItem->pExpr->pColl
83927 if( pListItem->pExpr && ALWAYS(pListItem->pExpr->pColl) ){
83929 zColl = pListItem->pExpr->pColl->zName;
87605 ** pExpr points to an expression which implements a function. If
87611 SQLITE_PRIVATE int sqlite3IsLikeFunction(sqlite3 *db, Expr *pExpr, int *pIsNocase, char *aWc){
87613 if( pExpr->op!=TK_FUNCTION
87614 || !pExpr->x.pList
87615 || pExpr->x.pList->nExpr!=2
87619 assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
87620 pDef = sqlite3FindFunction(db, pExpr->u.zToken,
87621 sqlite3Strlen30(pExpr->u.zToken),
89638 if( sqlite3ResolveExprNames(&sNC, pList->a[i].pExpr) ){
89789 sqlite3ExprCode(pParse, pList->a[keyColumn].pExpr, regCols);
89818 sqlite3ExprCodeAndCache(pParse, pList->a[j].pExpr, regCols+i+1);
89856 sqlite3ExprCode(pParse, pList->a[keyColumn].pExpr, regRowid);
89923 sqlite3ExprCode(pParse, pList->a[j].pExpr, iRegStore);
90635 assert( pEList->a[0].pExpr );
90636 if( pEList->a[0].pExpr->op!=TK_ALL ){
95159 p->affinity = sqlite3CompareAffinity(pEList->a[0].pExpr, pDest->affinity);
95275 pColl = sqlite3ExprCollSeq(pParse, pItem->pExpr);
95487 ** expression pExpr. The string may be treated as static by the caller.
95505 Expr *pExpr,
95515 if( NEVER(pExpr==0) || pNC->pSrcList==0 ) return 0;
95517 switch( pExpr->op ){
95526 int iCol = pExpr->iColumn; /* Index of column in pTab */
95527 testcase( pExpr->op==TK_AGG_COLUMN );
95528 testcase( pExpr->op==TK_COLUMN );
95531 for(j=0;j<pTabList->nSrc && pTabList->a[j].iCursor!=pExpr->iTable;j++);
95561 assert( pTab && pExpr->pTab==pTab );
95573 Expr *p = pS->pEList->a[iCol].pExpr;
95606 Select *pS = pExpr->x.pSelect;
95607 Expr *p = pS->pEList->a[0].pExpr;
95608 assert( ExprHasProperty(pExpr, EP_xIsSelect) );
95643 Expr *p = pEList->a[i].pExpr;
95695 p = pEList->a[i].pExpr;
95768 p = pEList->a[i].pExpr;
95863 p = a[i].pExpr;
96015 pRet = sqlite3ExprCollSeq(pParse, p->pEList->a[iCol].pExpr);
96497 sqlite3CompareAffinity(p->pEList->a[0].pExpr, pDest->affinity);
96764 Expr *pTerm = pOrderBy->a[i].pExpr;
97013 ** Scan through the expression pExpr. Replace every reference to
97022 ** changes to pExpr so that it refers directly to the source table
97027 Expr *pExpr, /* Expr in which substitution occurs */
97031 if( pExpr==0 ) return 0;
97032 if( pExpr->op==TK_COLUMN && pExpr->iTable==iTable ){
97033 if( pExpr->iColumn<0 ){
97034 pExpr->op = TK_NULL;
97037 assert( pEList!=0 && pExpr->iColumn<pEList->nExpr );
97038 assert( pExpr->pLeft==0 && pExpr->pRight==0 );
97039 pNew = sqlite3ExprDup(db, pEList->a[pExpr->iColumn].pExpr, 0);
97040 if( pNew && pExpr->pColl ){
97041 pNew->pColl = pExpr->pColl;
97043 sqlite3ExprDelete(db, pExpr);
97044 pExpr = pNew;
97047 pExpr->pLeft = substExpr(db, pExpr->pLeft, iTable, pEList);
97048 pExpr->pRight = substExpr(db, pExpr->pRight, iTable, pEList);
97049 if( ExprHasProperty(pExpr, EP_xIsSelect) ){
97050 substSelect(db, pExpr->x.pSelect, iTable, pEList);
97052 substExprList(db, pExpr->x.pList, iTable, pEList);
97055 return pExpr;
97066 pList->a[i].pExpr = substExpr(db, pList->a[i].pExpr, iTable, pEList);
97597 Expr *pExpr;
97601 pExpr = pEList->a[0].pExpr;
97602 if( pExpr->op!=TK_AGG_FUNCTION ) return 0;
97603 if( NEVER(ExprHasProperty(pExpr, EP_xIsSelect)) ) return 0;
97604 pEList = pExpr->x.pList;
97606 if( pEList->a[0].pExpr->op!=TK_AGG_COLUMN ) return WHERE_ORDERBY_NORMAL;
97607 assert( !ExprHasProperty(pExpr, EP_IntValue) );
97608 if( sqlite3StrICmp(pExpr->u.zToken,"min")==0 ){
97610 }else if( sqlite3StrICmp(pExpr->u.zToken,"max")==0 ){
97629 Expr *pExpr;
97639 pExpr = p->pEList->a[0].pExpr;
97640 assert( pTab && !pTab->pSelect && pExpr );
97643 if( pExpr->op!=TK_AGG_FUNCTION ) return 0;
97645 if( pExpr->flags&EP_Distinct ) return 0;
97793 Expr *pE = pEList->a[k].pExpr;
97812 Expr *pE = a[k].pExpr;
97817 pNew = sqlite3ExprListAppend(pParse, pNew, a[k].pExpr);
97824 a[k].pExpr = 0;
97849 Expr *pExpr, *pRight;
97884 pExpr = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight, 0);
97890 pExpr = pRight;
97892 pNew = sqlite3ExprListAppend(pParse, pNew, pExpr);
98062 Expr *pE = pFunc->pExpr;
98086 ExprList *pList = pF->pExpr->x.pList;
98087 assert( !ExprHasProperty(pF->pExpr, EP_xIsSelect) );
98111 ExprList *pList = pF->pExpr->x.pList;
98112 assert( !ExprHasProperty(pF->pExpr, EP_xIsSelect) );
98132 pColl = sqlite3ExprCollSeq(pParse, pItem->pExpr);
98166 sqlite3ExprCode(pParse, pC->pExpr, pC->iMem);
98558 CollSeq *pColl = sqlite3ExprCollSeq(pParse, pEList->a[iExpr].pExpr);
98633 assert( !ExprHasProperty(sAggInfo.aFunc[i].pExpr, EP_xIsSelect) );
98634 sqlite3ExprAnalyzeAggList(&sNC, sAggInfo.aFunc[i].pExpr->x.pList);
98770 sqlite3ExprCode(pParse, pGroupBy->a[j].pExpr, iBMem+j);
98942 assert( !ExprHasProperty(p->pEList->a[0].pExpr, EP_xIsSelect) );
98943 pMinMax = sqlite3ExprListDup(db, p->pEList->a[0].pExpr->x.pList,0);
98947 pMinMax->a[0].pExpr->op = TK_COLUMN;
100636 if( sqlite3ResolveExprNames(&sNC, pChanges->a[i].pExpr) ){
100643 pRowidExpr = pChanges->a[i].pExpr;
100652 pRowidExpr = pChanges->a[i].pExpr;
100875 sqlite3ExprCode(pParse, pChanges->a[j].pExpr, regNew+i);
101052 Expr *pExpr; /* Temporary expression */
101072 pExpr = sqlite3ExprDup(db, pChanges->a[aXRef[i]].pExpr, 0);
101074 pExpr = sqlite3Expr(db, TK_ID, pTab->aCol[i].zName);
101076 pEList = sqlite3ExprListAppend(pParse, pEList, pExpr);
102383 ** second parameter (pExpr) is the first argument to this function.
102384 ** If pExpr is a column in a virtual table, then let the virtual
102398 Expr *pExpr /* First argument to the function */
102412 if( NEVER(pExpr==0) ) return pDef;
102413 if( pExpr->op!=TK_COLUMN ) return pDef;
102414 pTab = pExpr->pTab;
102605 ** categories, then eOperator==0. The WhereTerm.pExpr field is still set
102627 Expr *pExpr; /* Pointer to the subexpression that is this term */
102639 Bitmask prereqRight; /* Bitmask of tables used by pExpr->pRight */
102640 Bitmask prereqAll; /* Bitmask of tables referenced by pExpr */
102646 #define TERM_DYNAMIC 0x01 /* Need to call sqlite3ExprDelete(db, pExpr) */
102848 sqlite3ExprDelete(db, a->pExpr);
102902 pTerm->pExpr = p;
102919 ** The original WHERE clause in pExpr is unaltered. All this routine
102920 ** does is make slot[] entries point to substructure within pExpr.
102926 static void whereSplit(WhereClause *pWC, Expr *pExpr, int op){
102928 if( pExpr==0 ) return;
102929 if( pExpr->op!=op ){
102930 whereClauseInsert(pWC, pExpr, 0);
102932 whereSplit(pWC, pExpr->pLeft, op);
102933 whereSplit(pWC, pExpr->pRight, op);
103007 mask |= exprTableUsage(pMaskSet, pList->a[i].pExpr);
103070 static void exprCommute(Parse *pParse, Expr *pExpr){
103071 u16 expRight = (pExpr->pRight->flags & EP_ExpCollate);
103072 u16 expLeft = (pExpr->pLeft->flags & EP_ExpCollate);
103073 assert( allowedOp(pExpr->op) && pExpr->op!=TK_IN );
103074 pExpr->pRight->pColl = sqlite3ExprCollSeq(pParse, pExpr->pRight);
103075 pExpr->pLeft->pColl = sqlite3ExprCollSeq(pParse, pExpr->pLeft);
103076 SWAP(CollSeq*,pExpr->pRight->pColl,pExpr->pLeft->pColl);
103077 pExpr->pRight->flags = (pExpr->pRight->flags & ~EP_ExpCollate) | expLeft;
103078 pExpr->pLeft->flags = (pExpr->pLeft->flags & ~EP_ExpCollate) | expRight;
103079 SWAP(Expr*,pExpr->pRight,pExpr->pLeft);
103080 if( pExpr->op>=TK_GT ){
103085 assert( pExpr->op>=TK_GT && pExpr->op<=TK_GE );
103086 pExpr->op = ((pExpr->op-TK_GT)^2)+TK_GT;
103140 Expr *pX = pTerm->pExpr;
103198 Expr *pExpr, /* Test this expression */
103213 if( !sqlite3IsLikeFunction(db, pExpr, pnoCase, wc) ){
103219 pList = pExpr->x.pList;
103220 pLeft = pList->a[1].pExpr;
103228 pRight = pList->a[0].pExpr;
103292 Expr *pExpr /* Test this expression */
103296 if( pExpr->op!=TK_FUNCTION ){
103299 if( sqlite3StrICmp(pExpr->u.zToken,"match")!=0 ){
103302 pList = pExpr->x.pList;
103306 if( pList->a[1].pExpr->op != TK_COLUMN ){
103407 Expr *pExpr = pTerm->pExpr; /* The expression of the term */
103422 assert( pExpr->op==TK_OR );
103428 whereSplit(pOrWc, pExpr, TK_OR);
103455 whereSplit(pAndWC, pOrTerm->pExpr, TK_AND);
103461 assert( pAndTerm->pExpr );
103462 if( allowedOp(pAndTerm->pExpr->op) ){
103578 affRight = sqlite3ExprAffinity(pOrTerm->pExpr->pRight);
103579 affLeft = sqlite3ExprAffinity(pOrTerm->pExpr->pLeft);
103606 pDup = sqlite3ExprDup(db, pOrTerm->pExpr->pRight, 0);
103608 pLeft = pOrTerm->pExpr->pLeft;
103615 transferJoinMarkings(pNew, pExpr);
103636 ** "pExpr" field filled in. The job of this routine is to analyze the
103647 pExpr
103659 Expr *pExpr; /* The expression to be analyzed */
103660 Bitmask prereqLeft; /* Prerequesites of the pExpr->pLeft */
103661 Bitmask prereqAll; /* Prerequesites of pExpr */
103666 int op; /* Top-level operator. pExpr->op */
103675 pExpr = pTerm->pExpr;
103676 prereqLeft = exprTableUsage(pMaskSet, pExpr->pLeft);
103677 op = pExpr->op;
103679 assert( pExpr->pRight==0 );
103680 if( ExprHasProperty(pExpr, EP_xIsSelect) ){
103681 pTerm->prereqRight = exprSelectTableUsage(pMaskSet, pExpr->x.pSelect);
103683 pTerm->prereqRight = exprListTableUsage(pMaskSet, pExpr->x.pList);
103688 pTerm->prereqRight = exprTableUsage(pMaskSet, pExpr->pRight);
103690 prereqAll = exprTableUsage(pMaskSet, pExpr);
103691 if( ExprHasProperty(pExpr, EP_FromJoin) ){
103692 Bitmask x = getMask(pMaskSet, pExpr->iRightJoinTable);
103702 Expr *pLeft = pExpr->pLeft;
103703 Expr *pRight = pExpr->pRight;
103714 pDup = sqlite3ExprDup(db, pExpr, 0);
103727 pDup = pExpr;
103757 else if( pExpr->op==TK_BETWEEN && pWC->op==TK_AND ){
103758 ExprList *pList = pExpr->x.pList;
103767 sqlite3ExprDup(db, pExpr->pLeft, 0),
103768 sqlite3ExprDup(db, pList->a[i].pExpr, 0), 0);
103783 else if( pExpr->op==TK_OR ){
103802 && isLikeOrGlob(pParse, pExpr, &pStr1, &isComplete, &noCase)
103812 pLeft = pExpr->x.pList->a[1].pExpr;
103861 if( isMatchOfColumn(pExpr) ){
103867 pRight = pExpr->x.pList->a[0].pExpr;
103868 pLeft = pExpr->x.pList->a[1].pExpr;
103902 if( pExpr->op==TK_NOTNULL
103903 && pExpr->pLeft->op==TK_COLUMN
103904 && pExpr->pLeft->iColumn>=0
103907 Expr *pLeft = pExpr->pLeft;
103950 if( (exprTableUsage(pMaskSet, pList->a[iFirst++].pExpr)&allowed)!=0 ){
103978 Expr *p = pList->a[i].pExpr;
104029 Expr *p = pDistinct->a[i].pExpr;
104033 Expr *pX = pTerm->pExpr;
104081 Expr *p = pDistinct->a[i].pExpr;
104170 Expr *pExpr; /* The expression of the ORDER BY pTerm */
104171 CollSeq *pColl; /* The collating sequence of pExpr */
104177 pExpr = pTerm->pExpr;
104178 if( pExpr->op!=TK_COLUMN || pExpr->iTable!=base ){
104183 pColl = sqlite3ExprCollSeq(pParse, pExpr);
104199 if( pExpr->iColumn!=iColumn || sqlite3StrICmp(pColl->zName, zColl) ){
104442 if( !sqlite3IndexAffinityOk(pTerm->pExpr, aff) ) return 0;
104620 Expr *pX = pTerm->pExpr;
104714 Expr *pExpr = pOrderBy->a[i].pExpr;
104715 if( pExpr->op!=TK_COLUMN || pExpr->iTable!=pSrc->iCursor ) break;
104771 Expr *pExpr = pOrderBy->a[i].pExpr;
104772 pIdxOrderBy[i].iColumn = pExpr->iColumn;
105144 ** If expression pExpr represents a literal value, set *pp to point to
105150 ** If the current parse is a recompile (sqlite3Reprepare()) and pExpr
105162 Expr *pExpr,
105166 if( pExpr->op==TK_VARIABLE
105167 || (pExpr->op==TK_REGISTER && pExpr->op2==TK_VARIABLE)
105169 int iVar = pExpr->iColumn;
105174 return sqlite3ValueFromExpr(pParse->db, pExpr, SQLITE_UTF8, aff, pp);
105237 Expr *pExpr = pLower->pExpr->pRight;
105238 rc = valueFromExpr(pParse, pExpr, aff, &pRangeVal);
105249 Expr *pExpr = pUpper->pExpr->pRight;
105250 rc = valueFromExpr(pParse, pExpr, aff, &pRangeVal);
105289 ** for that index. When pExpr==NULL that means the constraint is
105304 Expr *pExpr, /* Expression for VALUE in the x=VALUE constraint */
105315 if( pExpr ){
105316 rc = valueFromExpr(pParse, pExpr, aff, &pRhs);
105364 rc = whereEqualScanEst(pParse, p, pList->a[i].pExpr, &nEst);
105567 Expr *pExpr = pTerm->pExpr;
105569 if( ExprHasProperty(pExpr, EP_xIsSelect) ){
105573 }else if( ALWAYS(pExpr->x.pList && pExpr->x.pList->nExpr) ){
105575 nInMul *= pExpr->x.pList->nExpr;
105688 whereEqualScanEst(pParse, pProbe, pFirstTerm->pExpr->pRight, &nRow);
105691 whereInScanEst(pParse, pProbe, pFirstTerm->pExpr->x.pList, &nRow);
105943 && (pLevel->iLeftJoin==0 || ExprHasProperty(pTerm->pExpr, EP_FromJoin))
106012 Expr *pX = pTerm->pExpr;
106156 Expr *pRight = pTerm->pExpr->pRight;
106407 sqlite3ExprCode(pParse, pWC->a[iTerm].pExpr->pRight, iReg+j+1);
106441 assert( pTerm->pExpr!=0 );
106486 pX = pStart->pExpr;
106500 pX = pEnd->pExpr;
106610 /* assert( pOrderBy->a[0].pExpr->iColumn==pIdx->aiColumn[nEq] ); */
106658 Expr *pRight = pRangeStart->pExpr->pRight;
106698 Expr *pRight = pRangeEnd->pExpr->pRight;
106885 Expr *pExpr = pWC->a[iTerm].pExpr;
106886 if( ExprHasProperty(pExpr, EP_FromJoin) ) continue;
106889 pExpr = sqlite3ExprDup(pParse->db, pExpr, 0);
106890 pAndExpr = sqlite3ExprAnd(pParse->db, pAndExpr, pExpr);
106901 Expr *pOrExpr = pOrTerm->pExpr;
106982 pE = pTerm->pExpr;
107007 assert( pTerm->pExpr );
107008 sqlite3ExprIfFalse(pParse, pTerm->pExpr, addrCont, SQLITE_JUMPIFNULL);
107873 pOut->pExpr = sqlite3PExpr(pParse, op, 0, 0, pValue);
107888 pOut->pExpr = sqlite3PExpr(pParse, op, pLeft->pExpr, pRight->pExpr, 0);
107902 pOut->pExpr = sqlite3PExpr(pParse, op, pOperand->pExpr, 0, 0);
107927 pOut->pExpr = sqlite3PExpr(pParse, op, pOperand->pExpr, 0, 0);
109194 sqlite3ExprDelete(pParse->db, (yypminor->yy342).pExpr);
110038 v.pExpr = sqlite3PExpr(pParse, TK_UMINUS, yymsp[0].minor.yy342.pExpr, 0, 0);
110061 {sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy342.pExpr);}
110122 {sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy342.pExpr);}
110205 yygotominor.yy442 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy442, yymsp[-1].minor.yy342.pExpr);
110292 {yygotominor.yy122 = yymsp[0].minor.yy342.pExpr;}
110319 yygotominor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy442,yymsp[-1].minor.yy342.pExpr);
110325 yygotominor.yy442 = sqlite3ExprListAppend(pParse,0,yymsp[-1].minor.yy342.pExpr);
110340 {yygotominor.yy64.pLimit = yymsp[0].minor.yy342.pExpr; yygotominor.yy64.pOffset = 0;}
110343 {yygotominor.yy64.pLimit = yymsp[-2].minor.yy342.pExpr; yygotominor.yy64.pOffset = yymsp[0].minor.yy342.pExpr;}
110346 {yygotominor.yy64.pOffset = yymsp[-2].minor.yy342.pExpr; yygotominor.yy64.pLimit = yymsp[0].minor.yy342.pExpr;}
110363 yygotominor.yy442 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy442, yymsp[0].minor.yy342.pExpr);
110369 yygotominor.yy442 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy342.pExpr);
110425 {yygotominor.yy342.pExpr = yymsp[-1].minor.yy342.pExpr; spanSet(&yygotominor.yy342,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0);}
110440 yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp2, 0);
110450 yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp4, 0);
110461 yygotominor.yy342.pExpr = 0;
110463 yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_REGISTER, 0, 0, &yymsp[0].minor.yy0);
110464 if( yygotominor.yy342.pExpr ) sqlite3GetInt32(&yymsp[0].minor.yy0.z[1], &yygotominor.yy342.pExpr->iTable);
110472 sqlite3ExprAssignVarNumber(pParse, yygotominor.yy342.pExpr);
110478 yygotominor.yy342.pExpr = sqlite3ExprSetCollByToken(pParse, yymsp[-2].minor.yy342.pExpr, &yymsp[0].minor.yy0);
110485 yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_CAST, yymsp[-3].minor.yy342.pExpr, 0, &yymsp[-1].minor.yy0);
110494 yygotominor.yy342.pExpr = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy442, &yymsp[-4].minor.yy0);
110496 if( yymsp[-2].minor.yy392 && yygotominor.yy342.pExpr ){
110497 yygotominor.yy342.pExpr->flags |= EP_Distinct;
110503 yygotominor.yy342.pExpr = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0);
110511 yygotominor.yy342.pExpr = sqlite3ExprFunction(pParse, 0,&yymsp[0].minor.yy0);
110512 if( yygotominor.yy342.pExpr ){
110513 yygotominor.yy342.pExpr->op = TK_CONST_FUNC;
110539 pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy342.pExpr);
110540 pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy342.pExpr);
110541 yygotominor.yy342.pExpr = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy318.eOperator);
110542 if( yymsp[-1].minor.yy318.not ) yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy342.pExpr, 0, 0);
110545 if( yygotominor.yy342.pExpr ) yygotominor.yy342.pExpr->flags |= EP_InfixFunc;
110551 pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy342.pExpr);
110552 pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy342.pExpr);
110553 pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy342.pExpr);
110554 yygotominor.yy342.pExpr = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy318.eOperator);
110555 if( yymsp[-3].minor.yy318.not ) yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy342.pExpr, 0, 0);
110558 if( yygotominor.yy342.pExpr ) yygotominor.yy342.pExpr->flags |= EP_InfixFunc;
110570 binaryToUnaryIfNull(pParse, yymsp[0].minor.yy342.pExpr, yygotominor.yy342.pExpr, TK_ISNULL);
110576 binaryToUnaryIfNull(pParse, yymsp[0].minor.yy342.pExpr, yygotominor.yy342.pExpr, TK_NOTNULL);
110591 ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy342.pExpr);
110592 pExpr);
110593 yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy342.pExpr, 0, 0);
110594 if( yygotominor.yy342.pExpr ){
110595 yygotominor.yy342.pExpr->x.pList = pList;
110599 if( yymsp[-3].minor.yy392 ) yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy342.pExpr, 0, 0);
110615 yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_INTEGER, 0, 0, &sqlite3IntTokens[yymsp[-3].minor.yy392]);
110616 sqlite3ExprDelete(pParse->db, yymsp[-4].minor.yy342.pExpr);
110618 yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy342.pExpr, 0, 0);
110619 if( yygotominor.yy342.pExpr ){
110620 yygotominor.yy342.pExpr->x.pList = yymsp[-1].minor.yy442;
110621 sqlite3ExprSetHeight(pParse, yygotominor.yy342.pExpr);
110625 if( yymsp[-3].minor.yy392 ) yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy342.pExpr, 0, 0);
110633 yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_SELECT, 0, 0, 0);
110634 if( yygotominor.yy342.pExpr ){
110635 yygotominor.yy342.pExpr->x.pSelect = yymsp[-1].minor.yy159;
110636 ExprSetProperty(yygotominor.yy342.pExpr, EP_xIsSelect);
110637 sqlite3ExprSetHeight(pParse, yygotominor.yy342.pExpr);
110647 yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy342.pExpr, 0, 0);
110648 if( yygotominor.yy342.pExpr ){
110649 yygotominor.yy342.pExpr->x.pSelect = yymsp[-1].minor.yy159;
110650 ExprSetProperty(yygotominor.yy342.pExpr, EP_xIsSelect);
110651 sqlite3ExprSetHeight(pParse, yygotominor.yy342.pExpr);
110655 if( yymsp[-3].minor.yy392 ) yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy342.pExpr, 0, 0);
110663 yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-3].minor.yy342.pExpr, 0, 0);
110664 if( yygotominor.yy342.pExpr ){
110665 yygotominor.yy342.pExpr->x.pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0,0);
110666 ExprSetProperty(yygotominor.yy342.pExpr, EP_xIsSelect);
110667 sqlite3ExprSetHeight(pParse, yygotominor.yy342.pExpr);
110671 if( yymsp[-2].minor.yy392 ) yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy342.pExpr, 0, 0);
110678 Expr *p = yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_EXISTS, 0, 0, 0);
110692 yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy122, yymsp[-1].minor.yy122, 0);
110693 if( yygotominor.yy342.pExpr ){
110694 yygotominor.yy342.pExpr->x.pList = yymsp[-2].minor.yy442;
110695 sqlite3ExprSetHeight(pParse, yygotominor.yy342.pExpr);
110705 yygotominor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy442, yymsp[-2].minor.yy342.pExpr);
110706 yygotominor.yy442 = sqlite3ExprListAppend(pParse,yygotominor.yy442, yymsp[0].minor.yy342.pExpr);
110711 yygotominor.yy442 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy342.pExpr);
110712 yygotominor.yy442 = sqlite3ExprListAppend(pParse,yygotominor.yy442, yymsp[0].minor.yy342.pExpr);
110716 {yygotominor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy442,yymsp[0].minor.yy342.pExpr);}
110719 {yygotominor.yy442 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy342.pExpr);}
110823 { yygotominor.yy122 = yymsp[0].minor.yy342.pExpr; }
110879 yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0, 0);
110880 if( yygotominor.yy342.pExpr ){
110881 yygotominor.yy342.pExpr->affinity = OE_Ignore;
110889 yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0, &yymsp[-1].minor.yy0);
110890 if( yygotominor.yy342.pExpr ) {
110891 yygotominor.yy342.pExpr->affinity = (char)yymsp[-3].minor.yy392;
110910 sqlite3Attach(pParse, yymsp[-3].minor.yy342.pExpr, yymsp[-1].minor.yy342.pExpr, yymsp[0].minor.yy122);
110915 sqlite3Detach(pParse, yymsp[0].minor.yy342.pExpr);
116654 Fts3Expr *pExpr; /* Parsed MATCH query string */
118134 sqlite3Fts3ExprFree(pCsr->pExpr);
119575 sqlite3Fts3ExprFree(pCsr->pExpr);
119597 p->azColumn, p->bHasStat, p->nColumn, iCol, zQuery, -1, &pCsr->pExpr
119697 }else if( iCol==p->nColumn+2 && pCsr->pExpr ){
120228 ** by pExpr.
120243 Fts3Expr *pExpr, /* Allocate readers for this expression */
120248 if( pExpr && SQLITE_OK==*pRc ){
120249 if( pExpr->eType==FTSQUERY_PHRASE ){
120251 int nToken = pExpr->pPhrase->nToken;
120254 Fts3PhraseToken *pToken = &pExpr->pPhrase->aToken[i];
120263 assert( pExpr->pPhrase->iDoclistToken==0 );
120264 pExpr->pPhrase->iDoclistToken = -1;
120266 *pnOr += (pExpr->eType==FTSQUERY_OR);
120267 fts3EvalAllocateReaders(pCsr, pExpr->pLeft, pnToken, pnOr, pRc);
120268 fts3EvalAllocateReaders(pCsr, pExpr->pRight, pnToken, pnOr, pRc);
120665 Fts3Expr *pExpr, /* Expression to initialize phrases in */
120669 if( pExpr && SQLITE_OK==*pRc ){
120670 if( pExpr->eType==FTSQUERY_PHRASE ){
120672 int nToken = pExpr->pPhrase->nToken;
120674 if( pExpr->pPhrase->aToken[i].pDeferred==0 ) break;
120676 pExpr->bDeferred = (i==nToken);
120677 *pRc = fts3EvalPhraseStart(pCsr, bOptOk, pExpr->pPhrase);
120679 fts3EvalStartReaders(pCsr, pExpr->pLeft, bOptOk, pRc);
120680 fts3EvalStartReaders(pCsr, pExpr->pRight, bOptOk, pRc);
120681 pExpr->bDeferred = (pExpr->pLeft->bDeferred && pExpr->pRight->bDeferred);
120718 Fts3Expr *pExpr, /* Expression to consider */
120724 if( pExpr->eType==FTSQUERY_PHRASE ){
120725 Fts3Phrase *pPhrase = pExpr->pPhrase;
120736 }else if( pExpr->eType!=FTSQUERY_NOT ){
120737 assert( pExpr->eType==FTSQUERY_OR
120738 || pExpr->eType==FTSQUERY_AND
120739 || pExpr->eType==FTSQUERY_NEAR
120741 assert( pExpr->pLeft && pExpr->pRight );
120742 if( pExpr->eType==FTSQUERY_OR ){
120743 pRoot = pExpr->pLeft;
120747 fts3EvalTokenCosts(pCsr, pRoot, pExpr->pLeft, ppTC, ppOr, pRc);
120748 if( pExpr->eType==FTSQUERY_OR ){
120749 pRoot = pExpr->pRight;
120753 fts3EvalTokenCosts(pCsr, pRoot, pExpr->pRight, ppTC, ppOr, pRc);
120949 ** the full-text query currently stored in pCsr->pExpr. To iterate through
120966 fts3EvalAllocateReaders(pCsr, pCsr->pExpr, &nToken, &nOr, &rc);
120985 fts3EvalTokenCosts(pCsr, 0, pCsr->pExpr, &pTC, &ppOr, &rc);
121000 fts3EvalStartReaders(pCsr, pCsr->pExpr, 1, &rc);
121079 ** successful, the following variables in pExpr are set:
121114 Fts3Expr *pExpr, /* Expr. to advance to next matching row */
121119 assert( pExpr->bEof==0 );
121120 pExpr->bStart = 1;
121122 switch( pExpr->eType ){
121125 Fts3Expr *pLeft = pExpr->pLeft;
121126 Fts3Expr *pRight = pExpr->pRight;
121133 pExpr->iDocid = pRight->iDocid;
121134 pExpr->bEof = pRight->bEof;
121139 pExpr->iDocid = pLeft->iDocid;
121140 pExpr->bEof = pLeft->bEof;
121154 pExpr->iDocid = pLeft->iDocid;
121155 pExpr->bEof = (pLeft->bEof || pRight->bEof);
121161 Fts3Expr *pLeft = pExpr->pLeft;
121162 Fts3Expr *pRight = pExpr->pRight;
121177 pExpr->bEof = (pLeft->bEof && pRight->bEof);
121180 pExpr->iDocid = pLeft->iDocid;
121182 pExpr->iDocid = pRight->iDocid;
121189 Fts3Expr *pLeft = pExpr->pLeft;
121190 Fts3Expr *pRight = pExpr->pRight;
121206 pExpr->iDocid = pLeft->iDocid;
121207 pExpr->bEof = pLeft->bEof;
121212 Fts3Phrase *pPhrase = pExpr->pPhrase;
121214 *pRc = fts3EvalPhraseNext(pCsr, pPhrase, &pExpr->bEof);
121215 pExpr->iDocid = pPhrase->doclist.iDocid;
121223 ** If *pRc is not SQLITE_OK, or if pExpr is not the root node of a NEAR
121237 static int fts3EvalNearTest(Fts3Expr *pExpr, int *pRc){
121240 /* The following block runs if pExpr is the root of a NEAR query.
121261 && pExpr->eType==FTSQUERY_NEAR
121262 && pExpr->bEof==0
121263 && (pExpr->pParent==0 || pExpr->pParent->eType!=FTSQUERY_NEAR)
121270 for(p=pExpr; p->pLeft; p=p->pLeft){
121288 aPoslist = pExpr->pRight->pPhrase->doclist.pList;
121289 nToken = pExpr->pRight->pPhrase->nToken;
121290 for(p=pExpr->pLeft; p && res; p=p->pLeft){
121321 Fts3Expr *pExpr, /* Expr to test. May or may not be root. */
121326 switch( pExpr->eType ){
121330 fts3EvalTestExpr(pCsr, pExpr->pLeft, pRc)
121331 && fts3EvalTestExpr(pCsr, pExpr->pRight, pRc)
121332 && fts3EvalNearTest(pExpr, pRc)
121351 && pExpr->eType==FTSQUERY_NEAR
121352 && (pExpr->pParent==0 || pExpr->pParent->eType!=FTSQUERY_NEAR)
121355 for(p=pExpr; p->pPhrase==0; p=p->pLeft){
121368 int bHit1 = fts3EvalTestExpr(pCsr, pExpr->pLeft, pRc);
121369 int bHit2 = fts3EvalTestExpr(pCsr, pExpr->pRight, pRc);
121376 fts3EvalTestExpr(pCsr, pExpr->pLeft, pRc)
121377 && !fts3EvalTestExpr(pCsr, pExpr->pRight, pRc)
121383 && (pExpr->iDocid==pCsr->iPrevId || pExpr->bDeferred)
121385 Fts3Phrase *pPhrase = pExpr->pPhrase;
121386 assert( pExpr->bDeferred || pPhrase->doclist.bFreeList==0 );
121387 if( pExpr->bDeferred ){
121392 pExpr->iDocid = pCsr->iPrevId;
121394 bHit = (pExpr->bEof==0 && pExpr->iDocid==pCsr->iPrevId);
121444 bMiss = (0==fts3EvalTestExpr(pCsr, pCsr->pExpr, &rc));
121455 ** Fts3Cursor.pExpr.
121459 Fts3Expr *pExpr = pCsr->pExpr;
121461 if( pExpr==0 ){
121469 fts3EvalNextRow(pCsr, pExpr, &rc);
121470 pCsr->isEof = pExpr->bEof;
121473 pCsr->iPrevId = pExpr->iDocid;
121480 ** Restart interation for expression pExpr so that the next call to
121490 Fts3Expr *pExpr,
121493 if( pExpr && *pRc==SQLITE_OK ){
121494 Fts3Phrase *pPhrase = pExpr->pPhrase;
121509 pExpr->iDocid = 0;
121510 pExpr->bEof = 0;
121511 pExpr->bStart = 0;
121513 fts3EvalRestart(pCsr, pExpr->pLeft, pRc);
121514 fts3EvalRestart(pCsr, pExpr->pRight, pRc);
121520 ** expression rooted at pExpr, the cursor iterates through all rows matched
121521 ** by pExpr, calling this function for each row. This function increments
121526 static void fts3EvalUpdateCounts(Fts3Expr *pExpr){
121527 if( pExpr ){
121528 Fts3Phrase *pPhrase = pExpr->pPhrase;
121545 pExpr->aMI[iCol*3 + 1] += iCnt;
121546 pExpr->aMI[iCol*3 + 2] += (iCnt>0);
121553 fts3EvalUpdateCounts(pExpr->pLeft);
121554 pExpr->pRight);
121559 ** Expression pExpr must be of type FTSQUERY_PHRASE.
121562 ** populates the Fts3Expr.aMI[] array for expression pExpr. If pExpr is part
121571 Fts3Expr *pExpr /* FTSQUERY_PHRASE expression */
121575 assert( pExpr->eType==FTSQUERY_PHRASE );
121576 if( pExpr->aMI==0 ){
121586 pRoot = pExpr;
121683 Fts3Expr *pExpr, /* Phrase expression */
121690 if( pExpr->bDeferred && pExpr->pParent->eType!=FTSQUERY_NEAR ){
121697 rc = fts3EvalGatherStats(pCsr, pExpr);
121699 assert( pExpr->aMI );
121701 aiOut[iCol*3 + 1] = pExpr->aMI[iCol*3 + 1];
121702 aiOut[iCol*3 + 2] = pExpr->aMI[iCol*3 + 2];
121711 ** The expression pExpr passed as the second argument to this function
121731 Fts3Expr *pExpr, /* Phrase to return doclist for */
121734 Fts3Phrase *pPhrase = pExpr->pPhrase;
121741 || pExpr->bEof
121742 || pExpr->iDocid!=pCsr->iPrevId
123159 static char *exprToString(Fts3Expr *pExpr, char *zBuf){
123160 switch( pExpr->eType ){
123162 Fts3Phrase *pPhrase = pExpr->pPhrase;
123176 zBuf = sqlite3_mprintf("%zNEAR/%d ", zBuf, pExpr->nNear);
123190 if( zBuf ) zBuf = exprToString(pExpr->pLeft, zBuf);
123193 if( zBuf ) zBuf = exprToString(pExpr->pRight, zBuf);
123226 Fts3Expr *pExpr;
123268 pTokenizer, 0, azCol, 0, nCol, nCol, zExpr, nExpr, &pExpr
123272 }else if( rc==SQLITE_NOMEM || !(zBuf = exprToString(pExpr, 0)) ){
123279 sqlite3Fts3ExprFree(pExpr);
128749 Fts3Expr *pExpr, /* Expression to iterate phrases of */
128755 int eType = pExpr->eType; /* Type of expression node pExpr */
128758 assert( pExprpExpr->pRight );
128759 rc = fts3ExprIterate2(pExpr->pLeft, piPhrase, x, pCtx);
128761 rc = fts3ExprIterate2(pExpr->pRight, piPhrase, x, pCtx);
128764 rc = x(pExpr, *piPhrase, pCtx);
128781 Fts3Expr *pExpr, /* Expression to iterate phrases of */
128786 return fts3ExprIterate2(pExpr, &iPhrase, x, pCtx);
128794 static int fts3ExprLoadDoclistsCb(Fts3Expr *pExpr, int iPhrase, void *ctx){
128796 Fts3Phrase *pPhrase = pExpr->pPhrase;
128825 rc = fts3ExprIterate(pCsr->pExpr, fts3ExprLoadDoclistsCb, (void *)&sCtx);
128831 static int fts3ExprPhraseCountCb(Fts3Expr *pExpr, int iPhrase, void *ctx){
128833 UNUSED_PARAMETER(pExpr);
128837 static int fts3ExprPhraseCount(Fts3Expr *pExpr){
128839 (void)fts3ExprIterate(pExpr, fts3ExprPhraseCountCb, (void *)&nPhrase);
128969 static int fts3SnippetFindPositions(Fts3Expr *pExpr, int iPhrase, void *ctx){
128974 pPhrase->nToken = pExpr->pPhrase->nToken;
128976 pCsr = sqlite3Fts3EvalPhrasePoslist(p->pCsr, pExpr, p->iCol);
129052 (void)fts3ExprIterate(pCsr->pExpr, fts3SnippetFindPositions, (void *)&sIter);
129356 ** If the phrase pExpr consists entirely of deferred tokens, then all X and
129363 Fts3Expr *pExpr, /* Phrase expression node */
129369 p->pCursor, pExpr, &p->aMatchinfo[3*iPhrase*p->nCol]
129379 Fts3Expr *pExpr, /* Phrase expression node */
129389 pCsr = sqlite3Fts3EvalPhrasePoslist(p->pCursor, pExpr, i);
129478 Fts3Expr *pExpr; /* Pointer to phrase expression */
129491 Fts3Expr *pExpr, /* Phrase expression node */
129496 aIter[iPhrase].pExpr = pExpr;
129545 (void)fts3ExprIterate(pCsr->pExpr, fts3MatchinfoLcsCb, (void*)aIter);
129549 nToken -= pIter->pExpr->pPhrase->nToken;
129559 pIt->pRead = sqlite3Fts3EvalPhrasePoslist(pCsr, pIt->pExpr, iCol);
129688 Fts3Expr *pExpr;
129690 pExpr = pCsr->pExpr;
129698 rc = fts3ExprIterate(pExpr, fts3ExprGlobalHitsCb,(void*)pInfo);
129701 (void)fts3ExprIterate(pExpr, fts3ExprLocalHitsCb,(void*)pInfo);
129752 pCsr->nPhrase = fts3ExprPhraseCount(pCsr->pExpr);
129812 if( !pCsr->pExpr ){
129905 static int fts3ExprTermOffsetInit(Fts3Expr *pExpr, int iPhrase, void *ctx){
129913 pList = sqlite3Fts3EvalPhrasePoslist(p->pCsr, pExpr, p->iCol);
129914 nTerm = pExpr->pPhrase->nToken;
129947 if( !pCsr->pExpr ){
129985 (void)fts3ExprIterate(pCsr->pExpr, fts3ExprTermOffsetInit, (void *)&sCtx);
130095 if( !pCsr->pExpr ){
133620 URegularExpression *pExpr = (URegularExpression *)p;
133621 uregex_close(pExpr);
133645 URegularExpression *pExpr;
133658 pExpr = sqlite3_get_auxdata(p, 0);
133659 if( !pExpr ){
133664 pExpr = uregex_open(zPattern, -1, 0, 0, &status);
133667 sqlite3_set_auxdata(p, 0, pExpr, icuRegexpDelete);
133669 assert(!pExpr);
133676 uregex_setText(pExpr, zString, -1, &status);
133683 res = uregex_matches(pExpr, 0, &status);
133694 uregex_setText(pExpr, 0, 0, &status);