blob: 8d1a119fbf9102b7932c9bb272198157adf16b4f [file] [log] [blame]
drhb19a2bc2001-09-16 00:13:26 +00001# 2001 September 15
drhed7c8552001-04-11 14:29:21 +00002#
drhb19a2bc2001-09-16 00:13:26 +00003# The author disclaims copyright to this source code. In place of
4# a legal notice, here is a blessing:
drhed7c8552001-04-11 14:29:21 +00005#
drhb19a2bc2001-09-16 00:13:26 +00006# 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.
drhed7c8552001-04-11 14:29:21 +00009#
10#***********************************************************************
11# This file attempts to check the library in an out-of-memory situation.
drhc89b91b2005-01-03 01:32:59 +000012# When compiled with -DSQLITE_DEBUG=1, the SQLite library accepts a special
drh6d4abfb2001-10-22 02:58:08 +000013# command (sqlite_malloc_fail N) which causes the N-th malloc to fail. This
drhed7c8552001-04-11 14:29:21 +000014# special feature is used to see what happens in the library if a malloc
15# were to really fail due to an out-of-memory situation.
16#
danielk1977aca790a2005-01-13 11:07:52 +000017# $Id: malloc.test,v 1.19 2005/01/13 11:07:54 danielk1977 Exp $
drhed7c8552001-04-11 14:29:21 +000018
19set testdir [file dirname $argv0]
20source $testdir/tester.tcl
21
22# Only run these tests if memory debugging is turned on.
23#
drhb5f70c22004-02-14 01:39:50 +000024if {[info command sqlite_malloc_stat]==""} {
drhc89b91b2005-01-03 01:32:59 +000025 puts "Skipping malloc tests: not compiled with -DSQLITE_DEBUG..."
drhed7c8552001-04-11 14:29:21 +000026 finish_test
27 return
28}
29
danielk19774397de52005-01-12 12:44:03 +000030# Usage: do_malloc_test <test number> <options...>
31#
32# The first argument, <test number>, is an integer used to name the
33# tests executed by this proc. Options are as follows:
34#
35# -tclprep TCL script to run to prepare test.
36# -sqlprep SQL script to run to prepare test.
danielk1977656152c2005-01-12 13:04:54 +000037# -tclbody TCL script to run with malloc failure simulation.
38# -sqlbody TCL script to run with malloc failure simulation.
39#
40# This command runs a series of tests to verify SQLite's ability
41# to handle an out-of-memory condition gracefully. It is assumed
42# that if this condition occurs a malloc() call will return a
43# NULL pointer. Linux, for example, doesn't do that by default. See
44# the "BUGS" section of malloc(3).
45#
46# Each iteration of a loop, the TCL commands in any argument passed
47# to the -tclbody switch, followed by the SQL commands in any argument
48# passed to the -sqlbody switch are executed. Each iteration the
49# Nth call to sqliteMalloc() is made to fail, where N is increased
50# each time the loop runs starting from 1. When all commands execute
51# successfully, the loop ends.
danielk19774397de52005-01-12 12:44:03 +000052#
53proc do_malloc_test {tn args} {
54 array set ::mallocopts $args
55
56 set ::go 1
57 for {set ::n 1} {$::go} {incr ::n} {
58
59 do_test malloc-$tn.$::n {
60
61 sqlite_malloc_fail 0
62 catch {db close}
63 catch {file delete -force test.db}
64 catch {file delete -force test.db-journal}
65 catch {file delete -force test2.db}
66 catch {file delete -force test2.db-journal}
67 set ::DB [sqlite3 db test.db]
68
69 if {[info exists ::mallocopts(-tclprep)]} {
70 eval $::mallocopts(-tclprep)
71 }
72 if {[info exists ::mallocopts(-sqlprep)]} {
73 execsql $::mallocopts(-sqlprep)
74 }
75
76 sqlite_malloc_fail $::n
77 set ::mallocbody {}
78 if {[info exists ::mallocopts(-tclbody)]} {
79 append ::mallocbody "$::mallocopts(-tclbody)\n"
80 }
81 if {[info exists ::mallocopts(-sqlbody)]} {
82 append ::mallocbody "db eval {$::mallocopts(-sqlbody)}"
83 }
84
85 set v [catch $::mallocbody msg]
86
87 set leftover [lindex [sqlite_malloc_stat] 2]
88 if {$leftover>0} {
89 if {$leftover>1} {puts "\nLeftover: $leftover\nReturn=$v Message=$msg"}
90 set ::go 0
91 set v {1 1}
92 } else {
93 set v2 [expr {$msg=="" || $msg=="out of memory"}]
94 if {!$v2} {puts "\nError message returned: $msg"}
95 lappend v $v2
96 }
97 } {1 1}
98 }
danielk1977aca790a2005-01-13 11:07:52 +000099 unset ::mallocopts
danielk19774397de52005-01-12 12:44:03 +0000100}
101
drhed7c8552001-04-11 14:29:21 +0000102for {set go 1; set i 1} {$go} {incr i} {
103 do_test malloc-1.$i {
104 sqlite_malloc_fail 0
drh6d4abfb2001-10-22 02:58:08 +0000105 catch {db close}
106 catch {file delete -force test.db}
107 catch {file delete -force test.db-journal}
drh46934232004-11-20 19:18:00 +0000108 sqlite_malloc_fail $i [expr {$i%4}]
drhef4ac8f2004-06-19 00:16:31 +0000109 set v [catch {sqlite3 db test.db} msg]
drh6d4abfb2001-10-22 02:58:08 +0000110 if {$v} {
111 set msg ""
112 } else {
113 set v [catch {execsql {
114 CREATE TABLE t1(
115 a int, b float, c double, d text, e varchar(20),
116 primary key(a,b,c)
117 );
118 CREATE INDEX i1 ON t1(a,b);
119 INSERT INTO t1 VALUES(1,2.3,4.5,'hi','there');
120 INSERT INTO t1 VALUES(6,7.0,0.8,'hello','out yonder');
121 SELECT * FROM t1;
122 SELECT avg(b) FROM t1 GROUP BY a HAVING b>20.0;
123 DELETE FROM t1 WHERE a IN (SELECT min(a) FROM t1);
124 SELECT count(*) FROM t1;
125 }} msg]
126 }
127 set leftover [lindex [sqlite_malloc_stat] 2]
128 if {$leftover>0} {
129 if {$leftover>1} {puts "\nLeftover: $leftover\nReturn=$v Message=$msg"}
drhed7c8552001-04-11 14:29:21 +0000130 set ::go 0
131 set v {1 1}
132 } else {
drh6d4abfb2001-10-22 02:58:08 +0000133 set v2 [expr {$msg=="" || $msg=="out of memory"}]
134 if {!$v2} {puts "\nError message returned: $msg"}
135 lappend v $v2
drhed7c8552001-04-11 14:29:21 +0000136 }
137 } {1 1}
138}
drhd4007282001-04-12 23:21:58 +0000139
danielk1977b5548a82004-06-26 13:51:33 +0000140# Ensure that no file descriptors were leaked.
141do_test malloc-1.X {
142 catch {db close}
143 set sqlite_open_file_count
144} {0}
145
drhd4007282001-04-12 23:21:58 +0000146set fd [open ./data.tmp w]
drh6d4abfb2001-10-22 02:58:08 +0000147for {set i 1} {$i<=20} {incr i} {
drh5f3b4ab2004-05-27 17:22:54 +0000148 puts $fd "$i\t[expr {$i*$i}]\t[expr {100-$i}] abcdefghijklmnopqrstuvwxyz"
drhd4007282001-04-12 23:21:58 +0000149}
150close $fd
151
152for {set go 1; set i 1} {$go} {incr i} {
153 do_test malloc-2.$i {
154 sqlite_malloc_fail 0
drh6d4abfb2001-10-22 02:58:08 +0000155 catch {db close}
156 catch {file delete -force test.db}
157 catch {file delete -force test.db-journal}
drhd4007282001-04-12 23:21:58 +0000158 sqlite_malloc_fail $i
drhef4ac8f2004-06-19 00:16:31 +0000159 set v [catch {sqlite3 db test.db} msg]
drh6d4abfb2001-10-22 02:58:08 +0000160 if {$v} {
161 set msg ""
162 } else {
163 set v [catch {execsql {
164 CREATE TABLE t1(a int, b int, c int);
165 CREATE INDEX i1 ON t1(a,b);
drh5f3b4ab2004-05-27 17:22:54 +0000166 INSERT INTO t1 VALUES(1,1,'99 abcdefghijklmnopqrstuvwxyz');
167 INSERT INTO t1 VALUES(2,4,'98 abcdefghijklmnopqrstuvwxyz');
168 INSERT INTO t1 VALUES(3,9,'97 abcdefghijklmnopqrstuvwxyz');
169 INSERT INTO t1 VALUES(4,16,'96 abcdefghijklmnopqrstuvwxyz');
170 INSERT INTO t1 VALUES(5,25,'95 abcdefghijklmnopqrstuvwxyz');
171 INSERT INTO t1 VALUES(6,36,'94 abcdefghijklmnopqrstuvwxyz');
drh6d4abfb2001-10-22 02:58:08 +0000172 SELECT 'stuff', count(*) as 'other stuff', max(a+10) FROM t1;
173 UPDATE t1 SET b=b||b||b||b;
174 UPDATE t1 SET b=a WHERE a in (10,12,22);
175 INSERT INTO t1(c,b,a) VALUES(20,10,5);
176 INSERT INTO t1 SELECT * FROM t1
177 WHERE a IN (SELECT a FROM t1 WHERE a<10);
178 DELETE FROM t1 WHERE a>=10;
179 DROP INDEX i1;
180 DELETE FROM t1;
181 }} msg]
182 }
183 set leftover [lindex [sqlite_malloc_stat] 2]
184 if {$leftover>0} {
185 if {$leftover>1} {puts "\nLeftover: $leftover\nReturn=$v Message=$msg"}
drhd4007282001-04-12 23:21:58 +0000186 set ::go 0
187 set v {1 1}
188 } else {
drh6d4abfb2001-10-22 02:58:08 +0000189 set v2 [expr {$msg=="" || $msg=="out of memory"}]
190 if {!$v2} {puts "\nError message returned: $msg"}
191 lappend v $v2
192 }
193 } {1 1}
194}
195
danielk1977b5548a82004-06-26 13:51:33 +0000196# Ensure that no file descriptors were leaked.
197do_test malloc-2.X {
198 catch {db close}
199 set sqlite_open_file_count
200} {0}
201
drh6d4abfb2001-10-22 02:58:08 +0000202for {set go 1; set i 1} {$go} {incr i} {
203 do_test malloc-3.$i {
204 sqlite_malloc_fail 0
205 catch {db close}
206 catch {file delete -force test.db}
207 catch {file delete -force test.db-journal}
208 sqlite_malloc_fail $i
drhef4ac8f2004-06-19 00:16:31 +0000209 set v [catch {sqlite3 db test.db} msg]
drh6d4abfb2001-10-22 02:58:08 +0000210 if {$v} {
211 set msg ""
212 } else {
213 set v [catch {execsql {
214 BEGIN TRANSACTION;
215 CREATE TABLE t1(a int, b int, c int);
216 CREATE INDEX i1 ON t1(a,b);
drh5f3b4ab2004-05-27 17:22:54 +0000217 INSERT INTO t1 VALUES(1,1,99);
218 INSERT INTO t1 VALUES(2,4,98);
219 INSERT INTO t1 VALUES(3,9,97);
220 INSERT INTO t1 VALUES(4,16,96);
221 INSERT INTO t1 VALUES(5,25,95);
222 INSERT INTO t1 VALUES(6,36,94);
drh6d4abfb2001-10-22 02:58:08 +0000223 INSERT INTO t1(c,b,a) VALUES(20,10,5);
224 DELETE FROM t1 WHERE a>=10;
225 DROP INDEX i1;
226 DELETE FROM t1;
227 ROLLBACK;
228 }} msg]
229 }
230 set leftover [lindex [sqlite_malloc_stat] 2]
231 if {$leftover>0} {
232 if {$leftover>1} {puts "\nLeftover: $leftover\nReturn=$v Message=$msg"}
233 set ::go 0
234 set v {1 1}
235 } else {
236 set v2 [expr {$msg=="" || $msg=="out of memory"}]
237 if {!$v2} {puts "\nError message returned: $msg"}
238 lappend v $v2
239 }
240 } {1 1}
241}
danielk1977b5548a82004-06-26 13:51:33 +0000242
243# Ensure that no file descriptors were leaked.
244do_test malloc-3.X {
245 catch {db close}
246 set sqlite_open_file_count
247} {0}
248
drh6d4abfb2001-10-22 02:58:08 +0000249for {set go 1; set i 1} {$go} {incr i} {
250 do_test malloc-4.$i {
251 sqlite_malloc_fail 0
252 catch {db close}
253 catch {file delete -force test.db}
254 catch {file delete -force test.db-journal}
255 sqlite_malloc_fail $i
drhef4ac8f2004-06-19 00:16:31 +0000256 set v [catch {sqlite3 db test.db} msg]
drh6d4abfb2001-10-22 02:58:08 +0000257 if {$v} {
258 set msg ""
259 } else {
260 set v [catch {execsql {
261 BEGIN TRANSACTION;
262 CREATE TABLE t1(a int, b int, c int);
263 CREATE INDEX i1 ON t1(a,b);
drh5f3b4ab2004-05-27 17:22:54 +0000264 INSERT INTO t1 VALUES(1,1,99);
265 INSERT INTO t1 VALUES(2,4,98);
266 INSERT INTO t1 VALUES(3,9,97);
267 INSERT INTO t1 VALUES(4,16,96);
268 INSERT INTO t1 VALUES(5,25,95);
269 INSERT INTO t1 VALUES(6,36,94);
drh6d4abfb2001-10-22 02:58:08 +0000270 UPDATE t1 SET b=a WHERE a in (10,12,22);
271 INSERT INTO t1 SELECT * FROM t1
272 WHERE a IN (SELECT a FROM t1 WHERE a<10);
273 DROP INDEX i1;
274 DELETE FROM t1;
275 COMMIT;
276 }} msg]
277 }
278 set leftover [lindex [sqlite_malloc_stat] 2]
279 if {$leftover>0} {
280 if {$leftover>1} {puts "\nLeftover: $leftover\nReturn=$v Message=$msg"}
281 set ::go 0
282 set v {1 1}
283 } else {
284 set v2 [expr {$msg=="" || $msg=="out of memory"}]
285 if {!$v2} {puts "\nError message returned: $msg"}
286 lappend v $v2
drhd4007282001-04-12 23:21:58 +0000287 }
288 } {1 1}
289}
danielk1977b5548a82004-06-26 13:51:33 +0000290
291# Ensure that no file descriptors were leaked.
292do_test malloc-4.X {
293 catch {db close}
294 set sqlite_open_file_count
295} {0}
296
drhe4697f52002-05-23 02:09:03 +0000297for {set go 1; set i 1} {$go} {incr i} {
298 do_test malloc-5.$i {
299 sqlite_malloc_fail 0
300 catch {db close}
301 catch {file delete -force test.db}
302 catch {file delete -force test.db-journal}
303 sqlite_malloc_fail $i
drhef4ac8f2004-06-19 00:16:31 +0000304 set v [catch {sqlite3 db test.db} msg]
drhe4697f52002-05-23 02:09:03 +0000305 if {$v} {
306 set msg ""
307 } else {
308 set v [catch {execsql {
309 BEGIN TRANSACTION;
310 CREATE TABLE t1(a,b);
311 CREATE TABLE t2(x,y);
312 CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
313 INSERT INTO t2(x,y) VALUES(new.rowid,1);
314 END;
315 INSERT INTO t1(a,b) VALUES(2,3);
316 COMMIT;
317 }} msg]
318 }
319 set leftover [lindex [sqlite_malloc_stat] 2]
320 if {$leftover>0} {
321 if {$leftover>1} {puts "\nLeftover: $leftover\nReturn=$v Message=$msg"}
322 set ::go 0
323 set v {1 1}
324 } else {
325 set v2 [expr {$msg=="" || $msg=="out of memory"}]
326 if {!$v2} {puts "\nError message returned: $msg"}
327 lappend v $v2
328 }
329 } {1 1}
330}
danielk1977b5548a82004-06-26 13:51:33 +0000331
332# Ensure that no file descriptors were leaked.
333do_test malloc-5.X {
334 catch {db close}
335 set sqlite_open_file_count
336} {0}
337
danielk197796fb0dd2004-06-30 09:49:22 +0000338for {set go 1; set i 1} {$go} {incr i} {
339 do_test malloc-6.$i {
340 sqlite_malloc_fail 0
341 catch {db close}
342 catch {file delete -force test.db}
343 catch {file delete -force test.db-journal}
344 sqlite3 db test.db
345 execsql {
346 BEGIN TRANSACTION;
347 CREATE TABLE t1(a);
348 INSERT INTO t1 VALUES(1);
349 INSERT INTO t1 SELECT a*2 FROM t1;
350 INSERT INTO t1 SELECT a*2 FROM t1;
351 INSERT INTO t1 SELECT a*2 FROM t1;
352 INSERT INTO t1 SELECT a*2 FROM t1;
353 INSERT INTO t1 SELECT a*2 FROM t1;
354 INSERT INTO t1 SELECT a*2 FROM t1;
355 INSERT INTO t1 SELECT a*2 FROM t1;
356 INSERT INTO t1 SELECT a*2 FROM t1;
357 INSERT INTO t1 SELECT a*2 FROM t1;
358 INSERT INTO t1 SELECT a*2 FROM t1;
359 DELETE FROM t1 where rowid%5 = 0;
360 COMMIT;
361 }
362 sqlite_malloc_fail $i
363 set v [catch {execsql {
364 VACUUM;
365 }} msg]
366 set leftover [lindex [sqlite_malloc_stat] 2]
367 if {$leftover>0} {
368 if {$leftover>1} {puts "\nLeftover: $leftover\nReturn=$v Message=$msg"}
369 set ::go 0
370 set v {1 1}
371 } else {
372 set v2 [expr {$msg=="" || $msg=="out of memory"}]
373 if {!$v2} {puts "\nError message returned: $msg"}
374 lappend v $v2
375 }
376 } {1 1}
377}
378
danielk197701427a62005-01-11 13:02:33 +0000379for {set go 1; set i 1} {$go} {incr i} {
380 do_test malloc-7.$i {
381 sqlite_malloc_fail 0
382 catch {db close}
383 catch {file delete -force test.db}
384 catch {file delete -force test.db-journal}
385 sqlite3 db test.db
386 execsql {
387 CREATE TABLE t1(a, b);
388 INSERT INTO t1 VALUES(1, 2);
389 INSERT INTO t1 VALUES(3, 4);
390 INSERT INTO t1 VALUES(5, 6);
danielk1977b5402fb2005-01-12 07:15:04 +0000391 INSERT INTO t1 VALUES(7, randstr(1200,1200));
danielk197701427a62005-01-11 13:02:33 +0000392 }
393 sqlite_malloc_fail $i
394 set v [catch {execsql {
danielk1977b5402fb2005-01-12 07:15:04 +0000395 SELECT min(a) FROM t1 WHERE a<6 GROUP BY b;
396 SELECT a FROM t1 WHERE a<6 ORDER BY a;
397 SELECT b FROM t1 WHERE a>6;
danielk197701427a62005-01-11 13:02:33 +0000398 }} msg]
399 set leftover [lindex [sqlite_malloc_stat] 2]
400 if {$leftover>0} {
401 if {$leftover>1} {puts "\nLeftover: $leftover\nReturn=$v Message=$msg"}
402 set ::go 0
403 set v {1 1}
404 } else {
405 set v2 [expr {$msg=="" || $msg=="out of memory"}]
406 if {!$v2} {puts "\nError message returned: $msg"}
407 lappend v $v2
408 }
409 } {1 1}
410}
411
danielk1977b5402fb2005-01-12 07:15:04 +0000412# This block is designed to test that some malloc failures that may
413# occur in vdbeapi.c. Specifically, if a malloc failure that occurs
414# when converting UTF-16 text to integers and real numbers is handled
415# correctly.
416#
danielk19778b60e0f2005-01-12 09:10:39 +0000417# This is done by retrieving a string from the database engine and
418# manipulating it using the sqlite3_column_*** APIs. This doesn't
419# actually return an error to the user when a malloc() fails.. That
420# could be viewed as a bug.
421#
422# These tests only run if UTF-16 support is compiled in.
danielk1977b5402fb2005-01-12 07:15:04 +0000423#
424for {set go 1; set i 1} {$go && $::sqlite_options(utf16)} {incr i} {
425 do_test malloc-8.$i {
426 sqlite_malloc_fail 0
427 catch {db close}
428 catch {file delete -force test.db}
429 catch {file delete -force test.db-journal}
430
431 set ::DB [sqlite3 db test.db]
432 set sql "SELECT '[string repeat abc 20]', '[string repeat def 20]', ?"
433 set ::STMT [sqlite3_prepare $::DB $sql -1 X]
434 sqlite3_step $::STMT
435
436 if { $::tcl_platform(byteOrder)=="littleEndian" } {
437 set ::bomstr "\xFF\xFE"
438 } else {
439 set ::bomstr "\xFE\xFF"
440 }
441 append ::bomstr [encoding convertto unicode "123456789_123456789_12345678"]
442
443 sqlite_malloc_fail $i
444 catch {
445 sqlite3_column_text16 $::STMT 0
446 sqlite3_column_int $::STMT 0
447 sqlite3_column_text16 $::STMT 1
448 sqlite3_column_double $::STMT 1
449 sqlite3_reset $::STMT
450 sqlite3_bind_text16 $::STMT 1 $::bomstr 60
451
452 } msg
453 sqlite3_finalize $::STMT
454 if {[lindex [sqlite_malloc_stat] 2]>0} {
455 set ::go 0
456 }
457 expr 0
458 } {0}
459}
460
danielk19774397de52005-01-12 12:44:03 +0000461
danielk19778b60e0f2005-01-12 09:10:39 +0000462# This block tests that malloc() failures that occur whilst commiting
463# a multi-file transaction are handled correctly.
464#
danielk19774397de52005-01-12 12:44:03 +0000465do_malloc_test 9 -sqlprep {
466 ATTACH 'test2.db' as test2;
467 CREATE TABLE abc1(a, b, c);
468 CREATE TABLE test2.abc2(a, b, c);
469} -sqlbody {
470 BEGIN;
471 INSERT INTO abc1 VALUES(1, 2, 3);
472 INSERT INTO abc2 VALUES(1, 2, 3);
473 COMMIT;
danielk19778b60e0f2005-01-12 09:10:39 +0000474}
475
danielk19774397de52005-01-12 12:44:03 +0000476# This block tests malloc() failures that occur while opening a
477# connection to a database.
478do_malloc_test 10 -sqlprep {
479 CREATE TABLE abc(a, b, c);
480} -tclbody {
481 set ::DB [sqlite3 db2 test.db]
482 db2 eval {SELECT * FROM sqlite_master}
483 db2 close
484}
485
486# This block tests malloc() failures that occur within calls to
487# sqlite3_create_function().
488do_malloc_test 11 -tclbody {
danielk19772c336542005-01-13 02:14:23 +0000489 set rc [sqlite3_create_function $::DB]
490 if {[string match $rc SQLITE_NOMEM]} {
danielk19774397de52005-01-12 12:44:03 +0000491 error "out of memory"
492 }
493}
494
495do_malloc_test 12 -tclbody {
496 set sql16 [encoding convertto unicode "SELECT * FROM sqlite_master"]
497 append sql16 "\00\00"
498 set ::STMT [sqlite3_prepare16 $::DB $sql16 -1 DUMMY]
499 sqlite3_finalize $::STMT
500}
danielk19778b60e0f2005-01-12 09:10:39 +0000501
danielk1977aca790a2005-01-13 11:07:52 +0000502# Test malloc errors when replaying two hot journals from a 2-file
503# transaction. This test only runs on UNIX.
504if {$tcl_platform(platform)=="unix"} {
505 do_malloc_test 13 -tclprep {
506 set rc [crashsql 1 test2.db {
507 ATTACH 'test2.db' as aux;
508 PRAGMA cache_size = 10;
509 BEGIN;
510 CREATE TABLE aux.t2(a, b, c);
511 CREATE TABLE t1(a, b, c);
512 COMMIT;
513 }]
514 if {$rc!="1 {child process exited abnormally}"} {
515 error "Wrong error message: $rc"
516 }
517 } -sqlbody {
518 ATTACH 'test2.db' as aux;
519 SELECT * FROM t1;
520 SELECT * FROM t2;
521 }
522}
523
524do_malloc_test 14 -tclprep {
525 catch {db close}
526 sqlite3 db2 test2.db
527 db2 eval {
528 PRAGMA synchronous = 0;
529 CREATE TABLE t1(a, b);
530 INSERT INTO t1 VALUES(1, 2);
531 BEGIN;
532 INSERT INTO t1 VALUES(3, 4);
533 }
534 file copy -force test2.db test.db
535 file copy -force test2.db-journal test.db-journal
536 db2 close
537} -tclbody {
538 sqlite3 db test.db
539 db eval {
540 SELECT * FROM t1;
541 }
542}
543
danielk197796fb0dd2004-06-30 09:49:22 +0000544# Ensure that no file descriptors were leaked.
danielk1977b5402fb2005-01-12 07:15:04 +0000545do_test malloc-99.X {
danielk197796fb0dd2004-06-30 09:49:22 +0000546 catch {db close}
547 set sqlite_open_file_count
548} {0}
549
drhed7c8552001-04-11 14:29:21 +0000550sqlite_malloc_fail 0
551finish_test