2010-10-19 18:07:59 +04:00
|
|
|
# 2006 October 31
|
2007-08-20 21:38:42 +04:00
|
|
|
#
|
2010-10-19 18:07:59 +04:00
|
|
|
# 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.
|
2007-08-20 21:38:42 +04:00
|
|
|
#
|
|
|
|
#*************************************************************************
|
|
|
|
# This file implements regression tests for SQLite library. The focus
|
2010-10-19 18:07:59 +04:00
|
|
|
# here is testing correct handling of very long terms.
|
2007-08-20 21:38:42 +04:00
|
|
|
#
|
|
|
|
|
|
|
|
set testdir [file dirname $argv0]
|
|
|
|
source $testdir/tester.tcl
|
|
|
|
|
2010-10-19 18:07:59 +04:00
|
|
|
# If SQLITE_ENABLE_FTS3 is not defined, omit this file.
|
2007-08-20 21:38:42 +04:00
|
|
|
ifcapable !fts3 {
|
|
|
|
finish_test
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
# Generate a document of bigterms based on characters from the list
|
|
|
|
# chars.
|
|
|
|
proc bigtermdoc {chars len} {
|
|
|
|
set doc ""
|
|
|
|
foreach char $chars {
|
2010-10-19 18:07:59 +04:00
|
|
|
append doc " " [string repeat $char $len]
|
2007-08-20 21:38:42 +04:00
|
|
|
}
|
|
|
|
return $doc
|
|
|
|
}
|
|
|
|
|
|
|
|
set len 5000
|
|
|
|
set doc1 [bigtermdoc {a b c d} $len]
|
|
|
|
set doc2 [bigtermdoc {b d e f} $len]
|
|
|
|
set doc3 [bigtermdoc {a c e} $len]
|
|
|
|
|
2010-10-19 18:07:59 +04:00
|
|
|
set aterm [string repeat a $len]
|
|
|
|
set bterm [string repeat b $len]
|
|
|
|
set xterm [string repeat x $len]
|
2007-08-20 21:38:42 +04:00
|
|
|
|
|
|
|
db eval {
|
|
|
|
CREATE VIRTUAL TABLE t1 USING fts3(content);
|
|
|
|
INSERT INTO t1 (rowid, content) VALUES(1, $doc1);
|
|
|
|
INSERT INTO t1 (rowid, content) VALUES(2, $doc2);
|
|
|
|
INSERT INTO t1 (rowid, content) VALUES(3, $doc3);
|
|
|
|
}
|
|
|
|
|
|
|
|
# No hits at all. Returns empty doclists from termSelect().
|
|
|
|
do_test fts3ah-1.1 {
|
|
|
|
execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'something'}
|
|
|
|
} {}
|
|
|
|
|
|
|
|
do_test fts3ah-1.2 {
|
|
|
|
execsql {SELECT rowid FROM t1 WHERE t1 MATCH $aterm}
|
|
|
|
} {1 3}
|
|
|
|
|
2010-10-20 22:56:04 +04:00
|
|
|
do_test fts3ah-1.3 {
|
2007-08-20 21:38:42 +04:00
|
|
|
execsql {SELECT rowid FROM t1 WHERE t1 MATCH $xterm}
|
|
|
|
} {}
|
|
|
|
|
2010-10-20 22:56:04 +04:00
|
|
|
do_test fts3ah-1.4 {
|
2007-08-20 21:38:42 +04:00
|
|
|
execsql "SELECT rowid FROM t1 WHERE t1 MATCH '$aterm -$xterm'"
|
|
|
|
} {1 3}
|
|
|
|
|
2010-10-20 22:56:04 +04:00
|
|
|
do_test fts3ah-1.5 {
|
2007-08-20 21:38:42 +04:00
|
|
|
execsql "SELECT rowid FROM t1 WHERE t1 MATCH '\"$aterm $bterm\"'"
|
|
|
|
} {1}
|
|
|
|
|
|
|
|
finish_test
|