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

Side by Side Diff: third_party/sqlite/src/ext/fts5/test/fts5ab.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
1 # 2014 June 17 1 # 2014 June 17
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 implements regression tests for SQLite library. The 11 # This file implements regression tests for SQLite library. The
12 # focus of this script is testing the FTS5 module. 12 # focus of this script is testing the FTS5 module.
13 # 13 #
14 # 14 #
15 15
16 source [file join [file dirname [info script]] fts5_common.tcl] 16 source [file join [file dirname [info script]] fts5_common.tcl]
17 set testprefix fts5ab 17 set testprefix fts5ab
18 18
19 # If SQLITE_ENABLE_FTS5 is defined, omit this file. 19 # If SQLITE_ENABLE_FTS5 is defined, omit this file.
20 ifcapable !fts5 { 20 ifcapable !fts5 {
21 finish_test 21 finish_test
22 return 22 return
23 } 23 }
24 24
25 foreach_detail_mode $testprefix {
26
25 do_execsql_test 1.0 { 27 do_execsql_test 1.0 {
26 CREATE VIRTUAL TABLE t1 USING fts5(a, b); 28 CREATE VIRTUAL TABLE t1 USING fts5(a, b, detail=%DETAIL%);
27 INSERT INTO t1 VALUES('hello', 'world'); 29 INSERT INTO t1 VALUES('hello', 'world');
28 INSERT INTO t1 VALUES('one two', 'three four'); 30 INSERT INTO t1 VALUES('one two', 'three four');
29 INSERT INTO t1(rowid, a, b) VALUES(45, 'forty', 'five'); 31 INSERT INTO t1(rowid, a, b) VALUES(45, 'forty', 'five');
30 } 32 }
31 33
32 do_execsql_test 1.1 { 34 do_execsql_test 1.1 {
33 SELECT * FROM t1 ORDER BY rowid DESC; 35 SELECT * FROM t1 ORDER BY rowid DESC;
34 } { forty five {one two} {three four} hello world } 36 } { forty five {one two} {three four} hello world }
35 37
36 do_execsql_test 1.2 { 38 do_execsql_test 1.2 {
(...skipping 13 matching lines...) Expand all
50 } {} 52 } {}
51 53
52 do_execsql_test 1.6 { 54 do_execsql_test 1.6 {
53 SELECT * FROM t1 WHERE rowid=1.99; 55 SELECT * FROM t1 WHERE rowid=1.99;
54 } {} 56 } {}
55 57
56 #------------------------------------------------------------------------- 58 #-------------------------------------------------------------------------
57 59
58 reset_db 60 reset_db
59 do_execsql_test 2.1 { 61 do_execsql_test 2.1 {
60 CREATE VIRTUAL TABLE t1 USING fts5(x); 62 CREATE VIRTUAL TABLE t1 USING fts5(x, detail=%DETAIL%);
61 INSERT INTO t1(t1, rank) VALUES('pgsz', 32); 63 INSERT INTO t1(t1, rank) VALUES('pgsz', 32);
62 INSERT INTO t1 VALUES('one'); 64 INSERT INTO t1 VALUES('one');
63 INSERT INTO t1 VALUES('two'); 65 INSERT INTO t1 VALUES('two');
64 INSERT INTO t1 VALUES('three'); 66 INSERT INTO t1 VALUES('three');
65 } 67 }
66 68
67 do_catchsql_test 2.2 { 69 do_catchsql_test 2.2 {
68 SELECT rowid, * FROM t1 WHERE t1 MATCH 'AND AND' 70 SELECT rowid, * FROM t1 WHERE t1 MATCH 'AND AND'
69 } {1 {fts5: syntax error near "AND"}} 71 } {1 {fts5: syntax error near "AND"}}
70 72
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 do_execsql_test 3.4.$tn { 154 do_execsql_test 3.4.$tn {
153 SELECT rowid FROM t1 WHERE t1 MATCH $expr 155 SELECT rowid FROM t1 WHERE t1 MATCH $expr
154 } $res 156 } $res
155 } 157 }
156 158
157 #------------------------------------------------------------------------- 159 #-------------------------------------------------------------------------
158 # Documents with more than 2M tokens. 160 # Documents with more than 2M tokens.
159 # 161 #
160 162
161 do_execsql_test 4.0 { 163 do_execsql_test 4.0 {
162 CREATE VIRTUAL TABLE s1 USING fts5(x); 164 CREATE VIRTUAL TABLE s1 USING fts5(x, detail=%DETAIL%);
163 } 165 }
164 foreach {tn doc} [list \ 166 foreach {tn doc} [list \
165 1 [string repeat {a x } 1500000] \ 167 1 [string repeat {a x } 1500000] \
166 2 "[string repeat {a a } 1500000] x" \ 168 2 "[string repeat {a a } 1500000] x" \
167 ] { 169 ] {
168 do_execsql_test 4.$tn { INSERT INTO s1 VALUES($doc) } 170 do_execsql_test 4.$tn { INSERT INTO s1 VALUES($doc) }
169 } 171 }
170 172
171 do_execsql_test 4.3 { 173 do_execsql_test 4.3 {
172 SELECT rowid FROM s1 WHERE s1 MATCH 'x' 174 SELECT rowid FROM s1 WHERE s1 MATCH 'x'
173 } {1 2} 175 } {1 2}
174 176
175 do_execsql_test 4.4 { 177 if {[detail_is_full]} {
176 SELECT rowid FROM s1 WHERE s1 MATCH '"a x"' 178 do_execsql_test 4.4 {
179 SELECT rowid FROM s1 WHERE s1 MATCH '"a x"'
180 } {1 2}
181 }
182
183 do_execsql_test 4.5 {
184 SELECT rowid FROM s1 WHERE s1 MATCH 'a x'
177 } {1 2} 185 } {1 2}
178 186
179 #------------------------------------------------------------------------- 187 #-------------------------------------------------------------------------
180 # Check that a special case of segment promotion works. The case is where 188 # Check that a special case of segment promotion works. The case is where
181 # a new segment is written to level L, but the oldest segment within level 189 # a new segment is written to level L, but the oldest segment within level
182 # (L-2) is larger than it. 190 # (L-2) is larger than it.
183 # 191 #
184 do_execsql_test 5.0 { 192 do_execsql_test 5.0 {
185 CREATE VIRTUAL TABLE s2 USING fts5(x); 193 CREATE VIRTUAL TABLE s2 USING fts5(x, detail=%DETAIL%);
186 INSERT INTO s2(s2, rank) VALUES('pgsz', 32); 194 INSERT INTO s2(s2, rank) VALUES('pgsz', 32);
187 INSERT INTO s2(s2, rank) VALUES('automerge', 0); 195 INSERT INTO s2(s2, rank) VALUES('automerge', 0);
188 } 196 }
189 197
190 proc rnddoc {n} { 198 proc rnddoc {n} {
191 set map [list 0 a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j] 199 set map [list 0 a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j]
192 set doc [list] 200 set doc [list]
193 for {set i 0} {$i < $n} {incr i} { 201 for {set i 0} {$i < $n} {incr i} {
194 lappend doc [string map $map [format %.3d [expr int(rand()*1000)]]] 202 lappend doc [string map $map [format %.3d [expr int(rand()*1000)]]]
195 } 203 }
(...skipping 19 matching lines...) Expand all
215 execsql { INSERT INTO s2 VALUES(rnddoc(50)) } 223 execsql { INSERT INTO s2 VALUES(rnddoc(50)) }
216 } 224 }
217 fts5_level_segs s2 225 fts5_level_segs s2
218 } {8 0 0} 226 } {8 0 0}
219 227
220 # Test also the other type of segment promotion - when a new segment is written 228 # Test also the other type of segment promotion - when a new segment is written
221 # that is larger than segments immediately following it. 229 # that is larger than segments immediately following it.
222 do_test 5.3 { 230 do_test 5.3 {
223 execsql { 231 execsql {
224 DROP TABLE s2; 232 DROP TABLE s2;
225 CREATE VIRTUAL TABLE s2 USING fts5(x); 233 CREATE VIRTUAL TABLE s2 USING fts5(x, detail=%DETAIL%);
226 INSERT INTO s2(s2, rank) VALUES('pgsz', 32); 234 INSERT INTO s2(s2, rank) VALUES('pgsz', 32);
227 INSERT INTO s2(s2, rank) VALUES('automerge', 0); 235 INSERT INTO s2(s2, rank) VALUES('automerge', 0);
228 } 236 }
229 237
230 for {set i 1} {$i <= 16} {incr i} { 238 for {set i 1} {$i <= 16} {incr i} {
231 execsql { INSERT INTO s2 VALUES(rnddoc(5)) } 239 execsql { INSERT INTO s2 VALUES(rnddoc(5)) }
232 } 240 }
233 fts5_level_segs s2 241 fts5_level_segs s2
234 } {0 1} 242 } {0 1}
235 243
236 do_test 5.4 { 244 do_test 5.4 {
237 execsql { INSERT INTO s2 VALUES(rnddoc(160)) } 245 execsql { INSERT INTO s2 VALUES(rnddoc(160)) }
238 fts5_level_segs s2 246 fts5_level_segs s2
239 } {2 0} 247 } {2 0}
240 248
241 #------------------------------------------------------------------------- 249 #-------------------------------------------------------------------------
242 # 250 #
243 do_execsql_test 6.0 { 251 do_execsql_test 6.0 {
244 CREATE VIRTUAL TABLE s3 USING fts5(x); 252 CREATE VIRTUAL TABLE s3 USING fts5(x, detail=%DETAIL%);
245 BEGIN; 253 BEGIN;
246 INSERT INTO s3 VALUES('a b c'); 254 INSERT INTO s3 VALUES('a b c');
247 INSERT INTO s3 VALUES('A B C'); 255 INSERT INTO s3 VALUES('A B C');
248 } 256 }
249 257
250 do_execsql_test 6.1.1 { 258 do_execsql_test 6.1.1 {
251 SELECT rowid FROM s3 WHERE s3 MATCH 'a' 259 SELECT rowid FROM s3 WHERE s3 MATCH 'a'
252 } {1 2} 260 } {1 2}
253 261
254 do_execsql_test 6.1.2 { 262 do_execsql_test 6.1.2 {
(...skipping 14 matching lines...) Expand all
269 execsql { 277 execsql {
270 BEGIN; 278 BEGIN;
271 INSERT INTO s3(s3) VALUES('optimize'); 279 INSERT INTO s3(s3) VALUES('optimize');
272 ROLLBACK; 280 ROLLBACK;
273 } 281 }
274 } {} 282 } {}
275 283
276 #------------------------------------------------------------------------- 284 #-------------------------------------------------------------------------
277 # 285 #
278 set doc [string repeat "a b c " 500] 286 set doc [string repeat "a b c " 500]
279 breakpoint
280 do_execsql_test 7.0 { 287 do_execsql_test 7.0 {
281 CREATE VIRTUAL TABLE x1 USING fts5(x); 288 CREATE VIRTUAL TABLE x1 USING fts5(x, detail=%DETAIL%);
282 INSERT INTO x1(x1, rank) VALUES('pgsz', 32); 289 INSERT INTO x1(x1, rank) VALUES('pgsz', 32);
283 INSERT INTO x1 VALUES($doc); 290 INSERT INTO x1 VALUES($doc);
284 } 291 }
285 292
293 } ;# foreach_detail_mode...
286 294
287 295
288 finish_test 296 finish_test
289 297
OLDNEW
« no previous file with comments | « third_party/sqlite/src/ext/fts5/test/fts5aa.test ('k') | third_party/sqlite/src/ext/fts5/test/fts5ac.test » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698