624edacf6a
FossilOrigin-Name: 352413eed469802665e7d2c17b7fe6e3a0b0b2209ce45bdc85fd4243cec50ea6
125 lines
3.3 KiB
Plaintext
125 lines
3.3 KiB
Plaintext
# 2017 March 22
|
|
#
|
|
# The author disclaims copyright to this source code. In place of
|
|
# a legal notice, here is a blessing:
|
|
#
|
|
# May you do good and not evil.
|
|
# May you find forgiveness for yourself and forgive others.
|
|
# May you share freely, never taking more than you give.
|
|
#
|
|
#*************************************************************************
|
|
# This file implements regression tests for SQLite library. The
|
|
# focus of this script is testing the FTS3 module.
|
|
#
|
|
|
|
set testdir [file dirname $argv0]
|
|
source $testdir/tester.tcl
|
|
set testprefix fts3misc
|
|
|
|
# If SQLITE_ENABLE_FTS3 is defined, omit this file.
|
|
ifcapable !fts3 {
|
|
finish_test
|
|
return
|
|
}
|
|
|
|
#-------------------------------------------------------------------------
|
|
# A self-join.
|
|
#
|
|
do_execsql_test 1.0 {
|
|
CREATE VIRTUAL TABLE t1 USING fts3(a, b);
|
|
INSERT INTO t1 VALUES('one', 'i');
|
|
INSERT INTO t1 VALUES('one', 'ii');
|
|
INSERT INTO t1 VALUES('two', 'i');
|
|
INSERT INTO t1 VALUES('two', 'ii');
|
|
}
|
|
|
|
do_execsql_test 1.1 {
|
|
SELECT a.a, b.b FROM t1 a, t1 b WHERE a.t1 MATCH 'two' AND b.t1 MATCH 'i'
|
|
} {two i two i two i two i}
|
|
|
|
#-------------------------------------------------------------------------
|
|
# FTS tables with 128 or more columns.
|
|
#
|
|
proc v1 {v} {
|
|
set vector [list a b c d e f g h]
|
|
set res [list]
|
|
for {set i 0} {$i<8} {incr i} {
|
|
if {$v & (1 << $i)} { lappend res [lindex $vector $i] }
|
|
}
|
|
set res
|
|
}
|
|
proc v2 {v} {
|
|
set vector [list d e f g h i j k]
|
|
set res [list]
|
|
for {set i 0} {$i<8} {incr i} {
|
|
if {$v & (1 << $i)} { lappend res [lindex $vector $i] }
|
|
}
|
|
set res
|
|
}
|
|
db func v1 v1
|
|
db func v2 v2
|
|
|
|
do_test 2.0 {
|
|
set cols [list]
|
|
for {set i 0} {$i<200} {incr i} {
|
|
lappend cols "c$i"
|
|
}
|
|
execsql "CREATE VIRTUAL TABLE t2 USING fts3([join $cols ,])"
|
|
execsql {
|
|
WITH data(i) AS (
|
|
SELECT 1 UNION ALL SELECT i+1 FROM data WHERE i<200
|
|
)
|
|
INSERT INTO t2(c198, c199) SELECT v1(i), v2(i) FROM data;
|
|
}
|
|
} {}
|
|
do_execsql_test 2.1 {
|
|
SELECT rowid FROM t2 WHERE t2 MATCH '"a b c"'
|
|
} {
|
|
7 15 23 31 39 47 55 63 71 79 87 95 103 111
|
|
119 127 135 143 151 159 167 175 183 191 199
|
|
}
|
|
do_execsql_test 2.2 {
|
|
SELECT rowid FROM t2 WHERE t2 MATCH '"g h i"'
|
|
} {
|
|
56 57 58 59 60 61 62 63 120 121 122 123 124
|
|
125 126 127 184 185 186 187 188 189 190 191
|
|
}
|
|
do_execsql_test 2.3 {
|
|
SELECT rowid FROM t2 WHERE t2 MATCH '"i h"'
|
|
} {
|
|
}
|
|
do_execsql_test 2.4 {
|
|
SELECT rowid FROM t2 WHERE t2 MATCH '"f e"'
|
|
} {
|
|
}
|
|
do_execsql_test 2.5 {
|
|
SELECT rowid FROM t2 WHERE t2 MATCH '"e f"'
|
|
} {
|
|
6 7 14 15 22 23 30 31 38 39 46 47 48 49 50 51 52 53 54 55 56
|
|
57 58 59 60 61 62 63 70 71 78 79 86 87 94 95 102 103 110
|
|
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
|
|
134 135 142 143 150 151 158 159 166 167 174 175 176 177 178 179 180
|
|
181 182 183 184 185 186 187 188 189 190 191 198 199
|
|
}
|
|
|
|
# Range constraints on the docid using non-integer values.
|
|
#
|
|
do_execsql_test 2.6 {
|
|
SELECT rowid FROM t2 WHERE t2 MATCH 'e' AND rowid BETWEEN NULL AND 45;
|
|
} {}
|
|
do_execsql_test 2.7 {
|
|
SELECT rowid FROM t2 WHERE t2 MATCH 'e' AND rowid BETWEEN 11.5 AND 48.2;
|
|
} {
|
|
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
|
29 30 31 34 35 38 39 42 43 46 47 48
|
|
}
|
|
do_execsql_test 2.8 {
|
|
SELECT rowid FROM t2 WHERE t2 MATCH 'e' AND rowid BETWEEN '11.5' AND '48.2';
|
|
} {
|
|
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
|
29 30 31 34 35 38 39 42 43 46 47 48
|
|
}
|
|
|
|
|
|
finish_test
|