]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Correctly handle queries that use secondary indices of WITHOUT ROWID tables.
authordrh <drh@noemail.net>
Thu, 24 Oct 2013 00:18:18 +0000 (00:18 +0000)
committerdrh <drh@noemail.net>
Thu, 24 Oct 2013 00:18:18 +0000 (00:18 +0000)
FossilOrigin-Name: d8bc8595301789d0e9de24c391808121905ab559

manifest
manifest.uuid
src/where.c

index 17e84b0df0b1527e58148580de377583ea669b96..a21fff8720062e8b9248c7c269a4cb3bd1e0b1b8 100644 (file)
--- a/manifest
+++ b/manifest
@@ -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
index a0b77dfbae25c50693f819dc29791200e275df85..929c2dd3f92d5faad7c8a83e4111a24a08549117 100644 (file)
@@ -1 +1 @@
-247f389930aededaa54ecb792748aa8d0ad6d57b
\ No newline at end of file
+d8bc8595301789d0e9de24c391808121905ab559
\ No newline at end of file
index 5859f83242bfbe73f49bde3da76ec34413b9d3f0..a43c5a39c0dd58e4e80d4f43cb7f82e6c6512259 100644 (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