]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Experimental fix for [f777251dc7]. This may be changed yet.
authordan <dan@noemail.net>
Fri, 16 Oct 2009 14:55:03 +0000 (14:55 +0000)
committerdan <dan@noemail.net>
Fri, 16 Oct 2009 14:55:03 +0000 (14:55 +0000)
FossilOrigin-Name: 174477bca05d019e663fd2b7cd031189ab2e010a

manifest
manifest.uuid
src/btree.c
src/vacuum.c
src/vdbe.c
test/tkt-f777251dc7a.test [new file with mode: 0644]

index 0a9435d41e18a81421751a1f1f54d4c8b7d9fe82..f5eea181a1cb3669546b769c1b79f66b9b860a11 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,8 +1,5 @@
------BEGIN PGP SIGNED MESSAGE-----
-Hash: SHA1
-
-C Fix\scomment\stypos\sin\sbtreeInt.h.
-D 2009-10-16T13:23:33
+C Experimental\sfix\sfor\s[f777251dc7].\sThis\smay\sbe\schanged\syet.
+D 2009-10-16T14:55:03
 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
 F Makefile.in 4ca3f1dd6efa2075bcb27f4dc43eef749877740d
 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -109,7 +106,7 @@ F src/auth.c a5471a6951a18f79d783da34be22cd94dfbe603a
 F src/backup.c 6f1c2d9862c8a3feb7739dfcca02c1f5352e37f3
 F src/bitvec.c ed215b95734045e58358c3b3e16448f8fe6a235a
 F src/btmutex.c 0f43a75bb5b8147b386e8e1c3e71ba734e3863b7
-F src/btree.c 9c425425784c5d569bc0309c22251698ba906451
+F src/btree.c 953ad6635e39df97bcd5ff6983128622c634e9f6
 F src/btree.h 577448a890c2ab9b21e6ab74f073526184bceebe
 F src/btreeInt.h cce1c3360cd5549ffa79f981951dfae93118ad79
 F src/build.c 3c5762687d0554ebe8844dfaddb828fcc15fe16d
@@ -208,8 +205,8 @@ F src/trigger.c 2053afa9952f69cf451bc0e6ea88072701f2925e
 F src/update.c 2c8a64237e4fae604468d14380b877d169545b63
 F src/utf.c 99cf927eabb104621ba889ac0dd075fc1657ad30
 F src/util.c 59d4e9456bf1fe581f415a783fa0cee6115c8f35
-F src/vacuum.c 869d08eaab64e2a4eaf4ef9ea34b851892b65a75
-F src/vdbe.c 93fb0b490db0e27291d5240b00320a378199e0b8
+F src/vacuum.c f2347520907ee4ec867c9b804d24456b0fd912a7
+F src/vdbe.c b00293fa34fe0e065610f355fd95988fa357068a
 F src/vdbe.h 7d5075e3fa4e5587a9be8d5e503857c825490cef
 F src/vdbeInt.h 7afb76c0296f9a2310e565803fa66798ef47e9d5
 F src/vdbeapi.c 524d79eb17bbcbe31c37c908b8e01edc5c684a90
@@ -592,6 +589,7 @@ F test/threadtest2.c ace893054fa134af3fc8d6e7cfecddb8e3acefb9
 F test/tkt-2ea2425d34.test 1cf13e6f75d149b3209a0cb32927a82d3d79fb28
 F test/tkt-4a03edc4c8.test 2865e4edbc075b954daa82f8da7cc973033ec76e
 F test/tkt-5ee23731f.test 3581260f2a71e51db94e1506ba6b0f7311d002a9
+F test/tkt-f777251dc7a.test 6f24c053bc5cdb7e1e19be9a72c8887cf41d5e87
 F test/tkt1435.test f8c52c41de6e5ca02f1845f3a46e18e25cadac00
 F test/tkt1443.test bacc311da5c96a227bf8c167e77a30c99f8e8368
 F test/tkt1444.test a9d72f9e942708bd82dde6c707da61c489e213e9
@@ -760,14 +758,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
 F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
-P c1d499afc50d54b376945b4efb65c56c787a073d
-R cf7ba44c45be9336ed7c2a5c9b298530
-U drh
-Z 27563b519474558dd6b5547423b5bb90
------BEGIN PGP SIGNATURE-----
-Version: GnuPG v1.4.6 (GNU/Linux)
-
-iD8DBQFK2HPYoxKgR168RlERAkZuAJ92TotoUKoCIhNfm2FWCGunPPZHjQCfVF36
-HyFlyXF9kYuWkApFgboU+4c=
-=hlwq
------END PGP SIGNATURE-----
+P 550566a75fc79e3662431ba493af853b522d8850
+R 778bb64a8b1c35d3d0457babdafdb276
+U dan
+Z b88fc6ff2b43f8e3419b27ff47f04190
index 403801e475c00b844afd51fe691f589e4efa9174..c42015e338fa6876badfd0a079e05d57d763b247 100644 (file)
@@ -1 +1 @@
-550566a75fc79e3662431ba493af853b522d8850
\ No newline at end of file
+174477bca05d019e663fd2b7cd031189ab2e010a
\ No newline at end of file
index a9ab44504786a35eb5a1a16afd17dc03b01537fc..218c96835229074b1f6d1a959f9043ad12141868 100644 (file)
@@ -2965,18 +2965,13 @@ int sqlite3BtreeCommitPhaseOne(Btree *p, const char *zMaster){
 */
 static void btreeEndTransaction(Btree *p){
   BtShared *pBt = p->pBt;
-  BtCursor *pCsr;
   assert( sqlite3BtreeHoldsMutex(p) );
 
-  /* Search for a cursor held open by this b-tree connection. If one exists,
-  ** then the transaction will be downgraded to a read-only transaction
-  ** instead of actually concluded. A subsequent call to CommitPhaseTwo() 
-  ** or Rollback() will finish the transaction and unlock the database.  */
-  for(pCsr=pBt->pCursor; pCsr && pCsr->pBtree!=p; pCsr=pCsr->pNext);
-  assert( pCsr==0 || p->inTrans>TRANS_NONE );
-
   btreeClearHasContent(pBt);
-  if( pCsr ){
+  if( p->inTrans>TRANS_NONE && p->db->activeVdbeCnt>1 ){
+    /* If there are other active statements that belong to this database
+    ** handle, downgrade to a read-only transaction. The other statements
+    ** may still be reading from the database.  */
     downgradeAllSharedCacheTableLocks(p);
     p->inTrans = TRANS_READ;
   }else{
index 00f3511d8871106eb71530795ec88a1fdd63c1c7..8f9221e5cd287358abc1faa4752516ce459bab25 100644 (file)
@@ -130,6 +130,12 @@ int sqlite3RunVacuum(char **pzErrMsg, sqlite3 *db){
   assert( strcmp(db->aDb[db->nDb-1].zName,"vacuum_db")==0 );
   pTemp = db->aDb[db->nDb-1].pBt;
 
+  /* The call to execSql() to attach the temp database has left the file
+  ** locked (as there was more than one active statement when the transaction
+  ** to read the schema was concluded. Unlock it here so that this doesn't
+  ** cause problems for the call to BtreeSetPageSize() below.  */
+  sqlite3BtreeCommit(pTemp);
+
   nRes = sqlite3BtreeGetReserve(pMain);
 
   /* A VACUUM cannot change the pagesize of an encrypted database. */
index c89dbd7bc44cc45b9e0445e2bc56a165665f2618..19d24af20dcc1b59ad6c15a01ba42d130d0eb736 100644 (file)
@@ -2855,6 +2855,7 @@ case OP_SetCookie: {       /* in3 */
     /* Invalidate all prepared statements whenever the TEMP database
     ** schema is changed.  Ticket #1644 */
     sqlite3ExpirePreparedStatements(db);
+    p->expired = 0;
   }
   break;
 }
@@ -2972,6 +2973,11 @@ case OP_OpenWrite: {
   VdbeCursor *pCur;
   Db *pDb;
 
+  if( p->expired ){
+    rc = SQLITE_ABORT;
+    break;
+  }
+
   nField = 0;
   pKeyInfo = 0;
   p2 = pOp->p2;
diff --git a/test/tkt-f777251dc7a.test b/test/tkt-f777251dc7a.test
new file mode 100644 (file)
index 0000000..6f0b43f
--- /dev/null
@@ -0,0 +1,99 @@
+# 2009 October 16
+#
+# The author disclaims copyright to this source code.  In place of
+# a legal notice, here is a blessing:
+#
+#    May you do good and not evil.
+#    May you find forgiveness for yourself and forgive others.
+#    May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests to verify that ticket [f777251dc7a] has been
+# fixed.  
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test tkt-f7772-1.1 {
+  execsql {
+     CREATE TEMP TABLE t1(x UNIQUE);
+     INSERT INTO t1 VALUES(1);
+     CREATE TABLE t2(x, y);
+     INSERT INTO t2 VALUES(1, 2);
+     CREATE TEMP TABLE t3(w, z);
+  }
+} {}
+
+proc force_rollback {} {
+  catch {db eval {INSERT OR ROLLBACK INTO t1 VALUES(1)}}
+}
+db function force_rollback force_rollback
+
+do_test tkt-f7772-1.2 {
+  catchsql {
+    BEGIN IMMEDIATE;
+    SELECT x, force_rollback(), EXISTS(SELECT 1 FROM t3 WHERE w=x) FROM t2;
+  }
+} {1 {callback requested query abort}}
+do_test tkt-f7772-1.3 {
+  sqlite3_get_autocommit db
+} {1}
+
+do_test tkt-f7772-2.1 {
+  execsql {
+     DROP TABLE IF EXISTS t1;
+     DROP TABLE IF EXISTS t2;
+     DROP TABLE IF EXISTS t3;
+
+     CREATE TEMP TABLE t1(x UNIQUE);
+     INSERT INTO t1 VALUES(1);
+     CREATE TABLE t2(x, y);
+     INSERT INTO t2 VALUES(1, 2);
+  }
+} {}
+do_test tkt-f7772-2.2 {
+  execsql {
+    BEGIN IMMEDIATE;
+    CREATE TEMP TABLE t3(w, z);
+  }
+  catchsql {
+    SELECT x, force_rollback(), EXISTS(SELECT 1 FROM t3 WHERE w=x) FROM t2
+  }
+} {1 {callback requested query abort}}
+do_test tkt-f7772-2.3 {
+  sqlite3_get_autocommit db
+} {1}
+
+do_test tkt-f7772-3.1 {
+  execsql {
+    DROP TABLE IF EXISTS t1;
+    DROP TABLE IF EXISTS t2;
+    DROP TABLE IF EXISTS t3;
+
+    CREATE TEMP TABLE t1(x);
+    CREATE TABLE t2(x);
+    CREATE TABLE t3(x);
+  
+    INSERT INTO t1 VALUES(1);
+    INSERT INTO t1 VALUES(2);
+    INSERT INTO t2 VALUES(1);
+    INSERT INTO t2 VALUES(2);
+  }
+} {}
+
+proc ins {} { db eval {INSERT INTO t3 VALUES('hello')} }
+db function ins ins
+
+do_test tkt-f7772-3.2 {
+  execsql {
+    SELECT ins() AS x FROM t2 UNION ALL SELECT ins() AS x FROM t1
+  }
+} {{} {} {} {}}
+do_test tkt-f7772-3.3 {
+  execsql { SELECT * FROM t3 }
+} {hello hello hello hello}
+
+finish_test