]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Fix compiler warnings. Fix a harmless off-by-one error in the solver.
authordrh <drh@noemail.net>
Wed, 19 Jun 2013 03:27:12 +0000 (03:27 +0000)
committerdrh <drh@noemail.net>
Wed, 19 Jun 2013 03:27:12 +0000 (03:27 +0000)
FossilOrigin-Name: 10021941d0258951b916e788881df140113f0597

manifest
manifest.uuid
src/prepare.c
src/where.c

index 3817eca13bc59ff1393aacf6f071ccc15e9eeccf..d232347684f3b2d469bab20aac834e0d714c8055 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Adjustments\sto\stestcase()\smacros\sfor\simproved\stestability.
-D 2013-06-18T20:06:23.048
+C Fix\scompiler\swarnings.\s\sFix\sa\sharmless\soff-by-one\serror\sin\sthe\ssolver.
+D 2013-06-19T03:27:12.614
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in 5e41da95d92656a5004b03d3576e8b226858a28e
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -210,7 +210,7 @@ F src/pcache.c f8043b433a57aba85384a531e3937a804432a346
 F src/pcache.h a5e4f5d9f5d592051d91212c5949517971ae6222
 F src/pcache1.c d23d07716de96c7c0c2503ec5051a4384c3fb938
 F src/pragma.c 67a611bd4be0754f27ee13eb87932c3b14415862
-F src/prepare.c 213de4aae5e29cfbb32202d1c09f4fc4b5a51b09
+F src/prepare.c 2306be166bbeddf454e18bf8b21dba8388d05328
 F src/printf.c bff529ed47657098c55c9910b9c69b1b3b1a1353
 F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50
 F src/resolve.c 89f9003e8316ee3a172795459efc2a0274e1d5a8
@@ -289,7 +289,7 @@ F src/vtab.c b05e5f1f4902461ba9f5fc49bb7eb7c3a0741a83
 F src/wal.c 436bfceb141b9423c45119e68e444358ee0ed35d
 F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4
 F src/walker.c 4fa43583d0a84b48f93b1e88f11adf2065be4e73
-F src/where.c 85b7b80a350951444c8e3e45bf2f7e6cc6d34683
+F src/where.c 5cc059bd283fe9f99800270c797fabdcbef8009a
 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2
 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
 F test/aggnested.test 45c0201e28045ad38a530b5a144b73cd4aa2cfd6
@@ -1096,7 +1096,7 @@ F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
 F tool/wherecosttest.c f407dc4c79786982a475261866a161cd007947ae
 F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac
-P 4c6d58d75d51e1ce829aec214617c3a89e784a2d
-R f77d52adfdd29eb20a93333ac0fbc3fa
+P 4fbb0c4d26c54aaefbe5397cde2a0b9d2ce3885f
+R dae7f42197a8d862e7c14dd3769614f8
 U drh
-Z e0df54c8e9d824f28c0e34a1e5fe6134
+Z e26ab5beb4ba36d99e52a8a301bdec10
index cf33cbf052627e6d876154fed6493f0ac92157f9..011a8dd71fbca0b756fbb717bd93287ca14f533c 100644 (file)
@@ -1 +1 @@
-4fbb0c4d26c54aaefbe5397cde2a0b9d2ce3885f
\ No newline at end of file
+10021941d0258951b916e788881df140113f0597
\ No newline at end of file
index 319bb5012e0323e043320998192a0c133c74eb70..28145aa4e7ef035d9862ef89ffdf64625df98dae 100644 (file)
@@ -592,7 +592,7 @@ static int sqlite3Prepare(
   sqlite3VtabUnlockList(db);
 
   pParse->db = db;
-  pParse->nQueryLoop = 1;
+  pParse->nQueryLoop = 0;  /* Logarithmic, so 0 really means 1 */
   if( nBytes>=0 && (nBytes==0 || zSql[nBytes-1]!=0) ){
     char *zSqlCopy;
     int mxLen = db->aLimit[SQLITE_LIMIT_SQL_LENGTH];
@@ -614,7 +614,7 @@ static int sqlite3Prepare(
   }else{
     sqlite3RunParser(pParse, zSql, &zErrMsg);
   }
-  assert( 1==pParse->nQueryLoop );
+  assert( 0==pParse->nQueryLoop );
 
   if( db->mallocFailed ){
     pParse->rc = SQLITE_NOMEM;
index dc4a515b904abdfb28a3ae4972c267eeff314942..73fdcaa431cbec0fb3634d4082ec5e36464340d0 100644 (file)
@@ -4237,7 +4237,7 @@ static int whereLoopAddBtreeIndex(
   int rc = SQLITE_OK;             /* Return code */
   WhereCost nRowEst;              /* Estimated index selectivity */
   WhereCost rLogSize;             /* Logarithm of table size */
-  WhereTerm *pTop, *pBtm;         /* Top and bottom range constraints */
+  WhereTerm *pTop = 0, *pBtm = 0; /* Top and bottom range constraints */
 
   pNew = pBuilder->pNew;
   if( db->mallocFailed ) return SQLITE_NOMEM;
@@ -4257,6 +4257,7 @@ static int whereLoopAddBtreeIndex(
   if( pNew->u.btree.nEq < pProbe->nColumn ){
     iCol = pProbe->aiColumn[pNew->u.btree.nEq];
     nRowEst = whereCost(pProbe->aiRowEst[pNew->u.btree.nEq+1]);
+    if( nRowEst==0 && pProbe->onError==OE_None ) nRowEst = 1;
   }else{
     iCol = -1;
     nRowEst = 0;
@@ -4786,7 +4787,7 @@ static int whereLoopAddOr(WhereLoopBuilder *pBuilder, Bitmask mExtra){
       sSubBuild.pOrderBy = 0;
       sSubBuild.pBest = &sBest;
 
-      for(pOrTerm=pOrWC->a; rc==SQLITE_OK && pOrTerm<pOrWCEnd; pOrTerm++){
+      for(pOrTerm=pOrWC->a; pOrTerm<pOrWCEnd; pOrTerm++){
         if( (pOrTerm->eOperator & WO_AND)!=0 ){
           sSubBuild.pWC = &pOrTerm->u.pAndInfo->wc;
         }else if( pOrTerm->leftCursor==iCur ){
@@ -4810,6 +4811,8 @@ static int whereLoopAddOr(WhereLoopBuilder *pBuilder, Bitmask mExtra){
         {
           rc = whereLoopAddBtree(&sSubBuild, mExtra);
         }
+        /* sBest.maskSelf is always zero if an error occurs */
+        assert( rc==SQLITE_OK || sBest.maskSelf==0 );
         if( sBest.maskSelf==0 ) break;
         assert( sBest.rSetup==0 );
         rTotal = whereCostAdd(rTotal, sBest.rRun);
@@ -5135,6 +5138,10 @@ static const char *wherePathName(WherePath *pPath, int nLoop, WhereLoop *pLast){
 ** attempts to find the lowest cost path that visits each WhereLoop
 ** once.  This path is then loaded into the pWInfo->a[].pWLoop fields.
 **
+** Assume that the total number of output rows that will need to be sorted
+** will be nRowEst (in the 10*log2 representation).  Or, ignore sorting
+** costs if nRowEst==0.
+**
 ** Return SQLITE_OK on success or SQLITE_NOMEM of a memory allocation
 ** error occurs.
 */
@@ -5146,7 +5153,7 @@ static int wherePathSolver(WhereInfo *pWInfo, WhereCost nRowEst){
   int iLoop;                /* Loop counter over the terms of the join */
   int ii, jj;               /* Loop counters */
   WhereCost rCost;             /* Cost of a path */
-  WhereCost mxCost;            /* Maximum cost of a set of paths */
+  WhereCost mxCost = 0;        /* Maximum cost of a set of paths */
   WhereCost rSortCost;         /* Cost to do a sort */
   int nTo, nFrom;           /* Number of valid entries in aTo[] and aFrom[] */
   WherePath *aFrom;         /* All nFrom paths at the previous level */
@@ -5739,7 +5746,7 @@ WhereInfo *sqlite3WhereBegin(
     wherePathSolver(pWInfo, 0);
     if( db->mallocFailed ) goto whereBeginError;
     if( pWInfo->pOrderBy ){
-       wherePathSolver(pWInfo, pWInfo->nRowOut);
+       wherePathSolver(pWInfo, pWInfo->nRowOut+1);
        if( db->mallocFailed ) goto whereBeginError;
     }
   }