OLD | NEW |
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 fts5ae | 17 set testprefix fts5ae |
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(t1, rank) VALUES('pgsz', 32); | 29 INSERT INTO t1(t1, rank) VALUES('pgsz', 32); |
28 } | 30 } |
29 | 31 |
30 do_execsql_test 1.1 { | 32 do_execsql_test 1.1 { |
31 INSERT INTO t1 VALUES('hello', 'world'); | 33 INSERT INTO t1 VALUES('hello', 'world'); |
32 SELECT rowid FROM t1 WHERE t1 MATCH 'hello' ORDER BY rowid ASC; | 34 SELECT rowid FROM t1 WHERE t1 MATCH 'hello' ORDER BY rowid ASC; |
33 } {1} | 35 } {1} |
34 | 36 |
35 do_execsql_test 1.2 { | 37 do_execsql_test 1.2 { |
36 INSERT INTO t1 VALUES('world', 'hello'); | 38 INSERT INTO t1 VALUES('world', 'hello'); |
(...skipping 11 matching lines...) Expand all Loading... |
48 | 50 |
49 do_execsql_test 1.4.2 { | 51 do_execsql_test 1.4.2 { |
50 SELECT rowid FROM t1 WHERE t1 MATCH 'hello' ORDER BY rowid ASC; | 52 SELECT rowid FROM t1 WHERE t1 MATCH 'hello' ORDER BY rowid ASC; |
51 } {1 2 4} | 53 } {1 2 4} |
52 | 54 |
53 fts5_aux_test_functions db | 55 fts5_aux_test_functions db |
54 | 56 |
55 #------------------------------------------------------------------------- | 57 #------------------------------------------------------------------------- |
56 # | 58 # |
57 do_execsql_test 2.0 { | 59 do_execsql_test 2.0 { |
58 CREATE VIRTUAL TABLE t2 USING fts5(x, y); | 60 CREATE VIRTUAL TABLE t2 USING fts5(x, y, detail=%DETAIL%); |
59 INSERT INTO t2 VALUES('u t l w w m s', 'm f m o l t k o p e'); | 61 INSERT INTO t2 VALUES('u t l w w m s', 'm f m o l t k o p e'); |
60 INSERT INTO t2 VALUES('f g q e l n d m z x q', 'z s i i i m f w w f n g p'); | 62 INSERT INTO t2 VALUES('f g q e l n d m z x q', 'z s i i i m f w w f n g p'); |
61 } | 63 } |
62 | 64 |
63 do_execsql_test 2.1 { | 65 do_execsql_test 2.1 { |
64 SELECT rowid, fts5_test_poslist(t2) FROM t2 | 66 SELECT rowid, fts5_test_poslist(t2) FROM t2 |
65 WHERE t2 MATCH 'm' ORDER BY rowid; | 67 WHERE t2 MATCH 'm' ORDER BY rowid; |
66 } { | 68 } { |
67 1 {0.0.5 0.1.0 0.1.2} | 69 1 {0.0.5 0.1.0 0.1.2} |
68 2 {0.0.7 0.1.5} | 70 2 {0.0.7 0.1.5} |
69 } | 71 } |
70 | 72 |
71 do_execsql_test 2.2 { | 73 do_execsql_test 2.2 { |
72 SELECT rowid, fts5_test_poslist(t2) FROM t2 | 74 SELECT rowid, fts5_test_poslist(t2) FROM t2 |
73 WHERE t2 MATCH 'u OR q' ORDER BY rowid; | 75 WHERE t2 MATCH 'u OR q' ORDER BY rowid; |
74 } { | 76 } { |
75 1 {0.0.0} | 77 1 {0.0.0} |
76 2 {1.0.2 1.0.10} | 78 2 {1.0.2 1.0.10} |
77 } | 79 } |
78 | 80 |
79 do_execsql_test 2.3 { | 81 if {[detail_is_full]} { |
80 SELECT rowid, fts5_test_poslist(t2) FROM t2 | 82 do_execsql_test 2.3 { |
81 WHERE t2 MATCH 'y:o' ORDER BY rowid; | 83 SELECT rowid, fts5_test_poslist(t2) FROM t2 |
82 } { | 84 WHERE t2 MATCH 'y:o' ORDER BY rowid; |
83 1 {0.1.3 0.1.7} | 85 } { |
| 86 1 {0.1.3 0.1.7} |
| 87 } |
84 } | 88 } |
85 | 89 |
86 #------------------------------------------------------------------------- | 90 #------------------------------------------------------------------------- |
87 # | 91 # |
88 do_execsql_test 3.0 { | 92 do_execsql_test 3.0 { |
89 CREATE VIRTUAL TABLE t3 USING fts5(x, y); | 93 CREATE VIRTUAL TABLE t3 USING fts5(x, y, detail=%DETAIL%); |
90 INSERT INTO t3 VALUES( 'j f h o x x a z g b a f a m i b', 'j z c z y x w t'); | 94 INSERT INTO t3 VALUES( 'j f h o x x a z g b a f a m i b', 'j z c z y x w t'); |
91 INSERT INTO t3 VALUES( 'r c', ''); | 95 INSERT INTO t3 VALUES( 'r c', ''); |
92 } | 96 } |
93 | 97 |
94 do_execsql_test 3.1 { | 98 if {[detail_is_full]} { |
95 SELECT rowid, fts5_test_poslist(t3) FROM t3 WHERE t3 MATCH 'NEAR(a b)'; | 99 do_execsql_test 3.1 { |
96 } { | 100 SELECT rowid, fts5_test_poslist(t3) FROM t3 WHERE t3 MATCH 'NEAR(a b)'; |
97 1 {0.0.6 1.0.9 0.0.10 0.0.12 1.0.15} | 101 } { |
98 } | 102 1 {0.0.6 1.0.9 0.0.10 0.0.12 1.0.15} |
| 103 } |
99 | 104 |
100 do_execsql_test 3.2 { | 105 do_execsql_test 3.2 { |
101 SELECT rowid, fts5_test_poslist(t3) FROM t3 WHERE t3 MATCH 'NEAR(r c)'; | 106 SELECT rowid, fts5_test_poslist(t3) FROM t3 WHERE t3 MATCH 'NEAR(r c)'; |
102 } { | 107 } { |
103 2 {0.0.0 1.0.1} | 108 2 {0.0.0 1.0.1} |
| 109 } |
104 } | 110 } |
105 | 111 |
106 do_execsql_test 3.3 { | 112 do_execsql_test 3.3 { |
107 INSERT INTO t3 | 113 INSERT INTO t3 |
108 VALUES('k x j r m a d o i z j', 'r t t t f e b r x i v j v g o'); | 114 VALUES('k x j r m a d o i z j', 'r t t t f e b r x i v j v g o'); |
109 SELECT rowid, fts5_test_poslist(t3) | 115 SELECT rowid, fts5_test_poslist(t3) |
110 FROM t3 WHERE t3 MATCH 'a OR b AND c'; | 116 FROM t3 WHERE t3 MATCH 'a OR b AND c'; |
111 } { | 117 } { |
112 1 {0.0.6 1.0.9 0.0.10 0.0.12 1.0.15 2.1.2} | 118 1 {0.0.6 1.0.9 0.0.10 0.0.12 1.0.15 2.1.2} |
113 3 0.0.5 | 119 3 0.0.5 |
114 } | 120 } |
115 | 121 |
116 #------------------------------------------------------------------------- | 122 #------------------------------------------------------------------------- |
117 # | 123 # |
118 do_execsql_test 4.0 { | 124 do_execsql_test 4.0 { |
119 CREATE VIRTUAL TABLE t4 USING fts5(x, y); | 125 CREATE VIRTUAL TABLE t4 USING fts5(x, y, detail=%DETAIL%); |
120 INSERT INTO t4 | 126 INSERT INTO t4 |
121 VALUES('k x j r m a d o i z j', 'r t t t f e b r x i v j v g o'); | 127 VALUES('k x j r m a d o i z j', 'r t t t f e b r x i v j v g o'); |
122 } | 128 } |
123 | 129 |
124 do_execsql_test 4.1 { | 130 do_execsql_test 4.1 { |
125 SELECT rowid, fts5_test_poslist(t4) FROM t4 WHERE t4 MATCH 'a OR b AND c'; | 131 SELECT rowid, fts5_test_poslist(t4) FROM t4 WHERE t4 MATCH 'a OR b AND c'; |
126 } { | 132 } { |
127 1 0.0.5 | 133 1 0.0.5 |
128 } | 134 } |
129 | 135 |
130 #------------------------------------------------------------------------- | 136 #------------------------------------------------------------------------- |
131 # Test that the xColumnSize() and xColumnAvgsize() APIs work. | 137 # Test that the xColumnSize() and xColumnAvgsize() APIs work. |
132 # | 138 # |
133 reset_db | 139 reset_db |
134 fts5_aux_test_functions db | 140 fts5_aux_test_functions db |
135 | 141 |
136 do_execsql_test 5.1 { | 142 do_execsql_test 5.1 { |
137 CREATE VIRTUAL TABLE t5 USING fts5(x, y); | 143 CREATE VIRTUAL TABLE t5 USING fts5(x, y, detail=%DETAIL%); |
138 INSERT INTO t5 VALUES('a b c d', 'e f g h i j'); | 144 INSERT INTO t5 VALUES('a b c d', 'e f g h i j'); |
139 INSERT INTO t5 VALUES('', 'a'); | 145 INSERT INTO t5 VALUES('', 'a'); |
140 INSERT INTO t5 VALUES('a', ''); | 146 INSERT INTO t5 VALUES('a', ''); |
141 } | 147 } |
142 do_execsql_test 5.2 { | 148 do_execsql_test 5.2 { |
143 SELECT rowid, fts5_test_columnsize(t5) FROM t5 WHERE t5 MATCH 'a' | 149 SELECT rowid, fts5_test_columnsize(t5) FROM t5 WHERE t5 MATCH 'a' |
144 ORDER BY rowid DESC; | 150 ORDER BY rowid DESC; |
145 } { | 151 } { |
146 3 {1 0} | 152 3 {1 0} |
147 2 {0 1} | 153 2 {0 1} |
(...skipping 27 matching lines...) Expand all Loading... |
175 2 {8 12} | 181 2 {8 12} |
176 1 {8 12} | 182 1 {8 12} |
177 } | 183 } |
178 | 184 |
179 #------------------------------------------------------------------------- | 185 #------------------------------------------------------------------------- |
180 # Test the xTokenize() API | 186 # Test the xTokenize() API |
181 # | 187 # |
182 reset_db | 188 reset_db |
183 fts5_aux_test_functions db | 189 fts5_aux_test_functions db |
184 do_execsql_test 6.1 { | 190 do_execsql_test 6.1 { |
185 CREATE VIRTUAL TABLE t6 USING fts5(x, y); | 191 CREATE VIRTUAL TABLE t6 USING fts5(x, y, detail=%DETAIL%); |
186 INSERT INTO t6 VALUES('There are more', 'things in heaven and earth'); | 192 INSERT INTO t6 VALUES('There are more', 'things in heaven and earth'); |
187 INSERT INTO t6 VALUES(', Horatio, Than are', 'dreamt of in your philosophy.'); | 193 INSERT INTO t6 VALUES(', Horatio, Than are', 'dreamt of in your philosophy.'); |
188 } | 194 } |
189 | 195 |
190 do_execsql_test 6.2 { | 196 do_execsql_test 6.2 { |
191 SELECT rowid, fts5_test_tokenize(t6) FROM t6 WHERE t6 MATCH 't*' | 197 SELECT rowid, fts5_test_tokenize(t6) FROM t6 WHERE t6 MATCH 't*' |
192 } { | 198 } { |
193 1 {{there are more} {things in heaven and earth}} | 199 1 {{there are more} {things in heaven and earth}} |
194 2 {{horatio than are} {dreamt of in your philosophy}} | 200 2 {{horatio than are} {dreamt of in your philosophy}} |
195 } | 201 } |
196 | 202 |
197 #------------------------------------------------------------------------- | 203 #------------------------------------------------------------------------- |
198 # Test the xQueryPhrase() API | 204 # Test the xQueryPhrase() API |
199 # | 205 # |
200 reset_db | 206 reset_db |
201 fts5_aux_test_functions db | 207 fts5_aux_test_functions db |
202 do_execsql_test 7.1 { | 208 do_execsql_test 7.1 { |
203 CREATE VIRTUAL TABLE t7 USING fts5(x, y); | 209 CREATE VIRTUAL TABLE t7 USING fts5(x, y, detail=%DETAIL%); |
204 } | 210 } |
205 do_test 7.2 { | 211 do_test 7.2 { |
206 foreach {x y} { | 212 foreach {x y} { |
207 {q i b w s a a e l o} {i b z a l f p t e u} | 213 {q i b w s a a e l o} {i b z a l f p t e u} |
208 {b a z t a l o x d i} {b p a d b f h d w y} | 214 {b a z t a l o x d i} {b p a d b f h d w y} |
209 {z m h n p p u i e g} {v h d v b x j j c z} | 215 {z m h n p p u i e g} {v h d v b x j j c z} |
210 {a g i m v a u c b i} {p k s o t l r t b m} | 216 {a g i m v a u c b i} {p k s o t l r t b m} |
211 {v v c j o d a s c p} {f f v o k p o f o g} | 217 {v v c j o d a s c p} {f f v o k p o f o g} |
212 } { | 218 } { |
213 execsql {INSERT INTO t7 VALUES($x, $y)} | 219 execsql {INSERT INTO t7 VALUES($x, $y)} |
(...skipping 19 matching lines...) Expand all Loading... |
233 } {5 5 5 5} | 239 } {5 5 5 5} |
234 | 240 |
235 #do_execsql_test 7.4 { | 241 #do_execsql_test 7.4 { |
236 # SELECT rowid, bm25debug(t7) FROM t7 WHERE t7 MATCH 'a'; | 242 # SELECT rowid, bm25debug(t7) FROM t7 WHERE t7 MATCH 'a'; |
237 #} {5 5 5 5} | 243 #} {5 5 5 5} |
238 # | 244 # |
239 | 245 |
240 #------------------------------------------------------------------------- | 246 #------------------------------------------------------------------------- |
241 # | 247 # |
242 do_test 8.1 { | 248 do_test 8.1 { |
243 execsql { CREATE VIRTUAL TABLE t8 USING fts5(x, y) } | 249 execsql { CREATE VIRTUAL TABLE t8 USING fts5(x, y, detail=%DETAIL%) } |
244 foreach {rowid x y} { | 250 foreach {rowid x y} { |
245 0 {A o} {o o o C o o o o o o o o} | 251 0 {A o} {o o o C o o o o o o o o} |
246 1 {o o B} {o o o C C o o o o o o o} | 252 1 {o o B} {o o o C C o o o o o o o} |
247 2 {A o o} {o o o o D D o o o o o o} | 253 2 {A o o} {o o o o D D o o o o o o} |
248 3 {o B} {o o o o o D o o o o o o} | 254 3 {o B} {o o o o o D o o o o o o} |
249 4 {E o G} {H o o o o o o o o o o o} | 255 4 {E o G} {H o o o o o o o o o o o} |
250 5 {F o G} {I o J o o o o o o o o o} | 256 5 {F o G} {I o J o o o o o o o o o} |
251 6 {E o o} {H o J o o o o o o o o o} | 257 6 {E o o} {H o J o o o o o o o o o} |
252 7 {o o o} {o o o o o o o o o o o o} | 258 7 {o o o} {o o o o o o o o o o o o} |
253 9 {o o o} {o o o o o o o o o o o o} | 259 9 {o o o} {o o o o o o o o o o o o} |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 1 {a AND b} 2 | 299 1 {a AND b} 2 |
294 2 {a OR b} 2 | 300 2 {a OR b} 2 |
295 3 {a OR b OR c} 3 | 301 3 {a OR b OR c} 3 |
296 4 {NEAR(a b)} 2 | 302 4 {NEAR(a b)} 2 |
297 } { | 303 } { |
298 do_execsql_test 9.2.$tn { | 304 do_execsql_test 9.2.$tn { |
299 SELECT fts5_test_phrasecount(t9) FROM t9 WHERE t9 MATCH $q LIMIT 1 | 305 SELECT fts5_test_phrasecount(t9) FROM t9 WHERE t9 MATCH $q LIMIT 1 |
300 } $cnt | 306 } $cnt |
301 } | 307 } |
302 | 308 |
| 309 } |
| 310 |
303 finish_test | 311 finish_test |
304 | 312 |
OLD | NEW |