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
21 #----------------------------------------------------------------------
22 # The following tests - savepoint-1.* - test that the SAVEPOINT, RELEASE
23 # and ROLLBACK TO comands are correctly parsed, and that the auto-commit
24 # flag is correctly set and unset as a result.
26 do_test savepoint-1.1 {
33 do_test savepoint-1.2 {
39 do_test savepoint-1.3 {
40 execsql { SAVEPOINT sp1 }
44 do_test savepoint-1.4.1 {
50 sqlite3_get_autocommit db
52 do_test savepoint-1.4.2 {
58 sqlite3_get_autocommit db
60 do_test savepoint-1.4.3 {
61 execsql { RELEASE sp1 }
62 sqlite3_get_autocommit db
64 do_test savepoint-1.4.4 {
70 sqlite3_get_autocommit db
72 do_test savepoint-1.4.5 {
73 execsql { RELEASE SAVEPOINT sp1 }
74 sqlite3_get_autocommit db
76 do_test savepoint-1.4.6 {
81 ROLLBACK TO SAVEPOINT sp3;
82 ROLLBACK TRANSACTION TO sp2;
83 ROLLBACK TRANSACTION TO SAVEPOINT sp1;
85 sqlite3_get_autocommit db
87 do_test savepoint-1.4.7 {
88 execsql { RELEASE SAVEPOINT SP1 }
89 sqlite3_get_autocommit db
91 do_test savepoint-1.5 {
97 do_test savepoint-1.6 {
100 wal_check_journal_mode savepoint-1.7
102 #------------------------------------------------------------------------
103 # These tests - savepoint-2.* - test rollbacks and releases of savepoints
104 # with a very simple data set.
107 do_test savepoint-2.1 {
109 CREATE TABLE t1(a, b, c);
111 INSERT INTO t1 VALUES(1, 2, 3);
113 UPDATE t1 SET a = 2, b = 3, c = 4;
115 execsql { SELECT * FROM t1 }
117 do_test savepoint-2.2 {
121 execsql { SELECT * FROM t1 }
123 do_test savepoint-2.3 {
125 INSERT INTO t1 VALUES(4, 5, 6);
127 execsql { SELECT * FROM t1 }
129 do_test savepoint-2.4 {
133 execsql { SELECT * FROM t1 }
137 do_test savepoint-2.5 {
139 INSERT INTO t1 VALUES(7, 8, 9);
141 INSERT INTO t1 VALUES(10, 11, 12);
143 execsql { SELECT * FROM t1 }
144 } {1 2 3 7 8 9 10 11 12}
145 do_test savepoint-2.6 {
149 execsql { SELECT * FROM t1 }
151 do_test savepoint-2.7 {
153 INSERT INTO t1 VALUES(10, 11, 12);
155 execsql { SELECT * FROM t1 }
156 } {1 2 3 7 8 9 10 11 12}
157 do_test savepoint-2.8 {
161 execsql { SELECT * FROM t1 }
163 do_test savepoint-2.9 {
165 INSERT INTO t1 VALUES('a', 'b', 'c');
167 INSERT INTO t1 VALUES('d', 'e', 'f');
169 execsql { SELECT * FROM t1 }
170 } {1 2 3 a b c d e f}
171 do_test savepoint-2.10 {
175 execsql { SELECT * FROM t1 }
176 } {1 2 3 a b c d e f}
177 do_test savepoint-2.11 {
181 execsql { SELECT * FROM t1 }
183 wal_check_journal_mode savepoint-2.12
185 #------------------------------------------------------------------------
186 # This block of tests - savepoint-3.* - test that when a transaction
187 # savepoint is rolled back, locks are not released from database files.
188 # And that when a transaction savepoint is released, they are released.
190 # These tests do not work in WAL mode. WAL mode does not take RESERVED
191 # locks on the database file.
193 if {[wal_is_wal_mode]==0} {
194 do_test savepoint-3.1 {
195 execsql { SAVEPOINT "transaction" }
196 execsql { PRAGMA lock_status }
197 } {main unlocked temp closed}
199 do_test savepoint-3.2 {
200 execsql { INSERT INTO t1 VALUES(1, 2, 3) }
201 execsql { PRAGMA lock_status }
202 } {main reserved temp closed}
204 do_test savepoint-3.3 {
205 execsql { ROLLBACK TO "transaction" }
206 execsql { PRAGMA lock_status }
207 } {main reserved temp closed}
209 do_test savepoint-3.4 {
210 execsql { INSERT INTO t1 VALUES(1, 2, 3) }
211 execsql { PRAGMA lock_status }
212 } {main reserved temp closed}
214 do_test savepoint-3.5 {
215 execsql { RELEASE "transaction" }
216 execsql { PRAGMA lock_status }
217 } {main unlocked temp closed}
220 #------------------------------------------------------------------------
221 # Test that savepoints that include schema modifications are handled
222 # correctly. Test cases savepoint-4.*.
224 do_test savepoint-4.1 {
226 CREATE TABLE t2(d, e, f);
227 SELECT sql FROM sqlite_master;
229 } {{CREATE TABLE t1(a, b, c)} {CREATE TABLE t2(d, e, f)}}
230 do_test savepoint-4.2 {
233 CREATE TABLE t3(g,h);
234 INSERT INTO t3 VALUES('I', 'II');
239 do_test savepoint-4.3 {
241 CREATE TABLE t3(g, h, i);
242 INSERT INTO t3 VALUES('III', 'IV', 'V');
244 execsql {SELECT * FROM t3}
246 do_test savepoint-4.4 {
247 execsql { ROLLBACK TO one; }
248 execsql {SELECT * FROM t3}
250 do_test savepoint-4.5 {
253 SELECT sql FROM sqlite_master;
255 } {{CREATE TABLE t1(a, b, c)} {CREATE TABLE t2(d, e, f)}}
257 do_test savepoint-4.6 {
260 INSERT INTO t1 VALUES('o', 't', 't');
262 CREATE TABLE t3(a, b, c);
263 INSERT INTO t3 VALUES('z', 'y', 'x');
265 execsql {SELECT * FROM t3}
267 do_test savepoint-4.7 {
271 INSERT INTO t3 VALUES('value');
273 execsql {SELECT * FROM t3}
275 do_test savepoint-4.8 {
278 wal_check_journal_mode savepoint-4.9
280 #------------------------------------------------------------------------
281 # Test some logic errors to do with the savepoint feature.
285 do_test savepoint-5.1.1 {
287 CREATE TABLE blobs(x);
288 INSERT INTO blobs VALUES('a twentyeight character blob');
290 set fd [db incrblob blobs x 1]
291 puts -nonewline $fd "hello"
292 catchsql {SAVEPOINT abc}
293 } {1 {cannot open savepoint - SQL statements in progress}}
294 do_test savepoint-5.1.2 {
296 catchsql {SAVEPOINT abc}
299 do_test savepoint-5.2 {
300 execsql {RELEASE abc}
301 catchsql {RELEASE abc}
302 } {1 {no such savepoint: abc}}
304 do_test savepoint-5.3.1 {
305 execsql {SAVEPOINT abc}
306 catchsql {ROLLBACK TO def}
307 } {1 {no such savepoint: def}}
308 do_test savepoint-5.3.2.1 {
309 execsql {SAVEPOINT def}
310 set fd [db incrblob -readonly blobs x 1]
311 set rc [catch {seek $fd 0;read $fd} res]
313 } {0 {hellontyeight character blob}}
314 do_test savepoint-5.3.2.2 {
315 catchsql {ROLLBACK TO def}
317 do_test savepoint-5.3.2.3 {
318 set rc [catch {seek $fd 0; read $fd} res]
321 do_test savepoint-5.3.3 {
322 catchsql {RELEASE def}
324 do_test savepoint-5.3.4 {
326 execsql {savepoint def}
327 set fd [db incrblob blobs x 1]
328 catchsql {release def}
329 } {1 {cannot release savepoint - SQL statements in progress}}
330 do_test savepoint-5.3.5 {
332 execsql {release abc}
337 # Open a savepoint transaction and insert a row into the database. Then,
338 # using a second database handle, open a read-only transaction on the
339 # database file. Check that the savepoint transaction cannot be committed
340 # until after the read-only transaction has been closed.
344 # As above, except that the savepoint transaction can be successfully
345 # committed before the read-only transaction has been closed.
347 do_test savepoint-5.4.1 {
350 INSERT INTO blobs VALUES('another blob');
353 do_test savepoint-5.4.2 {
355 execsql { BEGIN ; SELECT count(*) FROM blobs } db2
357 if {[wal_is_wal_mode]} {
358 do_test savepoint-5.4.3 { catchsql "RELEASE main" } {0 {}}
359 do_test savepoint-5.4.4 { db2 close } {}
361 do_test savepoint-5.4.3 {
362 catchsql { RELEASE main }
363 } {1 {database is locked}}
364 do_test savepoint-5.4.4 {
366 catchsql { RELEASE main }
369 do_test savepoint-5.4.5 {
370 execsql { SELECT x FROM blobs WHERE rowid = 2 }
372 do_test savepoint-5.4.6 {
373 execsql { SELECT count(*) FROM blobs }
376 wal_check_journal_mode savepoint-5.5
378 #-------------------------------------------------------------------------
379 # The following tests, savepoint-6.*, test an incr-vacuum inside of a
380 # couple of nested savepoints.
382 ifcapable {autovacuum && pragma} {
387 do_test savepoint-6.1 {
388 execsql { PRAGMA auto_vacuum = incremental }
391 CREATE TABLE t1(a, b, c);
392 CREATE INDEX i1 ON t1(a, b);
394 INSERT INTO t1 VALUES(randstr(10,400),randstr(10,400),randstr(10,400));
396 set r "randstr(10,400)"
397 for {set ii 0} {$ii < 10} {incr ii} {
398 execsql "INSERT INTO t1 SELECT $r, $r, $r FROM t1"
403 integrity_check savepoint-6.2
405 do_test savepoint-6.3 {
407 PRAGMA cache_size = 10;
409 UPDATE t1 SET a = randstr(10,10) WHERE (rowid%4)==0;
411 DELETE FROM t1 WHERE rowid%2;
414 INSERT INTO t1 SELECT randstr(10,400), randstr(10,400), c FROM t1;
415 DELETE FROM t1 WHERE rowid%2;
422 integrity_check savepoint-6.4
424 wal_check_journal_mode savepoint-6.5
427 #-------------------------------------------------------------------------
428 # The following tests, savepoint-7.*, attempt to break the logic
429 # surrounding savepoints by growing and shrinking the database file.
435 do_test savepoint-7.1 {
436 execsql { PRAGMA auto_vacuum = incremental }
439 PRAGMA cache_size = 10;
441 CREATE TABLE t1(a PRIMARY KEY, b);
442 INSERT INTO t1(a) VALUES('alligator');
443 INSERT INTO t1(a) VALUES('angelfish');
444 INSERT INTO t1(a) VALUES('ant');
445 INSERT INTO t1(a) VALUES('antelope');
446 INSERT INTO t1(a) VALUES('ape');
447 INSERT INTO t1(a) VALUES('baboon');
448 INSERT INTO t1(a) VALUES('badger');
449 INSERT INTO t1(a) VALUES('bear');
450 INSERT INTO t1(a) VALUES('beetle');
451 INSERT INTO t1(a) VALUES('bird');
452 INSERT INTO t1(a) VALUES('bison');
453 UPDATE t1 SET b = randstr(1000,1000);
454 UPDATE t1 SET b = b||randstr(1000,1000);
455 UPDATE t1 SET b = b||randstr(1000,1000);
456 UPDATE t1 SET b = b||randstr(10,1000);
459 expr ([execsql { PRAGMA page_count }] > 20)
461 do_test savepoint-7.2.1 {
465 CREATE TABLE t2(a, b);
466 INSERT INTO t2 SELECT a, b FROM t1;
470 PRAGMA integrity_check;
473 do_test savepoint-7.2.2 {
476 PRAGMA integrity_check;
480 do_test savepoint-7.3.1 {
482 CREATE TABLE t2(a, b);
483 INSERT INTO t2 SELECT a, b FROM t1;
486 do_test savepoint-7.3.2 {
491 PRAGMA incremental_vacuum;
493 INSERT INTO t2 SELECT a, b FROM t1;
497 execsql { PRAGMA integrity_check }
499 wal_check_journal_mode savepoint-7.3.3
501 do_test savepoint-7.4.1 {
505 execsql { PRAGMA auto_vacuum = incremental }
508 CREATE TABLE t1(a, b, PRIMARY KEY(a, b));
509 INSERT INTO t1 VALUES(randstr(1000,1000), randstr(1000,1000));
513 PRAGMA incremental_vacuum;
518 execsql { PRAGMA integrity_check }
521 do_test savepoint-7.5.1 {
523 PRAGMA incremental_vacuum;
524 CREATE TABLE t5(x, y);
525 INSERT INTO t5 VALUES(1, randstr(1000,1000));
526 INSERT INTO t5 VALUES(2, randstr(1000,1000));
527 INSERT INTO t5 VALUES(3, randstr(1000,1000));
530 INSERT INTO t5 VALUES(4, randstr(1000,1000));
531 INSERT INTO t5 VALUES(5, randstr(1000,1000));
532 DELETE FROM t5 WHERE x=1 OR x=2;
534 PRAGMA incremental_vacuum;
536 INSERT INTO t5 VALUES(1, randstr(1000,1000));
537 INSERT INTO t5 VALUES(2, randstr(1000,1000));
541 PRAGMA integrity_check;
544 do_test savepoint-7.5.2 {
549 wal_check_journal_mode savepoint-7.5.3
551 # Test oddly named and quoted savepoints.
553 do_test savepoint-8-1 {
554 execsql { SAVEPOINT "save1" }
555 execsql { RELEASE save1 }
557 do_test savepoint-8-2 {
558 execsql { SAVEPOINT "Including whitespace " }
559 execsql { RELEASE "including Whitespace " }
562 # Test that the authorization callback works.
566 eval lappend ::authdata [lrange $args 0 4]
571 do_test savepoint-9.1 {
572 set ::authdata [list]
573 execsql { SAVEPOINT sp1 }
575 } {SQLITE_SAVEPOINT BEGIN sp1 {} {}}
576 do_test savepoint-9.2 {
577 set ::authdata [list]
578 execsql { ROLLBACK TO sp1 }
580 } {SQLITE_SAVEPOINT ROLLBACK sp1 {} {}}
581 do_test savepoint-9.3 {
582 set ::authdata [list]
583 execsql { RELEASE sp1 }
585 } {SQLITE_SAVEPOINT RELEASE sp1 {} {}}
588 eval lappend ::authdata [lrange $args 0 4]
593 do_test savepoint-9.4 {
594 set ::authdata [list]
595 set res [catchsql { SAVEPOINT sp1 }]
596 concat $::authdata $res
597 } {SQLITE_SAVEPOINT BEGIN sp1 {} {} 1 {not authorized}}
598 do_test savepoint-9.5 {
599 set ::authdata [list]
600 set res [catchsql { ROLLBACK TO sp1 }]
601 concat $::authdata $res
602 } {SQLITE_SAVEPOINT ROLLBACK sp1 {} {} 1 {not authorized}}
603 do_test savepoint-9.6 {
604 set ::authdata [list]
605 set res [catchsql { RELEASE sp1 }]
606 concat $::authdata $res
607 } {SQLITE_SAVEPOINT RELEASE sp1 {} {} 1 {not authorized}}
609 catch { db eval ROLLBACK }
613 #-------------------------------------------------------------------------
614 # The following tests - savepoint-10.* - test the interaction of
615 # savepoints and ATTACH statements.
618 # First make sure it is not possible to attach or detach a database while
619 # a savepoint is open (it is not possible if any transaction is open).
621 # UPDATE 2017-07-26: It is not possible to ATTACH and DETACH within a
624 do_test savepoint-10.1.1 {
627 ATTACH 'test2.db' AS aux;
631 do_test savepoint-10.1.2 {
634 ATTACH 'test2.db' AS aux;
639 ATTACH 'test2.db' AS aux;
642 do_test savepoint-10.1.3 {
649 # The lock state of the TEMP database can vary if SQLITE_TEMP_STORE=3
650 # And the following set of tests is only really interested in the status
651 # of the aux1 and aux2 locks. So record the current lock status of
652 # TEMP for use in the answers.
653 set templockstate [lindex [db eval {PRAGMA lock_status}] 3]
656 if {[wal_is_wal_mode]==0} {
657 do_test savepoint-10.2.1 {
661 ATTACH 'test2.db' AS aux1;
662 ATTACH 'test3.db' AS aux2;
664 CREATE TABLE main.t1(x, y);
665 CREATE TABLE aux1.t2(x, y);
666 CREATE TABLE aux2.t3(x, y);
667 SELECT name FROM sqlite_master;
668 SELECT name FROM aux1.sqlite_master;
669 SELECT name FROM aux2.sqlite_master;
672 do_test savepoint-10.2.2 {
673 execsql { PRAGMA lock_status }
674 } [list main unlocked temp $templockstate aux1 unlocked aux2 unlocked]
676 do_test savepoint-10.2.3 {
679 INSERT INTO t1 VALUES(1, 2);
682 } [list main reserved temp $templockstate aux1 unlocked aux2 unlocked]
683 do_test savepoint-10.2.4 {
685 INSERT INTO t3 VALUES(3, 4);
688 } [list main reserved temp $templockstate aux1 unlocked aux2 reserved]
689 do_test savepoint-10.2.5 {
692 INSERT INTO t2 VALUES(5, 6);
695 } [list main reserved temp $templockstate aux1 reserved aux2 reserved]
696 do_test savepoint-10.2.6 {
697 execsql { SELECT * FROM t2 }
699 do_test savepoint-10.2.7 {
700 execsql { ROLLBACK TO two }
701 execsql { SELECT * FROM t2 }
703 do_test savepoint-10.2.8 {
704 execsql { PRAGMA lock_status }
705 } [list main reserved temp $templockstate aux1 reserved aux2 reserved]
706 do_test savepoint-10.2.9 {
707 execsql { SELECT 'a', * FROM t1 ; SELECT 'b', * FROM t3 }
709 do_test savepoint-10.2.9 {
711 INSERT INTO t2 VALUES(5, 6);
720 do_test savepoint-10.2.9 {
721 execsql { PRAGMA lock_status }
722 } [list main unlocked temp $templockstate aux1 unlocked aux2 unlocked]
724 do_test savepoint-10.2.10 {
727 INSERT INTO t1 VALUES('a', 'b');
729 INSERT INTO t2 VALUES('c', 'd');
731 INSERT INTO t3 VALUES('e', 'f');
738 } {1 2 a b 5 6 c d 3 4 e f}
739 do_test savepoint-10.2.11 {
740 execsql { ROLLBACK TO two }
747 do_test savepoint-10.2.12 {
749 INSERT INTO t3 VALUES('g', 'h');
758 do_test savepoint-10.2.13 {
766 do_test savepoint-10.2.14 {
767 execsql { PRAGMA lock_status }
768 } [list main unlocked temp $templockstate aux1 unlocked aux2 unlocked]
771 #-------------------------------------------------------------------------
772 # The following tests - savepoint-11.* - test the interaction of
773 # savepoints and creating or dropping tables and indexes in
776 do_test savepoint-11.1 {
780 execsql { PRAGMA auto_vacuum = full; }
783 CREATE TABLE t1(a, b, UNIQUE(a, b));
784 INSERT INTO t1 VALUES(1, randstr(1000,1000));
785 INSERT INTO t1 VALUES(2, randstr(1000,1000));
788 do_test savepoint-11.2 {
791 CREATE TABLE t2(a, b, UNIQUE(a, b));
793 CREATE TABLE t3(a, b, UNIQUE(a, b));
796 integrity_check savepoint-11.3
797 do_test savepoint-11.4 {
798 execsql { ROLLBACK TO two }
800 integrity_check savepoint-11.5
801 do_test savepoint-11.6 {
803 CREATE TABLE t3(a, b, UNIQUE(a, b));
807 integrity_check savepoint-11.7
808 do_test savepoint-11.8 {
810 execsql { PRAGMA wal_checkpoint }
814 do_test savepoint-11.9 {
816 DROP TABLE IF EXISTS t1;
817 DROP TABLE IF EXISTS t2;
818 DROP TABLE IF EXISTS t3;
821 do_test savepoint-11.10 {
824 CREATE TABLE t1(a, b);
825 CREATE TABLE t2(x, y);
826 INSERT INTO t2 VALUES(1, 2);
828 INSERT INTO t2 VALUES(3, 4);
833 execsql {SELECT * FROM t2}
835 do_test savepoint-11.11 {
838 do_test savepoint-11.12 {
839 execsql {SELECT * FROM t2}
841 wal_check_journal_mode savepoint-11.13
843 #-------------------------------------------------------------------------
844 # The following tests - savepoint-12.* - test the interaction of
845 # savepoints and "ON CONFLICT ROLLBACK" clauses.
847 do_test savepoint-12.1 {
849 CREATE TABLE t4(a PRIMARY KEY, b);
850 INSERT INTO t4 VALUES(1, 'one');
853 do_test savepoint-12.2 {
854 # The final statement of the following SQL hits a constraint when the
855 # conflict handling mode is "OR ROLLBACK" and there are a couple of
856 # open savepoints. At one point this would fail to clear the internal
857 # record of the open savepoints, resulting in an assert() failure
862 INSERT INTO t4 VALUES(2, 'two');
864 INSERT INTO t4 VALUES(3, 'three');
866 INSERT OR ROLLBACK INTO t4 VALUES(1, 'one');
868 } {1 {UNIQUE constraint failed: t4.a}}
869 do_test savepoint-12.3 {
870 sqlite3_get_autocommit db
872 do_test savepoint-12.4 {
873 execsql { SAVEPOINT one }
875 wal_check_journal_mode savepoint-12.5
877 #-------------------------------------------------------------------------
878 # The following tests - savepoint-13.* - test the interaction of
879 # savepoints and "journal_mode = off".
881 if {[wal_is_wal_mode]==0} {
882 do_test savepoint-13.1 {
884 catch {forcedelete test.db}
888 CREATE TABLE t1(a PRIMARY KEY, b);
889 INSERT INTO t1 VALUES(1, 2);
891 PRAGMA journal_mode = off;
894 do_test savepoint-13.2 {
897 INSERT INTO t1 VALUES(3, 4);
898 INSERT INTO t1 SELECT a+4,b+4 FROM t1;
902 do_test savepoint-13.3 {
905 INSERT INTO t1 VALUES(9, 10);
907 INSERT INTO t1 VALUES(11, 12);
911 do_test savepoint-13.4 {
914 INSERT INTO t1 VALUES(13, 14);
916 INSERT INTO t1 VALUES(15, 16);
921 } {1 2 3 4 5 6 7 8 9 10 11 12}
926 do_multiclient_test tn {
927 do_test savepoint-14.$tn.1 {
930 INSERT INTO foo VALUES(1);
931 INSERT INTO foo VALUES(2);
938 do_test savepoint-14.$tn.2 {
941 INSERT INTO foo VALUES(1);
943 csql1 { RELEASE one }
944 } {1 {database is locked}}
945 do_test savepoint-14.$tn.3 {
946 sql1 { ROLLBACK TO one }
951 do_test savepoint-14.$tn.4 {
957 do_test savepoint-14.$tn.5 {
960 INSERT INTO foo VALUES(1);
962 csql1 { RELEASE one }
963 } {1 {database is locked}}
964 do_test savepoint-14.$tn.6 {
968 INSERT INTO foo VALUES(3);
969 INSERT INTO foo VALUES(4);
970 INSERT INTO foo VALUES(5);
974 do_test savepoint-14.$tn.7 {
975 sql2 { CREATE INDEX fooidx ON foo(x); }
976 sql3 { PRAGMA integrity_check }
980 do_multiclient_test tn {
981 do_test savepoint-15.$tn.1 {
984 INSERT INTO foo VALUES(1);
985 INSERT INTO foo VALUES(2);
987 sql2 { BEGIN; SELECT * FROM foo; }
989 do_test savepoint-15.$tn.2 {
991 PRAGMA locking_mode = EXCLUSIVE;
993 INSERT INTO foo VALUES(3);
996 } {1 {database is locked}}
997 do_test savepoint-15.$tn.3 {
1001 INSERT INTO foo VALUES(3);
1002 PRAGMA locking_mode = NORMAL;
1003 INSERT INTO foo VALUES(4);
1005 sql2 { CREATE INDEX fooidx ON foo(x); }
1006 sql3 { PRAGMA integrity_check }
1010 do_multiclient_test tn {
1011 do_test savepoint-16.$tn.1 {
1013 CREATE TABLE foo(x);
1014 INSERT INTO foo VALUES(1);
1015 INSERT INTO foo VALUES(2);
1018 do_test savepoint-16.$tn.2 {
1020 db eval {SELECT * FROM foo} {
1021 sql1 { INSERT INTO foo VALUES(3) }
1022 sql2 { SELECT * FROM foo }
1023 sql1 { INSERT INTO foo VALUES(4) }
1027 sql2 { CREATE INDEX fooidx ON foo(x); }
1028 sql3 { PRAGMA integrity_check }
1030 do_test savepoint-16.$tn.3 {
1031 sql1 { SELECT * FROM foo }
1035 #-------------------------------------------------------------------------
1036 # This next block of tests verifies that a problem reported on the mailing
1037 # list has been resolved. At one point the second "CREATE TABLE t6" would
1038 # fail as table t6 still existed in the internal cache of the db schema
1039 # (even though it had been removed from the database by the ROLLBACK
1043 do_execsql_test savepoint-17.1 {
1045 CREATE TABLE t6(a, b);
1046 INSERT INTO t6 VALUES(1, 2);
1048 INSERT INTO t6 VALUES(3, 4);
1054 do_execsql_test savepoint-17.2 {
1055 CREATE TABLE t6(a, b);