Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Invalidate prepared SQL statements when rolling back a transaction that includes schema modifications. (CVS 4216) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
a07143fc0578a5fc7c891e94616ee0b3 |
User & Date: | danielk1977 2007-08-13 15:28:34.000 |
Context
2007-08-13
| ||
16:15 | Update version number of documentation in preparation for version 3.4.2. (CVS 4217) (check-in: 1ed51e3ca0 user: drh tags: trunk) | |
15:28 | Invalidate prepared SQL statements when rolling back a transaction that includes schema modifications. (CVS 4216) (check-in: a07143fc05 user: danielk1977 tags: trunk) | |
15:18 | Disable tests that require 80-bit long doubles when the host only provides 64-bit long doubles. Ticket #2570. (CVS 4215) (check-in: 4f4f8ef416 user: drh tags: trunk) | |
Changes
Changes to src/main.c.
︙ | ︙ | |||
10 11 12 13 14 15 16 | ** ************************************************************************* ** Main file for the SQLite library. The routines in this file ** implement the programmer interface to the library. Routines in ** other files are for internal use by SQLite and should not be ** accessed by users of the library. ** | | | 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | ** ************************************************************************* ** Main file for the SQLite library. The routines in this file ** implement the programmer interface to the library. Routines in ** other files are for internal use by SQLite and should not be ** accessed by users of the library. ** ** $Id: main.c,v 1.378 2007/08/13 15:28:34 danielk1977 Exp $ */ #include "sqliteInt.h" #include "os.h" #include <ctype.h> /* ** The version of the library |
︙ | ︙ | |||
236 237 238 239 240 241 242 243 244 245 246 247 248 249 | } sqlite3BtreeRollback(db->aDb[i].pBt); db->aDb[i].inTrans = 0; } } sqlite3VtabRollback(db); if( db->flags&SQLITE_InternChanges ){ sqlite3ResetInternalSchema(db, 0); } /* If one has been configured, invoke the rollback-hook callback */ if( db->xRollbackCallback && (inTrans || !db->autoCommit) ){ db->xRollbackCallback(db->pRollbackArg); } | > | 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 | } sqlite3BtreeRollback(db->aDb[i].pBt); db->aDb[i].inTrans = 0; } } sqlite3VtabRollback(db); if( db->flags&SQLITE_InternChanges ){ sqlite3ExpirePreparedStatements(db); sqlite3ResetInternalSchema(db, 0); } /* If one has been configured, invoke the rollback-hook callback */ if( db->xRollbackCallback && (inTrans || !db->autoCommit) ){ db->xRollbackCallback(db->pRollbackArg); } |
︙ | ︙ |
Changes to test/misc4.test.
︙ | ︙ | |||
9 10 11 12 13 14 15 | # #*********************************************************************** # This file implements regression tests for SQLite library. # # This file implements tests for miscellanous features that were # left out of other test files. # | | | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | # #*********************************************************************** # This file implements regression tests for SQLite library. # # This file implements tests for miscellanous features that were # left out of other test files. # # $Id: misc4.test,v 1.22 2007/08/13 15:28:35 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # Prepare a statement that will create a temporary table. Then do # a rollback. Then try to execute the prepared statement. # |
︙ | ︙ | |||
36 37 38 39 40 41 42 43 44 45 46 47 48 49 | execsql { BEGIN; CREATE TABLE t3(a,b,c); INSERT INTO t1 SELECT * FROM t1; ROLLBACK; } } {} do_test misc4-1.3 { sqlite3_step $stmt } SQLITE_DONE do_test misc4-1.4 { execsql { SELECT * FROM temp.t2; } | > > > > > > > > > > > > | 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | execsql { BEGIN; CREATE TABLE t3(a,b,c); INSERT INTO t1 SELECT * FROM t1; ROLLBACK; } } {} # Because the previous transaction included a DDL statement and # was rolled back, statement $stmt was marked as expired. Executing it # now returns SQLITE_SCHEMA. do_test misc4-1.2.1 { list [sqlite3_step $stmt] [sqlite3_finalize $stmt] } {SQLITE_ERROR SQLITE_SCHEMA} do_test misc4-1.2.2 { set stmt [sqlite3_prepare $DB $sql -1 TAIL] set TAIL } {} do_test misc4-1.3 { sqlite3_step $stmt } SQLITE_DONE do_test misc4-1.4 { execsql { SELECT * FROM temp.t2; } |
︙ | ︙ |
Changes to test/schema.test.
︙ | ︙ | |||
9 10 11 12 13 14 15 | # #*********************************************************************** # This file implements regression tests for SQLite library. # # This file tests the various conditions under which an SQLITE_SCHEMA # error should be returned. # | | > | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | # #*********************************************************************** # This file implements regression tests for SQLite library. # # This file tests the various conditions under which an SQLITE_SCHEMA # error should be returned. # # $Id: schema.test,v 1.7 2007/08/13 15:28:35 danielk1977 Exp $ #--------------------------------------------------------------------- # When any of the following types of SQL statements or actions are # executed, all pre-compiled statements are invalidated. An attempt # to execute an invalidated statement always returns SQLITE_SCHEMA. # # CREATE/DROP TABLE...................................schema-1.* # CREATE/DROP VIEW....................................schema-2.* # CREATE/DROP TRIGGER.................................schema-3.* # CREATE/DROP INDEX...................................schema-4.* # DETACH..............................................schema-5.* # Deleting a user-function............................schema-6.* # Deleting a collation sequence.......................schema-7.* # Setting or changing the authorization function......schema-8.* # Rollback of a DDL statement.........................schema-12.* # # Test cases schema-9.* and schema-10.* test some specific bugs # that came up during development. # # Test cases schema-11.* test that it is impossible to delete or # change a collation sequence or user-function while SQL statements # are executing. Adding new collations or functions is allowed. |
︙ | ︙ | |||
328 329 330 331 332 333 334 335 336 | db collate tstcollate {} } msg] list $rc $msg } {1 {Unable to delete/modify collation sequence due to active statements}} do_test schema-11.8 { sqlite3_finalize $::STMT } {SQLITE_OK} finish_test | > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 | db collate tstcollate {} } msg] list $rc $msg } {1 {Unable to delete/modify collation sequence due to active statements}} do_test schema-11.8 { sqlite3_finalize $::STMT } {SQLITE_OK} # The following demonstrates why statements need to be expired whenever # there is a rollback (explicit or otherwise). # do_test schema-12.1 { # Begin a transaction and create a table. This increments # the schema cookie. Then compile an SQL statement, using # the current (incremented) value of the cookie. execsql { BEGIN; CREATE TABLE t3(a, b, c); } set ::STMT [sqlite3_prepare $::DB "CREATE TABLE t4(a,b,c)" -1 TAIL] # Rollback the transaction, resetting the schema cookie to the value # it had at the start of this test case. Then create a table, # incrementing the schema cookie. execsql { ROLLBACK; CREATE TABLE t4(a, b, c); } # The schema cookie now has the same value as it did when SQL statement # $::STMT was prepared. So unless it has been expired, it would be # possible to run the "CREATE TABLE t4" statement and create a # duplicate table. list [sqlite3_step $::STMT] [sqlite3_finalize $::STMT] } {SQLITE_ERROR SQLITE_SCHEMA} finish_test |