]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Optimizations associated with error handling in btree cursors.
authordrh <drh@noemail.net>
Wed, 2 Aug 2017 15:50:09 +0000 (15:50 +0000)
committerdrh <drh@noemail.net>
Wed, 2 Aug 2017 15:50:09 +0000 (15:50 +0000)
FossilOrigin-Name: 49ba54e26731ed371745d4bdd9dd1dfeb73357b6d206c85a4252ec866be971d0

manifest
manifest.uuid
src/btree.c

index 84830ead5a1d62dc2cef322a485ddc1777afd0cb..08fce324e4406e14fc7135eb2be84f39b856940a 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Remove\sunused\stoken\scodes.
-D 2017-08-02T12:38:10.936
+C Optimizations\sassociated\swith\serror\shandling\sin\sbtree\scursors.
+D 2017-08-02T15:50:09.496
 F Makefile.in d9873c9925917cca9990ee24be17eb9613a668012c85a343aef7e5536ae266e8
 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
 F Makefile.msc 02b469e9dcd5b7ee63fc1fb05babc174260ee4cfa4e0ef2e48c3c6801567a016
@@ -395,7 +395,7 @@ F src/auth.c 79f96c6f33bf0e5da8d1c282cee5ebb1852bb8a6ccca3e485d7c459b035d9c3c
 F src/backup.c faf17e60b43233c214aae6a8179d24503a61e83b
 F src/bitvec.c 17ea48eff8ba979f1f5b04cc484c7bb2be632f33
 F src/btmutex.c 0e9ce2d56159b89b9bc8e197e023ee11e39ff8ca
-F src/btree.c f55ea8f456d103328d61076be40fa39acbfea05eaa4eccfed275532a63c867c4
+F src/btree.c 412321430ea1b21b3c7935736ffcf45a8b5cb6db23958565ebdfba7154d2baa1
 F src/btree.h 3edc5329bc59534d2d15b4f069a9f54b779a7e51289e98fa481ae3c0e526a5ca
 F src/btreeInt.h 97700795edf8a43245720414798b7b29d8e465aef46bf301ffacd431910c0da1
 F src/build.c 1285d6b7da72d699db6aec36d04794629c8e0fb89bb1d8e3ba838fa56948643a
@@ -1640,7 +1640,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
 F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P cb3742f51f4b3aa0fd8dc373af771e93ddb4100787115705955f2008aef92745
-R f8d9deb47bc58de537908a281504a2fc
+P c45078c062f41f43c71965b2e5a97932ff79123eeb017ba853314987bebc2bca
+R 311e48ea3177d175c259daf3cb9b8b56
 U drh
-Z b1df4f0e6abea5a43cab52aedbd70d53
+Z e9a83e1f54df3423de8408fcd81dcfdb
index c04baf1a0f3c12129c9f4fcddfe578e2fb08e3c3..f858df400c4a7f02c7b3e8b2b45ebd7116367f62 100644 (file)
@@ -1 +1 @@
-c45078c062f41f43c71965b2e5a97932ff79123eeb017ba853314987bebc2bca
\ No newline at end of file
+49ba54e26731ed371745d4bdd9dd1dfeb73357b6d206c85a4252ec866be971d0
\ No newline at end of file
index 4d38315f309ca25a827641ff4756b9f9e7f5384c..899ad284114187541e518988df391e2dcfaf4e8e 100644 (file)
@@ -731,7 +731,7 @@ static int SQLITE_NOINLINE saveCursorsOnList(
           return rc;
         }
       }else{
-        testcase( p->iPage>0 );
+        testcase( p->iPage>=0 );
         btreeReleaseAllCursorPages(p);
       }
     }
@@ -3981,7 +3981,6 @@ int sqlite3BtreeTripAllCursors(Btree *pBtree, int errCode, int writeOnly){
   if( pBtree ){
     sqlite3BtreeEnter(pBtree);
     for(p=pBtree->pBt->pCursor; p; p=p->pNext){
-      int i;
       if( writeOnly && (p->curFlags & BTCF_WriteFlag)==0 ){
         if( p->eState==CURSOR_VALID || p->eState==CURSOR_SKIPNEXT ){
           rc = saveCursorPosition(p);
@@ -3995,10 +3994,7 @@ int sqlite3BtreeTripAllCursors(Btree *pBtree, int errCode, int writeOnly){
         p->eState = CURSOR_FAULT;
         p->skipNext = errCode;
       }
-      for(i=0; i<=p->iPage; i++){
-        releasePage(p->apPage[i]);
-        p->apPage[i] = 0;
-      }
+      btreeReleaseAllCursorPages(p);
     }
     sqlite3BtreeLeave(pBtree);
   }
@@ -4315,7 +4311,7 @@ int sqlite3BtreeCloseCursor(BtCursor *pCur){
       }while( ALWAYS(pPrev) );
     }
     for(i=0; i<=pCur->iPage; i++){
-      releasePage(pCur->apPage[i]);
+      releasePageNotNull(pCur->apPage[i]);
     }
     unlockBtreeIfUnused(pBt);
     sqlite3_free(pCur->aOverflow);
@@ -4938,13 +4934,7 @@ static int moveToRoot(BtCursor *pCur){
   assert( CURSOR_INVALID < CURSOR_REQUIRESEEK );
   assert( CURSOR_VALID   < CURSOR_REQUIRESEEK );
   assert( CURSOR_FAULT   > CURSOR_REQUIRESEEK );
-  if( pCur->eState>=CURSOR_REQUIRESEEK ){
-    if( pCur->eState==CURSOR_FAULT ){
-      assert( pCur->skipNext!=SQLITE_OK );
-      return pCur->skipNext;
-    }
-    sqlite3BtreeClearCursor(pCur);
-  }
+  assert( pCur->eState < CURSOR_REQUIRESEEK || pCur->iPage<0 );
 
   if( pCur->iPage>=0 ){
     if( pCur->iPage ){
@@ -4959,6 +4949,13 @@ static int moveToRoot(BtCursor *pCur){
     return SQLITE_OK;
   }else{
     assert( pCur->iPage==(-1) );
+    if( pCur->eState>=CURSOR_REQUIRESEEK ){
+      if( pCur->eState==CURSOR_FAULT ){
+        assert( pCur->skipNext!=SQLITE_OK );
+        return pCur->skipNext;
+      }
+      sqlite3BtreeClearCursor(pCur);
+    }
     rc = getAndInitPage(pCur->pBtree->pBt, pCur->pgnoRoot, &pCur->apPage[0],
                         0, pCur->curPagerFlags);
     if( rc!=SQLITE_OK ){
@@ -8254,7 +8251,7 @@ int sqlite3BtreeInsert(
     pCur->apPage[pCur->iPage]->nOverflow = 0;
     pCur->eState = CURSOR_INVALID;
     if( (flags & BTREE_SAVEPOSITION) && rc==SQLITE_OK ){
-      rc = moveToRoot(pCur);
+      btreeReleaseAllCursorPages(pCur);
       if( pCur->pKeyInfo ){
         assert( pCur->pKey==0 );
         pCur->pKey = sqlite3Malloc( pX->nKey );
@@ -8268,7 +8265,7 @@ int sqlite3BtreeInsert(
       pCur->nKey = pX->nKey;
     }
   }
-  assert( pCur->apPage[pCur->iPage]->nOverflow==0 );
+  assert( pCur->iPage<0 || pCur->apPage[pCur->iPage]->nOverflow==0 );
 
 end_insert:
   return rc;
@@ -8438,6 +8435,7 @@ int sqlite3BtreeDelete(BtCursor *pCur, u8 flags){
     }else{
       rc = moveToRoot(pCur);
       if( bPreserve ){
+        btreeReleaseAllCursorPages(pCur);
         pCur->eState = CURSOR_REQUIRESEEK;
       }
     }