]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Always reload the schema after a rollback. Ticket #594. (CVS 1229)
authordrh <drh@noemail.net>
Thu, 12 Feb 2004 15:31:21 +0000 (15:31 +0000)
committerdrh <drh@noemail.net>
Thu, 12 Feb 2004 15:31:21 +0000 (15:31 +0000)
FossilOrigin-Name: 12c7a83f8e4055c4590983ef212648c781ebd963

manifest
manifest.uuid
src/btree_rb.c
src/main.c
src/select.c
src/vdbeaux.c
test/attach.test
test/attach2.test
test/interrupt.test

index 68940ab758992a547a366093f1b85c809c9e2832..99d47db4091025963b0d4f008f368cfa7a9260ac 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C VACUUM\sreturns\sSQLITE_INTERRUPT\swhen\sinterrupted.\s\sTicket\s#593.\s(CVS\s1228)
-D 2004-02-12T13:02:56
+C Always\sreload\sthe\sschema\safter\sa\srollback.\s\sTicket\s#594.\s(CVS\s1229)
+D 2004-02-12T15:31:21
 F Makefile.in cfd75c46b335881999333a9e4b982fa8491f200b
 F Makefile.linux-gcc b86a99c493a5bfb402d1d9178dcdc4bd4b32f906
 F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
@@ -25,7 +25,7 @@ F src/attach.c 4a0a3c0885fec11a0a199a8031694d08925d0a27
 F src/auth.c c59ad0dab501888f8b1fccc25e2f5965d2265116
 F src/btree.c c325d46f0aa815d73358bf2e044dab23f645c214
 F src/btree.h 41cb3ff6ebc3f6da2d0a074e39ff8c7a2287469f
-F src/btree_rb.c ed844f9181d08efa4eaca2c157accc27434e345f
+F src/btree_rb.c 32b2cb4285c0fbd53b89de021637b63d52257e54
 F src/build.c 05ee0d69c7379ef3e20121b2197bfb8865003371
 F src/copy.c 9e47975ea96751c658bcf1a0c4f0bb7c6ee61e73
 F src/date.c c9d2bfd40b1c95f8f97d53a5eba981d7167c7b61
@@ -36,7 +36,7 @@ F src/func.c cbc5edd10c82a5193b9ca0726873328be445e6c1
 F src/hash.c 9b56ef3b291e25168f630d5643a4264ec011c70e
 F src/hash.h 3247573ab95b9dd90bcca0307a75d9a16da1ccc7
 F src/insert.c 01f66866f35c986eab4a57373ca689a3255ef2df
-F src/main.c 6ec57b0f146572033c70493417d251365a7b4fbe
+F src/main.c 79e303dc172579549f9921b4bfe94e0a8cb96722
 F src/md5.c fe4f9c9c6f71dfc26af8da63e4d04489b1430565
 F src/os.c f5fc4954725b2fcd852979f2746085fe8ca27710
 F src/os.h 250a3789be609adfee5c5aa20137ce8683276f24
@@ -46,7 +46,7 @@ F src/parse.y 7a121554c0c0c0150a77ab05417b01fa44813ac4
 F src/pragma.c 89d62c31c6f0a43376fe8d20549b87a6d30c467a
 F src/printf.c 84e4ea4ba49cbbf930e95e82295127ad5843ae1f
 F src/random.c 775913e0b7fbd6295d21f12a7bd35b46387c44b2
-F src/select.c a0211d1a6a94f6c3e611096e77f2d689a641495e
+F src/select.c a3a203f9b68c899ac69dbc5fa11cd649fd8acd06
 F src/shell.c c1c7242ede2af46044378d36d2c533e98fd59fb8
 F src/sqlite.h.in 1798588cab21ebf9fac3aad7fc1539b396c1f91d
 F src/sqliteInt.h f03de87717569619884830b1833eca2b257fc675
@@ -64,11 +64,11 @@ F src/vacuum.c d9e80c2b36ee1f623dbf1bdf3cedad24a23f87ac
 F src/vdbe.c f665f4c1dcee0665f26b88b9e7ede74c4ab9edd5
 F src/vdbe.h 3957844e46fea71fd030e78f6a3bd2f7e320fb43
 F src/vdbeInt.h 8a3baf749115cba81a810b7a52208aef055eda7b
-F src/vdbeaux.c c55d87d6658487e87ef09ca80c1aa2f314024fed
+F src/vdbeaux.c 7c83db889c336596f48defebdec4270ce3990847
 F src/where.c 1302d728bd338c237e6a8282e4e3eadbbdf11e45
 F test/all.test 569a92a8ee88f5300c057cc4a8f50fbbc69a3242
-F test/attach.test c26848402e7ac829e043e1fa5e0eb87032e5d81d
-F test/attach2.test b1baa766fe5bf82d9a58dbbcf3d4549274190f7d
+F test/attach.test 09ff5eec8e7103909beae14dbb1d97c01d64bfa4
+F test/attach2.test ce61e6185b3cd891cc0e9a4c868fcc65eb92fc55
 F test/auth.test 5c4d95cdaf539c0c236e20ce1f71a93e7dde9185
 F test/bigfile.test ea904b853ce2d703b16c5ce90e2b54951bc1ae81
 F test/bigrow.test 8ab252dba108f12ad64e337b0f2ff31a807ac578
@@ -94,7 +94,7 @@ F test/in.test 0de39b02ceeca90993b096822fb5a884661c5b47
 F test/index.test 9295deefbdb6dedbe01be8905f0c448fe5bd4079
 F test/insert.test a17b7f7017097afb2727aa5b67ceeb7ab0a120a1
 F test/insert2.test c288375a64dad3295044714f0dfed4a193cf067f
-F test/interrupt.test 09926d4d851864c99390545bd498348a1bf509e9
+F test/interrupt.test 5d4308fc33405abf305d52ddaa571a207768a911
 F test/intpkey.test 9320af48415c594afd4e15f8ef0daa272e05502e
 F test/ioerr.test 5dbaf09f96b56ee01cf3edd762b96eb4ad2c9ca4
 F test/join.test 9ef6aabaac9de51d5fc41e68d1f4355da05a84cd
@@ -184,7 +184,7 @@ F www/sqlite.tcl 3c83b08cf9f18aa2d69453ff441a36c40e431604
 F www/tclsqlite.tcl b9271d44dcf147a93c98f8ecf28c927307abd6da
 F www/vdbe.tcl 9b9095d4495f37697fd1935d10e14c6015e80aa1
 F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4
-P 300c5543dc83c6b7eacb0c81ed06f95004c0f6d8
-R 6e5176bc612d6cf5beab95037a0e3778
+P 2fe9f5101cb0f743532912ece3d37f6c873e7025
+R 6c2fc2ff1652d69a19fddf002bab9e52
 U drh
-Z d702251833e256e19bf4070671ed3290
+Z cb56b1ce256967725fed5e041788204c
index ab9aafda61c74cb8334ac8df49d5ff4338f03063..a23da2ceae614c8bec60fc10688e44c7b7f943e1 100644 (file)
@@ -1 +1 @@
-2fe9f5101cb0f743532912ece3d37f6c873e7025
\ No newline at end of file
+12c7a83f8e4055c4590983ef212648c781ebd963
\ No newline at end of file
index 3d828877350371ee9e5d30a36075986707ad1cb0..d57ddca726830430a2ff2892b738a57a863a6734 100644 (file)
@@ -9,7 +9,7 @@
 **    May you share freely, never taking more than you give.
 **
 *************************************************************************
-** $Id: btree_rb.c,v 1.22 2004/02/11 02:18:06 drh Exp $
+** $Id: btree_rb.c,v 1.23 2004/02/12 15:31:21 drh Exp $
 **
 ** This file implements an in-core database using Red-Black balanced
 ** binary trees.
@@ -723,13 +723,13 @@ static int memRbtreeCursor(
   pCur = *ppCur = sqliteMalloc(sizeof(RbtCursor));
   if( sqlite_malloc_failed ) return SQLITE_NOMEM;
   pCur->pTree  = sqliteHashFind(&tree->tblHash, 0, iTable);
+  assert( pCur->pTree );
   pCur->pRbtree = tree;
   pCur->iTree  = iTable;
   pCur->pOps = &sqliteRbtreeCursorOps;
   pCur->wrFlag = wrFlag;
   pCur->pShared = pCur->pTree->pCursors;
   pCur->pTree->pCursors = pCur;
-  
 
   assert( (*ppCur)->pTree );
   return SQLITE_OK;
index b338c3dda44b4548c5dd0c7c288f786204913173..ab0a6cf9f98e71e31466e0d596d910cbab170045 100644 (file)
@@ -14,7 +14,7 @@
 ** other files are for internal use by SQLite and should not be
 ** accessed by users of the library.
 **
-** $Id: main.c,v 1.147 2004/02/10 02:27:04 drh Exp $
+** $Id: main.c,v 1.148 2004/02/12 15:31:21 drh Exp $
 */
 #include "sqliteInt.h"
 #include "os.h"
@@ -387,6 +387,9 @@ int sqliteInit(sqlite *db, char **pzErrMsg){
     if( DbHasProperty(db, i, DB_SchemaLoaded) ) continue;
     assert( i!=1 );  /* Should have been initialized together with 0 */
     rc = sqliteInitOne(db, i, pzErrMsg);
+    if( rc ){
+      sqliteResetInternalSchema(db, i);
+    }
   }
   if( rc==SQLITE_OK ){
     db->flags |= SQLITE_Initialized;
@@ -422,7 +425,6 @@ int sqliteInit(sqlite *db, char **pzErrMsg){
       sqliteSetString(pzErrMsg, 
         "unable to upgrade database to the version 2.6 format",
         zErr ? ": " : 0, zErr, (char*)0);
-      sqliteStrRealloc(pzErrMsg);
     }
     sqlite_freemem(zErr);
   }
@@ -584,7 +586,8 @@ void sqliteRollbackAll(sqlite *db){
       db->aDb[i].inTrans = 0;
     }
   }
-  sqliteRollbackInternalChanges(db);
+  sqliteResetInternalSchema(db, 0);
+  /* sqliteRollbackInternalChanges(db); */
 }
 
 /*
index 818789d5c11e819eb2a8e9b43c2980ef4b137b3e..4b9c1bd35efe4a7401ac628e05fac8c7093e0e43 100644 (file)
@@ -12,7 +12,7 @@
 ** This file contains C code routines that are called by the parser
 ** to handle SELECT statements in SQLite.
 **
-** $Id: select.c,v 1.151 2004/02/09 14:37:50 drh Exp $
+** $Id: select.c,v 1.152 2004/02/12 15:31:21 drh Exp $
 */
 #include "sqliteInt.h"
 
@@ -676,7 +676,7 @@ static void generateColumnTypes(
       }
     }
     sqliteVdbeAddOp(v, OP_ColumnName, i + pEList->nExpr, 0);
-    sqliteVdbeChangeP3(v, -1, zType, P3_STATIC);
+    sqliteVdbeChangeP3(v, -1, zType, 0);
   }
 }
 
index f3f73cad00845cab3fabba01a1077f35fd0b1b0c..6e994918184989b03463000a1bab2cefa0da6ade 100644 (file)
@@ -829,6 +829,7 @@ int sqliteVdbeReset(Vdbe *p, char **pzErrMsg){
   }
   Cleanup(p);
   if( p->rc!=SQLITE_OK ){
+    int saved_flags;
     switch( p->errorAction ){
       case OE_Abort: {
         if( !p->undoTransOnError ){
index a64d933667c1b8e7b99937999d355c5fbf0f5f19..1abb5abeb26f31ea6ed24f61afbc350be4cdb057 100644 (file)
@@ -12,7 +12,7 @@
 # focus of this script is testing the ATTACH and DETACH commands
 # and related functionality.
 #
-# $Id: attach.test,v 1.11 2003/07/18 01:25:35 drh Exp $
+# $Id: attach.test,v 1.12 2004/02/12 15:31:22 drh Exp $
 #
 
 set testdir [file dirname $argv0]
@@ -364,8 +364,12 @@ do_test attach-3.13 {
   catchsql {UPDATE t2 SET x=x+1 WHERE x=50}
 } {1 {database is locked}}
 do_test attach-3.14 {
-  # the "database is locked" error on the previous test should have
-  # caused a rollback.
+  # Unable to reinitialize the schema tables because the aux database
+  # is still locked.
+  catchsql {SELECT * FROM t1}
+} {1 {database is locked}}
+do_test attach-3.15 {
+  execsql COMMIT db2
   execsql {SELECT * FROM t1}
 } {1 2 3 4}
 
index 49e2b89af2a27ed526bbf108fcef375f55f7cb09..e2680c1c3fff075efdf43b6bae673c4c68efe47e 100644 (file)
@@ -12,7 +12,7 @@
 # focus of this script is testing the ATTACH and DETACH commands
 # and related functionality.
 #
-# $Id: attach2.test,v 1.4 2004/01/20 11:54:03 drh Exp $
+# $Id: attach2.test,v 1.5 2004/02/12 15:31:22 drh Exp $
 #
 
 
@@ -108,6 +108,7 @@ do_test attach2-2.10 {
 do_test attach2-2.11 {
   # when the write failed in the previous test, the transaction should
   # have rolled back.
+  db2 eval ROLLBACK
   execsql {
     SELECT * FROM t1
   }
@@ -122,7 +123,6 @@ do_test attach2-2.12 {
 #
 do_test attach2-3.1 {
   db close
-  db2 eval ROLLBACK
   set DB [sqlite db test.db]
   set rc [catch {sqlite_compile $DB "ATTACH 'test2.db' AS t2" TAIL} VM]
   if {$rc} {lappend rc $VM}
index 39bf917a6a4c7f39a3e9b868c47299469b854ca5..22480f78828044b353c64d71970883bd5142587e 100644 (file)
@@ -11,7 +11,7 @@
 # This file implements regression tests for SQLite library.  The
 # focus of this script is the sqlite_interrupt() API.
 #
-# $Id: interrupt.test,v 1.1 2004/02/12 13:02:57 drh Exp $
+# $Id: interrupt.test,v 1.2 2004/02/12 15:31:22 drh Exp $
 
 
 set testdir [file dirname $argv0]
@@ -105,5 +105,40 @@ do_test interrupt-2.4 {
 } 1
 integrity_check interrupt-2.5
 
+# Ticket #594.  If an interrupt occurs in the middle of a transaction
+# and that transaction is later rolled back, the internal schema tables do
+# not reset.
+#
+for {set i 1} {$i<50} {incr i 5} {
+  do_test interrupt-3.$i.1 {
+    execsql {
+      BEGIN;
+      CREATE TEMP TABLE t2(x,y);
+      SELECT name FROM sqlite_temp_master;
+    }
+  } {t2}
+  do_test interrupt-3.$i.2 {
+    set ::sqlite_interrupt_count $::i
+    catchsql {
+      INSERT INTO t2 SELECT * FROM t1;
+    }
+  } {1 interrupted}
+  do_test interrupt-3.$i.3 {
+    execsql {
+      SELECT name FROM sqlite_temp_master;
+    }
+  } {t2}
+  do_test interrupt-3.$i.4 {
+    catchsql {
+      ROLLBACK
+    }
+  } {0 {}}
+  do_test interrupt-3.$i.5 {
+    catchsql {SELECT name FROM sqlite_temp_master};
+    execsql {
+      SELECT name FROM sqlite_temp_master;
+    }
+  } {}
+}
 
 finish_test