sl@0
|
1 |
# 2001 September 15
|
sl@0
|
2 |
#
|
sl@0
|
3 |
# The author disclaims copyright to this source code. In place of
|
sl@0
|
4 |
# a legal notice, here is a blessing:
|
sl@0
|
5 |
#
|
sl@0
|
6 |
# May you do good and not evil.
|
sl@0
|
7 |
# May you find forgiveness for yourself and forgive others.
|
sl@0
|
8 |
# May you share freely, never taking more than you give.
|
sl@0
|
9 |
#
|
sl@0
|
10 |
#***********************************************************************
|
sl@0
|
11 |
# This file implements regression tests for SQLite library. The
|
sl@0
|
12 |
# focus of this script is in-memory database backend.
|
sl@0
|
13 |
#
|
sl@0
|
14 |
# $Id: memdb.test,v 1.15 2006/01/30 22:48:44 drh Exp $
|
sl@0
|
15 |
|
sl@0
|
16 |
|
sl@0
|
17 |
set testdir [file dirname $argv0]
|
sl@0
|
18 |
source $testdir/tester.tcl
|
sl@0
|
19 |
|
sl@0
|
20 |
ifcapable memorydb {
|
sl@0
|
21 |
|
sl@0
|
22 |
# In the following sequence of tests, compute the MD5 sum of the content
|
sl@0
|
23 |
# of a table, make lots of modifications to that table, then do a rollback.
|
sl@0
|
24 |
# Verify that after the rollback, the MD5 checksum is unchanged.
|
sl@0
|
25 |
#
|
sl@0
|
26 |
# These tests were browed from trans.tcl.
|
sl@0
|
27 |
#
|
sl@0
|
28 |
do_test memdb-1.1 {
|
sl@0
|
29 |
db close
|
sl@0
|
30 |
sqlite3 db :memory:
|
sl@0
|
31 |
# sqlite3 db test.db
|
sl@0
|
32 |
execsql {
|
sl@0
|
33 |
BEGIN;
|
sl@0
|
34 |
CREATE TABLE t3(x TEXT);
|
sl@0
|
35 |
INSERT INTO t3 VALUES(randstr(10,400));
|
sl@0
|
36 |
INSERT INTO t3 VALUES(randstr(10,400));
|
sl@0
|
37 |
INSERT INTO t3 SELECT randstr(10,400) FROM t3;
|
sl@0
|
38 |
INSERT INTO t3 SELECT randstr(10,400) FROM t3;
|
sl@0
|
39 |
INSERT INTO t3 SELECT randstr(10,400) FROM t3;
|
sl@0
|
40 |
INSERT INTO t3 SELECT randstr(10,400) FROM t3;
|
sl@0
|
41 |
INSERT INTO t3 SELECT randstr(10,400) FROM t3;
|
sl@0
|
42 |
INSERT INTO t3 SELECT randstr(10,400) FROM t3;
|
sl@0
|
43 |
INSERT INTO t3 SELECT randstr(10,400) FROM t3;
|
sl@0
|
44 |
INSERT INTO t3 SELECT randstr(10,400) FROM t3;
|
sl@0
|
45 |
INSERT INTO t3 SELECT randstr(10,400) FROM t3;
|
sl@0
|
46 |
COMMIT;
|
sl@0
|
47 |
SELECT count(*) FROM t3;
|
sl@0
|
48 |
}
|
sl@0
|
49 |
} {1024}
|
sl@0
|
50 |
|
sl@0
|
51 |
# The following procedure computes a "signature" for table "t3". If
|
sl@0
|
52 |
# T3 changes in any way, the signature should change.
|
sl@0
|
53 |
#
|
sl@0
|
54 |
# This is used to test ROLLBACK. We gather a signature for t3, then
|
sl@0
|
55 |
# make lots of changes to t3, then rollback and take another signature.
|
sl@0
|
56 |
# The two signatures should be the same.
|
sl@0
|
57 |
#
|
sl@0
|
58 |
proc signature {{fn {}}} {
|
sl@0
|
59 |
set rx [db eval {SELECT x FROM t3}]
|
sl@0
|
60 |
# set r1 [md5 $rx\n]
|
sl@0
|
61 |
if {$fn!=""} {
|
sl@0
|
62 |
# set fd [open $fn w]
|
sl@0
|
63 |
# puts $fd $rx
|
sl@0
|
64 |
# close $fd
|
sl@0
|
65 |
}
|
sl@0
|
66 |
# set r [db eval {SELECT count(*), md5sum(x) FROM t3}]
|
sl@0
|
67 |
# puts "SIG($fn)=$r1"
|
sl@0
|
68 |
return [list [string length $rx] $rx]
|
sl@0
|
69 |
}
|
sl@0
|
70 |
|
sl@0
|
71 |
# Do rollbacks. Make sure the signature does not change.
|
sl@0
|
72 |
#
|
sl@0
|
73 |
set limit 10
|
sl@0
|
74 |
for {set i 2} {$i<=$limit} {incr i} {
|
sl@0
|
75 |
set ::sig [signature one]
|
sl@0
|
76 |
# puts "sig=$sig"
|
sl@0
|
77 |
set cnt [lindex $::sig 0]
|
sl@0
|
78 |
if {$i%2==0} {
|
sl@0
|
79 |
execsql {PRAGMA synchronous=FULL}
|
sl@0
|
80 |
} else {
|
sl@0
|
81 |
execsql {PRAGMA synchronous=NORMAL}
|
sl@0
|
82 |
}
|
sl@0
|
83 |
do_test memdb-1.$i.1-$cnt {
|
sl@0
|
84 |
execsql {
|
sl@0
|
85 |
BEGIN;
|
sl@0
|
86 |
DELETE FROM t3 WHERE random()%10!=0;
|
sl@0
|
87 |
INSERT INTO t3 SELECT randstr(10,10)||x FROM t3;
|
sl@0
|
88 |
INSERT INTO t3 SELECT randstr(10,10)||x FROM t3;
|
sl@0
|
89 |
ROLLBACK;
|
sl@0
|
90 |
}
|
sl@0
|
91 |
set sig2 [signature two]
|
sl@0
|
92 |
} $sig
|
sl@0
|
93 |
# puts "sig2=$sig2"
|
sl@0
|
94 |
# if {$sig2!=$sig} exit
|
sl@0
|
95 |
do_test memdb-1.$i.2-$cnt {
|
sl@0
|
96 |
execsql {
|
sl@0
|
97 |
BEGIN;
|
sl@0
|
98 |
DELETE FROM t3 WHERE random()%10!=0;
|
sl@0
|
99 |
INSERT INTO t3 SELECT randstr(10,10)||x FROM t3;
|
sl@0
|
100 |
DELETE FROM t3 WHERE random()%10!=0;
|
sl@0
|
101 |
INSERT INTO t3 SELECT randstr(10,10)||x FROM t3;
|
sl@0
|
102 |
ROLLBACK;
|
sl@0
|
103 |
}
|
sl@0
|
104 |
signature
|
sl@0
|
105 |
} $sig
|
sl@0
|
106 |
if {$i<$limit} {
|
sl@0
|
107 |
do_test memdb-1.$i.9-$cnt {
|
sl@0
|
108 |
execsql {
|
sl@0
|
109 |
INSERT INTO t3 SELECT randstr(10,400) FROM t3 WHERE random()%10==0;
|
sl@0
|
110 |
}
|
sl@0
|
111 |
} {}
|
sl@0
|
112 |
}
|
sl@0
|
113 |
set ::pager_old_format 0
|
sl@0
|
114 |
}
|
sl@0
|
115 |
|
sl@0
|
116 |
integrity_check memdb-2.1
|
sl@0
|
117 |
|
sl@0
|
118 |
do_test memdb-3.1 {
|
sl@0
|
119 |
execsql {
|
sl@0
|
120 |
CREATE TABLE t4(a,b,c,d);
|
sl@0
|
121 |
BEGIN;
|
sl@0
|
122 |
INSERT INTO t4 VALUES(1,2,3,4);
|
sl@0
|
123 |
SELECT * FROM t4;
|
sl@0
|
124 |
}
|
sl@0
|
125 |
} {1 2 3 4}
|
sl@0
|
126 |
do_test memdb-3.2 {
|
sl@0
|
127 |
execsql {
|
sl@0
|
128 |
SELECT name FROM sqlite_master WHERE type='table';
|
sl@0
|
129 |
}
|
sl@0
|
130 |
} {t3 t4}
|
sl@0
|
131 |
do_test memdb-3.3 {
|
sl@0
|
132 |
execsql {
|
sl@0
|
133 |
DROP TABLE t4;
|
sl@0
|
134 |
SELECT name FROM sqlite_master WHERE type='table';
|
sl@0
|
135 |
}
|
sl@0
|
136 |
} {t3}
|
sl@0
|
137 |
do_test memdb-3.4 {
|
sl@0
|
138 |
execsql {
|
sl@0
|
139 |
ROLLBACK;
|
sl@0
|
140 |
SELECT name FROM sqlite_master WHERE type='table';
|
sl@0
|
141 |
}
|
sl@0
|
142 |
} {t3 t4}
|
sl@0
|
143 |
|
sl@0
|
144 |
# Create tables for the first group of tests.
|
sl@0
|
145 |
#
|
sl@0
|
146 |
do_test memdb-4.0 {
|
sl@0
|
147 |
execsql {
|
sl@0
|
148 |
CREATE TABLE t1(a, b, c, UNIQUE(a,b));
|
sl@0
|
149 |
CREATE TABLE t2(x);
|
sl@0
|
150 |
SELECT c FROM t1 ORDER BY c;
|
sl@0
|
151 |
}
|
sl@0
|
152 |
} {}
|
sl@0
|
153 |
|
sl@0
|
154 |
# Six columns of configuration data as follows:
|
sl@0
|
155 |
#
|
sl@0
|
156 |
# i The reference number of the test
|
sl@0
|
157 |
# conf The conflict resolution algorithm on the BEGIN statement
|
sl@0
|
158 |
# cmd An INSERT or REPLACE command to execute against table t1
|
sl@0
|
159 |
# t0 True if there is an error from $cmd
|
sl@0
|
160 |
# t1 Content of "c" column of t1 assuming no error in $cmd
|
sl@0
|
161 |
# t2 Content of "x" column of t2
|
sl@0
|
162 |
#
|
sl@0
|
163 |
foreach {i conf cmd t0 t1 t2} {
|
sl@0
|
164 |
1 {} INSERT 1 {} 1
|
sl@0
|
165 |
2 {} {INSERT OR IGNORE} 0 3 1
|
sl@0
|
166 |
3 {} {INSERT OR REPLACE} 0 4 1
|
sl@0
|
167 |
4 {} REPLACE 0 4 1
|
sl@0
|
168 |
5 {} {INSERT OR FAIL} 1 {} 1
|
sl@0
|
169 |
6 {} {INSERT OR ABORT} 1 {} 1
|
sl@0
|
170 |
7 {} {INSERT OR ROLLBACK} 1 {} {}
|
sl@0
|
171 |
} {
|
sl@0
|
172 |
|
sl@0
|
173 |
# All tests after test 1 depend on conflict resolution. So end the
|
sl@0
|
174 |
# loop if that is not available in this build.
|
sl@0
|
175 |
ifcapable !conflict {if {$i>1} break}
|
sl@0
|
176 |
|
sl@0
|
177 |
do_test memdb-4.$i {
|
sl@0
|
178 |
if {$conf!=""} {set conf "ON CONFLICT $conf"}
|
sl@0
|
179 |
set r0 [catch {execsql [subst {
|
sl@0
|
180 |
DELETE FROM t1;
|
sl@0
|
181 |
DELETE FROM t2;
|
sl@0
|
182 |
INSERT INTO t1 VALUES(1,2,3);
|
sl@0
|
183 |
BEGIN $conf;
|
sl@0
|
184 |
INSERT INTO t2 VALUES(1);
|
sl@0
|
185 |
$cmd INTO t1 VALUES(1,2,4);
|
sl@0
|
186 |
}]} r1]
|
sl@0
|
187 |
catch {execsql {COMMIT}}
|
sl@0
|
188 |
if {$r0} {set r1 {}} {set r1 [execsql {SELECT c FROM t1}]}
|
sl@0
|
189 |
set r2 [execsql {SELECT x FROM t2}]
|
sl@0
|
190 |
list $r0 $r1 $r2
|
sl@0
|
191 |
} [list $t0 $t1 $t2]
|
sl@0
|
192 |
}
|
sl@0
|
193 |
|
sl@0
|
194 |
do_test memdb-5.0 {
|
sl@0
|
195 |
execsql {
|
sl@0
|
196 |
DROP TABLE t2;
|
sl@0
|
197 |
DROP TABLE t3;
|
sl@0
|
198 |
CREATE TABLE t2(a,b,c);
|
sl@0
|
199 |
INSERT INTO t2 VALUES(1,2,1);
|
sl@0
|
200 |
INSERT INTO t2 VALUES(2,3,2);
|
sl@0
|
201 |
INSERT INTO t2 VALUES(3,4,1);
|
sl@0
|
202 |
INSERT INTO t2 VALUES(4,5,4);
|
sl@0
|
203 |
SELECT c FROM t2 ORDER BY b;
|
sl@0
|
204 |
CREATE TABLE t3(x);
|
sl@0
|
205 |
INSERT INTO t3 VALUES(1);
|
sl@0
|
206 |
}
|
sl@0
|
207 |
} {1 2 1 4}
|
sl@0
|
208 |
|
sl@0
|
209 |
# Six columns of configuration data as follows:
|
sl@0
|
210 |
#
|
sl@0
|
211 |
# i The reference number of the test
|
sl@0
|
212 |
# conf1 The conflict resolution algorithm on the UNIQUE constraint
|
sl@0
|
213 |
# conf2 The conflict resolution algorithm on the BEGIN statement
|
sl@0
|
214 |
# cmd An UPDATE command to execute against table t1
|
sl@0
|
215 |
# t0 True if there is an error from $cmd
|
sl@0
|
216 |
# t1 Content of "b" column of t1 assuming no error in $cmd
|
sl@0
|
217 |
# t2 Content of "x" column of t3
|
sl@0
|
218 |
#
|
sl@0
|
219 |
foreach {i conf1 conf2 cmd t0 t1 t2} {
|
sl@0
|
220 |
1 {} {} UPDATE 1 {6 7 8 9} 1
|
sl@0
|
221 |
2 REPLACE {} UPDATE 0 {7 6 9} 1
|
sl@0
|
222 |
3 IGNORE {} UPDATE 0 {6 7 3 9} 1
|
sl@0
|
223 |
4 FAIL {} UPDATE 1 {6 7 3 4} 1
|
sl@0
|
224 |
5 ABORT {} UPDATE 1 {1 2 3 4} 1
|
sl@0
|
225 |
6 ROLLBACK {} UPDATE 1 {1 2 3 4} 0
|
sl@0
|
226 |
7 REPLACE {} {UPDATE OR IGNORE} 0 {6 7 3 9} 1
|
sl@0
|
227 |
8 IGNORE {} {UPDATE OR REPLACE} 0 {7 6 9} 1
|
sl@0
|
228 |
9 FAIL {} {UPDATE OR IGNORE} 0 {6 7 3 9} 1
|
sl@0
|
229 |
10 ABORT {} {UPDATE OR REPLACE} 0 {7 6 9} 1
|
sl@0
|
230 |
11 ROLLBACK {} {UPDATE OR IGNORE} 0 {6 7 3 9} 1
|
sl@0
|
231 |
12 {} {} {UPDATE OR IGNORE} 0 {6 7 3 9} 1
|
sl@0
|
232 |
13 {} {} {UPDATE OR REPLACE} 0 {7 6 9} 1
|
sl@0
|
233 |
14 {} {} {UPDATE OR FAIL} 1 {6 7 3 4} 1
|
sl@0
|
234 |
15 {} {} {UPDATE OR ABORT} 1 {1 2 3 4} 1
|
sl@0
|
235 |
16 {} {} {UPDATE OR ROLLBACK} 1 {1 2 3 4} 0
|
sl@0
|
236 |
} {
|
sl@0
|
237 |
# All tests after test 1 depend on conflict resolution. So end the
|
sl@0
|
238 |
# loop if that is not available in this build.
|
sl@0
|
239 |
ifcapable !conflict {
|
sl@0
|
240 |
if {$i>1} break
|
sl@0
|
241 |
}
|
sl@0
|
242 |
|
sl@0
|
243 |
if {$t0} {set t1 {column a is not unique}}
|
sl@0
|
244 |
do_test memdb-5.$i {
|
sl@0
|
245 |
if {$conf1!=""} {set conf1 "ON CONFLICT $conf1"}
|
sl@0
|
246 |
if {$conf2!=""} {set conf2 "ON CONFLICT $conf2"}
|
sl@0
|
247 |
set r0 [catch {execsql [subst {
|
sl@0
|
248 |
DROP TABLE t1;
|
sl@0
|
249 |
CREATE TABLE t1(a,b,c, UNIQUE(a) $conf1);
|
sl@0
|
250 |
INSERT INTO t1 SELECT * FROM t2;
|
sl@0
|
251 |
UPDATE t3 SET x=0;
|
sl@0
|
252 |
BEGIN $conf2;
|
sl@0
|
253 |
$cmd t3 SET x=1;
|
sl@0
|
254 |
$cmd t1 SET b=b*2;
|
sl@0
|
255 |
$cmd t1 SET a=c+5;
|
sl@0
|
256 |
}]} r1]
|
sl@0
|
257 |
catch {execsql {COMMIT}}
|
sl@0
|
258 |
if {!$r0} {set r1 [execsql {SELECT a FROM t1 ORDER BY b}]}
|
sl@0
|
259 |
set r2 [execsql {SELECT x FROM t3}]
|
sl@0
|
260 |
list $r0 $r1 $r2
|
sl@0
|
261 |
} [list $t0 $t1 $t2]
|
sl@0
|
262 |
}
|
sl@0
|
263 |
|
sl@0
|
264 |
do_test memdb-6.1 {
|
sl@0
|
265 |
execsql {
|
sl@0
|
266 |
SELECT * FROM t2;
|
sl@0
|
267 |
}
|
sl@0
|
268 |
} {1 2 1 2 3 2 3 4 1 4 5 4}
|
sl@0
|
269 |
do_test memdb-6.2 {
|
sl@0
|
270 |
execsql {
|
sl@0
|
271 |
BEGIN;
|
sl@0
|
272 |
DROP TABLE t2;
|
sl@0
|
273 |
SELECT name FROM sqlite_master WHERE type='table' ORDER BY 1;
|
sl@0
|
274 |
}
|
sl@0
|
275 |
} {t1 t3 t4}
|
sl@0
|
276 |
do_test memdb-6.3 {
|
sl@0
|
277 |
execsql {
|
sl@0
|
278 |
ROLLBACK;
|
sl@0
|
279 |
SELECT name FROM sqlite_master WHERE type='table' ORDER BY 1;
|
sl@0
|
280 |
}
|
sl@0
|
281 |
} {t1 t2 t3 t4}
|
sl@0
|
282 |
do_test memdb-6.4 {
|
sl@0
|
283 |
execsql {
|
sl@0
|
284 |
SELECT * FROM t2;
|
sl@0
|
285 |
}
|
sl@0
|
286 |
} {1 2 1 2 3 2 3 4 1 4 5 4}
|
sl@0
|
287 |
ifcapable compound {
|
sl@0
|
288 |
do_test memdb-6.5 {
|
sl@0
|
289 |
execsql {
|
sl@0
|
290 |
SELECT a FROM t2 UNION SELECT b FROM t2 ORDER BY 1;
|
sl@0
|
291 |
}
|
sl@0
|
292 |
} {1 2 3 4 5}
|
sl@0
|
293 |
} ;# ifcapable compound
|
sl@0
|
294 |
do_test memdb-6.6 {
|
sl@0
|
295 |
execsql {
|
sl@0
|
296 |
CREATE INDEX i2 ON t2(c);
|
sl@0
|
297 |
SELECT a FROM t2 ORDER BY c;
|
sl@0
|
298 |
}
|
sl@0
|
299 |
} {1 3 2 4}
|
sl@0
|
300 |
do_test memdb-6.6 {
|
sl@0
|
301 |
execsql {
|
sl@0
|
302 |
SELECT a FROM t2 ORDER BY c DESC;
|
sl@0
|
303 |
}
|
sl@0
|
304 |
} {4 2 3 1}
|
sl@0
|
305 |
do_test memdb-6.7 {
|
sl@0
|
306 |
execsql {
|
sl@0
|
307 |
BEGIN;
|
sl@0
|
308 |
CREATE TABLE t5(x,y);
|
sl@0
|
309 |
INSERT INTO t5 VALUES(1,2);
|
sl@0
|
310 |
SELECT * FROM t5;
|
sl@0
|
311 |
}
|
sl@0
|
312 |
} {1 2}
|
sl@0
|
313 |
do_test memdb-6.8 {
|
sl@0
|
314 |
execsql {
|
sl@0
|
315 |
SELECT name FROM sqlite_master WHERE type='table' ORDER BY 1;
|
sl@0
|
316 |
}
|
sl@0
|
317 |
} {t1 t2 t3 t4 t5}
|
sl@0
|
318 |
do_test memdb-6.9 {
|
sl@0
|
319 |
execsql {
|
sl@0
|
320 |
ROLLBACK;
|
sl@0
|
321 |
SELECT name FROM sqlite_master WHERE type='table' ORDER BY 1;
|
sl@0
|
322 |
}
|
sl@0
|
323 |
} {t1 t2 t3 t4}
|
sl@0
|
324 |
do_test memdb-6.10 {
|
sl@0
|
325 |
execsql {
|
sl@0
|
326 |
CREATE TABLE t5(x PRIMARY KEY, y UNIQUE);
|
sl@0
|
327 |
SELECT * FROM t5;
|
sl@0
|
328 |
}
|
sl@0
|
329 |
} {}
|
sl@0
|
330 |
do_test memdb-6.11 {
|
sl@0
|
331 |
execsql {
|
sl@0
|
332 |
SELECT * FROM t5 ORDER BY y DESC;
|
sl@0
|
333 |
}
|
sl@0
|
334 |
} {}
|
sl@0
|
335 |
|
sl@0
|
336 |
ifcapable conflict {
|
sl@0
|
337 |
do_test memdb-6.12 {
|
sl@0
|
338 |
execsql {
|
sl@0
|
339 |
INSERT INTO t5 VALUES(1,2);
|
sl@0
|
340 |
INSERT INTO t5 VALUES(3,4);
|
sl@0
|
341 |
REPLACE INTO t5 VALUES(1,4);
|
sl@0
|
342 |
SELECT rowid,* FROM t5;
|
sl@0
|
343 |
}
|
sl@0
|
344 |
} {3 1 4}
|
sl@0
|
345 |
do_test memdb-6.13 {
|
sl@0
|
346 |
execsql {
|
sl@0
|
347 |
DELETE FROM t5 WHERE x>5;
|
sl@0
|
348 |
SELECT * FROM t5;
|
sl@0
|
349 |
}
|
sl@0
|
350 |
} {1 4}
|
sl@0
|
351 |
do_test memdb-6.14 {
|
sl@0
|
352 |
execsql {
|
sl@0
|
353 |
DELETE FROM t5 WHERE y<3;
|
sl@0
|
354 |
SELECT * FROM t5;
|
sl@0
|
355 |
}
|
sl@0
|
356 |
} {1 4}
|
sl@0
|
357 |
}
|
sl@0
|
358 |
|
sl@0
|
359 |
do_test memdb-6.15 {
|
sl@0
|
360 |
execsql {
|
sl@0
|
361 |
DELETE FROM t5 WHERE x>0;
|
sl@0
|
362 |
SELECT * FROM t5;
|
sl@0
|
363 |
}
|
sl@0
|
364 |
} {}
|
sl@0
|
365 |
|
sl@0
|
366 |
ifcapable subquery {
|
sl@0
|
367 |
do_test memdb-7.1 {
|
sl@0
|
368 |
execsql {
|
sl@0
|
369 |
CREATE TABLE t6(x);
|
sl@0
|
370 |
INSERT INTO t6 VALUES(1);
|
sl@0
|
371 |
INSERT INTO t6 SELECT x+1 FROM t6;
|
sl@0
|
372 |
INSERT INTO t6 SELECT x+2 FROM t6;
|
sl@0
|
373 |
INSERT INTO t6 SELECT x+4 FROM t6;
|
sl@0
|
374 |
INSERT INTO t6 SELECT x+8 FROM t6;
|
sl@0
|
375 |
INSERT INTO t6 SELECT x+16 FROM t6;
|
sl@0
|
376 |
INSERT INTO t6 SELECT x+32 FROM t6;
|
sl@0
|
377 |
INSERT INTO t6 SELECT x+64 FROM t6;
|
sl@0
|
378 |
INSERT INTO t6 SELECT x+128 FROM t6;
|
sl@0
|
379 |
SELECT count(*) FROM (SELECT DISTINCT x FROM t6);
|
sl@0
|
380 |
}
|
sl@0
|
381 |
} {256}
|
sl@0
|
382 |
for {set i 1} {$i<=256} {incr i} {
|
sl@0
|
383 |
do_test memdb-7.2.$i {
|
sl@0
|
384 |
execsql "DELETE FROM t6 WHERE x=\
|
sl@0
|
385 |
(SELECT x FROM t6 ORDER BY random() LIMIT 1)"
|
sl@0
|
386 |
execsql {SELECT count(*) FROM t6}
|
sl@0
|
387 |
} [expr {256-$i}]
|
sl@0
|
388 |
}
|
sl@0
|
389 |
}
|
sl@0
|
390 |
|
sl@0
|
391 |
# Ticket #1524
|
sl@0
|
392 |
#
|
sl@0
|
393 |
do_test memdb-8.1 {
|
sl@0
|
394 |
db close
|
sl@0
|
395 |
sqlite3 db {:memory:}
|
sl@0
|
396 |
execsql {
|
sl@0
|
397 |
PRAGMA auto_vacuum=TRUE;
|
sl@0
|
398 |
CREATE TABLE t1(a);
|
sl@0
|
399 |
INSERT INTO t1 VALUES(randstr(5000,6000));
|
sl@0
|
400 |
INSERT INTO t1 VALUES(randstr(5000,6000));
|
sl@0
|
401 |
INSERT INTO t1 VALUES(randstr(5000,6000));
|
sl@0
|
402 |
INSERT INTO t1 VALUES(randstr(5000,6000));
|
sl@0
|
403 |
INSERT INTO t1 VALUES(randstr(5000,6000));
|
sl@0
|
404 |
SELECT count(*) FROM t1;
|
sl@0
|
405 |
}
|
sl@0
|
406 |
} 5
|
sl@0
|
407 |
do_test memdb-8.2 {
|
sl@0
|
408 |
execsql {
|
sl@0
|
409 |
DELETE FROM t1;
|
sl@0
|
410 |
SELECT count(*) FROM t1;
|
sl@0
|
411 |
}
|
sl@0
|
412 |
} 0
|
sl@0
|
413 |
|
sl@0
|
414 |
|
sl@0
|
415 |
} ;# ifcapable memorydb
|
sl@0
|
416 |
|
sl@0
|
417 |
finish_test
|