diff options
author | drh <drh@noemail.net> | 2015-08-25 16:57:52 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2015-08-25 16:57:52 +0000 |
commit | 1f9ca2c84ca1601fde33eab74d376ac1b1c9d3b0 (patch) | |
tree | 27077a7e223e2bf5378c681d1a0a5e29e3aa7c40 /src/expr.c | |
parent | a514b8eb0cc9c6773171381a1dfe5b456d963a97 (diff) | |
download | sqlite-1f9ca2c84ca1601fde33eab74d376ac1b1c9d3b0.tar.gz sqlite-1f9ca2c84ca1601fde33eab74d376ac1b1c9d3b0.zip |
Add code to maintain indexes with expression arguments across DELETE, INSERT,
and UPDATE statements. Legacy tests pass, but the new code paths are still
largely untested. The query planner currently makes no effort to use
expression indexes.
FossilOrigin-Name: efaabdb71626bdc03768e87e186c72f6f3da75b2
Diffstat (limited to 'src/expr.c')
-rw-r--r-- | src/expr.c | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/src/expr.c b/src/expr.c index 1aebef6b1..34c382a19 100644 --- a/src/expr.c +++ b/src/expr.c @@ -2432,6 +2432,28 @@ static void sqlite3ExprCachePinRegister(Parse *pParse, int iReg){ } } +/* Generate code that will load into register regOut a value that is +** appropriate for the iIdxCol-th column of index pIdx. +*/ +void sqlite3ExprCodeLoadIndexColumn( + Parse *pParse, /* The parsing context */ + Index *pIdx, /* The index whose column is to be loaded */ + int iTabCur, /* Cursor pointing to a table row */ + int iIdxCol, /* The column of the index to be loaded */ + int regOut /* Store the index column value in this register */ +){ + i16 iTabCol = pIdx->aiColumn[iIdxCol]; + if( iTabCol>=(-1) ){ + sqlite3ExprCodeGetColumnOfTable(pParse->pVdbe, pIdx->pTable, iTabCur, + iTabCol, regOut); + return; + } + assert( pIdx->aColExpr ); + assert( pIdx->aColExpr->nExpr>iIdxCol ); + pParse->iSelfTab = iTabCur; + sqlite3ExprCode(pParse, pIdx->aColExpr->a[iIdxCol].pExpr, regOut); +} + /* ** Generate code to extract the value of the iCol-th column of a table. */ @@ -2617,8 +2639,9 @@ int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target){ inReg = pExpr->iColumn + pParse->ckBase; break; }else{ - /* Deleting from a partial index */ - iTab = pParse->iPartIdxTab; + /* Coding an expression that is part of an index where column names + ** in the index refer to the table to which the index belongs */ + iTab = pParse->iSelfTab; } } inReg = sqlite3ExprCodeGetColumn(pParse, pExpr->pTab, |