Correctly handle queries that use secondary indices of WITHOUT ROWID tables.

FossilOrigin-Name: d8bc8595301789d0e9de24c391808121905ab559
This commit is contained in:
drh 2013-10-24 00:18:18 +00:00
parent dd9930ef20
commit 85c1c557d0
3 changed files with 19 additions and 8 deletions

View File

@ -1,5 +1,5 @@
C Change\sthe\ssqlite3OpenTable()\sutility\sto\sopen\sthe\sPRIMARY\sKEY\sindex\swhen\nreading\sa\sWITHOUT\sROWID\stable.
D 2013-10-23T23:37:02.093
C Correctly\shandle\squeries\sthat\suse\ssecondary\sindices\sof\sWITHOUT\sROWID\stables.
D 2013-10-24T00:18:18.383
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in 0522b53cdc1fcfc18f3a98e0246add129136c654
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@ -292,7 +292,7 @@ F src/vtab.c 5a423b042eb1402ef77697d03d6a67378d97bc8d
F src/wal.c 7dc3966ef98b74422267e7e6e46e07ff6c6eb1b4
F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4
F src/walker.c e9e593d5bb798c3e67fc3893dfe7055c9e7d8d74
F src/where.c 3dcdb0912101571b8821d564b90964bb34ea7ad1
F src/where.c b5f5244d53d965443661a324be270ac133cecd69
F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2
F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
F test/aggnested.test 45c0201e28045ad38a530b5a144b73cd4aa2cfd6
@ -1127,7 +1127,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01
F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff
P 2c028ddc85cb45746cad6ab0cefd99134fbd50d7
R 09a1279eaef47a31655fe176c982c7ce
P 247f389930aededaa54ecb792748aa8d0ad6d57b
R 427fde7ddc5af933d786f1c624b16eae
U drh
Z faf48e5960db188516b7851e14254c4b
Z 0442060427808d2c1b7f1561da464258

View File

@ -1 +1 @@
247f389930aededaa54ecb792748aa8d0ad6d57b
d8bc8595301789d0e9de24c391808121905ab559

View File

@ -3551,11 +3551,22 @@ static Bitmask codeOneLoopStart(
/* Seek the table cursor, if required */
disableTerm(pLevel, pRangeStart);
disableTerm(pLevel, pRangeEnd);
if( !omitTable ){
if( omitTable ){
/* pIdx is a covering index. No need to access the main table. */
}else if( HasRowid(pIdx->pTable) ){
iRowidReg = iReleaseReg = sqlite3GetTempReg(pParse);
sqlite3VdbeAddOp2(v, OP_IdxRowid, iIdxCur, iRowidReg);
sqlite3ExprCacheStore(pParse, iCur, -1, iRowidReg);
sqlite3VdbeAddOp2(v, OP_Seek, iCur, iRowidReg); /* Deferred seek */
}else{
Index *pPk = sqlite3PrimaryKeyIndex(pIdx->pTable);
iRowidReg = sqlite3GetTempRange(pParse, pPk->nKeyCol);
for(j=0; j<pPk->nKeyCol; j++){
k = sqlite3ColumnOfIndex(pIdx, pPk->aiColumn[j]);
sqlite3VdbeAddOp3(v, OP_Column, iIdxCur, k, iRowidReg+j);
}
sqlite3VdbeAddOp4(v, OP_NotFound, iCur, addrCont, iRowidReg,
SQLITE_INT_TO_PTR(pPk->nKeyCol), P4_INT32);
}
/* Record the instruction used to terminate the loop. Disable