3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing:
6 # May you do good and not evil.
7 # May you find forgiveness for yourself and forgive others.
8 # May you share freely, never taking more than you give.
10 #***********************************************************************
12 # $Id: savepoint.test,v 1.13 2009/07/18 08:30:45 danielk1977 Exp $
14 set testdir [file dirname $argv0]
15 source $testdir/tester.tcl
16 source $testdir/lock_common.tcl
17 source $testdir/malloc_common.tcl
19 #----------------------------------------------------------------------
20 # The following tests - savepoint-1.* - test that the SAVEPOINT, RELEASE
21 # and ROLLBACK TO comands are correctly parsed, and that the auto-commit
22 # flag is correctly set and unset as a result.
24 do_test savepoint-1.1 {
31 do_test savepoint-1.2 {
37 do_test savepoint-1.3 {
38 execsql { SAVEPOINT sp1 }
42 do_test savepoint-1.4.1 {
48 sqlite3_get_autocommit db
50 do_test savepoint-1.4.2 {
56 sqlite3_get_autocommit db
58 do_test savepoint-1.4.3 {
59 execsql { RELEASE sp1 }
60 sqlite3_get_autocommit db
62 do_test savepoint-1.4.4 {
68 sqlite3_get_autocommit db
70 do_test savepoint-1.4.5 {
71 execsql { RELEASE SAVEPOINT sp1 }
72 sqlite3_get_autocommit db
74 do_test savepoint-1.4.6 {
79 ROLLBACK TO SAVEPOINT sp3;
80 ROLLBACK TRANSACTION TO sp2;
81 ROLLBACK TRANSACTION TO SAVEPOINT sp1;
83 sqlite3_get_autocommit db
85 do_test savepoint-1.4.7 {
86 execsql { RELEASE SAVEPOINT SP1 }
87 sqlite3_get_autocommit db
89 do_test savepoint-1.5 {
95 do_test savepoint-1.6 {
98 wal_check_journal_mode savepoint-1.7
100 #------------------------------------------------------------------------
101 # These tests - savepoint-2.* - test rollbacks and releases of savepoints
102 # with a very simple data set.
105 do_test savepoint-2.1 {
107 CREATE TABLE t1(a, b, c);
109 INSERT INTO t1 VALUES(1, 2, 3);
111 UPDATE t1 SET a = 2, b = 3, c = 4;
113 execsql { SELECT * FROM t1 }
115 do_test savepoint-2.2 {
119 execsql { SELECT * FROM t1 }
121 do_test savepoint-2.3 {
123 INSERT INTO t1 VALUES(4, 5, 6);
125 execsql { SELECT * FROM t1 }
127 do_test savepoint-2.4 {
131 execsql { SELECT * FROM t1 }
135 do_test savepoint-2.5 {
137 INSERT INTO t1 VALUES(7, 8, 9);
139 INSERT INTO t1 VALUES(10, 11, 12);
141 execsql { SELECT * FROM t1 }
142 } {1 2 3 7 8 9 10 11 12}
143 do_test savepoint-2.6 {
147 execsql { SELECT * FROM t1 }
149 do_test savepoint-2.7 {
151 INSERT INTO t1 VALUES(10, 11, 12);
153 execsql { SELECT * FROM t1 }
154 } {1 2 3 7 8 9 10 11 12}
155 do_test savepoint-2.8 {
159 execsql { SELECT * FROM t1 }
161 do_test savepoint-2.9 {
163 INSERT INTO t1 VALUES('a', 'b', 'c');
165 INSERT INTO t1 VALUES('d', 'e', 'f');
167 execsql { SELECT * FROM t1 }
168 } {1 2 3 a b c d e f}
169 do_test savepoint-2.10 {
173 execsql { SELECT * FROM t1 }
174 } {1 2 3 a b c d e f}
175 do_test savepoint-2.11 {
179 execsql { SELECT * FROM t1 }
181 wal_check_journal_mode savepoint-2.12
183 #------------------------------------------------------------------------
184 # This block of tests - savepoint-3.* - test that when a transaction
185 # savepoint is rolled back, locks are not released from database files.
186 # And that when a transaction savepoint is released, they are released.
188 # These tests do not work in WAL mode. WAL mode does not take RESERVED
189 # locks on the database file.
191 if {[wal_is_wal_mode]==0} {
192 do_test savepoint-3.1 {
193 execsql { SAVEPOINT "transaction" }
194 execsql { PRAGMA lock_status }
195 } {main unlocked temp closed}
197 do_test savepoint-3.2 {
198 execsql { INSERT INTO t1 VALUES(1, 2, 3) }
199 execsql { PRAGMA lock_status }
200 } {main reserved temp closed}
202 do_test savepoint-3.3 {
203 execsql { ROLLBACK TO "transaction" }
204 execsql { PRAGMA lock_status }
205 } {main reserved temp closed}
207 do_test savepoint-3.4 {
208 execsql { INSERT INTO t1 VALUES(1, 2, 3) }
209 execsql { PRAGMA lock_status }
210 } {main reserved temp closed}
212 do_test savepoint-3.5 {
213 execsql { RELEASE "transaction" }
214 execsql { PRAGMA lock_status }
215 } {main unlocked temp closed}
218 #------------------------------------------------------------------------
219 # Test that savepoints that include schema modifications are handled
220 # correctly. Test cases savepoint-4.*.
222 do_test savepoint-4.1 {
224 CREATE TABLE t2(d, e, f);
225 SELECT sql FROM sqlite_master;
227 } {{CREATE TABLE t1(a, b, c)} {CREATE TABLE t2(d, e, f)}}
228 do_test savepoint-4.2 {
231 CREATE TABLE t3(g,h);
232 INSERT INTO t3 VALUES('I', 'II');
237 do_test savepoint-4.3 {
239 CREATE TABLE t3(g, h, i);
240 INSERT INTO t3 VALUES('III', 'IV', 'V');
242 execsql {SELECT * FROM t3}
244 do_test savepoint-4.4 {
245 execsql { ROLLBACK TO one; }
246 execsql {SELECT * FROM t3}
248 do_test savepoint-4.5 {
251 SELECT sql FROM sqlite_master;
253 } {{CREATE TABLE t1(a, b, c)} {CREATE TABLE t2(d, e, f)}}
255 do_test savepoint-4.6 {
258 INSERT INTO t1 VALUES('o', 't', 't');
260 CREATE TABLE t3(a, b, c);
261 INSERT INTO t3 VALUES('z', 'y', 'x');
263 execsql {SELECT * FROM t3}
265 do_test savepoint-4.7 {
269 INSERT INTO t3 VALUES('value');
271 execsql {SELECT * FROM t3}
273 do_test savepoint-4.8 {
276 wal_check_journal_mode savepoint-4.9
278 #------------------------------------------------------------------------
279 # Test some logic errors to do with the savepoint feature.
283 do_test savepoint-5.1.1 {
285 CREATE TABLE blobs(x);
286 INSERT INTO blobs VALUES('a twentyeight character blob');
288 set fd [db incrblob blobs x 1]
289 puts -nonewline $fd "hello"
290 catchsql {SAVEPOINT abc}
291 } {1 {cannot open savepoint - SQL statements in progress}}
292 do_test savepoint-5.1.2 {
294 catchsql {SAVEPOINT abc}
297 do_test savepoint-5.2 {
298 execsql {RELEASE abc}
299 catchsql {RELEASE abc}
300 } {1 {no such savepoint: abc}}
302 do_test savepoint-5.3.1 {
303 execsql {SAVEPOINT abc}
304 catchsql {ROLLBACK TO def}
305 } {1 {no such savepoint: def}}
306 do_test savepoint-5.3.2 {
307 execsql {SAVEPOINT def}
308 set fd [db incrblob -readonly blobs x 1]
309 catchsql {ROLLBACK TO def}
310 } {1 {cannot rollback savepoint - SQL statements in progress}}
311 do_test savepoint-5.3.3 {
312 catchsql {RELEASE def}
314 do_test savepoint-5.3.4 {
316 execsql {savepoint def}
317 set fd [db incrblob blobs x 1]
318 catchsql {release def}
319 } {1 {cannot release savepoint - SQL statements in progress}}
320 do_test savepoint-5.3.5 {
322 execsql {release abc}
327 # Open a savepoint transaction and insert a row into the database. Then,
328 # using a second database handle, open a read-only transaction on the
329 # database file. Check that the savepoint transaction cannot be committed
330 # until after the read-only transaction has been closed.
334 # As above, except that the savepoint transaction can be successfully
335 # committed before the read-only transaction has been closed.
337 do_test savepoint-5.4.1 {
340 INSERT INTO blobs VALUES('another blob');
343 do_test savepoint-5.4.2 {
345 execsql { BEGIN ; SELECT count(*) FROM blobs } db2
347 if {[wal_is_wal_mode]} {
348 do_test savepoint-5.4.3 { catchsql "RELEASE main" } {0 {}}
349 do_test savepoint-5.4.4 { db2 close } {}
351 do_test savepoint-5.4.3 {
352 catchsql { RELEASE main }
353 } {1 {database is locked}}
354 do_test savepoint-5.4.4 {
356 catchsql { RELEASE main }
359 do_test savepoint-5.4.5 {
360 execsql { SELECT x FROM blobs WHERE rowid = 2 }
362 do_test savepoint-5.4.6 {
363 execsql { SELECT count(*) FROM blobs }
366 wal_check_journal_mode savepoint-5.5
368 #-------------------------------------------------------------------------
369 # The following tests, savepoint-6.*, test an incr-vacuum inside of a
370 # couple of nested savepoints.
372 ifcapable {autovacuum && pragma} {
374 file delete -force test.db
377 do_test savepoint-6.1 {
378 execsql { PRAGMA auto_vacuum = incremental }
381 CREATE TABLE t1(a, b, c);
382 CREATE INDEX i1 ON t1(a, b);
384 INSERT INTO t1 VALUES(randstr(10,400),randstr(10,400),randstr(10,400));
386 set r "randstr(10,400)"
387 for {set ii 0} {$ii < 10} {incr ii} {
388 execsql "INSERT INTO t1 SELECT $r, $r, $r FROM t1"
393 integrity_check savepoint-6.2
395 do_test savepoint-6.3 {
397 PRAGMA cache_size = 10;
399 UPDATE t1 SET a = randstr(10,10) WHERE (rowid%4)==0;
401 DELETE FROM t1 WHERE rowid%2;
404 INSERT INTO t1 SELECT randstr(10,400), randstr(10,400), c FROM t1;
405 DELETE FROM t1 WHERE rowid%2;
412 integrity_check savepoint-6.4
414 wal_check_journal_mode savepoint-6.5
417 #-------------------------------------------------------------------------
418 # The following tests, savepoint-7.*, attempt to break the logic
419 # surrounding savepoints by growing and shrinking the database file.
422 file delete -force test.db
425 do_test savepoint-7.1 {
426 execsql { PRAGMA auto_vacuum = incremental }
429 PRAGMA cache_size = 10;
431 CREATE TABLE t1(a PRIMARY KEY, b);
432 INSERT INTO t1(a) VALUES('alligator');
433 INSERT INTO t1(a) VALUES('angelfish');
434 INSERT INTO t1(a) VALUES('ant');
435 INSERT INTO t1(a) VALUES('antelope');
436 INSERT INTO t1(a) VALUES('ape');
437 INSERT INTO t1(a) VALUES('baboon');
438 INSERT INTO t1(a) VALUES('badger');
439 INSERT INTO t1(a) VALUES('bear');
440 INSERT INTO t1(a) VALUES('beetle');
441 INSERT INTO t1(a) VALUES('bird');
442 INSERT INTO t1(a) VALUES('bison');
443 UPDATE t1 SET b = randstr(1000,1000);
444 UPDATE t1 SET b = b||randstr(1000,1000);
445 UPDATE t1 SET b = b||randstr(1000,1000);
446 UPDATE t1 SET b = b||randstr(10,1000);
449 expr ([execsql { PRAGMA page_count }] > 20)
451 do_test savepoint-7.2.1 {
455 CREATE TABLE t2(a, b);
456 INSERT INTO t2 SELECT a, b FROM t1;
460 PRAGMA integrity_check;
463 do_test savepoint-7.2.2 {
466 PRAGMA integrity_check;
470 do_test savepoint-7.3.1 {
472 CREATE TABLE t2(a, b);
473 INSERT INTO t2 SELECT a, b FROM t1;
476 do_test savepoint-7.3.2 {
481 PRAGMA incremental_vacuum;
483 INSERT INTO t2 SELECT a, b FROM t1;
487 execsql { PRAGMA integrity_check }
489 wal_check_journal_mode savepoint-7.3.3
491 do_test savepoint-7.4.1 {
493 file delete -force test.db
495 execsql { PRAGMA auto_vacuum = incremental }
498 CREATE TABLE t1(a, b, PRIMARY KEY(a, b));
499 INSERT INTO t1 VALUES(randstr(1000,1000), randstr(1000,1000));
503 PRAGMA incremental_vacuum;
508 execsql { PRAGMA integrity_check }
511 do_test savepoint-7.5.1 {
513 PRAGMA incremental_vacuum;
514 CREATE TABLE t5(x, y);
515 INSERT INTO t5 VALUES(1, randstr(1000,1000));
516 INSERT INTO t5 VALUES(2, randstr(1000,1000));
517 INSERT INTO t5 VALUES(3, randstr(1000,1000));
520 INSERT INTO t5 VALUES(4, randstr(1000,1000));
521 INSERT INTO t5 VALUES(5, randstr(1000,1000));
522 DELETE FROM t5 WHERE x=1 OR x=2;
524 PRAGMA incremental_vacuum;
526 INSERT INTO t5 VALUES(1, randstr(1000,1000));
527 INSERT INTO t5 VALUES(2, randstr(1000,1000));
531 PRAGMA integrity_check;
534 do_test savepoint-7.5.2 {
539 wal_check_journal_mode savepoint-7.5.3
541 # Test oddly named and quoted savepoints.
543 do_test savepoint-8-1 {
544 execsql { SAVEPOINT "save1" }
545 execsql { RELEASE save1 }
547 do_test savepoint-8-2 {
548 execsql { SAVEPOINT "Including whitespace " }
549 execsql { RELEASE "including Whitespace " }
552 # Test that the authorization callback works.
556 eval lappend ::authdata $args
561 do_test savepoint-9.1 {
562 set ::authdata [list]
563 execsql { SAVEPOINT sp1 }
565 } {SQLITE_SAVEPOINT BEGIN sp1 {} {}}
566 do_test savepoint-9.2 {
567 set ::authdata [list]
568 execsql { ROLLBACK TO sp1 }
570 } {SQLITE_SAVEPOINT ROLLBACK sp1 {} {}}
571 do_test savepoint-9.3 {
572 set ::authdata [list]
573 execsql { RELEASE sp1 }
575 } {SQLITE_SAVEPOINT RELEASE sp1 {} {}}
578 eval lappend ::authdata $args
583 do_test savepoint-9.4 {
584 set ::authdata [list]
585 set res [catchsql { SAVEPOINT sp1 }]
586 concat $::authdata $res
587 } {SQLITE_SAVEPOINT BEGIN sp1 {} {} 1 {not authorized}}
588 do_test savepoint-9.5 {
589 set ::authdata [list]
590 set res [catchsql { ROLLBACK TO sp1 }]
591 concat $::authdata $res
592 } {SQLITE_SAVEPOINT ROLLBACK sp1 {} {} 1 {not authorized}}
593 do_test savepoint-9.6 {
594 set ::authdata [list]
595 set res [catchsql { RELEASE sp1 }]
596 concat $::authdata $res
597 } {SQLITE_SAVEPOINT RELEASE sp1 {} {} 1 {not authorized}}
599 catch { db eval ROLLBACK }
603 #-------------------------------------------------------------------------
604 # The following tests - savepoint-10.* - test the interaction of
605 # savepoints and ATTACH statements.
608 # First make sure it is not possible to attach or detach a database while
609 # a savepoint is open (it is not possible if any transaction is open).
611 do_test savepoint-10.1.1 {
614 ATTACH 'test2.db' AS aux;
616 } {1 {cannot ATTACH database within transaction}}
617 do_test savepoint-10.1.2 {
620 ATTACH 'test2.db' AS aux;
626 } {1 {cannot DETACH database within transaction}}
627 do_test savepoint-10.1.3 {
634 # The lock state of the TEMP database can vary if SQLITE_TEMP_STORE=3
635 # And the following set of tests is only really interested in the status
636 # of the aux1 and aux2 locks. So record the current lock status of
637 # TEMP for use in the answers.
638 set templockstate [lindex [db eval {PRAGMA lock_status}] 3]
641 if {[wal_is_wal_mode]==0} {
642 do_test savepoint-10.2.1 {
643 file delete -force test3.db
644 file delete -force test2.db
646 ATTACH 'test2.db' AS aux1;
647 ATTACH 'test3.db' AS aux2;
649 CREATE TABLE main.t1(x, y);
650 CREATE TABLE aux1.t2(x, y);
651 CREATE TABLE aux2.t3(x, y);
652 SELECT name FROM sqlite_master
654 SELECT name FROM aux1.sqlite_master
656 SELECT name FROM aux2.sqlite_master;
659 do_test savepoint-10.2.2 {
660 execsql { PRAGMA lock_status }
661 } [list main unlocked temp $templockstate aux1 unlocked aux2 unlocked]
663 do_test savepoint-10.2.3 {
666 INSERT INTO t1 VALUES(1, 2);
669 } [list main reserved temp $templockstate aux1 unlocked aux2 unlocked]
670 do_test savepoint-10.2.4 {
672 INSERT INTO t3 VALUES(3, 4);
675 } [list main reserved temp $templockstate aux1 unlocked aux2 reserved]
676 do_test savepoint-10.2.5 {
679 INSERT INTO t2 VALUES(5, 6);
682 } [list main reserved temp $templockstate aux1 reserved aux2 reserved]
683 do_test savepoint-10.2.6 {
684 execsql { SELECT * FROM t2 }
686 do_test savepoint-10.2.7 {
687 execsql { ROLLBACK TO two }
688 execsql { SELECT * FROM t2 }
690 do_test savepoint-10.2.8 {
691 execsql { PRAGMA lock_status }
692 } [list main reserved temp $templockstate aux1 reserved aux2 reserved]
693 do_test savepoint-10.2.9 {
694 execsql { SELECT 'a', * FROM t1 UNION ALL SELECT 'b', * FROM t3 }
696 do_test savepoint-10.2.9 {
698 INSERT INTO t2 VALUES(5, 6);
707 do_test savepoint-10.2.9 {
708 execsql { PRAGMA lock_status }
709 } [list main unlocked temp $templockstate aux1 unlocked aux2 unlocked]
711 do_test savepoint-10.2.10 {
714 INSERT INTO t1 VALUES('a', 'b');
716 INSERT INTO t2 VALUES('c', 'd');
718 INSERT INTO t3 VALUES('e', 'f');
725 } {1 2 a b 5 6 c d 3 4 e f}
726 do_test savepoint-10.2.11 {
727 execsql { ROLLBACK TO two }
734 do_test savepoint-10.2.12 {
736 INSERT INTO t3 VALUES('g', 'h');
745 do_test savepoint-10.2.13 {
753 do_test savepoint-10.2.14 {
754 execsql { PRAGMA lock_status }
755 } [list main unlocked temp $templockstate aux1 unlocked aux2 unlocked]
758 #-------------------------------------------------------------------------
759 # The following tests - savepoint-11.* - test the interaction of
760 # savepoints and creating or dropping tables and indexes in
763 do_test savepoint-11.1 {
765 file delete -force test.db
767 execsql { PRAGMA auto_vacuum = full; }
770 CREATE TABLE t1(a, b, UNIQUE(a, b));
771 INSERT INTO t1 VALUES(1, randstr(1000,1000));
772 INSERT INTO t1 VALUES(2, randstr(1000,1000));
775 do_test savepoint-11.2 {
778 CREATE TABLE t2(a, b, UNIQUE(a, b));
780 CREATE TABLE t3(a, b, UNIQUE(a, b));
783 integrity_check savepoint-11.3
784 do_test savepoint-11.4 {
785 execsql { ROLLBACK TO two }
787 integrity_check savepoint-11.5
788 do_test savepoint-11.6 {
790 CREATE TABLE t3(a, b, UNIQUE(a, b));
794 integrity_check savepoint-11.7
795 do_test savepoint-11.8 {
797 execsql { PRAGMA wal_checkpoint }
801 do_test savepoint-11.9 {
803 DROP TABLE IF EXISTS t1;
804 DROP TABLE IF EXISTS t2;
805 DROP TABLE IF EXISTS t3;
808 do_test savepoint-11.10 {
811 CREATE TABLE t1(a, b);
812 CREATE TABLE t2(x, y);
813 INSERT INTO t2 VALUES(1, 2);
815 INSERT INTO t2 VALUES(3, 4);
820 execsql {SELECT * FROM t2}
822 do_test savepoint-11.11 {
825 do_test savepoint-11.12 {
826 execsql {SELECT * FROM t2}
828 wal_check_journal_mode savepoint-11.13
830 #-------------------------------------------------------------------------
831 # The following tests - savepoint-12.* - test the interaction of
832 # savepoints and "ON CONFLICT ROLLBACK" clauses.
834 do_test savepoint-12.1 {
836 CREATE TABLE t4(a PRIMARY KEY, b);
837 INSERT INTO t4 VALUES(1, 'one');
840 do_test savepoint-12.2 {
841 # The final statement of the following SQL hits a constraint when the
842 # conflict handling mode is "OR ROLLBACK" and there are a couple of
843 # open savepoints. At one point this would fail to clear the internal
844 # record of the open savepoints, resulting in an assert() failure
849 INSERT INTO t4 VALUES(2, 'two');
851 INSERT INTO t4 VALUES(3, 'three');
853 INSERT OR ROLLBACK INTO t4 VALUES(1, 'one');
855 } {1 {column a is not unique}}
856 do_test savepoint-12.3 {
857 sqlite3_get_autocommit db
859 do_test savepoint-12.4 {
860 execsql { SAVEPOINT one }
862 wal_check_journal_mode savepoint-12.5
864 #-------------------------------------------------------------------------
865 # The following tests - savepoint-13.* - test the interaction of
866 # savepoints and "journal_mode = off".
868 if {[wal_is_wal_mode]==0} {
869 do_test savepoint-13.1 {
871 catch {file delete -force test.db}
875 CREATE TABLE t1(a PRIMARY KEY, b);
876 INSERT INTO t1 VALUES(1, 2);
878 PRAGMA journal_mode = off;
881 do_test savepoint-13.2 {
884 INSERT INTO t1 VALUES(3, 4);
885 INSERT INTO t1 SELECT a+4,b+4 FROM t1;
889 do_test savepoint-13.3 {
892 INSERT INTO t1 VALUES(9, 10);
894 INSERT INTO t1 VALUES(11, 12);
898 do_test savepoint-13.4 {
901 INSERT INTO t1 VALUES(13, 14);
903 INSERT INTO t1 VALUES(15, 16);
908 } {1 2 3 4 5 6 7 8 9 10 11 12}
913 do_multiclient_test tn {
914 do_test savepoint-14.$tn.1 {
917 INSERT INTO foo VALUES(1);
918 INSERT INTO foo VALUES(2);
925 do_test savepoint-14.$tn.2 {
928 INSERT INTO foo VALUES(1);
930 csql1 { RELEASE one }
931 } {1 {database is locked}}
932 do_test savepoint-14.$tn.3 {
933 sql1 { ROLLBACK TO one }
938 do_test savepoint-14.$tn.4 {
944 do_test savepoint-14.$tn.5 {
947 INSERT INTO foo VALUES(1);
949 csql1 { RELEASE one }
950 } {1 {database is locked}}
951 do_test savepoint-14.$tn.6 {
955 INSERT INTO foo VALUES(3);
956 INSERT INTO foo VALUES(4);
957 INSERT INTO foo VALUES(5);
961 do_test savepoint-14.$tn.7 {
962 sql2 { CREATE INDEX fooidx ON foo(x); }
963 sql3 { PRAGMA integrity_check }
967 do_multiclient_test tn {
968 do_test savepoint-15.$tn.1 {
971 INSERT INTO foo VALUES(1);
972 INSERT INTO foo VALUES(2);
974 sql2 { BEGIN; SELECT * FROM foo; }
976 do_test savepoint-15.$tn.2 {
978 PRAGMA locking_mode = EXCLUSIVE;
980 INSERT INTO foo VALUES(3);
983 } {1 {database is locked}}
984 do_test savepoint-15.$tn.3 {
988 INSERT INTO foo VALUES(3);
989 PRAGMA locking_mode = NORMAL;
990 INSERT INTO foo VALUES(4);
992 sql2 { CREATE INDEX fooidx ON foo(x); }
993 sql3 { PRAGMA integrity_check }
997 do_multiclient_test tn {
998 do_test savepoint-16.$tn.1 {
1000 CREATE TABLE foo(x);
1001 INSERT INTO foo VALUES(1);
1002 INSERT INTO foo VALUES(2);
1005 do_test savepoint-16.$tn.2 {
1007 db eval {SELECT * FROM foo} {
1008 sql1 { INSERT INTO foo VALUES(3) }
1009 sql2 { SELECT * FROM foo }
1010 sql1 { INSERT INTO foo VALUES(4) }
1014 sql2 { CREATE INDEX fooidx ON foo(x); }
1015 sql3 { PRAGMA integrity_check }
1017 do_test savepoint-16.$tn.3 {
1018 sql1 { SELECT * FROM foo }
1022 #-------------------------------------------------------------------------
1023 # This next block of tests verifies that a problem reported on the mailing
1024 # list has been resolved. At one point the second "CREATE TABLE t6" would
1025 # fail as table t6 still existed in the internal cache of the db schema
1026 # (even though it had been removed from the database by the ROLLBACK
1030 do_execsql_test savepoint-17.1 {
1032 CREATE TABLE t6(a, b);
1033 INSERT INTO t6 VALUES(1, 2);
1035 INSERT INTO t6 VALUES(3, 4);
1041 do_execsql_test savepoint-17.2 {
1042 CREATE TABLE t6(a, b);