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

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

Issue 6990047: Import SQLite 3.7.6.3. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « third_party/sqlite/src/test/fts3cov.test ('k') | third_party/sqlite/src/test/fts3defer.test » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # 2008 June 26 1 # 2008 June 26
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 focus 11 # This file implements regression tests for SQLite library. The focus
12 # of this script is testing the FTS3 module's optimize() function. 12 # of this script is testing the FTS3 module's optimize() function.
13 # 13 #
14 # $Id: fts3d.test,v 1.2 2008/07/15 21:32:07 shess Exp $
15 #
16 14
17 set testdir [file dirname $argv0] 15 set testdir [file dirname $argv0]
18 source $testdir/tester.tcl 16 source $testdir/tester.tcl
17 source $testdir/fts3_common.tcl
19 18
20 # If SQLITE_ENABLE_FTS3 is not defined, omit this file. 19 # If SQLITE_ENABLE_FTS3 is not defined, omit this file.
21 ifcapable !fts3 { 20 ifcapable !fts3 {
22 finish_test 21 finish_test
23 return 22 return
24 } 23 }
25 24
26 #************************************************************************* 25 #*************************************************************************
27 # Probe to see if support for the FTS3 dump_* functions is compiled in.
28 # TODO(shess): Change main.mk to do the right thing and remove this test.
29 db eval {
30 DROP TABLE IF EXISTS t1;
31 CREATE VIRTUAL TABLE t1 USING fts3(c);
32 INSERT INTO t1 (docid, c) VALUES (1, 'x');
33 }
34
35 set s {SELECT dump_terms(t1, 1) FROM t1 LIMIT 1}
36 set r {1 {unable to use function dump_terms in the requested context}}
37 if {[catchsql $s]==$r} {
38 finish_test
39 return
40 }
41
42 #*************************************************************************
43 # Utility function to check for the expected terms in the segment 26 # Utility function to check for the expected terms in the segment
44 # level/index. _all version does same but for entire index. 27 # level/index. _all version does same but for entire index.
45 proc check_terms {test level index terms} { 28 proc check_terms {test level index terms} {
46 # TODO(shess): Figure out why uplevel in do_test can't catch 29 set where "level = $level AND idx = $index"
47 # $level and $index directly. 30 do_test $test.terms [list fts3_terms t1 $where] $terms
48 set ::level $level
49 set ::index $index
50 do_test $test.terms {
51 execsql {
52 SELECT dump_terms(t1, $::level, $::index) FROM t1 LIMIT 1;
53 }
54 } [list $terms]
55 } 31 }
56 proc check_terms_all {test terms} { 32 proc check_terms_all {test terms} {
57 do_test $test.terms { 33 do_test $test.terms [list fts3_terms t1 1] $terms
58 execsql {
59 SELECT dump_terms(t1) FROM t1 LIMIT 1;
60 }
61 } [list $terms]
62 } 34 }
63 35
64 # Utility function to check for the expected doclist for the term in 36 # Utility function to check for the expected doclist for the term in
65 # segment level/index. _all version does same for entire index. 37 # segment level/index. _all version does same for entire index.
66 proc check_doclist {test level index term doclist} { 38 proc check_doclist {test level index term doclist} {
67 # TODO(shess): Again, why can't the non-:: versions work? 39 set where "level = $level AND idx = $index"
68 set ::term $term 40 do_test $test.doclist [list fts3_doclist t1 $term $where] $doclist
69 set ::level $level
70 set ::index $index
71 do_test $test {
72 execsql {
73 SELECT dump_doclist(t1, $::term, $::level, $::index) FROM t1 LIMIT 1;
74 }
75 } [list $doclist]
76 } 41 }
77 proc check_doclist_all {test term doclist} { 42 proc check_doclist_all {test term doclist} {
78 set ::term $term 43 do_test $test.doclist [list fts3_doclist t1 $term 1] $doclist
79 do_test $test {
80 execsql {
81 SELECT dump_doclist(t1, $::term) FROM t1 LIMIT 1;
82 }
83 } [list $doclist]
84 } 44 }
85 45
86 #************************************************************************* 46 #*************************************************************************
87 # Test results when all rows are deleted and one is added back. 47 # Test results when all rows are deleted and one is added back.
88 # Previously older segments would continue to exist, but now the index 48 # Previously older segments would continue to exist, but now the index
89 # should be dropped when the table is empty. The results should look 49 # should be dropped when the table is empty. The results should look
90 # exactly like we never added the earlier rows in the first place. 50 # exactly like we never added the earlier rows in the first place.
91 db eval { 51 db eval {
92 DROP TABLE IF EXISTS t1; 52 DROP TABLE IF EXISTS t1;
93 CREATE VIRTUAL TABLE t1 USING fts3(c); 53 CREATE VIRTUAL TABLE t1 USING fts3(c);
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 check_doclist fts3d-4.4.4 1 0 one {[1] [2] [3]} 246 check_doclist fts3d-4.4.4 1 0 one {[1] [2] [3]}
287 check_doclist fts3d-4.4.5 1 0 test {[1 0[3]] [2 0[3]] [3 0[3]]} 247 check_doclist fts3d-4.4.5 1 0 test {[1 0[3]] [2 0[3]] [3 0[3]]}
288 check_doclist fts3d-4.4.6 1 0 that {[2 0[0]]} 248 check_doclist fts3d-4.4.6 1 0 that {[2 0[0]]}
289 check_doclist fts3d-4.4.7 1 0 this {[1 0[0]] [3 0[0]]} 249 check_doclist fts3d-4.4.7 1 0 this {[1 0[0]] [3 0[0]]}
290 check_doclist fts3d-4.4.8 1 0 three {[1] [2] [3]} 250 check_doclist fts3d-4.4.8 1 0 three {[1] [2] [3]}
291 check_doclist fts3d-4.4.9 1 0 two {[1] [2] [3]} 251 check_doclist fts3d-4.4.9 1 0 two {[1] [2] [3]}
292 check_doclist fts3d-4.4.10 1 0 was {[2 0[1]]} 252 check_doclist fts3d-4.4.10 1 0 was {[2 0[1]]}
293 253
294 # Optimize should leave the result in the level of the highest-level 254 # Optimize should leave the result in the level of the highest-level
295 # prior segment. 255 # prior segment.
256 breakpoint
296 do_test fts3d-4.5 { 257 do_test fts3d-4.5 {
297 execsql { 258 execsql {
298 SELECT OPTIMIZE(t1) FROM t1 LIMIT 1; 259 SELECT OPTIMIZE(t1) FROM t1 LIMIT 1;
299 SELECT level, idx FROM t1_segdir ORDER BY level, idx; 260 SELECT level, idx FROM t1_segdir ORDER BY level, idx;
300 } 261 }
301 } {{Index optimized} 1 0} 262 } {{Index optimized} 1 0}
302 263
303 # Identical to fts3d-4.matches. 264 # Identical to fts3d-4.matches.
304 do_test fts3d-4.5.matches { 265 do_test fts3d-4.5.matches {
305 execsql { 266 execsql {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 # Even if we move things around, still does nothing. 298 # Even if we move things around, still does nothing.
338 do_test fts3d-5.1 { 299 do_test fts3d-5.1 {
339 execsql { 300 execsql {
340 UPDATE t1_segdir SET level = 2 WHERE level = 1 AND idx = 0; 301 UPDATE t1_segdir SET level = 2 WHERE level = 1 AND idx = 0;
341 SELECT OPTIMIZE(t1) FROM t1 LIMIT 1; 302 SELECT OPTIMIZE(t1) FROM t1 LIMIT 1;
342 SELECT level, idx FROM t1_segdir ORDER BY level, idx; 303 SELECT level, idx FROM t1_segdir ORDER BY level, idx;
343 } 304 }
344 } {{Index already optimal} 2 0} 305 } {{Index already optimal} 2 0}
345 306
346 finish_test 307 finish_test
OLDNEW
« no previous file with comments | « third_party/sqlite/src/test/fts3cov.test ('k') | third_party/sqlite/src/test/fts3defer.test » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698