1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-30 19:03:16 +03:00

Remove the malloc2.test script since it was designed for use in versions

of SQLite that predate SQLite's ability to recover from out-of-memory
errors automatically.  Removing this script causes no reduction in
test coverage and removes potential problems reported by ticket #3213. (CVS 5409)

FossilOrigin-Name: 5bfc962533995530a0ef0875556f9f46e8dbf68b
This commit is contained in:
drh
2008-07-14 15:11:20 +00:00
parent ff1590ee00
commit 582de4f297
5 changed files with 11 additions and 364 deletions

View File

@ -1,5 +1,5 @@
C Write\ssqlite3_initialize()\scalls\sin\ssqlite3_malloc()\swithin\nSQLITE_OMIT_AUTOINIT.\s\sTicket\s#3217.\s(CVS\s5408)
D 2008-07-14T12:52:53
C Remove\sthe\smalloc2.test\sscript\ssince\sit\swas\sdesigned\sfor\suse\sin\sversions\nof\sSQLite\sthat\spredate\sSQLite's\sability\sto\srecover\sfrom\sout-of-memory\nerrors\sautomatically.\s\sRemoving\sthis\sscript\scauses\sno\sreduction\sin\ntest\scoverage\sand\sremoves\spotential\sproblems\sreported\sby\sticket\s#3213.\s(CVS\s5409)
D 2008-07-14T15:11:20
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
F Makefile.in a03f7cb4f7ad50bc53a788c6c544430e81f95de4
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@ -193,7 +193,7 @@ F src/vtab.c 2096c03ec5540a43c8c73a8f43407dfd3549a982
F src/where.c e4c40d224cc6931bece3a33b35bd6b6a8deade3f
F tclinstaller.tcl 4356d9d94d2b5ed5e68f9f0c80c4df3048dd7617
F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
F test/all.test ed6849e7a425620d5d4388409f3b15901b5bc2e7
F test/all.test 89e09ed0074083ac6f208dc3243429e8f89efb69
F test/alter.test 6353aae6839e486c9b7d8f73b1f4a1e98e57332c
F test/alter2.test dd55146e812622c8fc51fd2216bcd8dca8880752
F test/alter3.test 25b95a136708f22b87184fa6a4309eea03d65153
@ -226,7 +226,7 @@ F test/capi2.test cc64df7560a96f848f919ea2926c60acf639684b
F test/capi3.test ffc1156d1f28738eb335df0b88dd294bb3c94c27
F test/capi3b.test 664eb55318132f292f2c436f90906f578cad6b97
F test/capi3c.test 208713e5f3a63442c3574c55b83baa7cf8ac5f28
F test/capi3d.test 537de3a1f724862e327e02bb21b4a84f185dc1e2
F test/capi3d.test 57d83b690d7364bde02cddbf8339a4b50d80ce23
F test/cast.test ce8f14fc80f70b30ed984480cc0d8914a459e8f9
F test/check.test 024ed399600b799160378cf9d9f436bdf5dfd184
F test/collate1.test e3eaa48c21e150814be1a7b852d2a8af24458d04
@ -386,7 +386,6 @@ F test/lock4.test 09d97d52cae18fadfe631552af9880dac6b3ae90
F test/lock5.test f4eeb0400cf65c37f733cb3c74401136f8c46acd
F test/main.test 8d77c161757ef7d96eaff0413daa7120c3b316fe
F test/malloc.test 69f5bb5a13b24edb1322fc1f42894f9d2f6446b1
F test/malloc2.test c847c457d37cf37ff9ff989fa6bd1475f714e485
F test/malloc3.test 094f8195fe8e409bd4da0f1d769f7745faec62c8
F test/malloc4.test 957337613002b7058a85116493a262f679f3a261
F test/malloc5.test 1a68e56e513eab54d8c4cd1b769ff1d14e3f99f4
@ -605,7 +604,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81
F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
F tool/speedtest8.c 1dbced29de5f59ba2ebf877edcadf171540374d1
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
P 518a24aa3e042782fbf2e805cf080b61e58a8150
R 4e2c99acbcab1443d7a9872c7dddaedc
P 4961b0bbe8b9cf5fb27de7f2514e8ab399a00134
R 65a91dac815025c38b80c9e74c9e131b
U drh
Z 4ac79f627b8500f6ab489bf729aabafc
Z a7a9dcd0eb2d9135eecea29892bd5027

View File

@ -1 +1 @@
4961b0bbe8b9cf5fb27de7f2514e8ab399a00134
5bfc962533995530a0ef0875556f9f46e8dbf68b

View File

@ -10,7 +10,7 @@
#***********************************************************************
# This file runs all tests.
#
# $Id: all.test,v 1.56 2008/06/21 19:20:13 danielk1977 Exp $
# $Id: all.test,v 1.57 2008/07/14 15:11:20 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@ -74,15 +74,6 @@ lappend EXCLUDE mallocAll.test ;# Wrapper for running all malloc tests
set INCLUDE {
}
# Test files btree2.test and btree4.test don't work if the
# SQLITE_DEFAULT_AUTOVACUUM macro is defined to true (because they depend
# on tables being allocated starting at page 2).
#
ifcapable default_autovacuum {
lappend EXCLUDE btree2.test
lappend EXCLUDE btree4.test
}
for {set Counter 0} {$Counter<$COUNT && $nErr==0} {incr Counter} {
if {$Counter%2} {
set ::SETUP_SQL {PRAGMA default_synchronous=off;}

View File

@ -12,7 +12,7 @@
#
# This file is devoted to testing the sqlite3_next_stmt interface.
#
# $Id: capi3d.test,v 1.1 2008/06/19 02:52:25 drh Exp $
# $Id: capi3d.test,v 1.2 2008/07/14 15:11:20 drh Exp $
#
set testdir [file dirname $argv0]
@ -64,6 +64,7 @@ proc scramble {inlist} {
# Database initially has no prepared statements.
#
do_test capi3d-1.1 {
db cache flush
sqlite3_next_stmt db 0
} {}

View File

@ -1,344 +0,0 @@
# 2005 March 18
#
# The author disclaims copyright to this source code. In place of
# a legal notice, here is a blessing:
#
# May you do good and not evil.
# May you find forgiveness for yourself and forgive others.
# May you share freely, never taking more than you give.
#
#***********************************************************************
#
# This file attempts to check that the library can recover from a malloc()
# failure when sqlite3_global_recover() is invoked.
#
# (Later:) The sqlite3_global_recover() interface is now a no-op.
# Recovery from malloc() failures is automatic. But we keep these
# tests around because you can never have too many test cases.
#
# $Id: malloc2.test,v 1.13 2008/06/19 18:17:50 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
source $testdir/malloc_common.tcl
# Only run these tests if memory debugging is turned on.
#
if {!$MEMDEBUG} {
puts "Skipping malloc tests: not compiled with -DSQLITE_MEMDEBUG..."
finish_test
return
}
sqlite3_extended_result_codes db 1
proc do_malloc2_test {tn args} {
array set ::mallocopts $args
set sum [allcksum db]
save_prng_state
for {set ::n 1} {true} {incr ::n} {
# Run the SQL. Malloc number $::n is set to fail. A malloc() failure
# may or may not be reported.
restore_prng_state
sqlite3_memdebug_fail $::n -repeat 1
do_test malloc2-$tn.$::n.2 {
set res [catchsql [string trim $::mallocopts(-sql)]]
set rc [expr {
0==[string compare $res {1 {out of memory}}] ||
[db errorcode] == 3082 ||
0==[lindex $res 0]
}]
if {$rc!=1} {
puts "Error: $res"
}
set rc
} {1}
# If $::n is greater than the number of malloc() calls required to
# execute the SQL, then this test is finished. Break out of the loop.
set nFail [sqlite3_memdebug_fail -1 -benigncnt nBenign]
incr nFail [expr {-1*$nBenign}]
if {$nFail==0} break
# Nothing should work now, because the allocator should refuse to
# allocate any memory.
#
# Update: SQLite now automatically recovers from a malloc() failure.
# So the statement in the test below would work.
if 0 {
do_test malloc2-$tn.$::n.3 {
catchsql {SELECT 'nothing should work'}
} {1 {out of memory}}
}
# Recover from the malloc failure.
#
# Update: The new malloc() failure handling means that a transaction may
# still be active even if a malloc() has failed. But when these tests were
# written this was not the case. So do a manual ROLLBACK here so that the
# tests pass.
do_test malloc2-$tn.$::n.4 {
sqlite3_global_recover
catch {
execsql {
ROLLBACK;
}
}
expr 0
} {0}
# Checksum the database.
do_test malloc2-$tn.$::n.5 {
allcksum db
} $sum
integrity_check malloc2-$tn.$::n.6
if {$::nErr>1} return
}
unset ::mallocopts
}
do_test malloc2.1.setup {
execsql {
CREATE TABLE abc(a, b, c);
INSERT INTO abc VALUES(10, 20, 30);
INSERT INTO abc VALUES(40, 50, 60);
CREATE INDEX abc_i ON abc(a, b, c);
}
} {}
do_malloc2_test 1.1 -sql {
SELECT * FROM abc;
}
do_malloc2_test 1.2 -sql {
UPDATE abc SET c = c+10;
}
do_malloc2_test 1.3 -sql {
INSERT INTO abc VALUES(70, 80, 90);
}
do_malloc2_test 1.4 -sql {
DELETE FROM abc;
}
do_test malloc2.1.5 {
execsql {
SELECT * FROM abc;
}
} {}
do_test malloc2.2.setup {
execsql {
CREATE TABLE def(a, b, c);
CREATE INDEX def_i1 ON def(a);
CREATE INDEX def_i2 ON def(c);
BEGIN;
}
for {set i 0} {$i<20} {incr i} {
execsql {
INSERT INTO def VALUES(randstr(300,300),randstr(300,300),randstr(300,300));
}
}
execsql {
COMMIT;
}
} {}
do_malloc2_test 2 -sql {
BEGIN;
UPDATE def SET a = randstr(100,100) WHERE (oid%9)==0;
INSERT INTO def SELECT * FROM def WHERE (oid%13)==0;
CREATE INDEX def_i3 ON def(b);
UPDATE def SET a = randstr(100,100) WHERE (oid%9)==1;
INSERT INTO def SELECT * FROM def WHERE (oid%13)==1;
CREATE TABLE def2 AS SELECT * FROM def;
DROP TABLE def;
CREATE TABLE def AS SELECT * FROM def2;
DROP TABLE def2;
DELETE FROM def WHERE (oid%9)==2;
INSERT INTO def SELECT * FROM def WHERE (oid%13)==2;
COMMIT;
}
ifcapable tempdb {
do_test malloc2.3.setup {
execsql {
CREATE TEMP TABLE ghi(a, b, c);
BEGIN;
}
for {set i 0} {$i<20} {incr i} {
execsql {
INSERT INTO ghi VALUES(
randstr(300,300), randstr(300,300), randstr(300,300)
);
}
}
execsql {
COMMIT;
}
} {}
do_malloc2_test 3 -sql {
BEGIN;
CREATE INDEX ghi_i1 ON ghi(a);
UPDATE def SET a = randstr(100,100) WHERE (oid%2)==0;
UPDATE ghi SET a = randstr(100,100) WHERE (oid%2)==0;
COMMIT;
}
}
############################################################################
# The test cases below are to increase the code coverage in btree.c and
# pager.c of this test file. The idea is that each malloc() that occurs in
# these two source files should be made to fail at least once.
#
catchsql {
DROP TABLE ghi;
}
do_malloc2_test 4.1 -sql {
SELECT * FROM def ORDER BY oid ASC;
SELECT * FROM def ORDER BY oid DESC;
}
do_malloc2_test 4.2 -sql {
PRAGMA cache_size = 10;
BEGIN;
-- This will put about 25 pages on the free list.
DELETE FROM def WHERE 1;
-- Allocate 32 new root pages. This will exercise the 'extract specific
-- page from the freelist' code when in auto-vacuum mode (see the
-- allocatePage() routine in btree.c).
CREATE TABLE t1(a UNIQUE, b UNIQUE, c UNIQUE);
CREATE TABLE t2(a UNIQUE, b UNIQUE, c UNIQUE);
CREATE TABLE t3(a UNIQUE, b UNIQUE, c UNIQUE);
CREATE TABLE t4(a UNIQUE, b UNIQUE, c UNIQUE);
CREATE TABLE t5(a UNIQUE, b UNIQUE, c UNIQUE);
CREATE TABLE t6(a UNIQUE, b UNIQUE, c UNIQUE);
CREATE TABLE t7(a UNIQUE, b UNIQUE, c UNIQUE);
CREATE TABLE t8(a UNIQUE, b UNIQUE, c UNIQUE);
ROLLBACK;
}
########################################################################
# Test that the global linked list of database handles works. An assert()
# will fail if there is some problem.
do_test malloc2-5 {
sqlite3 db1 test.db
sqlite3 db2 test.db
sqlite3 db3 test.db
sqlite3 db4 test.db
sqlite3 db5 test.db
sqlite3_extended_result_codes db1 1
sqlite3_extended_result_codes db2 1
sqlite3_extended_result_codes db3 1
sqlite3_extended_result_codes db4 1
sqlite3_extended_result_codes db5 1
# Close the head of the list:
db5 close
# Close the end of the list:
db1 close
# Close a handle from the middle of the list:
db3 close
# Close the other two. Then open and close one more database, to make
# sure the head of the list was set back to NULL.
db2 close
db4 close
sqlite db1 test.db
db1 close
} {}
########################################################################
# Check that if a statement is active sqlite3_global_recover doesn't reset
# the sqlite3_malloc_failed variable.
#
# Update: There is now no sqlite3_malloc_failed variable, so these tests
# are not run.
#
# do_test malloc2-6.1 {
# set ::STMT [sqlite3_prepare $::DB {SELECT * FROM def} -1 DUMMY]
# sqlite3_step $::STMT
# } {SQLITE_ROW}
# do_test malloc2-6.2 {
# sqlite3 db1 test.db
# sqlite_malloc_fail 100
# catchsql {
# SELECT * FROM def;
# } db1
# } {1 {out of memory}}
# do_test malloc2-6.3 {
# sqlite3_global_recover
# } {SQLITE_BUSY}
# do_test malloc2-6.4 {
# catchsql {
# SELECT 'hello';
# }
# } {1 {out of memory}}
# do_test malloc2-6.5 {
# sqlite3_reset $::STMT
# } {SQLITE_OK}
# do_test malloc2-6.6 {
# sqlite3_global_recover
# } {SQLITE_OK}
# do_test malloc2-6.7 {
# catchsql {
# SELECT 'hello';
# }
# } {0 hello}
# do_test malloc2-6.8 {
# sqlite3_step $::STMT
# } {SQLITE_ERROR}
# do_test malloc2-6.9 {
# sqlite3_finalize $::STMT
# } {SQLITE_SCHEMA}
# do_test malloc2-6.10 {
# db1 close
# } {}
########################################################################
# Check that if an in-memory database is being used it is not possible
# to recover from a malloc() failure.
#
# Update: An in-memory database can now survive a malloc() failure, so these
# tests are not run.
#
# ifcapable memorydb {
# do_test malloc2-7.1 {
# sqlite3 db1 :memory:
# list
# } {}
# do_test malloc2-7.2 {
# sqlite_malloc_fail 100
# catchsql {
# SELECT * FROM def;
# }
# } {1 {out of memory}}
# do_test malloc2-7.3 {
# sqlite3_global_recover
# } {SQLITE_ERROR}
# do_test malloc2-7.4 {
# catchsql {
# SELECT 'hello';
# }
# } {1 {out of memory}}
# do_test malloc2-7.5 {
# db1 close
# } {}
# do_test malloc2-7.6 {
# sqlite3_global_recover
# } {SQLITE_OK}
# do_test malloc2-7.7 {
# catchsql {
# SELECT 'hello';
# }
# } {0 hello}
# }
finish_test