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 #************************************************************************* |
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 FTS3 module. | 12 # focus of this script is testing the FTS3 module. |
13 # | 13 # |
14 # $Id: fts3ao.test,v 1.1 2007/08/20 17:38:42 shess Exp $ | 14 # $Id: fts3ao.test,v 1.1 2007/08/20 17:38:42 shess Exp $ |
15 # | 15 # |
16 | 16 |
17 set testdir [file dirname $argv0] | 17 set testdir [file dirname $argv0] |
18 source $testdir/tester.tcl | 18 source $testdir/tester.tcl |
19 | 19 |
20 # If SQLITE_ENABLE_FTS3 is not defined, omit this file. | 20 # If SQLITE_ENABLE_FTS3 is not defined, omit this file. |
21 ifcapable !fts3 { | 21 ifcapable !fts3 { |
22 finish_test | 22 finish_test |
23 return | 23 return |
24 } | 24 } |
25 | 25 |
| 26 set ::testprefix fts3ao |
| 27 |
26 #--------------------------------------------------------------------- | 28 #--------------------------------------------------------------------- |
27 # These tests, fts3ao-1.*, test that ticket #2429 is fixed. | 29 # These tests, fts3ao-1.*, test that ticket #2429 is fixed. |
28 # | 30 # |
29 db eval { | 31 db eval { |
30 CREATE VIRTUAL TABLE t1 USING fts3(a, b, c); | 32 CREATE VIRTUAL TABLE t1 USING fts3(a, b, c); |
31 INSERT INTO t1(a, b, c) VALUES('one three four', 'one four', 'one four two'); | 33 INSERT INTO t1(a, b, c) VALUES('one three four', 'one four', 'one four two'); |
32 } | 34 } |
33 do_test fts3ao-1.1 { | 35 do_test fts3ao-1.1 { |
34 execsql { | 36 execsql { |
35 SELECT rowid, snippet(t1) FROM t1 WHERE c MATCH 'four'; | 37 SELECT rowid, snippet(t1) FROM t1 WHERE c MATCH 'four'; |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 } {} | 161 } {} |
160 | 162 |
161 do_test fts3ao-3.2 { | 163 do_test fts3ao-3.2 { |
162 execsql { SELECT a, b, c FROM t2 WHERE a MATCH 'song'; } | 164 execsql { SELECT a, b, c FROM t2 WHERE a MATCH 'song'; } |
163 } {{neung song sahm} {neung see} {neung see song}} | 165 } {{neung song sahm} {neung see} {neung see song}} |
164 | 166 |
165 do_test fts3ao-3.3 { | 167 do_test fts3ao-3.3 { |
166 execsql { SELECT a, b, c FROM t1 WHERE c MATCH 'two'; } | 168 execsql { SELECT a, b, c FROM t1 WHERE c MATCH 'two'; } |
167 } {{one three four} {one four} {one two}} | 169 } {{one three four} {one four} {one two}} |
168 | 170 |
| 171 #--------------------------------------------------------------------- |
| 172 # Test that it is possible to rename an fts3 table within a |
| 173 # transaction. |
| 174 # |
| 175 do_test fts3ao-4.1 { |
| 176 execsql { |
| 177 CREATE VIRTUAL TABLE t4 USING fts3; |
| 178 INSERT INTO t4 VALUES('the quick brown fox'); |
| 179 } |
| 180 } {} |
| 181 do_test fts3ao-4.2 { |
| 182 execsql { |
| 183 BEGIN; |
| 184 INSERT INTO t4 VALUES('jumped over the'); |
| 185 } |
| 186 } {} |
| 187 do_test fts3ao-4.3 { execsql { ALTER TABLE t4 RENAME TO t5; } } {} |
| 188 do_test fts3ao-4.4 { execsql { INSERT INTO t5 VALUES('lazy dog'); } } {} |
| 189 do_test fts3ao-4.5 { execsql COMMIT } {} |
| 190 do_test fts3ao-4.6 { |
| 191 execsql { SELECT * FROM t5 } |
| 192 } {{the quick brown fox} {jumped over the} {lazy dog}} |
| 193 do_test fts3ao-4.7 { |
| 194 execsql { |
| 195 BEGIN; |
| 196 INSERT INTO t5 VALUES('Down came a jumbuck to drink at that billabong'); |
| 197 ALTER TABLE t5 RENAME TO t6; |
| 198 INSERT INTO t6 VALUES('Down came the troopers, one, two, three'); |
| 199 ROLLBACK; |
| 200 SELECT * FROM t5; |
| 201 } |
| 202 } {{the quick brown fox} {jumped over the} {lazy dog}} |
| 203 |
| 204 # Test that it is possible to rename an FTS4 table. Renaming an FTS4 table |
| 205 # involves renaming the extra %_docsize and %_stat tables. |
| 206 # |
| 207 do_execsql_test 5.1 { |
| 208 CREATE VIRTUAL TABLE t7 USING FTS4; |
| 209 INSERT INTO t7 VALUES('coined by a German clinician'); |
| 210 SELECT count(*) FROM sqlite_master WHERE name LIKE 't7%'; |
| 211 SELECT count(*) FROM sqlite_master WHERE name LIKE 't8%'; |
| 212 } {6 0} |
| 213 do_execsql_test 5.2 { |
| 214 ALTER TABLE t7 RENAME TO t8; |
| 215 SELECT count(*) FROM sqlite_master WHERE name LIKE 't7%'; |
| 216 SELECT count(*) FROM sqlite_master WHERE name LIKE 't8%'; |
| 217 } {0 6} |
| 218 |
169 finish_test | 219 finish_test |
| 220 |
OLD | NEW |