]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
When constructing automatic indices do not include the same column more than
authordrh <drh@noemail.net>
Thu, 8 Apr 2010 00:40:15 +0000 (00:40 +0000)
committerdrh <drh@noemail.net>
Thu, 8 Apr 2010 00:40:15 +0000 (00:40 +0000)
once.

FossilOrigin-Name: d067d9f7a9138e026c1018361127e34385928657

manifest
manifest.uuid
src/where.c

index e0f98ad21df1957624cbbb4fcccb60a772d44752..9ce2db6894e1d966d46e2bf62cfe004d696ea96e 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,8 +1,8 @@
 -----BEGIN PGP SIGNED MESSAGE-----
 Hash: SHA1
 
-C Pull\sover\sthe\slatest\schanges\sfrom\sthe\strunk.
-D 2010-04-07T20:32:19
+C When\sconstructing\sautomatic\sindices\sdo\snot\sinclude\sthe\ssame\scolumn\smore\sthan\nonce.
+D 2010-04-08T00:40:15
 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
 F Makefile.in 4f2f967b7e58a35bb74fb7ec8ae90e0f4ca7868b
 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -225,7 +225,7 @@ F src/vdbemem.c 2a82f455f6ca6f78b59fb312f96054c04ae0ead1
 F src/vdbetrace.c 864cef96919323482ebd9986f2132435115e9cc2
 F src/vtab.c a0f8a40274e4261696ef57aa806de2776ab72cda
 F src/walker.c 3112bb3afe1d85dc52317cb1d752055e9a781f8f
-F src/where.c b3a57071f47adf46ddc8c0a2c2ccac2a7bcc5350
+F src/where.c 28c270dc93828e36392ddf85b9fd9400303c589c
 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
 F test/alias.test 4529fbc152f190268a15f9384a5651bbbabc9d87
 F test/all.test 14165b3e32715b700b5f0cbf8f6e3833dda0be45
@@ -799,14 +799,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
 F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
-P 1f40441204d9a912b1d6b67ff6ff9e17146c7abd a3540c6acf2bb6bdd44c101b63f17ca85e6b68ed
-R 7f80d010d15aec8e14d8cf92d911e2d4
+P e388fe8be878c80ef0bfd1699a7268cdb22cb3c6
+R 6de3d923fcac21cdb23f5cf757fdd27b
 U drh
-Z e9e2b30ff539b1f1c9a0478a2a8d653a
+Z 6fc29309948fba281b52ea8a8b714933
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.6 (GNU/Linux)
 
-iD8DBQFLvOvWoxKgR168RlERAg1MAJ9jynVuYFCgOw6be3NbgI4qOE4nnQCfUKhm
-r4JK585gjPilvuu1iGgxefA=
-=x2Vr
+iD8DBQFLvSXzoxKgR168RlERAjkFAJ9yq61smA3zQMYCS5Pw92gFWRWOugCfXsOv
+Eb6E6s/NHeERjTzdhu0QrwQ=
+=V5Mh
 -----END PGP SIGNATURE-----
index 70dd5d311849a267c4c6d1b58ea4853aa01ad28d..65764d36970306728f49edeb8a888a48849ffff8 100644 (file)
@@ -1 +1 @@
-e388fe8be878c80ef0bfd1699a7268cdb22cb3c6
\ No newline at end of file
+d067d9f7a9138e026c1018361127e34385928657
\ No newline at end of file
index 6d6b967c4c89175061634ddbed5987f9f8ed4466..81a74fa9a2a4e6158eda10273859fc91cbbd7b21 100644 (file)
@@ -1773,8 +1773,11 @@ static void constructAutomaticIndex(
   for(pTerm=pWC->a; pTerm<pWCEnd; pTerm++){
     if( termCanDriveIndex(pTerm, pSrc, notReady) ){
       int iCol = pTerm->u.leftColumn;
-      if( iCol<BMS && iCol>=0 ) idxCols |= 1<<iCol;
-      nColumn++;
+      Bitmask cMask = iCol>=BMS ? ((Bitmask)1)<<(BMS-1) : ((Bitmask)1)<<iCol;
+      if( (idxCols & cMask)==0 ){
+        nColumn++;
+        idxCols |= cMask;
+      }
     }
   }
   assert( nColumn>0 );
@@ -1788,7 +1791,7 @@ static void constructAutomaticIndex(
   ** original table changes and the index and table cannot both be used
   ** if they go out of sync.
   */
-  extraCols = pSrc->colUsed & ~idxCols;
+  extraCols = pSrc->colUsed & (~idxCols | (((Bitmask)1)<<(BMS-1)));
   mxBitCol = (pTable->nCol >= BMS-1) ? BMS-1 : pTable->nCol;
   for(i=0; i<mxBitCol; i++){
     if( extraCols & (1<<i) ) nColumn++;
@@ -1813,13 +1816,19 @@ static void constructAutomaticIndex(
   pIdx->nColumn = nColumn;
   pIdx->pTable = pTable;
   n = 0;
+  idxCols = 0;
   for(pTerm=pWC->a; pTerm<pWCEnd; pTerm++){
     if( termCanDriveIndex(pTerm, pSrc, notReady) ){
-      Expr *pX = pTerm->pExpr;
-      pIdx->aiColumn[n] = pTerm->u.leftColumn;
-      pColl = sqlite3BinaryCompareCollSeq(pParse, pX->pLeft, pX->pRight);
-      pIdx->azColl[n] = pColl->zName;
-      n++;
+      int iCol = pTerm->u.leftColumn;
+      Bitmask cMask = iCol>=BMS ? ((Bitmask)1)<<(BMS-1) : ((Bitmask)1)<<iCol;
+      if( (idxCols & cMask)==0 ){
+        Expr *pX = pTerm->pExpr;
+        idxCols |= cMask;
+        pIdx->aiColumn[n] = pTerm->u.leftColumn;
+        pColl = sqlite3BinaryCompareCollSeq(pParse, pX->pLeft, pX->pRight);
+        pIdx->azColl[n] = pColl->zName;
+        n++;
+      }
     }
   }
   assert( n==pLevel->plan.nEq );