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 # UPDATE 2017-07-26: It is not possible to ATTACH and DETACH within a
622 do_test savepoint-10.1.1 {
625 ATTACH 'test2.db' AS aux;
629 do_test savepoint-10.1.2 {
632 ATTACH 'test2.db' AS aux;
637 ATTACH 'test2.db' AS aux;
640 do_test savepoint-10.1.3 {
647 # The lock state of the TEMP database can vary if SQLITE_TEMP_STORE=3
648 # And the following set of tests is only really interested in the status
649 # of the aux1 and aux2 locks. So record the current lock status of
650 # TEMP for use in the answers.
651 set templockstate [lindex [db eval {PRAGMA lock_status}] 3]
654 if {[wal_is_wal_mode]==0} {
655 do_test savepoint-10.2.1 {
659 ATTACH 'test2.db' AS aux1;
660 ATTACH 'test3.db' AS aux2;
662 CREATE TABLE main.t1(x, y);
663 CREATE TABLE aux1.t2(x, y);
664 CREATE TABLE aux2.t3(x, y);
665 SELECT name FROM sqlite_master;
666 SELECT name FROM aux1.sqlite_master;
667 SELECT name FROM aux2.sqlite_master;
670 do_test savepoint-10.2.2 {
671 execsql { PRAGMA lock_status }
672 } [list main unlocked temp $templockstate aux1 unlocked aux2 unlocked]
674 do_test savepoint-10.2.3 {
677 INSERT INTO t1 VALUES(1, 2);
680 } [list main reserved temp $templockstate aux1 unlocked aux2 unlocked]
681 do_test savepoint-10.2.4 {
683 INSERT INTO t3 VALUES(3, 4);
686 } [list main reserved temp $templockstate aux1 unlocked aux2 reserved]
687 do_test savepoint-10.2.5 {
690 INSERT INTO t2 VALUES(5, 6);
693 } [list main reserved temp $templockstate aux1 reserved aux2 reserved]
694 do_test savepoint-10.2.6 {
695 execsql { SELECT * FROM t2 }
697 do_test savepoint-10.2.7 {
698 execsql { ROLLBACK TO two }
699 execsql { SELECT * FROM t2 }
701 do_test savepoint-10.2.8 {
702 execsql { PRAGMA lock_status }
703 } [list main reserved temp $templockstate aux1 reserved aux2 reserved]
704 do_test savepoint-10.2.9 {
705 execsql { SELECT 'a', * FROM t1 ; SELECT 'b', * FROM t3 }
707 do_test savepoint-10.2.9 {
709 INSERT INTO t2 VALUES(5, 6);
718 do_test savepoint-10.2.9 {
719 execsql { PRAGMA lock_status }
720 } [list main unlocked temp $templockstate aux1 unlocked aux2 unlocked]
722 do_test savepoint-10.2.10 {
725 INSERT INTO t1 VALUES('a', 'b');
727 INSERT INTO t2 VALUES('c', 'd');
729 INSERT INTO t3 VALUES('e', 'f');
736 } {1 2 a b 5 6 c d 3 4 e f}
737 do_test savepoint-10.2.11 {
738 execsql { ROLLBACK TO two }
745 do_test savepoint-10.2.12 {
747 INSERT INTO t3 VALUES('g', 'h');
756 do_test savepoint-10.2.13 {
764 do_test savepoint-10.2.14 {
765 execsql { PRAGMA lock_status }
766 } [list main unlocked temp $templockstate aux1 unlocked aux2 unlocked]
769 #-------------------------------------------------------------------------
770 # The following tests - savepoint-11.* - test the interaction of
771 # savepoints and creating or dropping tables and indexes in
774 do_test savepoint-11.1 {
778 execsql { PRAGMA auto_vacuum = full; }
781 CREATE TABLE t1(a, b, UNIQUE(a, b));
782 INSERT INTO t1 VALUES(1, randstr(1000,1000));
783 INSERT INTO t1 VALUES(2, randstr(1000,1000));
786 do_test savepoint-11.2 {
789 CREATE TABLE t2(a, b, UNIQUE(a, b));
791 CREATE TABLE t3(a, b, UNIQUE(a, b));
794 integrity_check savepoint-11.3
795 do_test savepoint-11.4 {
796 execsql { ROLLBACK TO two }
798 integrity_check savepoint-11.5
799 do_test savepoint-11.6 {
801 CREATE TABLE t3(a, b, UNIQUE(a, b));
805 integrity_check savepoint-11.7
806 do_test savepoint-11.8 {
808 execsql { PRAGMA wal_checkpoint }
812 do_test savepoint-11.9 {
814 DROP TABLE IF EXISTS t1;
815 DROP TABLE IF EXISTS t2;
816 DROP TABLE IF EXISTS t3;
819 do_test savepoint-11.10 {
822 CREATE TABLE t1(a, b);
823 CREATE TABLE t2(x, y);
824 INSERT INTO t2 VALUES(1, 2);
826 INSERT INTO t2 VALUES(3, 4);
831 execsql {SELECT * FROM t2}
833 do_test savepoint-11.11 {
836 do_test savepoint-11.12 {
837 execsql {SELECT * FROM t2}
839 wal_check_journal_mode savepoint-11.13
841 #-------------------------------------------------------------------------
842 # The following tests - savepoint-12.* - test the interaction of
843 # savepoints and "ON CONFLICT ROLLBACK" clauses.
845 do_test savepoint-12.1 {
847 CREATE TABLE t4(a PRIMARY KEY, b);
848 INSERT INTO t4 VALUES(1, 'one');
851 do_test savepoint-12.2 {
852 # The final statement of the following SQL hits a constraint when the
853 # conflict handling mode is "OR ROLLBACK" and there are a couple of
854 # open savepoints. At one point this would fail to clear the internal
855 # record of the open savepoints, resulting in an assert() failure
860 INSERT INTO t4 VALUES(2, 'two');
862 INSERT INTO t4 VALUES(3, 'three');
864 INSERT OR ROLLBACK INTO t4 VALUES(1, 'one');
866 } {1 {UNIQUE constraint failed: t4.a}}
867 do_test savepoint-12.3 {
868 sqlite3_get_autocommit db
870 do_test savepoint-12.4 {
871 execsql { SAVEPOINT one }
873 wal_check_journal_mode savepoint-12.5
875 #-------------------------------------------------------------------------
876 # The following tests - savepoint-13.* - test the interaction of
877 # savepoints and "journal_mode = off".
879 if {[wal_is_wal_mode]==0} {
880 do_test savepoint-13.1 {
882 catch {forcedelete test.db}
886 CREATE TABLE t1(a PRIMARY KEY, b);
887 INSERT INTO t1 VALUES(1, 2);
889 PRAGMA journal_mode = off;
892 do_test savepoint-13.2 {
895 INSERT INTO t1 VALUES(3, 4);
896 INSERT INTO t1 SELECT a+4,b+4 FROM t1;
900 do_test savepoint-13.3 {
903 INSERT INTO t1 VALUES(9, 10);
905 INSERT INTO t1 VALUES(11, 12);
909 do_test savepoint-13.4 {
912 INSERT INTO t1 VALUES(13, 14);
914 INSERT INTO t1 VALUES(15, 16);
919 } {1 2 3 4 5 6 7 8 9 10 11 12}
924 do_multiclient_test tn {
925 do_test savepoint-14.$tn.1 {
928 INSERT INTO foo VALUES(1);
929 INSERT INTO foo VALUES(2);
936 do_test savepoint-14.$tn.2 {
939 INSERT INTO foo VALUES(1);
941 csql1 { RELEASE one }
942 } {1 {database is locked}}
943 do_test savepoint-14.$tn.3 {
944 sql1 { ROLLBACK TO one }
949 do_test savepoint-14.$tn.4 {
955 do_test savepoint-14.$tn.5 {
958 INSERT INTO foo VALUES(1);
960 csql1 { RELEASE one }
961 } {1 {database is locked}}
962 do_test savepoint-14.$tn.6 {
966 INSERT INTO foo VALUES(3);
967 INSERT INTO foo VALUES(4);
968 INSERT INTO foo VALUES(5);
972 do_test savepoint-14.$tn.7 {
973 sql2 { CREATE INDEX fooidx ON foo(x); }
974 sql3 { PRAGMA integrity_check }
978 do_multiclient_test tn {
979 do_test savepoint-15.$tn.1 {
982 INSERT INTO foo VALUES(1);
983 INSERT INTO foo VALUES(2);
985 sql2 { BEGIN; SELECT * FROM foo; }
987 do_test savepoint-15.$tn.2 {
989 PRAGMA locking_mode = EXCLUSIVE;
991 INSERT INTO foo VALUES(3);
994 } {1 {database is locked}}
995 do_test savepoint-15.$tn.3 {
999 INSERT INTO foo VALUES(3);
1000 PRAGMA locking_mode = NORMAL;
1001 INSERT INTO foo VALUES(4);
1003 sql2 { CREATE INDEX fooidx ON foo(x); }
1004 sql3 { PRAGMA integrity_check }
1008 do_multiclient_test tn {
1009 do_test savepoint-16.$tn.1 {
1011 CREATE TABLE foo(x);
1012 INSERT INTO foo VALUES(1);
1013 INSERT INTO foo VALUES(2);
1016 do_test savepoint-16.$tn.2 {
1018 db eval {SELECT * FROM foo} {
1019 sql1 { INSERT INTO foo VALUES(3) }
1020 sql2 { SELECT * FROM foo }
1021 sql1 { INSERT INTO foo VALUES(4) }
1025 sql2 { CREATE INDEX fooidx ON foo(x); }
1026 sql3 { PRAGMA integrity_check }
1028 do_test savepoint-16.$tn.3 {
1029 sql1 { SELECT * FROM foo }
1033 #-------------------------------------------------------------------------
1034 # This next block of tests verifies that a problem reported on the mailing
1035 # list has been resolved. At one point the second "CREATE TABLE t6" would
1036 # fail as table t6 still existed in the internal cache of the db schema
1037 # (even though it had been removed from the database by the ROLLBACK
1041 do_execsql_test savepoint-17.1 {
1043 CREATE TABLE t6(a, b);
1044 INSERT INTO t6 VALUES(1, 2);
1046 INSERT INTO t6 VALUES(3, 4);
1052 do_execsql_test savepoint-17.2 {
1053 CREATE TABLE t6(a, b);