| Index: third_party/sqlite/sqlite-src-3100200/src/whereInt.h
|
| diff --git a/third_party/sqlite/sqlite-src-3080704/src/whereInt.h b/third_party/sqlite/sqlite-src-3100200/src/whereInt.h
|
| similarity index 83%
|
| copy from third_party/sqlite/sqlite-src-3080704/src/whereInt.h
|
| copy to third_party/sqlite/sqlite-src-3100200/src/whereInt.h
|
| index f17906e63a81f0ebbb2d4f28f31a440393abf413..1a189980ef52ecc72a97c9f349739a10776dab58 100644
|
| --- a/third_party/sqlite/sqlite-src-3080704/src/whereInt.h
|
| +++ b/third_party/sqlite/sqlite-src-3100200/src/whereInt.h
|
| @@ -19,7 +19,7 @@
|
| ** Trace output macros
|
| */
|
| #if defined(SQLITE_TEST) || defined(SQLITE_DEBUG)
|
| -/***/ int sqlite3WhereTrace = 0;
|
| +/***/ int sqlite3WhereTrace;
|
| #endif
|
| #if defined(SQLITE_DEBUG) \
|
| && (defined(SQLITE_TEST) || defined(SQLITE_ENABLE_WHERETRACE))
|
| @@ -69,6 +69,10 @@ struct WhereLevel {
|
| int addrCont; /* Jump here to continue with the next loop cycle */
|
| int addrFirst; /* First instruction of interior of the loop */
|
| int addrBody; /* Beginning of the body of this loop */
|
| +#ifndef SQLITE_LIKE_DOESNT_MATCH_BLOBS
|
| + int iLikeRepCntr; /* LIKE range processing counter register */
|
| + int addrLikeRep; /* LIKE range processing address */
|
| +#endif
|
| u8 iFrom; /* Which entry in the FROM clause */
|
| u8 op, p3, p5; /* Opcode, P3 & P5 of the opcode that ends the loop */
|
| int p1, p2; /* Operands of the opcode used to ends the loop */
|
| @@ -85,6 +89,9 @@ struct WhereLevel {
|
| } u;
|
| struct WhereLoop *pWLoop; /* The selected WhereLoop object */
|
| Bitmask notReady; /* FROM entries not usable at this level */
|
| +#ifdef SQLITE_ENABLE_STMT_SCANSTATUS
|
| + int addrVisit; /* Address at which row is visited */
|
| +#endif
|
| };
|
|
|
| /*
|
| @@ -115,7 +122,6 @@ struct WhereLoop {
|
| union {
|
| struct { /* Information for internal btree tables */
|
| u16 nEq; /* Number of equality constraints */
|
| - u16 nSkip; /* Number of initial index columns to skip */
|
| Index *pIndex; /* Index used, or NULL */
|
| } btree;
|
| struct { /* Information for virtual tables */
|
| @@ -128,12 +134,13 @@ struct WhereLoop {
|
| } u;
|
| u32 wsFlags; /* WHERE_* flags describing the plan */
|
| u16 nLTerm; /* Number of entries in aLTerm[] */
|
| + u16 nSkip; /* Number of NULL aLTerm[] entries */
|
| /**** whereLoopXfer() copies fields above ***********************/
|
| # define WHERE_LOOP_XFER_SZ offsetof(WhereLoop,nLSlot)
|
| u16 nLSlot; /* Number of slots allocated for aLTerm[] */
|
| WhereTerm **aLTerm; /* WhereTerms used */
|
| WhereLoop *pNextLoop; /* Next WhereLoop object in the WhereClause */
|
| - WhereTerm *aLTermSpace[4]; /* Initial aLTerm[] space */
|
| + WhereTerm *aLTermSpace[3]; /* Initial aLTerm[] space */
|
| };
|
|
|
| /* This object holds the prerequisites and the cost of running a
|
| @@ -156,10 +163,6 @@ struct WhereOrSet {
|
| WhereOrCost a[N_OR_COST]; /* Set of best costs */
|
| };
|
|
|
| -
|
| -/* Forward declaration of methods */
|
| -static int whereLoopResize(sqlite3*, WhereLoop*, int);
|
| -
|
| /*
|
| ** Each instance of this object holds a sequence of WhereLoop objects
|
| ** that implement some or all of a query plan.
|
| @@ -250,8 +253,9 @@ struct WhereTerm {
|
| } u;
|
| LogEst truthProb; /* Probability of truth for this expression */
|
| u16 eOperator; /* A WO_xx value describing <op> */
|
| - u8 wtFlags; /* TERM_xxx bit flags. See below */
|
| + u16 wtFlags; /* TERM_xxx bit flags. See below */
|
| u8 nChild; /* Number of children that must disable us */
|
| + u8 eMatchOp; /* Op for vtab MATCH/LIKE/GLOB/REGEXP terms */
|
| WhereClause *pWC; /* The clause this term is part of */
|
| Bitmask prereqRight; /* Bitmask of tables used by pExpr->pRight */
|
| Bitmask prereqAll; /* Bitmask of tables referenced by pExpr */
|
| @@ -272,6 +276,10 @@ struct WhereTerm {
|
| #else
|
| # define TERM_VNULL 0x00 /* Disabled if not using stat3 */
|
| #endif
|
| +#define TERM_LIKEOPT 0x100 /* Virtual terms from the LIKE optimization */
|
| +#define TERM_LIKECOND 0x200 /* Conditionally this LIKE operator term */
|
| +#define TERM_LIKE 0x400 /* The original LIKE operator */
|
| +#define TERM_IS 0x800 /* Term.pExpr is an IS operator */
|
|
|
| /*
|
| ** An instance of the WhereScan object is used as an iterator for locating
|
| @@ -280,13 +288,15 @@ struct WhereTerm {
|
| struct WhereScan {
|
| WhereClause *pOrigWC; /* Original, innermost WhereClause */
|
| WhereClause *pWC; /* WhereClause currently being scanned */
|
| - char *zCollName; /* Required collating sequence, if not NULL */
|
| + const char *zCollName; /* Required collating sequence, if not NULL */
|
| + Expr *pIdxExpr; /* Search for this index expression */
|
| char idxaff; /* Must match this affinity, if zCollName!=NULL */
|
| unsigned char nEquiv; /* Number of entries in aEquiv[] */
|
| unsigned char iEquiv; /* Next unused slot in aEquiv[] */
|
| u32 opMask; /* Acceptable operators */
|
| int k; /* Resume scanning at this->pWC->a[this->k] */
|
| - int aEquiv[22]; /* Cursor,Column pairs for equivalence classes */
|
| + int aiCur[11]; /* Cursors in the equivalence class */
|
| + i16 aiColumn[11]; /* Corresponding column number in the eq-class */
|
| };
|
|
|
| /*
|
| @@ -364,6 +374,11 @@ struct WhereMaskSet {
|
| };
|
|
|
| /*
|
| +** Initialize a WhereMaskSet object
|
| +*/
|
| +#define initMaskSet(P) (P)->n=0
|
| +
|
| +/*
|
| ** This object is a convenience wrapper holding all information needed
|
| ** to construct WhereLoop objects for a particular query.
|
| */
|
| @@ -400,7 +415,7 @@ struct WhereInfo {
|
| u16 wctrlFlags; /* Flags originally passed to sqlite3WhereBegin() */
|
| i8 nOBSat; /* Number of ORDER BY terms satisfied by indices */
|
| u8 sorted; /* True if really sorted (not just grouped) */
|
| - u8 okOnePass; /* Ok to use one-pass algorithm for UPDATE/DELETE */
|
| + u8 eOnePass; /* ONEPASS_OFF, or _SINGLE, or _MULTI */
|
| u8 untestedTerms; /* Not all WHERE terms resolved by outer loop */
|
| u8 eDistinct; /* One of the WHERE_DISTINCT_* values below */
|
| u8 nLevel; /* Number of nested loop */
|
| @@ -415,26 +430,84 @@ struct WhereInfo {
|
| };
|
|
|
| /*
|
| +** Private interfaces - callable only by other where.c routines.
|
| +**
|
| +** where.c:
|
| +*/
|
| +Bitmask sqlite3WhereGetMask(WhereMaskSet*,int);
|
| +WhereTerm *sqlite3WhereFindTerm(
|
| + WhereClause *pWC, /* The WHERE clause to be searched */
|
| + int iCur, /* Cursor number of LHS */
|
| + int iColumn, /* Column number of LHS */
|
| + Bitmask notReady, /* RHS must not overlap with this mask */
|
| + u32 op, /* Mask of WO_xx values describing operator */
|
| + Index *pIdx /* Must be compatible with this index, if not NULL */
|
| +);
|
| +
|
| +/* wherecode.c: */
|
| +#ifndef SQLITE_OMIT_EXPLAIN
|
| +int sqlite3WhereExplainOneScan(
|
| + Parse *pParse, /* Parse context */
|
| + SrcList *pTabList, /* Table list this loop refers to */
|
| + WhereLevel *pLevel, /* Scan to write OP_Explain opcode for */
|
| + int iLevel, /* Value for "level" column of output */
|
| + int iFrom, /* Value for "from" column of output */
|
| + u16 wctrlFlags /* Flags passed to sqlite3WhereBegin() */
|
| +);
|
| +#else
|
| +# define sqlite3WhereExplainOneScan(u,v,w,x,y,z) 0
|
| +#endif /* SQLITE_OMIT_EXPLAIN */
|
| +#ifdef SQLITE_ENABLE_STMT_SCANSTATUS
|
| +void sqlite3WhereAddScanStatus(
|
| + Vdbe *v, /* Vdbe to add scanstatus entry to */
|
| + SrcList *pSrclist, /* FROM clause pLvl reads data from */
|
| + WhereLevel *pLvl, /* Level to add scanstatus() entry for */
|
| + int addrExplain /* Address of OP_Explain (or 0) */
|
| +);
|
| +#else
|
| +# define sqlite3WhereAddScanStatus(a, b, c, d) ((void)d)
|
| +#endif
|
| +Bitmask sqlite3WhereCodeOneLoopStart(
|
| + WhereInfo *pWInfo, /* Complete information about the WHERE clause */
|
| + int iLevel, /* Which level of pWInfo->a[] should be coded */
|
| + Bitmask notReady /* Which tables are currently available */
|
| +);
|
| +
|
| +/* whereexpr.c: */
|
| +void sqlite3WhereClauseInit(WhereClause*,WhereInfo*);
|
| +void sqlite3WhereClauseClear(WhereClause*);
|
| +void sqlite3WhereSplit(WhereClause*,Expr*,u8);
|
| +Bitmask sqlite3WhereExprUsage(WhereMaskSet*, Expr*);
|
| +Bitmask sqlite3WhereExprListUsage(WhereMaskSet*, ExprList*);
|
| +void sqlite3WhereExprAnalyze(SrcList*, WhereClause*);
|
| +void sqlite3WhereTabFuncArgs(Parse*, struct SrcList_item*, WhereClause*);
|
| +
|
| +
|
| +
|
| +
|
| +
|
| +/*
|
| ** Bitmasks for the operators on WhereTerm objects. These are all
|
| ** operators that are of interest to the query planner. An
|
| ** OR-ed combination of these values can be used when searching for
|
| ** particular WhereTerms within a WhereClause.
|
| */
|
| -#define WO_IN 0x001
|
| -#define WO_EQ 0x002
|
| +#define WO_IN 0x0001
|
| +#define WO_EQ 0x0002
|
| #define WO_LT (WO_EQ<<(TK_LT-TK_EQ))
|
| #define WO_LE (WO_EQ<<(TK_LE-TK_EQ))
|
| #define WO_GT (WO_EQ<<(TK_GT-TK_EQ))
|
| #define WO_GE (WO_EQ<<(TK_GE-TK_EQ))
|
| -#define WO_MATCH 0x040
|
| -#define WO_ISNULL 0x080
|
| -#define WO_OR 0x100 /* Two or more OR-connected terms */
|
| -#define WO_AND 0x200 /* Two or more AND-connected terms */
|
| -#define WO_EQUIV 0x400 /* Of the form A==B, both columns */
|
| -#define WO_NOOP 0x800 /* This term does not restrict search space */
|
| +#define WO_MATCH 0x0040
|
| +#define WO_IS 0x0080
|
| +#define WO_ISNULL 0x0100
|
| +#define WO_OR 0x0200 /* Two or more OR-connected terms */
|
| +#define WO_AND 0x0400 /* Two or more AND-connected terms */
|
| +#define WO_EQUIV 0x0800 /* Of the form A==B, both columns */
|
| +#define WO_NOOP 0x1000 /* This term does not restrict search space */
|
|
|
| -#define WO_ALL 0xfff /* Mask of all possible WO_* values */
|
| -#define WO_SINGLE 0x0ff /* Mask of all non-compound WO_* values */
|
| +#define WO_ALL 0x1fff /* Mask of all possible WO_* values */
|
| +#define WO_SINGLE 0x01ff /* Mask of all non-compound WO_* values */
|
|
|
| /*
|
| ** These are definitions of bits in the WhereLoop.wsFlags field.
|
| @@ -459,3 +532,4 @@ struct WhereInfo {
|
| #define WHERE_AUTO_INDEX 0x00004000 /* Uses an ephemeral index */
|
| #define WHERE_SKIPSCAN 0x00008000 /* Uses the skip-scan algorithm */
|
| #define WHERE_UNQ_WANTED 0x00010000 /* WHERE_ONEROW would have been helpful*/
|
| +#define WHERE_PARTIALIDX 0x00020000 /* The automatic index is partial */
|
|
|