-C Get\sthe\sindexed\sexpression\soptimization\sworking\sfor\svirtual\sgenerated\scolumns.
-D 2022-10-17T14:30:01.606
+C Improved\scomments\sand\sfunction\snames.\s\sNo\slogic\schanges.
+D 2022-10-17T14:46:39.146
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
F src/dbpage.c 5808e91bc27fa3981b028000f8fadfdc10ce9e59a34ce7dc4e035a69be3906ec
F src/dbstat.c 861e08690fcb0f2ee1165eff0060ea8d4f3e2ea10f80dab7d32ad70443a6ff2d
F src/delete.c 86573edae75e3d3e9a8b590d87db8e47222103029df4f3e11fa56044459b514e
-F src/expr.c 4a13a0e5c30be801b0adc295ef74e0f1aa8c041aefdcb5d0d424337ecefa2806
+F src/expr.c ba67701bd7621ebba9c472fcc2dbd4f6444260530e694fa9d87281f9aedec93c
F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007
F src/fkey.c 722f20779f5342a787922deded3628d8c74b5249cab04098cf17ee2f2aaff002
F src/func.c fe2a795ad647ce42054873ac91c43beb7b5d204892903a67f6e7e314379b9d4a
F src/sqlite.h.in d9c8a6243fc0a1c270d69db33758e34b810af3462f9bc5b4af113b347e07c69d
F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
F src/sqlite3ext.h 5336beea1868d99d2f62e628dbea55e97267dbff8193291ab175e960c5df9141
-F src/sqliteInt.h 2a182a906ac614eb240a68abba8eaf4b018693fd2410ddaa133c08de00507e0a
+F src/sqliteInt.h ed402c12a8b0920ae28cf79631d31490376ca3eed76b386b646712a1dda9e945
F src/sqliteLimit.h d7323ffea5208c6af2734574bae933ca8ed2ab728083caa117c9738581a31657
F src/status.c 160c445d7d28c984a0eae38c144f6419311ed3eace59b44ac6dafc20db4af749
F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1
F src/wal.c b9df133a705093da8977da5eb202eaadb844839f1c7297c08d33471f5491843d
F src/wal.h c3aa7825bfa2fe0d85bef2db94655f99870a285778baa36307c0a16da32b226a
F src/walker.c f890a3298418d7cba3b69b8803594fdc484ea241206a8dfa99db6dd36f8cbb3b
-F src/where.c 5d687c1f910b9b52284e0f7881a4d9b0ea9e9902b222dcc38e07a02ebeea3550
+F src/where.c 3ab52180ad3a4eea7a2061bd804850f443298adbdc9264642d0a28affe26fb4c
F src/whereInt.h 70cd30de9ed784aa33fa6bd1245f060617de7a00d992469b6d8e419eed915743
F src/wherecode.c 8ec5a413f12af06638dcca36d0954be2151eea6f293d3c67397cef6a90d6adf1
F src/whereexpr.c bf8c155212c886621d71c951053660de6fcc4ee907b17aa02da0a96a39aa9405
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P 56ef97e64efb84176df570819474901d492209ff80ce4355ff896dea9d2b8a51
-R de79047dd54e7d5b7736aaaf7de5ad42
+P 8a510cb0880349370ad19b0852f270ca072bff7871f0dc272964af31c32a7c37
+R 2b7b8043aec8092eea598ea28e3a1178
U drh
-Z 08d869d5cc79e1976c4600c81c421785
+Z e241a4932bd8de7b16432b2f0cb5fca6
# Remove this line to create a well-formed Fossil manifest.
-8a510cb0880349370ad19b0852f270ca072bff7871f0dc272964af31c32a7c37
\ No newline at end of file
+8f460b3b15bf4b88a224907d2f83e4ed6bf84d6b3f480008a1b187ea49c6ce1d
\ No newline at end of file
}
/*
-** Check to see if pExpr is one of the indexed expression on pParse->pIdxExpr.
+** Check to see if pExpr is one of the indexed expressions on pParse->pIdxExpr.
** If it is, then resolve the expression by reading from the index and
-** return the register into which the value has been read. If there is
-** no match, return negative.
+** return the register into which the value has been read. If pExpr is
+** not an indexed expression, then return negative.
*/
-static SQLITE_NOINLINE int sqlite3ExprIndexLookup(
+static SQLITE_NOINLINE int sqlite3IndexedExprLookup(
Parse *pParse, /* The parsing context */
Expr *pExpr, /* The expression to potentially bypass */
int target /* Where to store the result of the expression */
){
- IndexExpr *p;
+ IndexedExpr *p;
Vdbe *v;
for(p=pParse->pIdxExpr; p; p=p->pIENext){
if( p->iDataCur<0 ) continue;
if( pParse->pIdxExpr!=0
&& pExpr!=0
&& !ExprHasProperty(pExpr, EP_Leaf)
- && (r1 = sqlite3ExprIndexLookup(pParse, pExpr, target))>=0
+ && (r1 = sqlite3IndexedExprLookup(pParse, pExpr, target))>=0
){
return r1;
}
typedef struct FuncDefHash FuncDefHash;
typedef struct IdList IdList;
typedef struct Index Index;
-typedef struct IndexExpr IndexExpr;
+typedef struct IndexedExpr IndexedExpr;
typedef struct IndexSample IndexSample;
typedef struct KeyClass KeyClass;
typedef struct KeyInfo KeyInfo;
unsigned bNoQuery:1; /* Do not use this index to optimize queries */
unsigned bAscKeyBug:1; /* True if the bba7b69f9849b5bf bug applies */
unsigned bHasVCol:1; /* Index references one or more VIRTUAL columns */
- unsigned bHasExpr:1; /* This is an index on an expression */
+ unsigned bHasExpr:1; /* Index contains an expression, either a literal
+ ** expression, or a reference to a VIRTUAL column */
#ifdef SQLITE_ENABLE_STAT4
int nSample; /* Number of elements in aSample[] */
int nSampleCol; /* Size of IndexSample.anEq[] and so on */
#endif
/*
-** If there is an index on an expression in scope such that the value
-** of the expression pExpr can be read out of the index with cursor iCur
-** at column iCol, then an instance of this object records that fact.
+** For each index X that has as one of its arguments either an expression
+** or the name of a virtual generated column, and if X is in scope such that
+** the value of the expression can simply be read from the index, then
+** there is an instance of this object on the Parse.pIdxExpr list.
**
-** A linked list of these objects is attached to Parse and records all
-** expressions that can be short-circuited by extracting a valid from
-** an index.
+** During code generation, while generating code to evaluate expressions,
+** this list is consulted and if a matching expression is found, the value
+** is read from the index rather than being recomputed.
*/
-struct IndexExpr {
+struct IndexedExpr {
Expr *pExpr; /* The expression contained in the index */
int iDataCur; /* The data cursor associated with the index */
int iIdxCur; /* The index cursor */
- int iIdxCol; /* The column of the index that contains pExpr */
+ int iIdxCol; /* The index column that contains value of pExpr */
u8 bMaybeNullRow; /* True if we need an OP_IfNullRow check */
- IndexExpr *pIENext; /* Next in a list of all indexed expressions */
+ IndexedExpr *pIENext; /* Next in a list of all indexed expressions */
};
/*
int nLabelAlloc; /* Number of slots in aLabel */
int *aLabel; /* Space to hold the labels */
ExprList *pConstExpr;/* Constant expressions */
- IndexExpr *pIdxExpr; /* List of all expression in active indexes */
+ IndexedExpr *pIdxExpr;/* List of expressions used by active indexes */
Token constraintName;/* Name of the constraint currently being parsed */
yDbMask writeMask; /* Start a write transaction on these databases */
yDbMask cookieMask; /* Bitmask of schema verified databases */
** This is an sqlite3ParserAddCleanup() callback that is invoked to
** free the Parse->pIdxExpr list when the Parse object is destroyed.
*/
-static void whereIndexExprCleanup(sqlite3 *db, void *pObject){
+static void whereIndexedExprCleanup(sqlite3 *db, void *pObject){
Parse *pParse = (Parse*)pObject;
while( pParse->pIdxExpr!=0 ){
- IndexExpr *p = pParse->pIdxExpr;
+ IndexedExpr *p = pParse->pIdxExpr;
pParse->pIdxExpr = p->pIENext;
sqlite3ExprDelete(db, p->pExpr);
sqlite3DbFreeNN(db, p);
** number for the index and iDataCur is the cursor number for the corresponding
** table.
**
-** This routine adds IndexExpr entries to the Parse->pIdxExpr field for
+** This routine adds IndexedExpr entries to the Parse->pIdxExpr field for
** each of the expressions in the index so that the expression code generator
** will know to replace occurrences of the indexed expression with
** references to the corresponding column of the index.
*/
-static SQLITE_NOINLINE void whereAddIndexExpr(
- Parse *pParse, /* Add IndexExpr entries to pParse->pIdxExpr */
+static SQLITE_NOINLINE void whereAddIndexedExpr(
+ Parse *pParse, /* Add IndexedExpr entries to pParse->pIdxExpr */
Index *pIdx, /* The index-on-expression that contains the expressions */
int iIdxCur, /* Cursor number for pIdx */
SrcItem *pTabItem /* The FROM clause entry for the table */
){
int i;
- IndexExpr *p;
+ IndexedExpr *p;
Table *pTab;
assert( pIdx->bHasExpr );
pTab = pIdx->pTable;
}else{
continue;
}
- p = sqlite3DbMallocRaw(pParse->db, sizeof(IndexExpr));
+ p = sqlite3DbMallocRaw(pParse->db, sizeof(IndexedExpr));
if( p==0 ) break;
p->pIENext = pParse->pIdxExpr;
p->pExpr = sqlite3ExprDup(pParse->db, pExpr, 0);
p->bMaybeNullRow = (pTabItem->fg.jointype & (JT_LEFT|JT_LTORJ))!=0;
pParse->pIdxExpr = p;
if( p->pIENext==0 ){
- sqlite3ParserAddCleanup(pParse, whereIndexExprCleanup, pParse);
+ sqlite3ParserAddCleanup(pParse, whereIndexedExprCleanup, pParse);
}
}
}
}else{
iIndexCur = pParse->nTab++;
if( pIx->bHasExpr ){
- whereAddIndexExpr(pParse, pIx, iIndexCur, pTabItem);
+ whereAddIndexedExpr(pParse, pIx, iIndexCur, pTabItem);
}
}
pLevel->iIdxCur = iIndexCur;
last = pWInfo->iEndWhere;
}
if( pIdx->bHasExpr ){
- IndexExpr *p = pParse->pIdxExpr;
+ IndexedExpr *p = pParse->pIdxExpr;
while( p ){
if( p->iIdxCur==pLevel->iIdxCur ){
p->iDataCur = -1;