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

Side by Side Diff: third_party/sqlite/src/ext/fts5/test/fts5fault9.test

Issue 2751253002: [sql] Import SQLite 3.17.0. (Closed)
Patch Set: also clang on Linux i386 Created 3 years, 9 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
(Empty)
1 # 2015 September 3
2 #
3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing:
5 #
6 # 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.
9 #
10 #*************************************************************************
11 #
12 # This file is focused on OOM errors.
13 #
14
15 source [file join [file dirname [info script]] fts5_common.tcl]
16 source $testdir/malloc_common.tcl
17 set testprefix fts5fault9
18
19 # If SQLITE_ENABLE_FTS3 is defined, omit this file.
20 ifcapable !fts5 {
21 finish_test
22 return
23 }
24
25 foreach_detail_mode $testprefix {
26
27 fts5_aux_test_functions db
28
29 do_execsql_test 1.0 {
30 CREATE VIRTUAL TABLE t1 USING fts5(a, b, detail=%DETAIL%);
31 INSERT INTO t1(t1, rank) VALUES('pgsz', 32);
32 WITH seq(s) AS ( SELECT 1 UNION ALL SELECT s+1 FROM seq WHERE s<50)
33 INSERT INTO t1 SELECT 'x x x y y y', 'a b c d e f' FROM seq;
34 }
35
36 do_faultsim_test 1 -faults oom-* -body {
37 execsql { SELECT count(*) FROM t1('x AND y') }
38 } -test {
39 faultsim_test_result {0 50}
40 }
41
42 do_execsql_test 2.0 {
43 CREATE VIRTUAL TABLE t2 USING fts5(a, b, detail=%DETAIL%);
44 INSERT INTO t2(t2, rank) VALUES('pgsz', 32);
45 INSERT INTO t2 VALUES('abc cba', 'cba abc');
46 INSERT INTO t2 VALUES('abc cba', 'cba abc');
47 INSERT INTO t2 VALUES('abc cba', 'cba abc');
48
49 INSERT INTO t2 VALUES('axy cyx', 'cyx axy');
50 INSERT INTO t2 VALUES('axy cyx', 'cyx axy');
51 INSERT INTO t2 VALUES('axy cyx', 'cyx axy');
52 }
53
54 do_faultsim_test 2 -faults oom-* -body {
55 execsql { SELECT count(*) FROM t2('a* AND c*') }
56 } -test {
57 faultsim_test_result {0 6}
58 }
59
60
61 do_execsql_test 3.0 {
62 CREATE VIRTUAL TABLE t3 USING fts5(a, detail=%DETAIL%);
63 INSERT INTO t3 VALUES('a x x a x a a a');
64 INSERT INTO t3 VALUES('x a a x a x x x');
65 }
66
67 do_faultsim_test 3.1 -faults oom-* -body {
68 execsql { SELECT highlight(t3, 0, '[', ']') FROM t3('a') }
69 } -test {
70 faultsim_test_result {0 {{[a] x x [a] x [a] [a] [a]} {x [a] [a] x [a] x x x}}}
71 }
72
73 do_faultsim_test 3.2 -faults oom-t* -body {
74 execsql { SELECT fts5_test_poslist2(t3) FROM t3('x') }
75 } -test {
76 faultsim_test_result \
77 {0 {{0.0.1 0.0.2 0.0.4} {0.0.0 0.0.3 0.0.5 0.0.6 0.0.7}}} \
78 {1 SQLITE_NOMEM}
79 }
80
81 #-------------------------------------------------------------------------
82 # Test OOM injection with the xPhraseFirstColumn() API and a tokenizer
83 # uses query synonyms.
84 #
85 fts5_tclnum_register db
86 do_execsql_test 4.0 {
87 CREATE VIRTUAL TABLE t4 USING fts5(x, y, z, detail=%DETAIL%, tokenize=tclnum);
88 INSERT INTO t4 VALUES('one two three', '1 2 3', 'i ii iii');
89 INSERT INTO t4 VALUES('1 2 3', 'i ii iii', 'one two three');
90 INSERT INTO t4 VALUES('i ii iii', 'one two three', 'i ii iii');
91
92 INSERT INTO t4 VALUES('a1 a2 a3', 'a4 a5 a6', 'a7 a8 a9');
93 INSERT INTO t4 VALUES('b1 b2 b3', 'b4 b5 b6', 'b7 b8 b9');
94 INSERT INTO t4 VALUES('c1 c2 c3', 'c4 c5 c6', 'c7 c8 c9');
95 }
96
97 do_faultsim_test 4.1 -faults oom-t* -body {
98 execsql { SELECT rowid, fts5_test_collist(t4) FROM t4('2') }
99 } -test {
100 faultsim_test_result \
101 {0 {1 {0.0 0.1 0.2} 2 {0.0 0.1 0.2} 3 {0.0 0.1 0.2}}} {1 SQLITE_NOMEM}
102 }
103
104 do_faultsim_test 4.2 -faults oom-t* -body {
105 execsql { SELECT rowid, fts5_test_collist(t4) FROM t4('a5 OR b5 OR c5') }
106 } -test {
107 faultsim_test_result \
108 {0 {4 {0.0 0.1 0.2} 5 {1.0 1.1 1.2} 6 {2.0 2.1 2.2}}} {1 SQLITE_NOMEM}
109 }
110
111
112 #-------------------------------------------------------------------------
113 # An OOM within an "ORDER BY rank" query.
114 #
115 db func rnddoc fts5_rnddoc
116 do_execsql_test 5.0 {
117 CREATE VIRTUAL TABLE xx USING fts5(x, y, detail=%DETAIL%);
118 INSERT INTO xx VALUES ('def', 'abc ' || rnddoc(10));
119 INSERT INTO xx VALUES ('def', 'abc abc' || rnddoc(9));
120 INSERT INTO xx VALUES ('def', 'abc abc abc' || rnddoc(8));
121 } {}
122 faultsim_save_and_close
123
124 do_faultsim_test 5 -faults oom-* -prep {
125 faultsim_restore_and_reopen
126 execsql { SELECT * FROM xx }
127 } -body {
128 execsql { SELECT rowid FROM xx('abc AND def') ORDER BY rank }
129 } -test {
130 faultsim_test_result [list 0 {3 2 1}]
131 }
132
133 set doc [string repeat "xyz " 500]
134 do_execsql_test 6.0 {
135 CREATE VIRTUAL TABLE yy USING fts5(y, detail=%DETAIL%);
136 INSERT INTO yy(yy, rank) VALUES('pgsz', 64);
137 INSERT INTO yy VALUES ($doc);
138 INSERT INTO yy VALUES ('1 2 3');
139 INSERT INTO yy VALUES ('xyz');
140 UPDATE yy SET y = y WHERE rowid = 1;
141 UPDATE yy SET y = y WHERE rowid = 1;
142 UPDATE yy SET y = y WHERE rowid = 1;
143 UPDATE yy SET y = y WHERE rowid = 1;
144 } {}
145
146 do_faultsim_test 6 -faults oom-* -body {
147 execsql { SELECT rowid FROM yy('xyz') }
148 } -test {
149 faultsim_test_result [list 0 {1 3}]
150 }
151
152
153 } ;# foreach_detail_mode...
154
155 finish_test
156
OLDNEW
« no previous file with comments | « third_party/sqlite/src/ext/fts5/test/fts5fault8.test ('k') | third_party/sqlite/src/ext/fts5/test/fts5faultA.test » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698