]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Fix an assert() in unlockBtreeIfUnused() so that it checks for the existance
authordrh <drh@noemail.net>
Tue, 14 May 2013 23:12:06 +0000 (23:12 +0000)
committerdrh <drh@noemail.net>
Tue, 14 May 2013 23:12:06 +0000 (23:12 +0000)
of an untripped cursor, not for the existance of any cursor at all.

FossilOrigin-Name: a6f851d0fe01d8c8d44a2fe0b716ff7a5194c63b

manifest
manifest.uuid
src/btree.c
test/misuse.test

index 008ee4a3dfe6b145c5642bbcb71a32f85ebcace4..0764d64e6e07832da1cda4b0fc0b9ac124a5399b 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Candidate\sfixes\sfor\sproblems\srevealed\sby\snotify2.test.\sNotify2.test\sis\sstill\sfailing\sat\sthis\spoint.
-D 2013-05-13T18:23:15.893
+C Fix\san\sassert()\sin\sunlockBtreeIfUnused()\sso\sthat\sit\schecks\sfor\sthe\sexistance\nof\san\suntripped\scursor,\snot\sfor\sthe\sexistance\sof\sany\scursor\sat\sall.
+D 2013-05-14T23:12:06.185
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in ce81671efd6223d19d4c8c6b88ac2c4134427111
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -137,7 +137,7 @@ F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34
 F src/backup.c b266767351ae2d847716c56fcb2a1fea7c761c03
 F src/bitvec.c 19a4ba637bd85f8f63fc8c9bae5ade9fb05ec1cb
 F src/btmutex.c 976f45a12e37293e32cae0281b15a21d48a8aaa7
-F src/btree.c 480a6d255cc4f066029daf23dd54acf152cd0e13
+F src/btree.c 34ea83e16ece6d666214c7d0c3a39ce92fe292fd
 F src/btree.h 6fa8a3ff2483d0bb64a9f0105a8cedeac9e00cca
 F src/btreeInt.h eecc84f02375b2bb7a44abbcbbe3747dde73edb2
 F src/build.c 083da8466fd7e481cb8bd5264398f537507f6176
@@ -646,7 +646,7 @@ F test/misc4.test 9c078510fbfff05a9869a0b6d8b86a623ad2c4f6
 F test/misc5.test 528468b26d03303b1f047146e5eefc941b9069f5
 F test/misc6.test 953cc693924d88e6117aeba16f46f0bf5abede91
 F test/misc7.test dd82ec9250b89178b96cd28b2aca70639d21e5b3
-F test/misuse.test ba4fb5d1a6101d1c171ea38b3c613d0661c83054
+F test/misuse.test 9e580d30f94968ebb57878de3503608dc9f0f226
 F test/mmap1.test 8696aa1b0bd88961c2f16af2a3f7a69d701cea50
 F test/mmap2.test a5ba639f90b5fc487400a49e158e14e465943e98
 F test/multiplex.test e08cc7177bd6d85990ee1d71100bb6c684c02256
@@ -1063,10 +1063,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381
 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
 F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac
-P cf5c3642247fdd34d87f0368594cd7b8f081636a
-R 9334ad7d318214aee7b701f9959b5d6e
-T *branch * shared-cache-fixes
-T *sym-shared-cache-fixes *
-T -sym-trunk *
-U dan
-Z 816ab4789f48f56b3bf310736184e47d
+P ea0428f9b6e63066e7444a2ba2f8c12a2e3ab7e4
+R 2410ec7fd380116c79746c720dac4cd6
+U drh
+Z 5ded41815869fd9a599b4926f7c8b138
index 133cb8b7941eb3a8ac482ab2b4c76467cb5e3e72..fc052d359f487541e3a95f135e3930d289fe7142 100644 (file)
@@ -1 +1 @@
-ea0428f9b6e63066e7444a2ba2f8c12a2e3ab7e4
\ No newline at end of file
+a6f851d0fe01d8c8d44a2fe0b716ff7a5194c63b
\ No newline at end of file
index 616d4036818028994eae94c2c074ab3170ca8cd2..297b0a7f8e40e14ee8b19f5bc6951cc15ed36e1e 100644 (file)
@@ -2517,6 +2517,29 @@ page1_init_failed:
   return rc;
 }
 
+#ifndef NDEBUG
+/*
+** Return the number of cursors open on pBt. This is for use
+** in assert() expressions, so it is only compiled if NDEBUG is not
+** defined.
+**
+** Only write cursors are counted if wrOnly is true.  If wrOnly is
+** false then all cursors are counted.
+**
+** For the purposes of this routine, a cursor is any cursor that
+** is capable of reading or writing to the databse.  Cursors that
+** have been tripped into the CURSOR_FAULT state are not counted.
+*/
+static int countValidCursors(BtShared *pBt, int wrOnly){
+  BtCursor *pCur;
+  int r = 0;
+  for(pCur=pBt->pCursor; pCur; pCur=pCur->pNext){
+    if( (wrOnly==0 || pCur->wrFlag) && pCur->eState!=CURSOR_FAULT ) r++; 
+  }
+  return r;
+}
+#endif
+
 /*
 ** If there are no outstanding cursors and we are not in the middle
 ** of a transaction but there is a read lock on the database, then
@@ -2527,7 +2550,7 @@ page1_init_failed:
 */
 static void unlockBtreeIfUnused(BtShared *pBt){
   assert( sqlite3_mutex_held(pBt->mutex) );
-  assert( pBt->pCursor==0 || pBt->inTransaction>TRANS_NONE );
+  assert( countValidCursors(pBt,0)==0 || pBt->inTransaction>TRANS_NONE );
   if( pBt->inTransaction==TRANS_NONE && pBt->pPage1!=0 ){
     assert( pBt->pPage1->aData );
     assert( sqlite3PagerRefcount(pBt->pPager)==1 );
@@ -3351,27 +3374,6 @@ int sqlite3BtreeCommit(Btree *p){
   return rc;
 }
 
-#ifndef NDEBUG
-/*
-** Return the number of write-cursors open on this handle. This is for use
-** in assert() expressions, so it is only compiled if NDEBUG is not
-** defined.
-**
-** For the purposes of this routine, a write-cursor is any cursor that
-** is capable of writing to the databse.  That means the cursor was
-** originally opened for writing and the cursor has not be disabled
-** by having its state changed to CURSOR_FAULT.
-*/
-static int countWriteCursors(BtShared *pBt){
-  BtCursor *pCur;
-  int r = 0;
-  for(pCur=pBt->pCursor; pCur; pCur=pCur->pNext){
-    if( pCur->wrFlag && pCur->eState!=CURSOR_FAULT ) r++; 
-  }
-  return r;
-}
-#endif
-
 /*
 ** This routine sets the state to CURSOR_FAULT and the error
 ** code to errCode for every cursor on BtShared that pBtree
@@ -3451,7 +3453,7 @@ int sqlite3BtreeRollback(Btree *p, int tripCode){
       pBt->nPage = nPage;
       releasePage(pPage1);
     }
-    assert( countWriteCursors(pBt)==0 );
+    assert( countValidCursors(pBt, 1)==0 );
     pBt->inTransaction = TRANS_READ;
   }
 
index 71ee0118c8b6ef9f9fb884798fd756c92d3238e1..84ead1c6696782ee60bda0b7ec53b32e7355f1d9 100644 (file)
@@ -170,7 +170,7 @@ do_test misuse-4.3 {
     }
   } msg]
   lappend v $msg $r
-} {0 {} SQLITE_BUSY}
+} {1 {callback requested query abort} SQLITE_BUSY}
 do_test misuse-4.4 {
   # Flush the TCL statement cache here, otherwise the sqlite3_close() will
   # fail because there are still un-finalized() VDBEs.