Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: third_party/sqlite/src/test/mallocA.test

Issue 901033002: Import SQLite 3.8.7.4. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Chromium changes to support SQLite 3.8.7.4. Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # 2007 April 30 1 # 2007 April 30
2 # 2 #
3 # The author disclaims copyright to this source code. In place of 3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing: 4 # a legal notice, here is a blessing:
5 # 5 #
6 # May you do good and not evil. 6 # May you do good and not evil.
7 # May you find forgiveness for yourself and forgive others. 7 # May you find forgiveness for yourself and forgive others.
8 # May you share freely, never taking more than you give. 8 # May you share freely, never taking more than you give.
9 # 9 #
10 #*********************************************************************** 10 #***********************************************************************
11 # This file contains additional out-of-memory checks (see malloc.tcl). 11 # This file contains additional out-of-memory checks (see malloc.tcl).
12 # 12 #
13 # $Id: mallocA.test,v 1.8 2008/02/18 22:24:58 drh Exp $ 13 # $Id: mallocA.test,v 1.8 2008/02/18 22:24:58 drh Exp $
14 14
15 set testdir [file dirname $argv0] 15 set testdir [file dirname $argv0]
16 source $testdir/tester.tcl 16 source $testdir/tester.tcl
17 source $testdir/malloc_common.tcl 17 source $testdir/malloc_common.tcl
18 set testprefix mallocA
18 19
19 # Only run these tests if memory debugging is turned on. 20 # Only run these tests if memory debugging is turned on.
20 # 21 #
21 if {!$MEMDEBUG} { 22 if {!$MEMDEBUG} {
22 puts "Skipping mallocA tests: not compiled with -DSQLITE_MEMDEBUG..." 23 puts "Skipping mallocA tests: not compiled with -DSQLITE_MEMDEBUG..."
23 finish_test 24 finish_test
24 return 25 return
25 } 26 }
26 27
27
28 # Construct a test database 28 # Construct a test database
29 # 29 #
30 file delete -force test.db.bu 30 forcedelete test.db.bu
31 db eval { 31 db eval {
32 CREATE TABLE t1(a COLLATE NOCASE,b,c); 32 CREATE TABLE t1(a COLLATE NOCASE,b,c);
33 INSERT INTO t1 VALUES(1,2,3); 33 INSERT INTO t1 VALUES(1,2,3);
34 INSERT INTO t1 VALUES(1,2,4); 34 INSERT INTO t1 VALUES(1,2,4);
35 INSERT INTO t1 VALUES(2,3,4); 35 INSERT INTO t1 VALUES(2,3,4);
36 CREATE INDEX t1i1 ON t1(a); 36 CREATE INDEX t1i1 ON t1(a);
37 CREATE INDEX t1i2 ON t1(b,c); 37 CREATE INDEX t1i2 ON t1(b,c);
38 CREATE TABLE t2(x,y,z); 38 CREATE TABLE t2(x,y,z);
39 } 39 }
40 db close 40 db close
41 file copy test.db test.db.bu 41 copy_file test.db test.db.bu
42
43 42
44 do_malloc_test mallocA-1 -testdb test.db.bu -sqlbody { 43 do_malloc_test mallocA-1 -testdb test.db.bu -sqlbody {
45 ANALYZE 44 ANALYZE
46 } 45 }
47 do_malloc_test mallocA-1.1 -testdb test.db.bu -sqlbody { 46 do_malloc_test mallocA-1.1 -testdb test.db.bu -sqlbody {
48 ANALYZE t1 47 ANALYZE t1
49 } 48 }
50 do_malloc_test mallocA-1.2 -testdb test.db.bu -sqlbody { 49 do_malloc_test mallocA-1.2 -testdb test.db.bu -sqlbody {
51 ANALYZE main 50 ANALYZE main
52 } 51 }
53 do_malloc_test mallocA-1.3 -testdb test.db.bu -sqlbody { 52 do_malloc_test mallocA-1.3 -testdb test.db.bu -sqlbody {
54 ANALYZE main.t1 53 ANALYZE main.t1
55 } 54 }
55
56 ifcapable reindex { 56 ifcapable reindex {
57 do_malloc_test mallocA-2 -testdb test.db.bu -sqlbody { 57 do_malloc_test mallocA-2 -testdb test.db.bu -sqlbody {
58 REINDEX; 58 REINDEX;
59 } 59 }
60 do_malloc_test mallocA-3 -testdb test.db.bu -sqlbody { 60 do_malloc_test mallocA-3 -testdb test.db.bu -sqlbody {
61 REINDEX t1; 61 REINDEX t1;
62 } 62 }
63 do_malloc_test mallocA-4 -testdb test.db.bu -sqlbody { 63 do_malloc_test mallocA-4 -testdb test.db.bu -sqlbody {
64 REINDEX main.t1; 64 REINDEX main.t1;
65 } 65 }
66 do_malloc_test mallocA-5 -testdb test.db.bu -sqlbody { 66 do_malloc_test mallocA-5 -testdb test.db.bu -sqlbody {
67 REINDEX nocase; 67 REINDEX nocase;
68 } 68 }
69 } 69 }
70 70
71 reset_db
72 sqlite3_db_config_lookaside db 0 0 0
73 do_execsql_test 6-prep {
74 CREATE TABLE t1(a, b);
75 CREATE INDEX i1 ON t1(a, b);
76 INSERT INTO t1 VALUES('abc', 'w'); -- rowid=1
77 INSERT INTO t1 VALUES('abc', 'x'); -- rowid=2
78 INSERT INTO t1 VALUES('abc', 'y'); -- rowid=3
79 INSERT INTO t1 VALUES('abc', 'z'); -- rowid=4
80
81 INSERT INTO t1 VALUES('def', 'w'); -- rowid=5
82 INSERT INTO t1 VALUES('def', 'x'); -- rowid=6
83 INSERT INTO t1 VALUES('def', 'y'); -- rowid=7
84 INSERT INTO t1 VALUES('def', 'z'); -- rowid=8
85
86 ANALYZE;
87 }
88
89 do_faultsim_test 6.1 -faults oom* -body {
90 execsql { SELECT rowid FROM t1 WHERE a='abc' AND b='x' }
91 } -test {
92 faultsim_test_result [list 0 2]
93 }
94 do_faultsim_test 6.2 -faults oom* -body {
95 execsql { SELECT rowid FROM t1 WHERE a='abc' AND b<'y' }
96 } -test {
97 faultsim_test_result [list 0 {1 2}]
98 }
99 ifcapable stat3 {
100 do_test 6.3-prep {
101 execsql {
102 PRAGMA writable_schema = 1;
103 CREATE TABLE sqlite_stat4 AS
104 SELECT tbl, idx, neq, nlt, ndlt, sqlite_record(sample) AS sample
105 FROM sqlite_stat3;
106 }
107 } {}
108 do_faultsim_test 6.3 -faults oom* -body {
109 execsql {
110 ANALYZE sqlite_master;
111 SELECT rowid FROM t1 WHERE a='abc' AND b<'y';
112 }
113 } -test {
114 faultsim_test_result [list 0 {1 2}]
115 }
116 }
117
118 do_execsql_test 7.0 {
119 PRAGMA cache_size = 5;
120 }
121 do_faultsim_test 7 -faults oom-trans* -prep {
122 } -body {
123 execsql {
124 WITH r(x,y) AS (
125 SELECT 1, randomblob(100)
126 UNION ALL
127 SELECT x+1, randomblob(100) FROM r
128 LIMIT 1000
129 )
130 SELECT count(x), length(y) FROM r GROUP BY (x%5)
131 }
132 } -test {
133 set res [list 200 100 200 100 200 100 200 100 200 100]
134 faultsim_test_result [list 0 $res]
135 }
136
137
71 # Ensure that no file descriptors were leaked. 138 # Ensure that no file descriptors were leaked.
72 do_test malloc-99.X { 139 do_test malloc-99.X {
73 catch {db close} 140 catch {db close}
74 set sqlite_open_file_count 141 set sqlite_open_file_count
75 } {0} 142 } {0}
76 143
77 file delete -force test.db.bu 144 forcedelete test.db.bu
78 finish_test 145 finish_test
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698