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.1 {
307 execsql {SAVEPOINT def}
308 set fd [db incrblob -readonly blobs x 1]
309 set rc [catch {seek $fd 0;read $fd} res]
311 } {0 {hellontyeight character blob}}
312 do_test savepoint-5.3.2.2 {
313 catchsql {ROLLBACK TO def}
315 do_test savepoint-5.3.2.3 {
316 set rc [catch {seek $fd 0; read $fd} res]
319 do_test savepoint-5.3.3 {
320 catchsql {RELEASE def}
322 do_test savepoint-5.3.4 {
324 execsql {savepoint def}
325 set fd [db incrblob blobs x 1]
326 catchsql {release def}
327 } {1 {cannot release savepoint - SQL statements in progress}}
328 do_test savepoint-5.3.5 {
330 execsql {release abc}
335 # Open a savepoint transaction and insert a row into the database. Then,
336 # using a second database handle, open a read-only transaction on the
337 # database file. Check that the savepoint transaction cannot be committed
338 # until after the read-only transaction has been closed.
342 # As above, except that the savepoint transaction can be successfully
343 # committed before the read-only transaction has been closed.
345 do_test savepoint-5.4.1 {
348 INSERT INTO blobs VALUES('another blob');
351 do_test savepoint-5.4.2 {
353 execsql { BEGIN ; SELECT count(*) FROM blobs } db2
355 if {[wal_is_wal_mode]} {
356 do_test savepoint-5.4.3 { catchsql "RELEASE main" } {0 {}}
357 do_test savepoint-5.4.4 { db2 close } {}
359 do_test savepoint-5.4.3 {
360 catchsql { RELEASE main }
361 } {1 {database is locked}}
362 do_test savepoint-5.4.4 {
364 catchsql { RELEASE main }
367 do_test savepoint-5.4.5 {
368 execsql { SELECT x FROM blobs WHERE rowid = 2 }
370 do_test savepoint-5.4.6 {
371 execsql { SELECT count(*) FROM blobs }
374 wal_check_journal_mode savepoint-5.5
376 #-------------------------------------------------------------------------
377 # The following tests, savepoint-6.*, test an incr-vacuum inside of a
378 # couple of nested savepoints.
380 ifcapable {autovacuum && pragma} {
385 do_test savepoint-6.1 {
386 execsql { PRAGMA auto_vacuum = incremental }
389 CREATE TABLE t1(a, b, c);
390 CREATE INDEX i1 ON t1(a, b);
392 INSERT INTO t1 VALUES(randstr(10,400),randstr(10,400),randstr(10,400));
394 set r "randstr(10,400)"
395 for {set ii 0} {$ii < 10} {incr ii} {
396 execsql "INSERT INTO t1 SELECT $r, $r, $r FROM t1"
401 integrity_check savepoint-6.2
403 do_test savepoint-6.3 {
405 PRAGMA cache_size = 10;
407 UPDATE t1 SET a = randstr(10,10) WHERE (rowid%4)==0;
409 DELETE FROM t1 WHERE rowid%2;
412 INSERT INTO t1 SELECT randstr(10,400), randstr(10,400), c FROM t1;
413 DELETE FROM t1 WHERE rowid%2;
420 integrity_check savepoint-6.4
422 wal_check_journal_mode savepoint-6.5
425 #-------------------------------------------------------------------------
426 # The following tests, savepoint-7.*, attempt to break the logic
427 # surrounding savepoints by growing and shrinking the database file.
433 do_test savepoint-7.1 {
434 execsql { PRAGMA auto_vacuum = incremental }
437 PRAGMA cache_size = 10;
439 CREATE TABLE t1(a PRIMARY KEY, b);
440 INSERT INTO t1(a) VALUES('alligator');
441 INSERT INTO t1(a) VALUES('angelfish');
442 INSERT INTO t1(a) VALUES('ant');
443 INSERT INTO t1(a) VALUES('antelope');
444 INSERT INTO t1(a) VALUES('ape');
445 INSERT INTO t1(a) VALUES('baboon');
446 INSERT INTO t1(a) VALUES('badger');
447 INSERT INTO t1(a) VALUES('bear');
448 INSERT INTO t1(a) VALUES('beetle');
449 INSERT INTO t1(a) VALUES('bird');
450 INSERT INTO t1(a) VALUES('bison');
451 UPDATE t1 SET b = randstr(1000,1000);
452 UPDATE t1 SET b = b||randstr(1000,1000);
453 UPDATE t1 SET b = b||randstr(1000,1000);
454 UPDATE t1 SET b = b||randstr(10,1000);
457 expr ([execsql { PRAGMA page_count }] > 20)
459 do_test savepoint-7.2.1 {
463 CREATE TABLE t2(a, b);
464 INSERT INTO t2 SELECT a, b FROM t1;
468 PRAGMA integrity_check;
471 do_test savepoint-7.2.2 {
474 PRAGMA integrity_check;
478 do_test savepoint-7.3.1 {
480 CREATE TABLE t2(a, b);
481 INSERT INTO t2 SELECT a, b FROM t1;
484 do_test savepoint-7.3.2 {
489 PRAGMA incremental_vacuum;
491 INSERT INTO t2 SELECT a, b FROM t1;
495 execsql { PRAGMA integrity_check }
497 wal_check_journal_mode savepoint-7.3.3
499 do_test savepoint-7.4.1 {
503 execsql { PRAGMA auto_vacuum = incremental }
506 CREATE TABLE t1(a, b, PRIMARY KEY(a, b));
507 INSERT INTO t1 VALUES(randstr(1000,1000), randstr(1000,1000));
511 PRAGMA incremental_vacuum;
516 execsql { PRAGMA integrity_check }
519 do_test savepoint-7.5.1 {
521 PRAGMA incremental_vacuum;
522 CREATE TABLE t5(x, y);
523 INSERT INTO t5 VALUES(1, randstr(1000,1000));
524 INSERT INTO t5 VALUES(2, randstr(1000,1000));
525 INSERT INTO t5 VALUES(3, randstr(1000,1000));
528 INSERT INTO t5 VALUES(4, randstr(1000,1000));
529 INSERT INTO t5 VALUES(5, randstr(1000,1000));
530 DELETE FROM t5 WHERE x=1 OR x=2;
532 PRAGMA incremental_vacuum;
534 INSERT INTO t5 VALUES(1, randstr(1000,1000));
535 INSERT INTO t5 VALUES(2, randstr(1000,1000));
539 PRAGMA integrity_check;
542 do_test savepoint-7.5.2 {
547 wal_check_journal_mode savepoint-7.5.3
549 # Test oddly named and quoted savepoints.
551 do_test savepoint-8-1 {
552 execsql { SAVEPOINT "save1" }
553 execsql { RELEASE save1 }
555 do_test savepoint-8-2 {
556 execsql { SAVEPOINT "Including whitespace " }
557 execsql { RELEASE "including Whitespace " }
560 # Test that the authorization callback works.
564 eval lappend ::authdata [lrange $args 0 4]
569 do_test savepoint-9.1 {
570 set ::authdata [list]
571 execsql { SAVEPOINT sp1 }
573 } {SQLITE_SAVEPOINT BEGIN sp1 {} {}}
574 do_test savepoint-9.2 {
575 set ::authdata [list]
576 execsql { ROLLBACK TO sp1 }
578 } {SQLITE_SAVEPOINT ROLLBACK sp1 {} {}}
579 do_test savepoint-9.3 {
580 set ::authdata [list]
581 execsql { RELEASE sp1 }
583 } {SQLITE_SAVEPOINT RELEASE sp1 {} {}}
586 eval lappend ::authdata [lrange $args 0 4]
591 do_test savepoint-9.4 {
592 set ::authdata [list]
593 set res [catchsql { SAVEPOINT sp1 }]
594 concat $::authdata $res
595 } {SQLITE_SAVEPOINT BEGIN sp1 {} {} 1 {not authorized}}
596 do_test savepoint-9.5 {
597 set ::authdata [list]
598 set res [catchsql { ROLLBACK TO sp1 }]
599 concat $::authdata $res
600 } {SQLITE_SAVEPOINT ROLLBACK sp1 {} {} 1 {not authorized}}
601 do_test savepoint-9.6 {
602 set ::authdata [list]
603 set res [catchsql { RELEASE sp1 }]
604 concat $::authdata $res
605 } {SQLITE_SAVEPOINT RELEASE sp1 {} {} 1 {not authorized}}
607 catch { db eval ROLLBACK }
611 #-------------------------------------------------------------------------
612 # The following tests - savepoint-10.* - test the interaction of
613 # savepoints and ATTACH statements.
616 # First make sure it is not possible to attach or detach a database while
617 # a savepoint is open (it is not possible if any transaction is open).
619 do_test savepoint-10.1.1 {
622 ATTACH 'test2.db' AS aux;
624 } {1 {cannot ATTACH database within transaction}}
625 do_test savepoint-10.1.2 {
628 ATTACH 'test2.db' AS aux;
634 } {1 {cannot DETACH database within transaction}}
635 do_test savepoint-10.1.3 {
642 # The lock state of the TEMP database can vary if SQLITE_TEMP_STORE=3
643 # And the following set of tests is only really interested in the status
644 # of the aux1 and aux2 locks. So record the current lock status of
645 # TEMP for use in the answers.
646 set templockstate [lindex [db eval {PRAGMA lock_status}] 3]
649 if {[wal_is_wal_mode]==0} {
650 do_test savepoint-10.2.1 {
654 ATTACH 'test2.db' AS aux1;
655 ATTACH 'test3.db' AS aux2;
657 CREATE TABLE main.t1(x, y);
658 CREATE TABLE aux1.t2(x, y);
659 CREATE TABLE aux2.t3(x, y);
660 SELECT name FROM sqlite_master;
661 SELECT name FROM aux1.sqlite_master;
662 SELECT name FROM aux2.sqlite_master;
665 do_test savepoint-10.2.2 {
666 execsql { PRAGMA lock_status }
667 } [list main unlocked temp $templockstate aux1 unlocked aux2 unlocked]
669 do_test savepoint-10.2.3 {
672 INSERT INTO t1 VALUES(1, 2);
675 } [list main reserved temp $templockstate aux1 unlocked aux2 unlocked]
676 do_test savepoint-10.2.4 {
678 INSERT INTO t3 VALUES(3, 4);
681 } [list main reserved temp $templockstate aux1 unlocked aux2 reserved]
682 do_test savepoint-10.2.5 {
685 INSERT INTO t2 VALUES(5, 6);
688 } [list main reserved temp $templockstate aux1 reserved aux2 reserved]
689 do_test savepoint-10.2.6 {
690 execsql { SELECT * FROM t2 }
692 do_test savepoint-10.2.7 {
693 execsql { ROLLBACK TO two }
694 execsql { SELECT * FROM t2 }
696 do_test savepoint-10.2.8 {
697 execsql { PRAGMA lock_status }
698 } [list main reserved temp $templockstate aux1 reserved aux2 reserved]
699 do_test savepoint-10.2.9 {
700 execsql { SELECT 'a', * FROM t1 ; SELECT 'b', * FROM t3 }
702 do_test savepoint-10.2.9 {
704 INSERT INTO t2 VALUES(5, 6);
713 do_test savepoint-10.2.9 {
714 execsql { PRAGMA lock_status }
715 } [list main unlocked temp $templockstate aux1 unlocked aux2 unlocked]
717 do_test savepoint-10.2.10 {
720 INSERT INTO t1 VALUES('a', 'b');
722 INSERT INTO t2 VALUES('c', 'd');
724 INSERT INTO t3 VALUES('e', 'f');
731 } {1 2 a b 5 6 c d 3 4 e f}
732 do_test savepoint-10.2.11 {
733 execsql { ROLLBACK TO two }
740 do_test savepoint-10.2.12 {
742 INSERT INTO t3 VALUES('g', 'h');
751 do_test savepoint-10.2.13 {
759 do_test savepoint-10.2.14 {
760 execsql { PRAGMA lock_status }
761 } [list main unlocked temp $templockstate aux1 unlocked aux2 unlocked]
764 #-------------------------------------------------------------------------
765 # The following tests - savepoint-11.* - test the interaction of
766 # savepoints and creating or dropping tables and indexes in
769 do_test savepoint-11.1 {
773 execsql { PRAGMA auto_vacuum = full; }
776 CREATE TABLE t1(a, b, UNIQUE(a, b));
777 INSERT INTO t1 VALUES(1, randstr(1000,1000));
778 INSERT INTO t1 VALUES(2, randstr(1000,1000));
781 do_test savepoint-11.2 {
784 CREATE TABLE t2(a, b, UNIQUE(a, b));
786 CREATE TABLE t3(a, b, UNIQUE(a, b));
789 integrity_check savepoint-11.3
790 do_test savepoint-11.4 {
791 execsql { ROLLBACK TO two }
793 integrity_check savepoint-11.5
794 do_test savepoint-11.6 {
796 CREATE TABLE t3(a, b, UNIQUE(a, b));
800 integrity_check savepoint-11.7
801 do_test savepoint-11.8 {
803 execsql { PRAGMA wal_checkpoint }
807 do_test savepoint-11.9 {
809 DROP TABLE IF EXISTS t1;
810 DROP TABLE IF EXISTS t2;
811 DROP TABLE IF EXISTS t3;
814 do_test savepoint-11.10 {
817 CREATE TABLE t1(a, b);
818 CREATE TABLE t2(x, y);
819 INSERT INTO t2 VALUES(1, 2);
821 INSERT INTO t2 VALUES(3, 4);
826 execsql {SELECT * FROM t2}
828 do_test savepoint-11.11 {
831 do_test savepoint-11.12 {
832 execsql {SELECT * FROM t2}
834 wal_check_journal_mode savepoint-11.13
836 #-------------------------------------------------------------------------
837 # The following tests - savepoint-12.* - test the interaction of
838 # savepoints and "ON CONFLICT ROLLBACK" clauses.
840 do_test savepoint-12.1 {
842 CREATE TABLE t4(a PRIMARY KEY, b);
843 INSERT INTO t4 VALUES(1, 'one');
846 do_test savepoint-12.2 {
847 # The final statement of the following SQL hits a constraint when the
848 # conflict handling mode is "OR ROLLBACK" and there are a couple of
849 # open savepoints. At one point this would fail to clear the internal
850 # record of the open savepoints, resulting in an assert() failure
855 INSERT INTO t4 VALUES(2, 'two');
857 INSERT INTO t4 VALUES(3, 'three');
859 INSERT OR ROLLBACK INTO t4 VALUES(1, 'one');
861 } {1 {UNIQUE constraint failed: t4.a}}
862 do_test savepoint-12.3 {
863 sqlite3_get_autocommit db
865 do_test savepoint-12.4 {
866 execsql { SAVEPOINT one }
868 wal_check_journal_mode savepoint-12.5
870 #-------------------------------------------------------------------------
871 # The following tests - savepoint-13.* - test the interaction of
872 # savepoints and "journal_mode = off".
874 if {[wal_is_wal_mode]==0} {
875 do_test savepoint-13.1 {
877 catch {forcedelete test.db}
881 CREATE TABLE t1(a PRIMARY KEY, b);
882 INSERT INTO t1 VALUES(1, 2);
884 PRAGMA journal_mode = off;
887 do_test savepoint-13.2 {
890 INSERT INTO t1 VALUES(3, 4);
891 INSERT INTO t1 SELECT a+4,b+4 FROM t1;
895 do_test savepoint-13.3 {
898 INSERT INTO t1 VALUES(9, 10);
900 INSERT INTO t1 VALUES(11, 12);
904 do_test savepoint-13.4 {
907 INSERT INTO t1 VALUES(13, 14);
909 INSERT INTO t1 VALUES(15, 16);
914 } {1 2 3 4 5 6 7 8 9 10 11 12}
919 do_multiclient_test tn {
920 do_test savepoint-14.$tn.1 {
923 INSERT INTO foo VALUES(1);
924 INSERT INTO foo VALUES(2);
931 do_test savepoint-14.$tn.2 {
934 INSERT INTO foo VALUES(1);
936 csql1 { RELEASE one }
937 } {1 {database is locked}}
938 do_test savepoint-14.$tn.3 {
939 sql1 { ROLLBACK TO one }
944 do_test savepoint-14.$tn.4 {
950 do_test savepoint-14.$tn.5 {
953 INSERT INTO foo VALUES(1);
955 csql1 { RELEASE one }
956 } {1 {database is locked}}
957 do_test savepoint-14.$tn.6 {
961 INSERT INTO foo VALUES(3);
962 INSERT INTO foo VALUES(4);
963 INSERT INTO foo VALUES(5);
967 do_test savepoint-14.$tn.7 {
968 sql2 { CREATE INDEX fooidx ON foo(x); }
969 sql3 { PRAGMA integrity_check }
973 do_multiclient_test tn {
974 do_test savepoint-15.$tn.1 {
977 INSERT INTO foo VALUES(1);
978 INSERT INTO foo VALUES(2);
980 sql2 { BEGIN; SELECT * FROM foo; }
982 do_test savepoint-15.$tn.2 {
984 PRAGMA locking_mode = EXCLUSIVE;
986 INSERT INTO foo VALUES(3);
989 } {1 {database is locked}}
990 do_test savepoint-15.$tn.3 {
994 INSERT INTO foo VALUES(3);
995 PRAGMA locking_mode = NORMAL;
996 INSERT INTO foo VALUES(4);
998 sql2 { CREATE INDEX fooidx ON foo(x); }
999 sql3 { PRAGMA integrity_check }
1003 do_multiclient_test tn {
1004 do_test savepoint-16.$tn.1 {
1006 CREATE TABLE foo(x);
1007 INSERT INTO foo VALUES(1);
1008 INSERT INTO foo VALUES(2);
1011 do_test savepoint-16.$tn.2 {
1013 db eval {SELECT * FROM foo} {
1014 sql1 { INSERT INTO foo VALUES(3) }
1015 sql2 { SELECT * FROM foo }
1016 sql1 { INSERT INTO foo VALUES(4) }
1020 sql2 { CREATE INDEX fooidx ON foo(x); }
1021 sql3 { PRAGMA integrity_check }
1023 do_test savepoint-16.$tn.3 {
1024 sql1 { SELECT * FROM foo }
1028 #-------------------------------------------------------------------------
1029 # This next block of tests verifies that a problem reported on the mailing
1030 # list has been resolved. At one point the second "CREATE TABLE t6" would
1031 # fail as table t6 still existed in the internal cache of the db schema
1032 # (even though it had been removed from the database by the ROLLBACK
1036 do_execsql_test savepoint-17.1 {
1038 CREATE TABLE t6(a, b);
1039 INSERT INTO t6 VALUES(1, 2);
1041 INSERT INTO t6 VALUES(3, 4);
1047 do_execsql_test savepoint-17.2 {
1048 CREATE TABLE t6(a, b);