aboutsummaryrefslogtreecommitdiff
path: root/src/delete.c
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2015-08-25 16:57:52 +0000
committerdrh <drh@noemail.net>2015-08-25 16:57:52 +0000
commit1f9ca2c84ca1601fde33eab74d376ac1b1c9d3b0 (patch)
tree27077a7e223e2bf5378c681d1a0a5e29e3aa7c40 /src/delete.c
parenta514b8eb0cc9c6773171381a1dfe5b456d963a97 (diff)
downloadsqlite-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/delete.c')
-rw-r--r--src/delete.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/delete.c b/src/delete.c
index 369cdaf6f..cff922cbb 100644
--- a/src/delete.c
+++ b/src/delete.c
@@ -411,6 +411,7 @@ void sqlite3DeleteFrom(
/* Extract the rowid or primary key for the current row */
if( pPk ){
for(i=0; i<nPk; i++){
+ assert( pPk->aiColumn[i]>=(-1) );
sqlite3ExprCodeGetColumnOfTable(v, pTab, iTabCur,
pPk->aiColumn[i], iPk+i);
}
@@ -789,14 +790,13 @@ int sqlite3GenerateIndexKey(
){
Vdbe *v = pParse->pVdbe;
int j;
- Table *pTab = pIdx->pTable;
int regBase;
int nCol;
if( piPartIdxLabel ){
if( pIdx->pPartIdxWhere ){
*piPartIdxLabel = sqlite3VdbeMakeLabel(v);
- pParse->iPartIdxTab = iDataCur;
+ pParse->iSelfTab = iDataCur;
sqlite3ExprCachePush(pParse);
sqlite3ExprIfFalseDup(pParse, pIdx->pPartIdxWhere, *piPartIdxLabel,
SQLITE_JUMPIFNULL);
@@ -808,9 +808,14 @@ int sqlite3GenerateIndexKey(
regBase = sqlite3GetTempRange(pParse, nCol);
if( pPrior && (regBase!=regPrior || pPrior->pPartIdxWhere) ) pPrior = 0;
for(j=0; j<nCol; j++){
- if( pPrior && pPrior->aiColumn[j]==pIdx->aiColumn[j] ) continue;
- sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, pIdx->aiColumn[j],
- regBase+j);
+ if( pPrior
+ && pPrior->aiColumn[j]==pIdx->aiColumn[j]
+ && pPrior->aiColumn[j]>=(-1)
+ ){
+ /* This column was already computed by the previous index */
+ continue;
+ }
+ sqlite3ExprCodeLoadIndexColumn(pParse, pIdx, iDataCur, j, regBase+j);
/* If the column affinity is REAL but the number is an integer, then it
** might be stored in the table as an integer (using a compact
** representation) then converted to REAL by an OP_RealAffinity opcode.