From: drh Date: Thu, 12 Feb 2004 15:31:21 +0000 (+0000) Subject: Always reload the schema after a rollback. Ticket #594. (CVS 1229) X-Git-Tag: version-3.6.10~4839 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8ef83ffed8ccde86d0bef04773872b1a555b64c2;p=thirdparty%2Fsqlite.git Always reload the schema after a rollback. Ticket #594. (CVS 1229) FossilOrigin-Name: 12c7a83f8e4055c4590983ef212648c781ebd963 --- diff --git a/manifest b/manifest index 68940ab758..99d47db409 100644 --- 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 diff --git a/manifest.uuid b/manifest.uuid index ab9aafda61..a23da2ceae 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2fe9f5101cb0f743532912ece3d37f6c873e7025 \ No newline at end of file +12c7a83f8e4055c4590983ef212648c781ebd963 \ No newline at end of file diff --git a/src/btree_rb.c b/src/btree_rb.c index 3d82887735..d57ddca726 100644 --- a/src/btree_rb.c +++ b/src/btree_rb.c @@ -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; diff --git a/src/main.c b/src/main.c index b338c3dda4..ab0a6cf9f9 100644 --- a/src/main.c +++ b/src/main.c @@ -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); */ } /* diff --git a/src/select.c b/src/select.c index 818789d5c1..4b9c1bd35e 100644 --- a/src/select.c +++ b/src/select.c @@ -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); } } diff --git a/src/vdbeaux.c b/src/vdbeaux.c index f3f73cad00..6e99491818 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -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 ){ diff --git a/test/attach.test b/test/attach.test index a64d933667..1abb5abeb2 100644 --- a/test/attach.test +++ b/test/attach.test @@ -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} diff --git a/test/attach2.test b/test/attach2.test index 49e2b89af2..e2680c1c3f 100644 --- a/test/attach2.test +++ b/test/attach2.test @@ -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} diff --git a/test/interrupt.test b/test/interrupt.test index 39bf917a6a..22480f7882 100644 --- a/test/interrupt.test +++ b/test/interrupt.test @@ -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