| OLD | NEW |
| 1 # 2014 June 17 | 1 # 2014 June 17 |
| 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 FTS5 module. | 12 # focus of this script is testing the FTS5 module. |
| 13 # | 13 # |
| 14 # More specifically, the focus is on testing prefix queries, both with and |
| 15 # without prefix indexes. |
| 14 # | 16 # |
| 15 | 17 |
| 16 source [file join [file dirname [info script]] fts5_common.tcl] | 18 source [file join [file dirname [info script]] fts5_common.tcl] |
| 17 set testprefix fts5ad | 19 set testprefix fts5ad |
| 18 | 20 |
| 19 # If SQLITE_ENABLE_FTS5 is defined, omit this file. | 21 # If SQLITE_ENABLE_FTS5 is defined, omit this file. |
| 20 ifcapable !fts5 { | 22 ifcapable !fts5 { |
| 21 finish_test | 23 finish_test |
| 22 return | 24 return |
| 23 } | 25 } |
| 24 | 26 |
| 27 foreach_detail_mode $testprefix { |
| 28 |
| 25 do_execsql_test 1.0 { | 29 do_execsql_test 1.0 { |
| 26 CREATE VIRTUAL TABLE yy USING fts5(x, y); | 30 CREATE VIRTUAL TABLE yy USING fts5(x, y, detail=%DETAIL%); |
| 27 INSERT INTO yy VALUES('Changes the result to be', 'the list of all matching'); | 31 INSERT INTO yy VALUES('Changes the result to be', 'the list of all matching'); |
| 28 INSERT INTO yy VALUES('indices (or all matching', 'values if -inline is'); | 32 INSERT INTO yy VALUES('indices (or all matching', 'values if -inline is'); |
| 29 INSERT INTO yy VALUES('specified as well.) If', 'indices are returned, the'); | 33 INSERT INTO yy VALUES('specified as well.) If', 'indices are returned, the'); |
| 30 } {} | 34 } {} |
| 31 | 35 |
| 32 foreach {tn match res} { | 36 foreach {tn match res} { |
| 33 1 {c*} {1} | 37 1 {c*} {1} |
| 34 2 {i*} {3 2} | 38 2 {i*} {3 2} |
| 35 3 {t*} {3 1} | 39 3 {t*} {3 1} |
| 36 4 {r*} {3 1} | 40 4 {r*} {3 1} |
| 37 } { | 41 } { |
| 38 do_execsql_test 1.$tn { | 42 do_execsql_test 1.$tn { |
| 39 SELECT rowid FROM yy WHERE yy MATCH $match ORDER BY rowid DESC | 43 SELECT rowid FROM yy WHERE yy MATCH $match ORDER BY rowid DESC |
| 40 } $res | 44 } $res |
| 41 } | 45 } |
| 42 | 46 |
| 43 foreach {tn match res} { | 47 foreach {tn match res} { |
| 44 5 {c*} {1} | 48 5 {c*} {1} |
| 45 6 {i*} {2 3} | 49 6 {i*} {2 3} |
| 46 7 {t*} {1 3} | 50 7 {t*} {1 3} |
| 47 8 {r*} {1 3} | 51 8 {r*} {1 3} |
| 48 } { | 52 } { |
| 49 do_execsql_test 1.$tn { | 53 do_execsql_test 1.$tn { |
| 50 SELECT rowid FROM yy WHERE yy MATCH $match | 54 SELECT rowid FROM yy WHERE yy MATCH $match |
| 51 } $res | 55 } $res |
| 52 } | 56 } |
| 53 | 57 |
| 54 foreach {T create} { | 58 foreach {T create} { |
| 55 2 { | 59 2 { |
| 56 CREATE VIRTUAL TABLE t1 USING fts5(a, b); | 60 CREATE VIRTUAL TABLE t1 USING fts5(a, b, detail=%DETAIL%); |
| 57 INSERT INTO t1(t1, rank) VALUES('pgsz', 32); | 61 INSERT INTO t1(t1, rank) VALUES('pgsz', 32); |
| 58 } | 62 } |
| 59 | 63 |
| 60 3 { | 64 3 { |
| 61 CREATE VIRTUAL TABLE t1 USING fts5(a, b, prefix=1,2,3,4,5); | 65 CREATE VIRTUAL TABLE t1 USING fts5(a, b, prefix="1,2,3,4", detail=%DETAIL%); |
| 62 INSERT INTO t1(t1, rank) VALUES('pgsz', 32); | 66 INSERT INTO t1(t1, rank) VALUES('pgsz', 32); |
| 63 } | 67 } |
| 64 | 68 |
| 65 4 { | 69 4 { |
| 66 CREATE VIRTUAL TABLE t1 USING fts5(a, b); | 70 CREATE VIRTUAL TABLE t1 USING fts5(a, b, detail=%DETAIL%); |
| 67 INSERT INTO t1(t1, rank) VALUES('pgsz', 32); | 71 INSERT INTO t1(t1, rank) VALUES('pgsz', 32); |
| 68 BEGIN; | 72 BEGIN; |
| 69 } | 73 } |
| 70 | 74 |
| 71 5 { | 75 5 { |
| 72 CREATE VIRTUAL TABLE t1 USING fts5(a, b, prefix=1,2,3,4,5); | 76 CREATE VIRTUAL TABLE t1 USING fts5(a, b, prefix="1,2,3,4", detail=%DETAIL%); |
| 73 INSERT INTO t1(t1, rank) VALUES('pgsz', 32); | 77 INSERT INTO t1(t1, rank) VALUES('pgsz', 32); |
| 74 BEGIN; | 78 BEGIN; |
| 75 } | 79 } |
| 76 | 80 |
| 77 } { | 81 } { |
| 78 | 82 |
| 79 do_test $T.1 { | 83 do_test $T.1 { |
| 80 execsql { DROP TABLE IF EXISTS t1 } | 84 execsql { DROP TABLE IF EXISTS t1 } |
| 81 execsql $create | 85 execsql $create |
| 82 } {} | 86 } {} |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 } | 232 } |
| 229 set n [llength $res] | 233 set n [llength $res] |
| 230 if {$T==5} breakpoint | 234 if {$T==5} breakpoint |
| 231 do_execsql_test $T.$bAsc.$tn.$n $sql $res | 235 do_execsql_test $T.$bAsc.$tn.$n $sql $res |
| 232 } | 236 } |
| 233 } | 237 } |
| 234 | 238 |
| 235 catchsql COMMIT | 239 catchsql COMMIT |
| 236 } | 240 } |
| 237 | 241 |
| 242 } |
| 243 |
| 238 finish_test | 244 finish_test |
| 239 | 245 |
| OLD | NEW |