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

Side by Side Diff: third_party/sqlite/sqlite-src-3080704/test/fts4aa.test

Issue 883353008: [sql] Import reference version of SQLite 3.8.7.4. (Closed) Base URL: http://chromium.googlesource.com/chromium/src.git@master
Patch Set: Hold back encoding change which is messing up patch. Created 5 years, 10 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 # 2010 February 02
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 # This file implements regression tests for SQLite library. The
12 # focus of this script is testing the FTS4 module.
13 #
14 #
15
16 set testdir [file dirname $argv0]
17 source $testdir/tester.tcl
18
19 # If SQLITE_ENABLE_FTS3 is defined, omit this file.
20 ifcapable !fts3 {
21 finish_test
22 return
23 }
24
25 # Create the fts_kjv_genesis procedure which fills and FTS3/4 table with
26 # the complete text of the Book of Genesis.
27 #
28 source $testdir/genesis.tcl
29
30 # The following is a list of queries to perform against the above
31 # FTS3/FTS4 database. We will be trying these queries in various
32 # configurations to ensure that they always return the same answers.
33 #
34 set fts4aa_queries {
35 {abraham}
36 {the king}
37 {"the king"}
38 {abraham OR joseph}
39 {ab* OR jos*}
40 {lived t*}
41 {spake hebrew}
42 {melchizedek}
43 {t* melchizedek}
44 {melchizedek t*}
45 }
46 unset -nocomplain fts4aa_res
47
48 # Set up the baseline results
49 #
50 do_test fts4aa-1.0 {
51 db eval {
52 CREATE VIRTUAL TABLE t1 USING fts4(words, tokenize porter);
53 }
54 fts_kjv_genesis
55 foreach q $::fts4aa_queries {
56 set r [db eval {SELECT docid FROM t1 WHERE words MATCH $q ORDER BY docid}]
57 set ::fts4aa_res($q) $r
58 }
59 } {}
60
61 # Legacy test cases
62 #
63 do_test fts4aa-1.1 {
64 db eval {
65 SELECT docid FROM t1 EXCEPT SELECT docid FROM t1_docsize
66 }
67 } {}
68 do_test fts4aa-1.2 {
69 db eval {
70 SELECT docid FROM t1_docsize EXCEPT SELECT docid FROM t1
71 }
72 } {}
73
74 proc mit {blob} {
75 set scan(littleEndian) i*
76 set scan(bigEndian) I*
77 binary scan $blob $scan($::tcl_platform(byteOrder)) r
78 return $r
79 }
80 db func mit mit
81
82 do_test fts4aa-1.3 {
83 db eval {
84 SELECT docid, mit(matchinfo(t1, 'pcxnal')) FROM t1 WHERE t1 MATCH 'melchized ek';
85 }
86 } {1014018 {1 1 1 1 1 1533 25 20}}
87 do_test fts4aa-1.4 {
88 db eval {
89 SELECT docid, mit(matchinfo(t1, 'pcxnal')) FROM t1
90 WHERE t1 MATCH 'spake hebrew'
91 ORDER BY docid;
92 }
93 } {1039014 {2 1 1 40 40 1 6 6 1533 25 42} 1039017 {2 1 1 40 40 1 6 6 1533 25 26} }
94 do_test fts4aa-1.5 {
95 db eval {
96 SELECT docid, mit(matchinfo(t1, 'pcxnal')) FROM t1
97 WHERE t1 MATCH 'laban overtook jacob'
98 ORDER BY docid;
99 }
100 } {1031025 {3 1 2 54 46 1 3 3 2 181 160 1533 25 24}}
101
102 do_test fts4aa-1.6 {
103 db eval {
104 DELETE FROM t1 WHERE docid!=1050026;
105 SELECT hex(size) FROM t1_docsize;
106 SELECT hex(value) FROM t1_stat;
107 }
108 } {17 01176F}
109
110 do_test fts4aa-1.7 {
111 db eval {
112 SELECT docid FROM t1 EXCEPT SELECT docid FROM t1_docsize
113 }
114 } {}
115 do_test fts4aa-1.8 {
116 db eval {
117 SELECT docid FROM t1_docsize EXCEPT SELECT docid FROM t1
118 }
119 } {}
120 ifcapable fts4_deferred {
121 do_test fts4aa-1.9 {
122 # Note: Token 'in' is being deferred in the following query.
123 db eval {
124 SELECT docid, mit(matchinfo(t1, 'pcxnal')) FROM t1
125 WHERE t1 MATCH 'joseph died in egypt'
126 ORDER BY docid;
127 }
128 } {1050026 {4 1 1 1 1 1 1 1 2 1 1 1 1 1 1 23 23}}
129 }
130
131 # Should get the same search results from FTS3
132 #
133 do_test fts4aa-2.0 {
134 db eval {
135 DROP TABLE t1;
136 CREATE VIRTUAL TABLE t1 USING fts3(words, tokenize porter);
137 }
138 fts_kjv_genesis
139 } {}
140 unset -nocomplain ii
141 set ii 0
142 foreach {q r} [array get fts4aa_res] {
143 incr ii
144 do_test fts4aa-2.$ii {
145 db eval {SELECT docid FROM t1 WHERE words MATCH $::q ORDER BY docid}
146 } $r
147 }
148
149 # Should get the same search results when the page size is very large
150 #
151 do_test fts4aa-3.0 {
152 db close
153 forcedelete test.db
154 sqlite3 db test.db
155 db eval {
156 PRAGMA page_size=65536;
157 CREATE VIRTUAL TABLE t1 USING fts4(words, tokenize porter);
158 }
159 fts_kjv_genesis
160 } {}
161 unset -nocomplain ii
162 set ii 0
163 foreach {q r} [array get fts4aa_res] {
164 incr ii
165 do_test fts4aa-3.$ii {
166 db eval {SELECT docid FROM t1 WHERE words MATCH $::q ORDER BY docid}
167 } $r
168 }
169
170 # Should get the same search results when an authorizer prevents
171 # all PRAGMA statements.
172 #
173 proc no_pragma_auth {code arg1 arg2 arg3 arg4 args} {
174 if {$code=="SQLITE_PRAGMA"} {return SQLITE_DENY}
175 return SQLITE_OK;
176 }
177 do_test fts4aa-4.0 {
178 db auth ::no_pragma_auth
179 db eval {
180 DROP TABLE t1;
181 CREATE VIRTUAL TABLE t1 USING fts4(words, tokenize porter);
182 }
183 fts_kjv_genesis
184 } {}
185 unset -nocomplain ii
186 set ii 0
187 foreach {q r} [array get fts4aa_res] {
188 incr ii
189 do_test fts4aa-4.$ii {
190 db eval {SELECT docid FROM t1 WHERE words MATCH $::q ORDER BY docid}
191 } $r
192 }
193
194 finish_test
OLDNEW
« no previous file with comments | « third_party/sqlite/sqlite-src-3080704/test/fts3varint.test ('k') | third_party/sqlite/sqlite-src-3080704/test/fts4check.test » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698