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

Side by Side Diff: third_party/sqlite/sqlite-src-3080704/test/fts3conf.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 # 2011 April 25
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 FTS3 module.
13
14
15 set testdir [file dirname $argv0]
16 source $testdir/tester.tcl
17 set testprefix fts3conf
18
19 # If SQLITE_ENABLE_FTS3 is defined, omit this file.
20 ifcapable !fts3 {
21 finish_test
22 return
23 }
24
25
26 proc fts3_integrity {tn db tbl} {
27
28 if {[sqlite3_get_autocommit $db]==0} {
29 error "fts3_integrity does not work with an open transaction"
30 }
31
32 set sql [db one {SELECT sql FROM sqlite_master WHERE name = $tbl}]
33 regexp -nocase {[^(]* using (.*)} $sql -> tail
34 set cols [list]
35 $db eval "PRAGMA table_info($tbl)" {
36 lappend cols $name
37 }
38 set cols [join [concat docid $cols] ,]
39
40 $db eval [subst {
41 CREATE VIRTUAL TABLE fts3check USING fts4term($tbl);
42 CREATE VIRTUAL TABLE temp.fts3check2 USING $tail;
43 INSERT INTO temp.fts3check2($cols) SELECT docid, * FROM $tbl;
44 CREATE VIRTUAL TABLE temp.fts3check3 USING fts4term(fts3check2);
45 }]
46
47 set m1 [$db one {SELECT md5sum(term, docid, col, pos) FROM fts3check}]
48 set m2 [$db one {SELECT md5sum(term, docid, col, pos) FROM fts3check3}]
49
50 $db eval {
51 DROP TABLE fts3check;
52 DROP TABLE temp.fts3check2;
53 DROP TABLE temp.fts3check3;
54 }
55
56 uplevel [list do_test $tn [list set {} $m1] $m2]
57 }
58
59 do_execsql_test 1.0.1 {
60 CREATE VIRTUAL TABLE t1 USING fts3(x);
61 INSERT INTO t1(rowid, x) VALUES(1, 'a b c d');
62 INSERT INTO t1(rowid, x) VALUES(2, 'e f g h');
63
64 CREATE TABLE source(a, b);
65 INSERT INTO source VALUES(4, 'z');
66 INSERT INTO source VALUES(2, 'y');
67 }
68 db_save_and_close
69
70 set T1 "INTO t1(rowid, x) VALUES(1, 'x')"
71 set T2 "INTO t1(rowid, x) SELECT * FROM source"
72
73 set T3 "t1 SET docid = 2 WHERE docid = 1"
74 set T4 "t1 SET docid = CASE WHEN docid = 1 THEN 4 ELSE 3 END WHERE docid <=2"
75
76 foreach {tn sql uses constraint data} [subst {
77 1 "INSERT OR ROLLBACK $T1" 0 1 {{a b c d} {e f g h}}
78 2 "INSERT OR ABORT $T1" 0 1 {{a b c d} {e f g h} {i j k l}}
79 3 "INSERT OR FAIL $T1" 0 1 {{a b c d} {e f g h} {i j k l}}
80 4 "INSERT OR IGNORE $T1" 0 0 {{a b c d} {e f g h} {i j k l}}
81 5 "INSERT OR REPLACE $T1" 0 0 {x {e f g h} {i j k l}}
82
83 6 "INSERT OR ROLLBACK $T2" 1 1 {{a b c d} {e f g h}}
84 7 "INSERT OR ABORT $T2" 1 1 {{a b c d} {e f g h} {i j k l}}
85 8 "INSERT OR FAIL $T2" 1 1 {{a b c d} {e f g h} {i j k l} z}
86 9 "INSERT OR IGNORE $T2" 1 0 {{a b c d} {e f g h} {i j k l} z}
87 10 "INSERT OR REPLACE $T2" 1 0 {{a b c d} y {i j k l} z}
88
89 11 "UPDATE OR ROLLBACK $T3" 1 1 {{a b c d} {e f g h}}
90 12 "UPDATE OR ABORT $T3" 1 1 {{a b c d} {e f g h} {i j k l}}
91 13 "UPDATE OR FAIL $T3" 1 1 {{a b c d} {e f g h} {i j k l}}
92 14 "UPDATE OR IGNORE $T3" 1 0 {{a b c d} {e f g h} {i j k l}}
93 15 "UPDATE OR REPLACE $T3" 1 0 {{a b c d} {i j k l}}
94
95 16 "UPDATE OR ROLLBACK $T4" 1 1 {{a b c d} {e f g h}}
96 17 "UPDATE OR ABORT $T4" 1 1 {{a b c d} {e f g h} {i j k l}}
97 18 "UPDATE OR FAIL $T4" 1 1 {{e f g h} {i j k l} {a b c d}}
98 19 "UPDATE OR IGNORE $T4" 1 0 {{e f g h} {i j k l} {a b c d}}
99 20 "UPDATE OR REPLACE $T4" 1 0 {{e f g h} {a b c d}}
100 }] {
101 db_restore_and_reopen
102 execsql {
103 BEGIN;
104 INSERT INTO t1(rowid, x) VALUES(3, 'i j k l');
105 }
106 set R(0) {0 {}}
107 set R(1) {1 {constraint failed}}
108 do_catchsql_test 1.$tn.1 $sql $R($constraint)
109 do_catchsql_test 1.$tn.2 { SELECT * FROM t1 } [list 0 $data]
110 catchsql COMMIT
111
112 fts3_integrity 1.$tn.3 db t1
113
114 do_test 1.$tn.4 [list sql_uses_stmt db $sql] $uses
115 }
116
117 do_execsql_test 2.1.1 {
118 DELETE FROM t1;
119 BEGIN;
120 INSERT INTO t1 VALUES('a b c');
121 SAVEPOINT a;
122 INSERT INTO t1 VALUES('x y z');
123 ROLLBACK TO a;
124 COMMIT;
125 }
126 fts3_integrity 2.1.2 db t1
127
128 do_catchsql_test 2.2.1 {
129 DELETE FROM t1;
130 BEGIN;
131 INSERT INTO t1(docid, x) VALUES(0, 'a b c');
132 INSERT INTO t1(docid, x) VALUES(1, 'a b c');
133 REPLACE INTO t1(docid, x) VALUES('zero', 'd e f');
134 } {1 {datatype mismatch}}
135 do_execsql_test 2.2.2 { COMMIT }
136 do_execsql_test 2.2.3 { SELECT * FROM t1 } {{a b c} {a b c}}
137 fts3_integrity 2.2.4 db t1
138
139 do_execsql_test 3.1 {
140 CREATE VIRTUAL TABLE t3 USING fts4;
141 REPLACE INTO t3(docid, content) VALUES (1, 'one two');
142 SELECT quote(matchinfo(t3, 'na')) FROM t3 WHERE t3 MATCH 'one'
143 } {X'0100000002000000'}
144
145 do_execsql_test 3.2 {
146 REPLACE INTO t3(docid, content) VALUES (2, 'one two three four');
147 SELECT quote(matchinfo(t3, 'na')) FROM t3 WHERE t3 MATCH 'four'
148 } {X'0200000003000000'}
149
150 do_execsql_test 3.3 {
151 REPLACE INTO t3(docid, content) VALUES (1, 'one two three four five six');
152 SELECT quote(matchinfo(t3, 'na')) FROM t3 WHERE t3 MATCH 'six'
153 } {X'0200000005000000'}
154
155 do_execsql_test 3.4 {
156 UPDATE OR REPLACE t3 SET docid = 2 WHERE docid=1;
157 SELECT quote(matchinfo(t3, 'na')) FROM t3 WHERE t3 MATCH 'six'
158 } {X'0100000006000000'}
159
160 do_execsql_test 3.5 {
161 UPDATE OR REPLACE t3 SET docid = 3 WHERE docid=2;
162 SELECT quote(matchinfo(t3, 'na')) FROM t3 WHERE t3 MATCH 'six'
163 } {X'0100000006000000'}
164
165 do_execsql_test 3.6 {
166 REPLACE INTO t3(docid, content) VALUES (3, 'one two');
167 SELECT quote(matchinfo(t3, 'na')) FROM t3 WHERE t3 MATCH 'one'
168 } {X'0100000002000000'}
169
170 do_execsql_test 3.7 {
171 REPLACE INTO t3(docid, content) VALUES (NULL, 'one two three four');
172 REPLACE INTO t3(docid, content) VALUES (NULL, 'one two three four five six');
173 SELECT docid FROM t3;
174 } {3 4 5}
175
176 do_execsql_test 3.8 {
177 UPDATE OR REPLACE t3 SET docid = 5, content='three four' WHERE docid = 4;
178 SELECT quote(matchinfo(t3, 'na')) FROM t3 WHERE t3 MATCH 'one'
179 } {X'0200000002000000'}
180
181 finish_test
OLDNEW
« no previous file with comments | « third_party/sqlite/sqlite-src-3080704/test/fts3comp1.test ('k') | third_party/sqlite/sqlite-src-3080704/test/fts3corrupt.test » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698