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

Side by Side Diff: third_party/sqlite/src/ext/fts5/test/fts5al.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 November 24 1 # 2014 November 24
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 # Specifically, this function tests the %_config table. 14 # Specifically, this function tests the %_config table.
15 # 15 #
16 16
17 source [file join [file dirname [info script]] fts5_common.tcl] 17 source [file join [file dirname [info script]] fts5_common.tcl]
18 set testprefix fts5al 18 set testprefix fts5al
19 19
20 # If SQLITE_ENABLE_FTS5 is defined, omit this file. 20 # If SQLITE_ENABLE_FTS5 is defined, omit this file.
21 ifcapable !fts5 { 21 ifcapable !fts5 {
22 finish_test 22 finish_test
23 return 23 return
24 } 24 }
25 25
26 foreach_detail_mode $testprefix {
27
26 do_execsql_test 1.1 { 28 do_execsql_test 1.1 {
27 CREATE VIRTUAL TABLE ft1 USING fts5(x); 29 CREATE VIRTUAL TABLE ft1 USING fts5(x, detail=%DETAIL%);
28 SELECT * FROM ft1_config; 30 SELECT * FROM ft1_config;
29 } {version 4} 31 } {version 4}
30 32
31 do_execsql_test 1.2 { 33 do_execsql_test 1.2 {
32 INSERT INTO ft1(ft1, rank) VALUES('pgsz', 32); 34 INSERT INTO ft1(ft1, rank) VALUES('pgsz', 32);
33 SELECT * FROM ft1_config; 35 SELECT * FROM ft1_config;
34 } {pgsz 32 version 4} 36 } {pgsz 32 version 4}
35 37
36 do_execsql_test 1.3 { 38 do_execsql_test 1.3 {
37 INSERT INTO ft1(ft1, rank) VALUES('pgsz', 64); 39 INSERT INTO ft1(ft1, rank) VALUES('pgsz', 64);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 do_test 2.2.$tn { 78 do_test 2.2.$tn {
77 catchsql { INSERT INTO ft1(ft1, rank) VALUES('rank', $defn) } 79 catchsql { INSERT INTO ft1(ft1, rank) VALUES('rank', $defn) }
78 } {1 {SQL logic error or missing database}} 80 } {1 {SQL logic error or missing database}}
79 } 81 }
80 82
81 #------------------------------------------------------------------------- 83 #-------------------------------------------------------------------------
82 # Assorted tests of the tcl interface for creating extension functions. 84 # Assorted tests of the tcl interface for creating extension functions.
83 # 85 #
84 86
85 do_execsql_test 3.1 { 87 do_execsql_test 3.1 {
86 CREATE VIRTUAL TABLE t1 USING fts5(x); 88 CREATE VIRTUAL TABLE t1 USING fts5(x, detail=%DETAIL%);
87 INSERT INTO t1 VALUES('q w e r t y'); 89 INSERT INTO t1 VALUES('q w e r t y');
88 INSERT INTO t1 VALUES('y t r e w q'); 90 INSERT INTO t1 VALUES('y t r e w q');
89 } 91 }
90 92
91 proc argtest {cmd args} { return $args } 93 proc argtest {cmd args} { return $args }
92 sqlite3_fts5_create_function db argtest argtest 94 sqlite3_fts5_create_function db argtest argtest
93 95
94 do_execsql_test 3.2.1 { 96 do_execsql_test 3.2.1 {
95 SELECT argtest(t1, 123) FROM t1 WHERE t1 MATCH 'q' 97 SELECT argtest(t1, 123) FROM t1 WHERE t1 MATCH 'q'
96 } {123 123} 98 } {123 123}
(...skipping 18 matching lines...) Expand all
115 } 117 }
116 sqlite3_fts5_create_function db insttest insttest 118 sqlite3_fts5_create_function db insttest insttest
117 119
118 do_execsql_test 3.4.1 { 120 do_execsql_test 3.4.1 {
119 SELECT insttest(t1) FROM t1 WHERE t1 MATCH 'q' 121 SELECT insttest(t1) FROM t1 WHERE t1 MATCH 'q'
120 } { 122 } {
121 {{0 0 0}} 123 {{0 0 0}}
122 {{0 0 5}} 124 {{0 0 5}}
123 } 125 }
124 126
125 do_execsql_test 3.4.2 { 127 if {[detail_is_full]} {
126 SELECT insttest(t1) FROM t1 WHERE t1 MATCH 'r+e OR w' 128 do_execsql_test 3.4.2 {
127 } { 129 SELECT insttest(t1) FROM t1 WHERE t1 MATCH 'r+e OR w'
128 {{1 0 1}} 130 } {
129 {{0 0 2} {1 0 4}} 131 {{1 0 1}}
132 {{0 0 2} {1 0 4}}
133 }
130 } 134 }
131 135
132 proc coltest {cmd} { 136 proc coltest {cmd} {
133 list [$cmd xColumnSize 0] [$cmd xColumnText 0] 137 list [$cmd xColumnSize 0] [$cmd xColumnText 0]
134 } 138 }
135 sqlite3_fts5_create_function db coltest coltest 139 sqlite3_fts5_create_function db coltest coltest
136 140
137 do_execsql_test 3.5.1 { 141 do_execsql_test 3.5.1 {
138 SELECT coltest(t1) FROM t1 WHERE t1 MATCH 'q' 142 SELECT coltest(t1) FROM t1 WHERE t1 MATCH 'q'
139 } { 143 } {
140 {6 {q w e r t y}} 144 {6 {q w e r t y}}
141 {6 {y t r e w q}} 145 {6 {y t r e w q}}
142 } 146 }
143 147
144 #------------------------------------------------------------------------- 148 #-------------------------------------------------------------------------
145 # Tests for remapping the "rank" column. 149 # Tests for remapping the "rank" column.
146 # 150 #
147 # 4.1.*: Mapped to a function with no arguments. 151 # 4.1.*: Mapped to a function with no arguments.
148 # 4.2.*: Mapped to a function with one or more arguments. 152 # 4.2.*: Mapped to a function with one or more arguments.
149 # 153 #
150 154
151 do_execsql_test 4.0 { 155 do_execsql_test 4.0 {
152 CREATE VIRTUAL TABLE t2 USING fts5(a, b); 156 CREATE VIRTUAL TABLE t2 USING fts5(a, b, detail=%DETAIL%);
153 INSERT INTO t2 VALUES('a s h g s b j m r h', 's b p a d b b a o e'); 157 INSERT INTO t2 VALUES('a s h g s b j m r h', 's b p a d b b a o e');
154 INSERT INTO t2 VALUES('r h n t a g r d d i', 'l d n j r c f t o q'); 158 INSERT INTO t2 VALUES('r h n t a g r d d i', 'l d n j r c f t o q');
155 INSERT INTO t2 VALUES('q k n i k c a a e m', 'c h n j p g s c i t'); 159 INSERT INTO t2 VALUES('q k n i k c a a e m', 'c h n j p g s c i t');
156 INSERT INTO t2 VALUES('h j g t r e l s g s', 'k q k c i i c k n s'); 160 INSERT INTO t2 VALUES('h j g t r e l s g s', 'k q k c i i c k n s');
157 INSERT INTO t2 VALUES('b l k h d n n n m i', 'p t i a r b t q o l'); 161 INSERT INTO t2 VALUES('b l k h d n n n m i', 'p t i a r b t q o l');
158 INSERT INTO t2 VALUES('k r i l j b g i p a', 't q c h a i m g n l'); 162 INSERT INTO t2 VALUES('k r i l j b g i p a', 't q c h a i m g n l');
159 INSERT INTO t2 VALUES('a e c q n m o m d g', 'l c t g i s q g q e'); 163 INSERT INTO t2 VALUES('a e c q n m o m d g', 'l c t g i s q g q e');
160 INSERT INTO t2 VALUES('b o j h f o g b p e', 'r t l h s b g i c p'); 164 INSERT INTO t2 VALUES('b o j h f o g b p e', 'r t l h s b g i c p');
161 INSERT INTO t2 VALUES('s q k f q b j g h f', 'n m a o p e i e k t'); 165 INSERT INTO t2 VALUES('s q k f q b j g h f', 'n m a o p e i e k t');
162 INSERT INTO t2 VALUES('o q g g q c o k a b', 'r t k p t f t h p c'); 166 INSERT INTO t2 VALUES('o q g g q c o k a b', 'r t k p t f t h p c');
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 SELECT rowid, rank FROM t2 WHERE t2 MATCH 'a' ORDER BY rank DESC 215 SELECT rowid, rank FROM t2 WHERE t2 MATCH 'a' ORDER BY rank DESC
212 } { 216 } {
213 5 103 9 102 6 9 10 8 3 6 2 4 1 0 7 0 217 5 103 9 102 6 9 10 8 3 6 2 4 1 0 7 0
214 } 218 }
215 219
216 proc rowidplus {cmd ival} { 220 proc rowidplus {cmd ival} {
217 expr [$cmd xRowid] + $ival 221 expr [$cmd xRowid] + $ival
218 } 222 }
219 sqlite3_fts5_create_function db rowidplus rowidplus 223 sqlite3_fts5_create_function db rowidplus rowidplus
220 224
221 do_execsql_test 4.2.1 { 225 if {[detail_is_full]} {
222 INSERT INTO t2(t2, rank) VALUES('rank', 'rowidplus(100) '); 226 do_execsql_test 4.2.1 {
223 SELECT rowid, rank FROM t2 WHERE t2 MATCH 'o + q + g' 227 INSERT INTO t2(t2, rank) VALUES('rank', 'rowidplus(100) ');
224 } { 228 SELECT rowid, rank FROM t2 WHERE t2 MATCH 'o + q + g'
225 10 110 229 } {
226 } 230 10 110
227 do_execsql_test 4.2.2 { 231 }
228 INSERT INTO t2(t2, rank) VALUES('rank', 'rowidplus(111) '); 232 do_execsql_test 4.2.2 {
229 SELECT rowid, rank FROM t2 WHERE t2 MATCH 'o + q + g' 233 INSERT INTO t2(t2, rank) VALUES('rank', 'rowidplus(111) ');
230 } { 234 SELECT rowid, rank FROM t2 WHERE t2 MATCH 'o + q + g'
231 10 121 235 } {
232 } 236 10 121
237 }
233 238
234 do_execsql_test 4.2.3 { 239 do_execsql_test 4.2.3 {
235 SELECT rowid, rank FROM t2 240 SELECT rowid, rank FROM t2
236 WHERE t2 MATCH 'o + q + g' AND rank MATCH 'rowidplus(112)' 241 WHERE t2 MATCH 'o + q + g' AND rank MATCH 'rowidplus(112)'
237 } { 242 } {
238 10 122 243 10 122
244 }
239 } 245 }
240 246
241 proc rowidmod {cmd imod} { 247 proc rowidmod {cmd imod} {
242 expr [$cmd xRowid] % $imod 248 expr [$cmd xRowid] % $imod
243 } 249 }
244 sqlite3_fts5_create_function db rowidmod rowidmod 250 sqlite3_fts5_create_function db rowidmod rowidmod
245 do_execsql_test 4.3.1 { 251 do_execsql_test 4.3.1 {
246 CREATE VIRTUAL TABLE t3 USING fts5(x); 252 CREATE VIRTUAL TABLE t3 USING fts5(x, detail=%DETAIL%);
247 INSERT INTO t3 VALUES('a one'); 253 INSERT INTO t3 VALUES('a one');
248 INSERT INTO t3 VALUES('a two'); 254 INSERT INTO t3 VALUES('a two');
249 INSERT INTO t3 VALUES('a three'); 255 INSERT INTO t3 VALUES('a three');
250 INSERT INTO t3 VALUES('a four'); 256 INSERT INTO t3 VALUES('a four');
251 INSERT INTO t3 VALUES('a five'); 257 INSERT INTO t3 VALUES('a five');
252 INSERT INTO t3(t3, rank) VALUES('rank', 'bm25()'); 258 INSERT INTO t3(t3, rank) VALUES('rank', 'bm25()');
253 } 259 }
254 260
255 do_execsql_test 4.3.2 { 261 do_execsql_test 4.3.2 {
256 SELECT * FROM t3 262 SELECT * FROM t3
(...skipping 23 matching lines...) Expand all
280 {a three} 0 {a one} 1 {a four} 1 {a two} 2 {a five} 2 286 {a three} 0 {a one} 1 {a four} 1 {a two} 2 {a five} 2
281 } 287 }
282 288
283 do_catchsql_test 4.4.3 { 289 do_catchsql_test 4.4.3 {
284 SELECT *, rank FROM t3 WHERE t3 MATCH 'a' AND rank MATCH 'xyz(3)' 290 SELECT *, rank FROM t3 WHERE t3 MATCH 'a' AND rank MATCH 'xyz(3)'
285 } {1 {no such function: xyz}} 291 } {1 {no such function: xyz}}
286 do_catchsql_test 4.4.4 { 292 do_catchsql_test 4.4.4 {
287 SELECT *, rank FROM t3 WHERE t3 MATCH 'a' AND rank MATCH NULL 293 SELECT *, rank FROM t3 WHERE t3 MATCH 'a' AND rank MATCH NULL
288 } {1 {parse error in rank function: }} 294 } {1 {parse error in rank function: }}
289 295
296 } ;# foreach_detail_mode
290 297
291 298
292 finish_test 299 finish_test
293 300
OLDNEW
« no previous file with comments | « third_party/sqlite/src/ext/fts5/test/fts5ak.test ('k') | third_party/sqlite/src/ext/fts5/test/fts5auto.test » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698