OLD | NEW |
1 # 2007 June 20 | 1 # 2007 June 20 |
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 #************************************************************************* |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 } {{one three four} {one two three}} | 104 } {{one three four} {one two three}} |
105 do_test fts3ao-2.12 { | 105 do_test fts3ao-2.12 { |
106 execsql { SELECT a, b, c FROM fts_t1 WHERE c MATCH 'four'; } | 106 execsql { SELECT a, b, c FROM fts_t1 WHERE c MATCH 'four'; } |
107 } {{one three four} {one four} {one four two}} | 107 } {{one three four} {one four} {one four two}} |
108 | 108 |
109 #------------------------------------------------------------------- | 109 #------------------------------------------------------------------- |
110 # Close, delete and reopen the database. The following test should | 110 # Close, delete and reopen the database. The following test should |
111 # be run on an initially empty db. | 111 # be run on an initially empty db. |
112 # | 112 # |
113 db close | 113 db close |
114 file delete -force test.db test.db-journal | 114 forcedelete test.db test.db-journal |
115 sqlite3 db test.db | 115 sqlite3 db test.db |
116 | 116 |
117 do_test fts3ao-3.1 { | 117 do_test fts3ao-3.1 { |
118 execsql { | 118 execsql { |
119 CREATE VIRTUAL TABLE t1 USING fts3(a, b, c); | 119 CREATE VIRTUAL TABLE t1 USING fts3(a, b, c); |
120 INSERT INTO t1(a, b, c) VALUES('one three four', 'one four', 'one two'); | 120 INSERT INTO t1(a, b, c) VALUES('one three four', 'one four', 'one two'); |
121 SELECT a, b, c FROM t1 WHERE c MATCH 'two'; | 121 SELECT a, b, c FROM t1 WHERE c MATCH 'two'; |
122 } | 122 } |
123 } {{one three four} {one four} {one two}} | 123 } {{one three four} {one four} {one two}} |
124 | 124 |
125 # This test was crashing at one point. | 125 # This test was crashing at one point. |
126 # | 126 # |
127 do_test fts3ao-3.2 { | 127 do_test fts3ao-3.2 { |
128 execsql { | 128 execsql { |
129 SELECT a, b, c FROM t1 WHERE c MATCH 'two'; | 129 SELECT a, b, c FROM t1 WHERE c MATCH 'two'; |
130 CREATE TABLE t3(a, b, c); | 130 CREATE TABLE t3(a, b, c); |
131 SELECT a, b, c FROM t1 WHERE c MATCH 'two'; | 131 SELECT a, b, c FROM t1 WHERE c MATCH 'two'; |
132 } | 132 } |
133 } {{one three four} {one four} {one two} {one three four} {one four} {one two}} | 133 } {{one three four} {one four} {one two} {one three four} {one four} {one two}} |
134 | 134 |
135 #--------------------------------------------------------------------- | 135 #--------------------------------------------------------------------- |
136 # Test that it is possible to rename an fts3 table in an attached | 136 # Test that it is possible to rename an fts3 table in an attached |
137 # database. | 137 # database. |
138 # | 138 # |
139 file delete -force test2.db test2.db-journal | 139 forcedelete test2.db test2.db-journal |
140 | 140 |
141 do_test fts3ao-3.1 { | 141 do_test fts3ao-3.1 { |
142 execsql { | 142 execsql { |
143 ATTACH 'test2.db' AS aux; | 143 ATTACH 'test2.db' AS aux; |
144 CREATE VIRTUAL TABLE aux.t1 USING fts3(a, b, c); | 144 CREATE VIRTUAL TABLE aux.t1 USING fts3(a, b, c); |
145 INSERT INTO aux.t1(a, b, c) VALUES( | 145 INSERT INTO aux.t1(a, b, c) VALUES( |
146 'neung song sahm', 'neung see', 'neung see song' | 146 'neung song sahm', 'neung see', 'neung see song' |
147 ); | 147 ); |
148 } | 148 } |
149 } {} | 149 } {} |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 do_test fts3ao-4.7 { | 193 do_test fts3ao-4.7 { |
194 execsql { | 194 execsql { |
195 BEGIN; | 195 BEGIN; |
196 INSERT INTO t5 VALUES('Down came a jumbuck to drink at that billabong'); | 196 INSERT INTO t5 VALUES('Down came a jumbuck to drink at that billabong'); |
197 ALTER TABLE t5 RENAME TO t6; | 197 ALTER TABLE t5 RENAME TO t6; |
198 INSERT INTO t6 VALUES('Down came the troopers, one, two, three'); | 198 INSERT INTO t6 VALUES('Down came the troopers, one, two, three'); |
199 ROLLBACK; | 199 ROLLBACK; |
200 SELECT * FROM t5; | 200 SELECT * FROM t5; |
201 } | 201 } |
202 } {{the quick brown fox} {jumped over the} {lazy dog}} | 202 } {{the quick brown fox} {jumped over the} {lazy dog}} |
| 203 do_execsql_test fts3ao-4.8 { |
| 204 SELECT snippet(t5, '[', ']') FROM t5 WHERE t5 MATCH 'the' |
| 205 } {{[the] quick brown fox} {jumped over [the]}} |
203 | 206 |
204 # Test that it is possible to rename an FTS4 table. Renaming an FTS4 table | 207 # Test that it is possible to rename an FTS4 table. Renaming an FTS4 table |
205 # involves renaming the extra %_docsize and %_stat tables. | 208 # involves renaming the extra %_docsize and %_stat tables. |
206 # | 209 # |
207 do_execsql_test 5.1 { | 210 do_execsql_test 5.1 { |
208 CREATE VIRTUAL TABLE t7 USING FTS4; | 211 CREATE VIRTUAL TABLE t7 USING FTS4; |
209 INSERT INTO t7 VALUES('coined by a German clinician'); | 212 INSERT INTO t7 VALUES('coined by a German clinician'); |
210 SELECT count(*) FROM sqlite_master WHERE name LIKE 't7%'; | 213 SELECT count(*) FROM sqlite_master WHERE name LIKE 't7%'; |
211 SELECT count(*) FROM sqlite_master WHERE name LIKE 't8%'; | 214 SELECT count(*) FROM sqlite_master WHERE name LIKE 't8%'; |
212 } {6 0} | 215 } {6 0} |
213 do_execsql_test 5.2 { | 216 do_execsql_test 5.2 { |
214 ALTER TABLE t7 RENAME TO t8; | 217 ALTER TABLE t7 RENAME TO t8; |
215 SELECT count(*) FROM sqlite_master WHERE name LIKE 't7%'; | 218 SELECT count(*) FROM sqlite_master WHERE name LIKE 't7%'; |
216 SELECT count(*) FROM sqlite_master WHERE name LIKE 't8%'; | 219 SELECT count(*) FROM sqlite_master WHERE name LIKE 't8%'; |
217 } {0 6} | 220 } {0 6} |
218 | 221 |
| 222 # At one point this was causing a memory leak. |
| 223 # |
| 224 foreach {tn sql} { |
| 225 1 {} |
| 226 2 { INSERT INTO ft(ft) VALUES('merge=2,2'); } |
| 227 } { |
| 228 reset_db |
| 229 do_execsql_test 6.$tn.1 " |
| 230 CREATE TABLE t1(x); |
| 231 CREATE VIRTUAL TABLE ft USING fts3; |
| 232 INSERT INTO ft VALUES('hello world'); |
| 233 $sql |
| 234 " |
| 235 |
| 236 db close |
| 237 sqlite3 db test.db |
| 238 do_execsql_test 6.$tn.2 { SELECT * FROM t1 } {} |
| 239 |
| 240 do_test 6.$tn.3 { |
| 241 sqlite3 db2 test.db |
| 242 db2 eval { DROP TABLE t1 } |
| 243 db2 close |
| 244 set stmt [sqlite3_prepare db { SELECT * FROM ft } -1 dummy] |
| 245 sqlite3_finalize $stmt |
| 246 } {SQLITE_OK} |
| 247 db close |
| 248 } |
| 249 |
219 finish_test | 250 finish_test |
220 | |
OLD | NEW |