Index: third_party/sqlite/src/test/malloc.test |
diff --git a/third_party/sqlite/src/test/malloc.test b/third_party/sqlite/src/test/malloc.test |
index 678b2be075fe8e2f831790c123f4e4b0f7f7032d..86145672a218a671aa2573307e8282b0ff0fdda9 100644 |
--- a/third_party/sqlite/src/test/malloc.test |
+++ b/third_party/sqlite/src/test/malloc.test |
@@ -20,6 +20,7 @@ |
set testdir [file dirname $argv0] |
source $testdir/tester.tcl |
+set ::testprefix malloc |
# Only run these tests if memory debugging is turned on. |
@@ -270,7 +271,7 @@ do_malloc_test 9 -sqlprep { |
do_malloc_test 10 -tclprep { |
catch {db2 close} |
db close |
- file delete -force test.db test.db-journal |
+ forcedelete test.db test.db-journal |
sqlite3 db test.db |
sqlite3_extended_result_codes db 1 |
db eval {CREATE TABLE abc(a, b, c)} |
@@ -341,8 +342,8 @@ if {$tcl_platform(platform)!="windows"} { |
BEGIN; |
INSERT INTO t1 VALUES(3, 4); |
} |
- copy_file test2.db test.db |
- copy_file test2.db-journal test.db-journal |
+ forcecopy test2.db test.db |
+ forcecopy test2.db-journal test.db-journal |
db2 close |
} -tclbody { |
sqlite3 db test.db |
@@ -499,7 +500,7 @@ unset static_string |
ifcapable attach { |
do_malloc_test 20 -tclprep { |
db close |
- file delete -force test2.db test2.db-journal |
+ forcedelete test2.db test2.db-journal |
sqlite3 db test2.db |
sqlite3_extended_result_codes db 1 |
db eval {CREATE TABLE t1(x);} |
@@ -842,7 +843,7 @@ do_malloc_test 36 -sqlprep { |
SELECT test_agg_errmsg16(), group_concat(a) FROM t1 |
} |
-# At one point, if an OOM occured immediately after obtaining a shared lock |
+# At one point, if an OOM occurred immediately after obtaining a shared lock |
# on the database file, the file remained locked. This test case ensures |
# that bug has been fixed.i |
if {[db eval {PRAGMA locking_mode}]!="exclusive"} { |
@@ -867,31 +868,59 @@ if {[db eval {PRAGMA locking_mode}]!="exclusive"} { |
catch { db2 close } |
} |
-ifcapable stat2&&utf16 { |
- do_malloc_test 38 -tclprep { |
- add_test_collate db 0 0 1 |
- execsql { |
- ANALYZE; |
- CREATE TABLE t4(x COLLATE test_collate); |
- CREATE INDEX t4x ON t4(x); |
- INSERT INTO sqlite_stat2 VALUES('t4', 't4x', 0, 'aaa'); |
- INSERT INTO sqlite_stat2 VALUES('t4', 't4x', 1, 'aaa'); |
- INSERT INTO sqlite_stat2 VALUES('t4', 't4x', 2, 'aaa'); |
- INSERT INTO sqlite_stat2 VALUES('t4', 't4x', 3, 'aaa'); |
- INSERT INTO sqlite_stat2 VALUES('t4', 't4x', 4, 'aaa'); |
- INSERT INTO sqlite_stat2 VALUES('t4', 't4x', 5, 'aaa'); |
- INSERT INTO sqlite_stat2 VALUES('t4', 't4x', 6, 'aaa'); |
- INSERT INTO sqlite_stat2 VALUES('t4', 't4x', 7, 'aaa'); |
- INSERT INTO sqlite_stat2 VALUES('t4', 't4x', 8, 'aaa'); |
- INSERT INTO sqlite_stat2 VALUES('t4', 't4x', 9, 'aaa'); |
- } |
- db close |
- sqlite3 db test.db |
- sqlite3_db_config_lookaside db 0 0 0 |
- add_test_collate db 0 0 1 |
- } -sqlbody { |
- SELECT * FROM t4 AS t41, t4 AS t42 WHERE t41.x>'ddd' AND t42.x>'ccc' |
+ |
+# Test that if an OOM error occurs, aux-data is still correctly destroyed. |
+# This test case was causing either a memory-leak or an assert() failure |
+# at one point, depending on the configuration. |
+# |
+do_malloc_test 39 -tclprep { |
+ sqlite3 db test.db |
+} -sqlbody { |
+ SELECT test_auxdata('abc', 'def'); |
+} -cleanup { |
+ db close |
+} |
+ |
+reset_db |
+add_test_utf16bin_collate db |
+do_execsql_test 40.1 { |
+ CREATE TABLE t1(a); |
+ INSERT INTO t1 VALUES('fghij'); |
+ INSERT INTO t1 VALUES('pqrst'); |
+ INSERT INTO t1 VALUES('abcde'); |
+ INSERT INTO t1 VALUES('uvwxy'); |
+ INSERT INTO t1 VALUES('klmno'); |
+} |
+do_execsql_test 40.2 { |
+ SELECT * FROM t1 ORDER BY 1 COLLATE utf16bin; |
+} {abcde fghij klmno pqrst uvwxy} |
+do_faultsim_test 40.3 -faults oom-trans* -body { |
+ execsql { |
+ SELECT * FROM t1 ORDER BY 1 COLLATE utf16bin; |
} |
+} -test { |
+ faultsim_test_result {0 {abcde fghij klmno pqrst uvwxy}} |
+ faultsim_integrity_check |
+} |
+ |
+reset_db |
+add_test_utf16bin_collate db |
+set big [string repeat x 200] |
+do_execsql_test 41.1 { |
+ DROP TABLE IF EXISTS t1; |
+ CREATE TABLE t1(a COLLATE utf16bin); |
+ INSERT INTO t1 VALUES('fghij' || $::big); |
+ INSERT INTO t1 VALUES('pqrst' || $::big); |
+ INSERT INTO t1 VALUES('abcde' || $::big); |
+ INSERT INTO t1 VALUES('uvwxy' || $::big); |
+ INSERT INTO t1 VALUES('klmno' || $::big); |
+ CREATE INDEX i1 ON t1(a); |
+} |
+do_faultsim_test 41.2 -faults oom* -body { |
+ execsql { SELECT * FROM t1 WHERE a = ('abcde' || $::big)} |
+} -test { |
+ faultsim_test_result [list 0 "abcde$::big"] |
+ faultsim_integrity_check |
} |
# Ensure that no file descriptors were leaked. |