]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
When moving a page to make way for the root page of a new table or index in an auto...
authordan <dan@noemail.net>
Wed, 3 Apr 2013 11:38:36 +0000 (11:38 +0000)
committerdan <dan@noemail.net>
Wed, 3 Apr 2013 11:38:36 +0000 (11:38 +0000)
FossilOrigin-Name: 9d9b1da54a555e8fb6037d63d1952458c12956d2

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

index a2604173873fc1e747567271e3c01490821fde1a..cf7c875169b0952224ac76c34fe9a8c1bde0af26 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C In\sbtree.c,\ssave\sthe\spositions\sof\sother\scursors\sopen\son\sthe\ssame\stable\swhen\swriting\svia\san\sincremental\sblob\shandle.\sOtherwise,\sthey\smay\sbe\sleft\sholding\san\sout-of-date\sxFetch\spage\sreference.
-D 2013-04-03T11:17:39.067
+C When\smoving\sa\spage\sto\smake\sway\sfor\sthe\sroot\spage\sof\sa\snew\stable\sor\sindex\sin\san\sauto-vacuum\sdatabase,\ssave\sthe\spositions\sof\sany\scursors\sthat\smay\sbe\sholding\sxFetch\sreferences\sto\sthe\spage\sbeing\smoved.
+D 2013-04-03T11:38:36.388
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in df3e48659d80e1b7765785d8d66c86b320f72cc7
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -121,7 +121,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 b38cb3a1758d46e76bec080994fed7313622687d
+F src/btree.c 4f4b23941b38f68db425f68960f26031204d9807
 F src/btree.h d9490cd37aaeb530a41b07f06e1262950b1be916
 F src/btreeInt.h eecc84f02375b2bb7a44abbcbbe3747dde73edb2
 F src/build.c 083da8466fd7e481cb8bd5264398f537507f6176
@@ -631,7 +631,7 @@ F test/misc5.test 528468b26d03303b1f047146e5eefc941b9069f5
 F test/misc6.test 953cc693924d88e6117aeba16f46f0bf5abede91
 F test/misc7.test dd82ec9250b89178b96cd28b2aca70639d21e5b3
 F test/misuse.test ba4fb5d1a6101d1c171ea38b3c613d0661c83054
-F test/mmap1.test 9f4cee0877549c80b13acd688c775254b2d61ec7
+F test/mmap1.test 5a662d506c367b082b24cb9186acb11efa6cbe3d
 F test/mmap2.test c0cbb978eda8d06d755ba8d9e59ec06ebf60c5cb
 F test/multiplex.test e08cc7177bd6d85990ee1d71100bb6c684c02256
 F test/multiplex2.test 580ca5817c7edbe4cc68fa150609c9473393003a
@@ -1042,7 +1042,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 24bab7596bb7385981a5d331df5eeb05353547f7
-R 5d2a80f93297e2bae93eb7d43d59c6c0
+P 3f09fba18f7e61e21381ffea13c31b968efd7d77
+R 7ec6dcb52e20c580b46b605bb884042f
 U dan
-Z a5b2fa9ebb6e4e86d546b82b43bf4939
+Z c27841a9d742e32f5c92b396fb592137
index d1325fe2f5b4799954919135e64b728fa30ab590..ab30a2773c1483f816cbf50941575bb4675a5c82 100644 (file)
@@ -1 +1 @@
-3f09fba18f7e61e21381ffea13c31b968efd7d77
\ No newline at end of file
+9d9b1da54a555e8fb6037d63d1952458c12956d2
\ No newline at end of file
index a1877ebfe8d3ecdedd1257e9d01f4d52b36065b8..dd37112c39ee175f7b9bb9b01a3e47af4221d7f0 100644 (file)
@@ -7269,6 +7269,14 @@ static int btreeCreateTable(Btree *p, int *piTable, int createTabFlags){
       u8 eType = 0;
       Pgno iPtrPage = 0;
 
+      /* Save the positions of any open cursors. This is required in
+      ** case they are holding a reference to an xFetch reference
+      ** corresponding to page pgnoRoot.  */
+      rc = saveAllCursors(pBt, 0, 0);
+      if( rc!=SQLITE_OK ){
+        return rc;
+      }
+
       releasePage(pPageMove);
 
       /* Move the page currently at pgnoRoot to pgnoMove. */
index 802b9210483478cebdb4c2876e90dae6655fa97f..d9babe3d86903c499966e5ba6a930699d5dd1228 100644 (file)
@@ -205,7 +205,46 @@ do_test 4.4 {
 
 do_execsql_test 4.5 { COMMIT }
 
-finish_test
+#-------------------------------------------------------------------------
+# Ensure that existing cursors holding xFetch() references are not 
+# confused if those pages are moved to make way for the root page of a
+# new table or index.
+#
+reset_db
+do_execsql_test 5.1 {
+  PRAGMA auto_vacuum = 2;
+  PRAGMA page_size = 1024;
+  CREATE TABLE t1(x);
+  INSERT INTO t1 VALUES($aaa);
+  INSERT INTO t1 VALUES($bbb);
+  INSERT INTO t1 VALUES($ccc);
+  INSERT INTO t1 VALUES($ddd);
 
+  PRAGMA auto_vacuum;
+  SELECT * FROM t1;
+} [list 2 $aaa $bbb $ccc $ddd]
+
+do_test 5.2 {
+  set ::STMT [sqlite3_prepare db "SELECT * FROM t1 ORDER BY rowid" -1 dummy]
+  sqlite3_step $::STMT
+  sqlite3_column_text $::STMT 0
+} $aaa
+
+do_execsql_test 5.3 {
+  CREATE TABLE t2(x);
+  INSERT INTO t2 VALUES('tricked you!');
+  INSERT INTO t2 VALUES('tricked you!');
+}
+
+do_test 5.4 {
+  sqlite3_step $::STMT
+  sqlite3_column_text $::STMT 0
+} $bbb
+
+do_test 5.5 {
+  sqlite3_finalize $::STMT
+} SQLITE_OK
+
+finish_test