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 #***********************************************************************
11 # This file implements regression tests for SQLite library. The
12 # focus of this file is testing the code in test_delete.c (the
13 # sqlite3_delete_database() API).
16 set testdir [file dirname $argv0]
17 source $testdir/tester.tcl
18 set testprefix delete_db
20 if {[atomic_batch_write test.db]} {
26 foreach f [glob -nocomplain test2*] { file delete $f }
27 foreach f [glob -nocomplain test3*] { file delete $f }
31 foreach f [glob -nocomplain test3*] { file delete $f }
32 foreach f [glob -nocomplain test2*] {
33 set p [string range $f 5 end]
34 file copy "test2$p" "test3$p"
39 lsort [glob -nocomplain test3*]
44 sqlite3 db test2.database
46 #-------------------------------------------------------------------------
50 # 1.3: Multiplexor with journal file.
51 # 1.4: Multiplexor with wal file.
53 # 2.* are a copy of 1.* with the multiplexor enabled.
60 CREATE TABLE t1(x, y);
62 INSERT INTO t1 VALUES(1, 2);
66 } {test3.database test3.database-journal}
69 sqlite3_delete_database test3.database
76 PRAGMA journal_mode = wal;
77 INSERT INTO t1 VALUES(3, 4);
81 } {test3.database test3.database-shm test3.database-wal}
83 sqlite3_delete_database test3.database
89 sqlite3_multiplex_initialize "" 0
90 sqlite3 db test2.database -vfs multiplex
91 sqlite3_multiplex_control db "main" chunk_size 32768
94 execsql { PRAGMA auto_vacuum = 0; }
96 CREATE TABLE x1(a, b);
97 WITH s(i) AS ( VALUES(1) UNION ALL SELECT i+1 FROM s WHERE i<1000 )
98 INSERT INTO x1 SELECT randomblob(100), randomblob(100) FROM s;
100 UPDATE x1 SET a=randomblob(101)
105 test3.database test3.database-journal test3.database001
106 test3.database002 test3.database003
109 sqlite3_delete_database test3.database
117 PRAGMA journal_mode = wal;
118 UPDATE x1 SET a=randomblob(102)
123 test3.database test3.database-shm test3.database-wal test3.database001
124 test3.database002 test3.database003
127 sqlite3_delete_database test3.database
132 ifcapable 8_3_names {
135 sqlite3 db file:test2.db?8_3_names=1 -uri 1
139 CREATE TABLE t1(x, y);
141 INSERT INTO t1 VALUES(1, 2);
145 } {test3.db test3.nal}
148 sqlite3_delete_database test3.db
155 PRAGMA journal_mode = wal;
156 INSERT INTO t1 VALUES(3, 4);
160 } {test3.db test3.shm test3.wal}
162 sqlite3_delete_database test3.db
169 sqlite3_multiplex_initialize "" 0
170 sqlite3 db file:test2.db?8_3_names=1 -uri 1 -vfs multiplex
171 sqlite3_multiplex_control db "main" chunk_size 32768
174 execsql { PRAGMA auto_vacuum = 0; }
176 CREATE TABLE x1(a, b);
177 WITH s(i) AS ( VALUES(1) UNION ALL SELECT i+1 FROM s WHERE i<1000 )
178 INSERT INTO x1 SELECT randomblob(100), randomblob(100) FROM s;
180 UPDATE x1 SET a=randomblob(101)
185 test3.001 test3.002 test3.003 test3.db test3.nal
188 sqlite3_delete_database test3.db
196 PRAGMA journal_mode = wal;
197 UPDATE x1 SET a=randomblob(102)
202 test3.001 test3.002 test3.003 test3.db test3.db-shm test3.wal
205 sqlite3_delete_database test3.db
212 sqlite3_multiplex_shutdown
216 sqlite3_delete_database dir2.db
219 sqlite3_delete_database dir2.db/test.db