1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-05 15:55:57 +03:00

Remove additional traces of FTS1 and FTS2 that were missed by [2bb50d5aedef0fd2]

FossilOrigin-Name: 9a12bac5d24c7a8364d2127fd12c3409a53ef83e408d10f344ddd311cdba98af
This commit is contained in:
drh
2023-06-07 15:00:54 +00:00
parent 1d7c88bf98
commit c5a5a54c51
38 changed files with 8 additions and 29802 deletions

View File

@@ -1,5 +1,5 @@
C Remove\sunused,\slegacy\sshell\sscript\s"mkso.sh"\sfrom\sthe\sroot\sof\sthe\srepo.
D 2023-06-07T14:47:29.936
C Remove\sadditional\straces\sof\sFTS1\sand\sFTS2\sthat\swere\smissed\sby\s[2bb50d5aedef0fd2]
D 2023-06-07T15:00:54.470
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@ -599,7 +599,7 @@ F src/insert.c a8de1db43335fc4946370a7a7e47d89975ad678ddb15078a150e993ba2fb37d4
F src/json.c 39b1c7527f3111923e65f168a87b03b591f12a41400a63d05c119794bee36620
F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa
F src/loadext.c 176d6b2cb18a6ad73b133db17f6fc351c4d9a2d510deebdb76c22bde9cfd1465
F src/main.c 8024bdacd452fc114e34a6bc9d75d1b33ac64c40222d2aa82d3edd1a1a58f976
F src/main.c fc470d4e05d31a5f7e76127bf72ce08e5e0101ddc5bc4d70191f020a949225f8
F src/malloc.c 47b82c5daad557d9b963e3873e99c22570fb470719082c6658bf64e3012f7d23
F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645
F src/mem1.c c12a42539b1ba105e3707d0e628ad70e611040d8f5e38cf942cee30c867083de
@@ -660,7 +660,7 @@ F src/test_backup.c bf5da90c9926df0a4b941f2d92825a01bbe090a0
F src/test_bestindex.c 68c62586d2ae9f032903fe53be743657d0c2aac0a850b880938b668e1161d516
F src/test_blob.c ae4a0620b478548afb67963095a7417cd06a4ec0a56adb453542203bfdcb31ce
F src/test_btree.c 8b2dc8b8848cf3a4db93f11578f075e82252a274
F src/test_config.c 8264637b06a3c1f0727c88d1ea32dcf7986b9e7e358a970cae87cdac8a5b2708
F src/test_config.c f0cc1f517deaa96dd384822ae2bb91534fa56aa458528b439830d709941d3932
F src/test_delete.c e2fe07646dff6300b48d49b2fee2fe192ed389e834dd635e3b3bac0ce0bf9f8f
F src/test_demovfs.c 38a459d1c78fd9afa770445b224c485e079018d6ac07332ff9bd07b54d2b8ce9
F src/test_devsym.c aff2255ea290d7718da08af30cdf18e470ff7325a5eff63e0057b1496ed66593
@@ -1014,40 +1014,6 @@ F test/fkey_malloc.test 594a7ea1fbab553c036c70813cd8bd9407d63749
F test/fordelete.test ba98f14446b310f9c9d935b97ec748753d0144a28b356ba30d1f4f6958fdde5c
F test/format4.test eeae341953db8b6bda7f549044797c3278a6cc345d11ada81471671b654f8ef4
F test/fts-9fd058691.test 78b887e30ae6816df0e1fed6259de4b5a64ad33c
F test/fts1a.test 46090311f85da51bb33bd5ce84f7948359c6d8d7
F test/fts1b.test 5d8a01aefbecc8b7442b36c94c05eb7a845462d5
F test/fts1c.test 85a525ce7428907469b4cce13d5563ce542ce64c
F test/fts1d.test a73deace5c18df4a549b12908bade4f05dcf1a2f
F test/fts1e.test 77244843e925560b5a0b70069c3e7ab62f181ed2
F test/fts1f.test 2d6cb10d8b7a4e6edc321bbdb3982f1f48774714
F test/fts1i.test 6bfe08cdfdced063a39a50c8601da65e6274d879
F test/fts1j.test e3797475796043a161e348c46a309664cac83f7f
F test/fts1k.test 65d3b41487b9f738d11b0f00eca375c0ca6bd970
F test/fts1l.test 15c119ed2362b2b28d5300c0540a6a43eab66c36
F test/fts1m.test 2d9ca67b095d49f037a914087cc0a61e89da4f0c
F test/fts1n.test a2317dcd27b1d087ee3878b30e0a59c593c98b7a
F test/fts1o.test d1554caede42bba2c82fe613bcc921856c196b752449ead0470fac52a20fd3b8
F test/fts1porter.test d86e9c3e0c7f8ff95add6582b4b585fb4e02b96d
F test/fts2.test e3fb95f96a650411574efc136f3fb10eef479ed7
F test/fts2a.test 473a5c8b473a4e21a8e3fddaed1e59666e0c6ab7
F test/fts2b.test 964abc0236c849c07ca1ae496bb25c268ae94816
F test/fts2c.test ffb5a35230ac72c4354535c547965ce6824537c0
F test/fts2d.test b7eaa671ca9a16997f3e5b158ee777ae21052b0b
F test/fts2e.test 2da13dbc2d009105f42196845c1e1ce136c03d38
F test/fts2f.test cf84096235991709c1e61caa389632aa0a4f976d
F test/fts2g.test 3d26fe171bda6133ebf5a380731d70eaa2ef2f6f73d79769cf8946e622b6d597
F test/fts2h.test 223af921323b409d4b5b18ff4e51619541b174bb
F test/fts2i.test 1b22451d1f13f7c509baec620dc3a4a754885dd6
F test/fts2j.test 298fa1670aa21cd445b282d139b70c72e7ade12b
F test/fts2k.test c7ebf4a4937594aa07459e3e1bca1251c1be8659
F test/fts2l.test 3333336621524cf7d60bb62d6ef6ab69647866ed
F test/fts2m.test 4b30142ead6f3ed076e880a2a464064c5ad58c51
F test/fts2n.test 12b9c5352128cebd1c6b8395e43788d4b09087c2
F test/fts2o.test 4054ac7433eb5440f1b1d200cfa449342dc4aabd991759139813e17c73e5bf9a
F test/fts2p.test 4b48c35c91e6a7dbf5ac8d1e5691823cc999aafb
F test/fts2q.test b2fbbe038b7a31a52a6079b215e71226d8c6a682
F test/fts2r.test b154c30b63061d8725e320fba1a39e2201cadd5e
F test/fts2token.test d8070b241a15ff13592a9ae4a8b7c171af6f445a
F test/fts3.test 672a040ea57036fb4b6fdc09027c18d7d24ab654
F test/fts3_common.tcl dffad248f9ce090800e272017d2898005c28ee6314fc1dd5550643a02666907a
F test/fts3aa.test 814d60a1ba30b4a71d8f9306a6564bc7b636dd6efacd2ad80306f9b23ef3ebee
@@ -2072,8 +2038,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P 2d58c77448cfaaf12887b60bcfea039d3410a750ac8955a817c45be85c00eb9e
R 7a2285e0d448f6afe90657dde8f7aa5e
P 57f75e48690bdeb9b6bb3f46eee39021e3eb8cc0c488d2584177baa11ac984e5
R 8c49a17aac51846f7845b86202ebf5a3
U drh
Z a3a9583ae8f7029fe7489a9e17318767
Z 964a3bf027f7a3b198b82aa573575b71
# Remove this line to create a well-formed Fossil manifest.

View File

@@ -1 +1 @@
57f75e48690bdeb9b6bb3f46eee39021e3eb8cc0c488d2584177baa11ac984e5
9a12bac5d24c7a8364d2127fd12c3409a53ef83e408d10f344ddd311cdba98af

View File

@@ -41,12 +41,6 @@ static int sqlite3TestExtInit(sqlite3 *db){
** Forward declarations of external module initializer functions
** for modules that need them.
*/
#ifdef SQLITE_ENABLE_FTS1
int sqlite3Fts1Init(sqlite3*);
#endif
#ifdef SQLITE_ENABLE_FTS2
int sqlite3Fts2Init(sqlite3*);
#endif
#ifdef SQLITE_ENABLE_FTS5
int sqlite3Fts5Init(sqlite3*);
#endif
@@ -59,12 +53,6 @@ int sqlite3StmtVtabInit(sqlite3*);
** built-in extensions.
*/
static int (*const sqlite3BuiltinExtensions[])(sqlite3*) = {
#ifdef SQLITE_ENABLE_FTS1
sqlite3Fts1Init,
#endif
#ifdef SQLITE_ENABLE_FTS2
sqlite3Fts2Init,
#endif
#ifdef SQLITE_ENABLE_FTS3
sqlite3Fts3Init,
#endif

View File

@@ -408,18 +408,6 @@ static void set_options(Tcl_Interp *interp){
Tcl_SetVar2(interp, "sqlite_options", "foreignkey", "1", TCL_GLOBAL_ONLY);
#endif
#ifdef SQLITE_ENABLE_FTS1
Tcl_SetVar2(interp, "sqlite_options", "fts1", "1", TCL_GLOBAL_ONLY);
#else
Tcl_SetVar2(interp, "sqlite_options", "fts1", "0", TCL_GLOBAL_ONLY);
#endif
#ifdef SQLITE_ENABLE_FTS2
Tcl_SetVar2(interp, "sqlite_options", "fts2", "1", TCL_GLOBAL_ONLY);
#else
Tcl_SetVar2(interp, "sqlite_options", "fts2", "0", TCL_GLOBAL_ONLY);
#endif
#ifdef SQLITE_ENABLE_FTS3
Tcl_SetVar2(interp, "sqlite_options", "fts3", "1", TCL_GLOBAL_ONLY);
#else

View File

@@ -1,186 +0,0 @@
# 2006 September 9
#
# 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 FTS1 module.
#
# $Id: fts1a.test,v 1.4 2006/09/28 19:43:32 drh Exp $
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
# If SQLITE_ENABLE_FTS1 is defined, omit this file.
ifcapable !fts1 {
finish_test
return
}
# Construct a full-text search table containing five keywords:
# one, two, three, four, and five, in various combinations. The
# rowid for each will be a bitmask for the elements it contains.
#
db eval {
CREATE VIRTUAL TABLE t1 USING fts1(content);
INSERT INTO t1(content) VALUES('one');
INSERT INTO t1(content) VALUES('two');
INSERT INTO t1(content) VALUES('one two');
INSERT INTO t1(content) VALUES('three');
INSERT INTO t1(content) VALUES('one three');
INSERT INTO t1(content) VALUES('two three');
INSERT INTO t1(content) VALUES('one two three');
INSERT INTO t1(content) VALUES('four');
INSERT INTO t1(content) VALUES('one four');
INSERT INTO t1(content) VALUES('two four');
INSERT INTO t1(content) VALUES('one two four');
INSERT INTO t1(content) VALUES('three four');
INSERT INTO t1(content) VALUES('one three four');
INSERT INTO t1(content) VALUES('two three four');
INSERT INTO t1(content) VALUES('one two three four');
INSERT INTO t1(content) VALUES('five');
INSERT INTO t1(content) VALUES('one five');
INSERT INTO t1(content) VALUES('two five');
INSERT INTO t1(content) VALUES('one two five');
INSERT INTO t1(content) VALUES('three five');
INSERT INTO t1(content) VALUES('one three five');
INSERT INTO t1(content) VALUES('two three five');
INSERT INTO t1(content) VALUES('one two three five');
INSERT INTO t1(content) VALUES('four five');
INSERT INTO t1(content) VALUES('one four five');
INSERT INTO t1(content) VALUES('two four five');
INSERT INTO t1(content) VALUES('one two four five');
INSERT INTO t1(content) VALUES('three four five');
INSERT INTO t1(content) VALUES('one three four five');
INSERT INTO t1(content) VALUES('two three four five');
INSERT INTO t1(content) VALUES('one two three four five');
}
do_test fts1a-1.1 {
execsql {SELECT rowid FROM t1 WHERE content MATCH 'one'}
} {1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31}
do_test fts1a-1.2 {
execsql {SELECT rowid FROM t1 WHERE content MATCH 'one two'}
} {3 7 11 15 19 23 27 31}
do_test fts1a-1.3 {
execsql {SELECT rowid FROM t1 WHERE content MATCH 'two one'}
} {3 7 11 15 19 23 27 31}
do_test fts1a-1.4 {
execsql {SELECT rowid FROM t1 WHERE content MATCH 'one two three'}
} {7 15 23 31}
do_test fts1a-1.5 {
execsql {SELECT rowid FROM t1 WHERE content MATCH 'one three two'}
} {7 15 23 31}
do_test fts1a-1.6 {
execsql {SELECT rowid FROM t1 WHERE content MATCH 'two three one'}
} {7 15 23 31}
do_test fts1a-1.7 {
execsql {SELECT rowid FROM t1 WHERE content MATCH 'two one three'}
} {7 15 23 31}
do_test fts1a-1.8 {
execsql {SELECT rowid FROM t1 WHERE content MATCH 'three one two'}
} {7 15 23 31}
do_test fts1a-1.9 {
execsql {SELECT rowid FROM t1 WHERE content MATCH 'three two one'}
} {7 15 23 31}
do_test fts1a-1.10 {
execsql {SELECT rowid FROM t1 WHERE content MATCH 'one two THREE'}
} {7 15 23 31}
do_test fts1a-1.11 {
execsql {SELECT rowid FROM t1 WHERE content MATCH ' ONE Two three '}
} {7 15 23 31}
do_test fts1a-2.1 {
execsql {SELECT rowid FROM t1 WHERE content MATCH '"one"'}
} {1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31}
do_test fts1a-2.2 {
execsql {SELECT rowid FROM t1 WHERE content MATCH '"one two"'}
} {3 7 11 15 19 23 27 31}
do_test fts1a-2.3 {
execsql {SELECT rowid FROM t1 WHERE content MATCH '"two one"'}
} {}
do_test fts1a-2.4 {
execsql {SELECT rowid FROM t1 WHERE content MATCH '"one two three"'}
} {7 15 23 31}
do_test fts1a-2.5 {
execsql {SELECT rowid FROM t1 WHERE content MATCH '"one three two"'}
} {}
do_test fts1a-2.6 {
execsql {SELECT rowid FROM t1 WHERE content MATCH '"one two three four"'}
} {15 31}
do_test fts1a-2.7 {
execsql {SELECT rowid FROM t1 WHERE content MATCH '"one three two four"'}
} {}
do_test fts1a-2.8 {
execsql {SELECT rowid FROM t1 WHERE content MATCH '"one three five"'}
} {21}
do_test fts1a-2.9 {
execsql {SELECT rowid FROM t1 WHERE content MATCH '"one three" five'}
} {21 29}
do_test fts1a-2.10 {
execsql {SELECT rowid FROM t1 WHERE content MATCH 'five "one three"'}
} {21 29}
do_test fts1a-2.11 {
execsql {SELECT rowid FROM t1 WHERE content MATCH 'five "one three" four'}
} {29}
do_test fts1a-2.12 {
execsql {SELECT rowid FROM t1 WHERE content MATCH 'five four "one three"'}
} {29}
do_test fts1a-2.13 {
execsql {SELECT rowid FROM t1 WHERE content MATCH '"one three" four five'}
} {29}
do_test fts1a-3.1 {
execsql {SELECT rowid FROM t1 WHERE content MATCH 'one'}
} {1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31}
do_test fts1a-3.2 {
execsql {SELECT rowid FROM t1 WHERE content MATCH 'one -two'}
} {1 5 9 13 17 21 25 29}
do_test fts1a-3.3 {
execsql {SELECT rowid FROM t1 WHERE content MATCH '-two one'}
} {1 5 9 13 17 21 25 29}
do_test fts1a-4.1 {
execsql {SELECT rowid FROM t1 WHERE content MATCH 'one OR two'}
} {1 2 3 5 6 7 9 10 11 13 14 15 17 18 19 21 22 23 25 26 27 29 30 31}
do_test fts1a-4.2 {
execsql {SELECT rowid FROM t1 WHERE content MATCH '"one two" OR three'}
} {3 4 5 6 7 11 12 13 14 15 19 20 21 22 23 27 28 29 30 31}
do_test fts1a-4.3 {
execsql {SELECT rowid FROM t1 WHERE content MATCH 'three OR "one two"'}
} {3 4 5 6 7 11 12 13 14 15 19 20 21 22 23 27 28 29 30 31}
do_test fts1a-4.4 {
execsql {SELECT rowid FROM t1 WHERE content MATCH 'one two OR three'}
} {3 5 7 11 13 15 19 21 23 27 29 31}
do_test fts1a-4.5 {
execsql {SELECT rowid FROM t1 WHERE content MATCH 'three OR two one'}
} {3 5 7 11 13 15 19 21 23 27 29 31}
do_test fts1a-4.6 {
execsql {SELECT rowid FROM t1 WHERE content MATCH 'one two OR three OR four'}
} {3 5 7 9 11 13 15 19 21 23 25 27 29 31}
do_test fts1a-4.7 {
execsql {SELECT rowid FROM t1 WHERE content MATCH 'two OR three OR four one'}
} {3 5 7 9 11 13 15 19 21 23 25 27 29 31}
# Test the ability to handle NULL content
#
do_test fts1a-5.1 {
execsql {INSERT INTO t1(content) VALUES(NULL)}
} {}
do_test fts1a-5.2 {
set rowid [db last_insert_rowid]
execsql {SELECT content FROM t1 WHERE rowid=$rowid}
} {{}}
do_test fts1a-5.3 {
execsql {SELECT rowid FROM t1 WHERE content MATCH NULL}
} {}
finish_test

View File

@@ -1,147 +0,0 @@
# 2006 September 13
#
# 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 FTS1 module.
#
# $Id: fts1b.test,v 1.4 2006/09/18 02:12:48 drh Exp $
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
# If SQLITE_ENABLE_FTS1 is defined, omit this file.
ifcapable !fts1 {
finish_test
return
}
# Fill the full-text index "t1" with phrases in english, spanish,
# and german. For the i-th row, fill in the names for the bits
# that are set in the value of i. The least significant bit is
# 1. For example, the value 5 is 101 in binary which will be
# converted to "one three" in english.
#
proc fill_multilanguage_fulltext_t1 {} {
set english {one two three four five}
set spanish {un dos tres cuatro cinco}
set german {eine zwei drei vier funf}
for {set i 1} {$i<=31} {incr i} {
set cmd "INSERT INTO t1 VALUES"
set vset {}
foreach lang {english spanish german} {
set words {}
for {set j 0; set k 1} {$j<5} {incr j; incr k $k} {
if {$k&$i} {lappend words [lindex [set $lang] $j]}
}
lappend vset "'$words'"
}
set sql "INSERT INTO t1(english,spanish,german) VALUES([join $vset ,])"
# puts $sql
db eval $sql
}
}
# Construct a full-text search table containing five keywords:
# one, two, three, four, and five, in various combinations. The
# rowid for each will be a bitmask for the elements it contains.
#
db eval {
CREATE VIRTUAL TABLE t1 USING fts1(english,spanish,german);
}
fill_multilanguage_fulltext_t1
do_test fts1b-1.1 {
execsql {SELECT rowid FROM t1 WHERE english MATCH 'one'}
} {1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31}
do_test fts1b-1.2 {
execsql {SELECT rowid FROM t1 WHERE spanish MATCH 'one'}
} {}
do_test fts1b-1.3 {
execsql {SELECT rowid FROM t1 WHERE german MATCH 'one'}
} {}
do_test fts1b-1.4 {
execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'one'}
} {1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31}
do_test fts1b-1.5 {
execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'one dos drei'}
} {7 15 23 31}
do_test fts1b-1.6 {
execsql {SELECT english, spanish, german FROM t1 WHERE rowid=1}
} {one un eine}
do_test fts1b-1.7 {
execsql {SELECT rowid FROM t1 WHERE t1 MATCH '"one un"'}
} {}
do_test fts1b-2.1 {
execsql {
CREATE VIRTUAL TABLE t2 USING fts1(from,to);
INSERT INTO t2([from],[to]) VALUES ('one two three', 'four five six');
SELECT [from], [to] FROM t2
}
} {{one two three} {four five six}}
# Compute an SQL string that contains the words one, two, three,... to
# describe bits set in the value $i. Only the lower 5 bits are examined.
#
proc wordset {i} {
set x {}
for {set j 0; set k 1} {$j<5} {incr j; incr k $k} {
if {$k&$i} {lappend x [lindex {one two three four five} $j]}
}
return '$x'
}
# Create a new FTS table with three columns:
#
# norm: words for the bits of rowid
# plusone: words for the bits of rowid+1
# invert: words for the bits of ~rowid
#
db eval {
CREATE VIRTUAL TABLE t4 USING fts1([norm],'plusone',"invert");
}
for {set i 1} {$i<=15} {incr i} {
set vset [list [wordset $i] [wordset [expr {$i+1}]] [wordset [expr {~$i}]]]
db eval "INSERT INTO t4(norm,plusone,invert) VALUES([join $vset ,]);"
}
do_test fts1b-4.1 {
execsql {SELECT rowid FROM t4 WHERE t4 MATCH 'norm:one'}
} {1 3 5 7 9 11 13 15}
do_test fts1b-4.2 {
execsql {SELECT rowid FROM t4 WHERE norm MATCH 'one'}
} {1 3 5 7 9 11 13 15}
do_test fts1b-4.3 {
execsql {SELECT rowid FROM t4 WHERE t4 MATCH 'one'}
} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15}
do_test fts1b-4.4 {
execsql {SELECT rowid FROM t4 WHERE t4 MATCH 'plusone:one'}
} {2 4 6 8 10 12 14}
do_test fts1b-4.5 {
execsql {SELECT rowid FROM t4 WHERE plusone MATCH 'one'}
} {2 4 6 8 10 12 14}
do_test fts1b-4.6 {
execsql {SELECT rowid FROM t4 WHERE t4 MATCH 'norm:one plusone:two'}
} {1 5 9 13}
do_test fts1b-4.7 {
execsql {SELECT rowid FROM t4 WHERE t4 MATCH 'norm:one two'}
} {1 3 5 7 9 11 13 15}
do_test fts1b-4.8 {
execsql {SELECT rowid FROM t4 WHERE t4 MATCH 'plusone:two norm:one'}
} {1 5 9 13}
do_test fts1b-4.9 {
execsql {SELECT rowid FROM t4 WHERE t4 MATCH 'two norm:one'}
} {1 3 5 7 9 11 13 15}
finish_test

File diff suppressed because it is too large Load Diff

View File

@@ -1,65 +0,0 @@
# 2006 October 1
#
# 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 FTS1 module, and in particular
# the Porter stemmer.
#
# $Id: fts1d.test,v 1.1 2006/10/01 18:41:21 drh Exp $
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
# If SQLITE_ENABLE_FTS1 is defined, omit this file.
ifcapable !fts1 {
finish_test
return
}
do_test fts1d-1.1 {
execsql {
CREATE VIRTUAL TABLE t1 USING fts1(content, tokenize porter);
INSERT INTO t1(rowid, content) VALUES(1, 'running and jumping');
SELECT rowid FROM t1 WHERE content MATCH 'run jump';
}
} {1}
do_test fts1d-1.2 {
execsql {
SELECT snippet(t1) FROM t1 WHERE t1 MATCH 'run jump';
}
} {{<b>running</b> and <b>jumping</b>}}
do_test fts1d-1.3 {
execsql {
INSERT INTO t1(rowid, content)
VALUES(2, 'abcdefghijklmnopqrstuvwyxz');
SELECT rowid, snippet(t1) FROM t1 WHERE t1 MATCH 'abcdefghijqrstuvwyxz'
}
} {2 <b>abcdefghijklmnopqrstuvwyxz</b>}
do_test fts1d-1.4 {
execsql {
SELECT rowid, snippet(t1) FROM t1 WHERE t1 MATCH 'abcdefghijXXXXqrstuvwyxz'
}
} {2 <b>abcdefghijklmnopqrstuvwyxz</b>}
do_test fts1d-1.5 {
execsql {
INSERT INTO t1(rowid, content)
VALUES(3, 'The value is 123456789');
SELECT rowid, snippet(t1) FROM t1 WHERE t1 MATCH '123789'
}
} {3 {The value is <b>123456789</b>}}
do_test fts1d-1.6 {
execsql {
SELECT rowid, snippet(t1) FROM t1 WHERE t1 MATCH '123000000789'
}
} {3 {The value is <b>123456789</b>}}
finish_test

View File

@@ -1,85 +0,0 @@
# 2006 October 19
#
# The author disclaims copyright to this source code.
#
#*************************************************************************
# This file implements regression tests for SQLite library. The
# focus of this script is testing deletions in the FTS1 module.
#
# $Id: fts1e.test,v 1.1 2006/10/19 23:28:35 shess Exp $
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
# If SQLITE_ENABLE_FTS1 is defined, omit this file.
ifcapable !fts1 {
finish_test
return
}
# Construct a full-text search table containing keywords which are the
# ordinal numbers of the bit positions set for a sequence of integers,
# which are used for the rowid. There are a total of 30 INSERT and
# DELETE statements, so that we'll test both the segmentMerge() merge
# (over the first 16) and the termSelect() merge (over the level-1
# segment and 14 level-0 segments).
db eval {
CREATE VIRTUAL TABLE t1 USING fts1(content);
INSERT INTO t1 (rowid, content) VALUES(1, 'one');
INSERT INTO t1 (rowid, content) VALUES(2, 'two');
INSERT INTO t1 (rowid, content) VALUES(3, 'one two');
INSERT INTO t1 (rowid, content) VALUES(4, 'three');
DELETE FROM t1 WHERE rowid = 1;
INSERT INTO t1 (rowid, content) VALUES(5, 'one three');
INSERT INTO t1 (rowid, content) VALUES(6, 'two three');
INSERT INTO t1 (rowid, content) VALUES(7, 'one two three');
DELETE FROM t1 WHERE rowid = 4;
INSERT INTO t1 (rowid, content) VALUES(8, 'four');
INSERT INTO t1 (rowid, content) VALUES(9, 'one four');
INSERT INTO t1 (rowid, content) VALUES(10, 'two four');
DELETE FROM t1 WHERE rowid = 7;
INSERT INTO t1 (rowid, content) VALUES(11, 'one two four');
INSERT INTO t1 (rowid, content) VALUES(12, 'three four');
INSERT INTO t1 (rowid, content) VALUES(13, 'one three four');
DELETE FROM t1 WHERE rowid = 10;
INSERT INTO t1 (rowid, content) VALUES(14, 'two three four');
INSERT INTO t1 (rowid, content) VALUES(15, 'one two three four');
INSERT INTO t1 (rowid, content) VALUES(16, 'five');
DELETE FROM t1 WHERE rowid = 13;
INSERT INTO t1 (rowid, content) VALUES(17, 'one five');
INSERT INTO t1 (rowid, content) VALUES(18, 'two five');
INSERT INTO t1 (rowid, content) VALUES(19, 'one two five');
DELETE FROM t1 WHERE rowid = 16;
INSERT INTO t1 (rowid, content) VALUES(20, 'three five');
INSERT INTO t1 (rowid, content) VALUES(21, 'one three five');
INSERT INTO t1 (rowid, content) VALUES(22, 'two three five');
DELETE FROM t1 WHERE rowid = 19;
DELETE FROM t1 WHERE rowid = 22;
}
do_test fts1f-1.1 {
execsql {SELECT COUNT(*) FROM t1}
} {14}
do_test fts1e-2.1 {
execsql {SELECT rowid FROM t1 WHERE content MATCH 'one'}
} {3 5 9 11 15 17 21}
do_test fts1e-2.2 {
execsql {SELECT rowid FROM t1 WHERE content MATCH 'two'}
} {2 3 6 11 14 15 18}
do_test fts1e-2.3 {
execsql {SELECT rowid FROM t1 WHERE content MATCH 'three'}
} {5 6 12 14 15 20 21}
do_test fts1e-2.4 {
execsql {SELECT rowid FROM t1 WHERE content MATCH 'four'}
} {8 9 11 12 14 15}
do_test fts1e-2.5 {
execsql {SELECT rowid FROM t1 WHERE content MATCH 'five'}
} {17 18 20 21}
finish_test

View File

@@ -1,90 +0,0 @@
# 2006 October 19
#
# The author disclaims copyright to this source code.
#
#*************************************************************************
# This file implements regression tests for SQLite library. The
# focus of this script is testing updates in the FTS1 module.
#
# $Id: fts1f.test,v 1.2 2007/02/23 00:14:06 shess Exp $
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
# If SQLITE_ENABLE_FTS1 is defined, omit this file.
ifcapable !fts1 {
finish_test
return
}
# Construct a full-text search table containing keywords which are the
# ordinal numbers of the bit positions set for a sequence of integers,
# which are used for the rowid. There are a total of 31 INSERT,
# UPDATE, and DELETE statements, so that we'll test both the
# segmentMerge() merge (over the first 16) and the termSelect() merge
# (over the level-1 segment and 15 level-0 segments).
db eval {
CREATE VIRTUAL TABLE t1 USING fts1(content);
INSERT INTO t1 (rowid, content) VALUES(1, 'one');
INSERT INTO t1 (rowid, content) VALUES(2, 'two');
INSERT INTO t1 (rowid, content) VALUES(3, 'one two');
INSERT INTO t1 (rowid, content) VALUES(4, 'three');
INSERT INTO t1 (rowid, content) VALUES(5, 'one three');
INSERT INTO t1 (rowid, content) VALUES(6, 'two three');
INSERT INTO t1 (rowid, content) VALUES(7, 'one two three');
DELETE FROM t1 WHERE rowid = 4;
INSERT INTO t1 (rowid, content) VALUES(8, 'four');
UPDATE t1 SET content = 'update one three' WHERE rowid = 1;
INSERT INTO t1 (rowid, content) VALUES(9, 'one four');
INSERT INTO t1 (rowid, content) VALUES(10, 'two four');
DELETE FROM t1 WHERE rowid = 7;
INSERT INTO t1 (rowid, content) VALUES(11, 'one two four');
INSERT INTO t1 (rowid, content) VALUES(12, 'three four');
INSERT INTO t1 (rowid, content) VALUES(13, 'one three four');
DELETE FROM t1 WHERE rowid = 10;
INSERT INTO t1 (rowid, content) VALUES(14, 'two three four');
INSERT INTO t1 (rowid, content) VALUES(15, 'one two three four');
UPDATE t1 SET content = 'update two five' WHERE rowid = 8;
INSERT INTO t1 (rowid, content) VALUES(16, 'five');
DELETE FROM t1 WHERE rowid = 13;
INSERT INTO t1 (rowid, content) VALUES(17, 'one five');
INSERT INTO t1 (rowid, content) VALUES(18, 'two five');
INSERT INTO t1 (rowid, content) VALUES(19, 'one two five');
DELETE FROM t1 WHERE rowid = 16;
INSERT INTO t1 (rowid, content) VALUES(20, 'three five');
INSERT INTO t1 (rowid, content) VALUES(21, 'one three five');
INSERT INTO t1 (rowid, content) VALUES(22, 'two three five');
DELETE FROM t1 WHERE rowid = 19;
UPDATE t1 SET content = 'update' WHERE rowid = 15;
}
do_test fts1f-1.1 {
execsql {SELECT COUNT(*) FROM t1}
} {16}
do_test fts1f-2.0 {
execsql {SELECT rowid FROM t1 WHERE content MATCH 'update'}
} {1 8 15}
do_test fts1f-2.1 {
execsql {SELECT rowid FROM t1 WHERE content MATCH 'one'}
} {1 3 5 9 11 17 21}
do_test fts1f-2.2 {
execsql {SELECT rowid FROM t1 WHERE content MATCH 'two'}
} {2 3 6 8 11 14 18 22}
do_test fts1f-2.3 {
execsql {SELECT rowid FROM t1 WHERE content MATCH 'three'}
} {1 5 6 12 14 20 21 22}
do_test fts1f-2.4 {
execsql {SELECT rowid FROM t1 WHERE content MATCH 'four'}
} {9 11 12 14}
do_test fts1f-2.5 {
execsql {SELECT rowid FROM t1 WHERE content MATCH 'five'}
} {8 17 18 20 21 22}
finish_test

View File

@@ -1,88 +0,0 @@
# 2007 January 17
#
# The author disclaims copyright to this source code.
#
#*************************************************************************
# This file implements regression tests for SQLite fts1 library. The
# focus here is testing handling of UPDATE when using UTF-16-encoded
# databases.
#
# $Id: fts1i.test,v 1.2 2007/01/24 03:43:20 drh Exp $
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
# If SQLITE_ENABLE_FTS1 is defined, omit this file.
ifcapable !fts1 {
finish_test
return
}
# Return the UTF-16 representation of the supplied UTF-8 string $str.
# If $nt is true, append two 0x00 bytes as a nul terminator.
# NOTE(shess) Copied from capi3.test.
proc utf16 {str {nt 1}} {
set r [encoding convertto unicode $str]
if {$nt} {
append r "\x00\x00"
}
return $r
}
db eval {
PRAGMA encoding = "UTF-16le";
CREATE VIRTUAL TABLE t1 USING fts1(content);
}
do_test fts1i-1.0 {
execsql {PRAGMA encoding}
} {UTF-16le}
do_test fts1i-1.1 {
execsql {INSERT INTO t1 (rowid, content) VALUES(1, 'one')}
execsql {SELECT content FROM t1 WHERE rowid = 1}
} {one}
do_test fts1i-1.2 {
set sql "INSERT INTO t1 (rowid, content) VALUES(2, 'two')"
set STMT [sqlite3_prepare $DB $sql -1 TAIL]
sqlite3_step $STMT
sqlite3_finalize $STMT
execsql {SELECT content FROM t1 WHERE rowid = 2}
} {two}
do_test fts1i-1.3 {
set sql "INSERT INTO t1 (rowid, content) VALUES(3, 'three')"
set STMT [sqlite3_prepare $DB $sql -1 TAIL]
sqlite3_step $STMT
sqlite3_finalize $STMT
set sql "UPDATE t1 SET content = 'trois' WHERE rowid = 3"
set STMT [sqlite3_prepare $DB $sql -1 TAIL]
sqlite3_step $STMT
sqlite3_finalize $STMT
execsql {SELECT content FROM t1 WHERE rowid = 3}
} {trois}
do_test fts1i-1.4 {
set sql16 [utf16 {INSERT INTO t1 (rowid, content) VALUES(4, 'four')}]
set STMT [sqlite3_prepare16 $DB $sql16 -1 TAIL]
sqlite3_step $STMT
sqlite3_finalize $STMT
execsql {SELECT content FROM t1 WHERE rowid = 4}
} {four}
do_test fts1i-1.5 {
set sql16 [utf16 {INSERT INTO t1 (rowid, content) VALUES(5, 'five')}]
set STMT [sqlite3_prepare16 $DB $sql16 -1 TAIL]
sqlite3_step $STMT
sqlite3_finalize $STMT
set sql "UPDATE t1 SET content = 'cinq' WHERE rowid = 5"
set STMT [sqlite3_prepare $DB $sql -1 TAIL]
sqlite3_step $STMT
sqlite3_finalize $STMT
execsql {SELECT content FROM t1 WHERE rowid = 5}
} {cinq}
finish_test

View File

@@ -1,89 +0,0 @@
# 2007 February 6
#
# The author disclaims copyright to this source code.
#
#*************************************************************************
# This file implements regression tests for SQLite library. This
# tests creating fts1 tables in an attached database.
#
# $Id: fts1j.test,v 1.1 2007/02/07 01:01:18 shess Exp $
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
# If SQLITE_ENABLE_FTS1 is defined, omit this file.
ifcapable !fts1 {
finish_test
return
}
# Clean up anything left over from a previous pass.
forcedelete test2.db
forcedelete test2.db-journal
sqlite3 db2 test2.db
db eval {
CREATE VIRTUAL TABLE t3 USING fts1(content);
INSERT INTO t3 (rowid, content) VALUES(1, "hello world");
}
db2 eval {
CREATE VIRTUAL TABLE t1 USING fts1(content);
INSERT INTO t1 (rowid, content) VALUES(1, "hello world");
INSERT INTO t1 (rowid, content) VALUES(2, "hello there");
INSERT INTO t1 (rowid, content) VALUES(3, "cruel world");
}
# This has always worked because the t1_* tables used by fts1 will be
# the defaults.
do_test fts1j-1.1 {
execsql {
ATTACH DATABASE 'test2.db' AS two;
SELECT rowid FROM t1 WHERE t1 MATCH 'hello';
DETACH DATABASE two;
}
} {1 2}
# Make certain we're detached if there was an error.
catch {db eval {DETACH DATABASE two}}
# In older code, this appears to work fine, but the t2_* tables used
# by fts1 will be created in database 'main' instead of database
# 'two'. It appears to work fine because the tables end up being the
# defaults, but obviously is badly broken if you hope to use things
# other than in the exact same ATTACH setup.
do_test fts1j-1.2 {
execsql {
ATTACH DATABASE 'test2.db' AS two;
CREATE VIRTUAL TABLE two.t2 USING fts1(content);
INSERT INTO t2 (rowid, content) VALUES(1, "hello world");
INSERT INTO t2 (rowid, content) VALUES(2, "hello there");
INSERT INTO t2 (rowid, content) VALUES(3, "cruel world");
SELECT rowid FROM t2 WHERE t2 MATCH 'hello';
DETACH DATABASE two;
}
} {1 2}
catch {db eval {DETACH DATABASE two}}
# In older code, this broke because the fts1 code attempted to create
# t3_* tables in database 'main', but they already existed. Normally
# this wouldn't happen without t3 itself existing, in which case the
# fts1 code would never be called in the first place.
do_test fts1j-1.3 {
execsql {
ATTACH DATABASE 'test2.db' AS two;
CREATE VIRTUAL TABLE two.t3 USING fts1(content);
INSERT INTO two.t3 (rowid, content) VALUES(2, "hello there");
INSERT INTO two.t3 (rowid, content) VALUES(3, "cruel world");
SELECT rowid FROM two.t3 WHERE t3 MATCH 'hello';
DETACH DATABASE two;
} db2
} {2}
catch {db eval {DETACH DATABASE two}}
catch {db2 close}
forcedelete test2.db
finish_test

View File

@@ -1,69 +0,0 @@
# 2007 March 28
#
# The author disclaims copyright to this source code.
#
#*************************************************************************
# This file implements regression tests for SQLite library. The focus
# of this script is testing isspace/isalnum/tolower problems with the
# FTS1 module. Unfortunately, this code isn't a really principled set
# of tests, because it is impossible to know where new uses of these
# functions might appear.
#
# $Id: fts1k.test,v 1.2 2007/12/13 21:54:11 drh Exp $
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
# If SQLITE_ENABLE_FTS1 is defined, omit this file.
ifcapable !fts1 {
finish_test
return
}
# Tests that startsWith() (calls isspace, tolower, isalnum) can handle
# hi-bit chars. parseSpec() also calls isalnum here.
do_test fts1k-1.1 {
execsql "CREATE VIRTUAL TABLE t1 USING fts1(content, \x80)"
} {}
# Additionally tests isspace() call in getToken(), and isalnum() call
# in tokenListToIdList().
do_test fts1k-1.2 {
catch {
execsql "CREATE VIRTUAL TABLE t2 USING fts1(content, tokenize \x80)"
}
sqlite3_errmsg $DB
} "unknown tokenizer: \x80"
# Additionally test final isalnum() in startsWith().
do_test fts1k-1.3 {
execsql "CREATE VIRTUAL TABLE t3 USING fts1(content, tokenize\x80)"
} {}
# The snippet-generation code has calls to isspace() which are sort of
# hard to get to. It finds convenient breakpoints by starting ~40
# chars before and after the matched term, and scanning ~10 chars
# around that position for isspace() characters. The long word with
# embedded hi-bit chars causes one of these isspace() calls to be
# exercised. The version with a couple extra spaces should cause the
# other isspace() call to be exercised. [Both cases have been tested
# in the debugger, but I'm hoping to continue to catch it if simple
# constant changes change things slightly.
#
# The trailing and leading hi-bit chars help with code which tests for
# isspace() to coalesce multiple spaces.
set word "\x80xxxxx\x80xxxxx\x80xxxxx\x80xxxxx\x80xxxxx\x80xxxxx\x80"
set phrase1 "$word $word $word target $word $word $word"
set phrase2 "$word $word $word target $word $word $word"
db eval {CREATE VIRTUAL TABLE t4 USING fts1(content)}
db eval "INSERT INTO t4 (content) VALUES ('$phrase1')"
db eval "INSERT INTO t4 (content) VALUES ('$phrase2')"
do_test fts1k-1.4 {
execsql {SELECT rowid, length(snippet(t4)) FROM t4 WHERE t4 MATCH 'target'}
} {1 111 2 117}
finish_test

View File

@@ -1,65 +0,0 @@
# 2007 April 9
#
# The author disclaims copyright to this source code.
#
#*************************************************************************
# This file implements regression tests for SQLite library. fts1
# DELETE handling assumed all fields were non-null. This was not
# the intention at all.
#
# $Id: fts1l.test,v 1.1 2007/04/09 20:45:42 shess Exp $
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
# If SQLITE_ENABLE_FTS1 is defined, omit this file.
ifcapable !fts1 {
finish_test
return
}
db eval {
CREATE VIRTUAL TABLE t1 USING fts1(col_a, col_b);
INSERT INTO t1(rowid, col_a, col_b) VALUES(1, 'testing', 'testing');
INSERT INTO t1(rowid, col_a, col_b) VALUES(2, 'only a', null);
INSERT INTO t1(rowid, col_a, col_b) VALUES(3, null, 'only b');
INSERT INTO t1(rowid, col_a, col_b) VALUES(4, null, null);
}
do_test fts1m-1.0 {
execsql {
SELECT COUNT(col_a), COUNT(col_b), COUNT(*) FROM t1;
}
} {2 2 4}
do_test fts1m-1.1 {
execsql {
DELETE FROM t1 WHERE rowid = 1;
SELECT COUNT(col_a), COUNT(col_b), COUNT(*) FROM t1;
}
} {1 1 3}
do_test fts1m-1.2 {
execsql {
DELETE FROM t1 WHERE rowid = 2;
SELECT COUNT(col_a), COUNT(col_b), COUNT(*) FROM t1;
}
} {0 1 2}
do_test fts1m-1.3 {
execsql {
DELETE FROM t1 WHERE rowid = 3;
SELECT COUNT(col_a), COUNT(col_b), COUNT(*) FROM t1;
}
} {0 0 1}
do_test fts1m-1.4 {
execsql {
DELETE FROM t1 WHERE rowid = 4;
SELECT COUNT(col_a), COUNT(col_b), COUNT(*) FROM t1;
}
} {0 0 0}
finish_test

View File

@@ -1,50 +0,0 @@
# 2007 July 27
#
# 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 FTS1 module, specifically snippet
# generation. Extracted from fts2o.test.
#
# $Id: fts1m.test,v 1.1 2007/07/25 00:25:20 shess Exp $
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
# If SQLITE_ENABLE_FTS1 is not defined, omit this file.
ifcapable !fts1 {
finish_test
return
}
#---------------------------------------------------------------------
# These tests, fts1m-1.*, test that ticket #2429 is fixed.
#
db eval {
CREATE VIRTUAL TABLE t1 USING fts1(a, b, c);
INSERT INTO t1(a, b, c) VALUES('one three four', 'one four', 'one four two');
}
do_test fts1m-1.1 {
execsql {
SELECT rowid, snippet(t1) FROM t1 WHERE c MATCH 'four';
}
} {1 {one <b>four</b> two}}
do_test fts1m-1.2 {
execsql {
SELECT rowid, snippet(t1) FROM t1 WHERE b MATCH 'four';
}
} {1 {one <b>four</b>}}
do_test fts1m-1.3 {
execsql {
SELECT rowid, snippet(t1) FROM t1 WHERE a MATCH 'four';
}
} {1 {one three <b>four</b>}}
finish_test

View File

@@ -1,45 +0,0 @@
# 2007 July 24
#
# 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 FTS1 module for errors in the handling
# of SQLITE_SCHEMA.
#
# $Id: fts1n.test,v 1.1 2007/07/25 00:38:06 shess Exp $
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
# If SQLITE_ENABLE_FTS1 is not defined, omit this file.
ifcapable !fts1 {
finish_test
return
}
do_test fts1m-1.1 {
execsql {
CREATE VIRTUAL TABLE t1 USING fts1(a, b, c);
INSERT INTO t1(a, b, c) VALUES('one three four', 'one four', 'one two');
SELECT a, b, c FROM t1 WHERE c MATCH 'two';
}
} {{one three four} {one four} {one two}}
# This test was crashing at one point.
#
do_test fts1m-1.2 {
execsql {
SELECT a, b, c FROM t1 WHERE c MATCH 'two';
CREATE TABLE t3(a, b, c);
SELECT a, b, c FROM t1 WHERE c MATCH 'two';
}
} {{one three four} {one four} {one two} {one three four} {one four} {one two}}
finish_test

View File

@@ -1,138 +0,0 @@
# 2007 July 24
#
# 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 FTS1 module rename functionality. Mostly
# copied from fts2o.test.
#
# $Id: fts1o.test,v 1.2 2007/08/30 20:01:33 shess Exp $
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
# If SQLITE_ENABLE_FTS1 is not defined, omit this file.
ifcapable !fts1 {
finish_test
return
}
db eval {
CREATE VIRTUAL TABLE t1 USING fts1(a, b, c);
INSERT INTO t1(a, b, c) VALUES('one three four', 'one four', 'one four two');
}
#---------------------------------------------------------------------
# Test that it is possible to rename an fts1 table.
#
do_test fts1o-1.1 {
execsql { SELECT tbl_name FROM sqlite_master WHERE type = 'table'}
} {t1 t1_content t1_term}
do_test fts1o-1.2 {
execsql { ALTER TABLE t1 RENAME to fts_t1; }
} {}
do_test fts1o-1.3 {
execsql { SELECT rowid, snippet(fts_t1) FROM fts_t1 WHERE a MATCH 'four'; }
} {1 {one three <b>four</b>}}
do_test fts1o-1.4 {
execsql { SELECT tbl_name FROM sqlite_master WHERE type = 'table'}
} {fts_t1 fts_t1_content fts_t1_term}
# See what happens when renaming the fts1 table fails.
#
do_test fts1o-2.1 {
catchsql {
CREATE TABLE t1_term(a, b, c);
ALTER TABLE fts_t1 RENAME to t1;
}
} {1 {SQL logic error}}
do_test fts1o-2.2 {
execsql { SELECT rowid, snippet(fts_t1) FROM fts_t1 WHERE a MATCH 'four'; }
} {1 {one three <b>four</b>}}
do_test fts1o-2.3 {
execsql { SELECT tbl_name FROM sqlite_master WHERE type = 'table'}
} {fts_t1 fts_t1_content fts_t1_term t1_term}
# See what happens when renaming the fts1 table fails inside a transaction.
#
do_test fts1o-3.1 {
execsql {
BEGIN;
INSERT INTO fts_t1(a, b, c) VALUES('one two three', 'one four', 'one two');
}
} {}
do_test fts1o-3.2 {
catchsql {
ALTER TABLE fts_t1 RENAME to t1;
}
} {1 {SQL logic error}}
# NOTE(shess) rowid AS rowid to defeat caching. Otherwise, this
# seg-faults, I suspect that there's something up with a stale
# virtual-table reference, but I'm not quite sure how it happens here
# but not for fts2o.test.
do_test fts1o-3.3 {
execsql { SELECT rowid AS rowid, snippet(fts_t1) FROM fts_t1 WHERE a MATCH 'four'; }
} {1 {one three <b>four</b>}}
do_test fts1o-3.4 {
execsql { SELECT tbl_name FROM sqlite_master WHERE type = 'table'}
} {fts_t1 fts_t1_content fts_t1_term t1_term}
do_test fts1o-3.5 {
execsql COMMIT
execsql {SELECT a FROM fts_t1}
} {{one three four} {one two three}}
do_test fts1o-3.6 {
execsql { SELECT a, b, c FROM fts_t1 WHERE c MATCH 'four'; }
} {{one three four} {one four} {one four two}}
#---------------------------------------------------------------------
# Test that it is possible to rename an fts1 table in an attached
# database.
#
forcedelete test2.db test2.db-journal
do_test fts1o-4.1 {
execsql {
DROP TABLE t1_term;
ALTER TABLE fts_t1 RENAME to t1;
SELECT a, b, c FROM t1 WHERE c MATCH 'two';
}
} {{one three four} {one four} {one four two} {one two three} {one four} {one two}}
do_test fts1o-4.2 {
execsql {
ATTACH 'test2.db' AS aux;
CREATE VIRTUAL TABLE aux.t1 USING fts1(a, b, c);
INSERT INTO aux.t1(a, b, c) VALUES(
'neung song sahm', 'neung see', 'neung see song'
);
}
} {}
do_test fts1o-4.3 {
execsql { SELECT a, b, c FROM aux.t1 WHERE a MATCH 'song'; }
} {{neung song sahm} {neung see} {neung see song}}
do_test fts1o-4.4 {
execsql { SELECT a, b, c FROM t1 WHERE c MATCH 'two'; }
} {{one three four} {one four} {one four two} {one two three} {one four} {one two}}
do_test fts1o-4.5 {
execsql { ALTER TABLE aux.t1 RENAME TO t2 }
} {}
do_test fts1o-4.6 {
execsql { SELECT a, b, c FROM t2 WHERE a MATCH 'song'; }
} {{neung song sahm} {neung see} {neung see song}}
do_test fts1o-4.7 {
execsql { SELECT a, b, c FROM t1 WHERE c MATCH 'two'; }
} {{one three four} {one four} {one four two} {one two three} {one four} {one two}}
finish_test

File diff suppressed because it is too large Load Diff

View File

@@ -1,67 +0,0 @@
# 2008 July 22
#
# 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 runs all tests.
#
# $Id: fts2.test,v 1.2 2008/07/23 18:17:32 drh Exp $
proc lshift {lvar} {
upvar $lvar l
set ret [lindex $l 0]
set l [lrange $l 1 end]
return $ret
}
while {[set arg [lshift argv]] != ""} {
switch -- $arg {
-sharedpagercache {
sqlite3_enable_shared_cache 1
}
-soak {
set G(issoak) 1
}
default {
set argv [linsert $argv 0 $arg]
break
}
}
}
set testdir [file dirname $argv0]
source $testdir/tester.tcl
# If SQLITE_ENABLE_FTS2 is defined, omit this file.
ifcapable !fts2 {
return
}
rename finish_test really_finish_test
proc finish_test {} {}
set G(isquick) 1
set EXCLUDE {
fts2.test
}
# Files to include in the test. If this list is empty then everything
# that is not in the EXCLUDE list is run.
#
set INCLUDE {
}
foreach testfile [lsort -dictionary [glob $testdir/fts2*.test]] {
set tail [file tail $testfile]
if {[lsearch -exact $EXCLUDE $tail]>=0} continue
if {[llength $INCLUDE]>0 && [lsearch -exact $INCLUDE $tail]<0} continue
source $testfile
catch {db close}
if {$sqlite_open_file_count>0} {
puts "$tail did not close all files: $sqlite_open_file_count"
fail_test $tail
set sqlite_open_file_count 0
}
}
set sqlite_open_file_count 0
really_finish_test

View File

@@ -1,202 +0,0 @@
# 2006 September 9
#
# 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 FTS2 module.
#
# $Id: fts2a.test,v 1.2 2007/05/21 21:59:18 shess Exp $
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
# If SQLITE_ENABLE_FTS2 is defined, omit this file.
ifcapable !fts2 {
finish_test
return
}
# Construct a full-text search table containing five keywords:
# one, two, three, four, and five, in various combinations. The
# rowid for each will be a bitmask for the elements it contains.
#
db eval {
CREATE VIRTUAL TABLE t1 USING fts2(content);
INSERT INTO t1(content) VALUES('one');
INSERT INTO t1(content) VALUES('two');
INSERT INTO t1(content) VALUES('one two');
INSERT INTO t1(content) VALUES('three');
INSERT INTO t1(content) VALUES('one three');
INSERT INTO t1(content) VALUES('two three');
INSERT INTO t1(content) VALUES('one two three');
INSERT INTO t1(content) VALUES('four');
INSERT INTO t1(content) VALUES('one four');
INSERT INTO t1(content) VALUES('two four');
INSERT INTO t1(content) VALUES('one two four');
INSERT INTO t1(content) VALUES('three four');
INSERT INTO t1(content) VALUES('one three four');
INSERT INTO t1(content) VALUES('two three four');
INSERT INTO t1(content) VALUES('one two three four');
INSERT INTO t1(content) VALUES('five');
INSERT INTO t1(content) VALUES('one five');
INSERT INTO t1(content) VALUES('two five');
INSERT INTO t1(content) VALUES('one two five');
INSERT INTO t1(content) VALUES('three five');
INSERT INTO t1(content) VALUES('one three five');
INSERT INTO t1(content) VALUES('two three five');
INSERT INTO t1(content) VALUES('one two three five');
INSERT INTO t1(content) VALUES('four five');
INSERT INTO t1(content) VALUES('one four five');
INSERT INTO t1(content) VALUES('two four five');
INSERT INTO t1(content) VALUES('one two four five');
INSERT INTO t1(content) VALUES('three four five');
INSERT INTO t1(content) VALUES('one three four five');
INSERT INTO t1(content) VALUES('two three four five');
INSERT INTO t1(content) VALUES('one two three four five');
}
do_test fts2a-1.1 {
execsql {SELECT rowid FROM t1 WHERE content MATCH 'one'}
} {1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31}
do_test fts2a-1.2 {
execsql {SELECT rowid FROM t1 WHERE content MATCH 'one two'}
} {3 7 11 15 19 23 27 31}
do_test fts2a-1.3 {
execsql {SELECT rowid FROM t1 WHERE content MATCH 'two one'}
} {3 7 11 15 19 23 27 31}
do_test fts2a-1.4 {
execsql {SELECT rowid FROM t1 WHERE content MATCH 'one two three'}
} {7 15 23 31}
do_test fts2a-1.5 {
execsql {SELECT rowid FROM t1 WHERE content MATCH 'one three two'}
} {7 15 23 31}
do_test fts2a-1.6 {
execsql {SELECT rowid FROM t1 WHERE content MATCH 'two three one'}
} {7 15 23 31}
do_test fts2a-1.7 {
execsql {SELECT rowid FROM t1 WHERE content MATCH 'two one three'}
} {7 15 23 31}
do_test fts2a-1.8 {
execsql {SELECT rowid FROM t1 WHERE content MATCH 'three one two'}
} {7 15 23 31}
do_test fts2a-1.9 {
execsql {SELECT rowid FROM t1 WHERE content MATCH 'three two one'}
} {7 15 23 31}
do_test fts2a-1.10 {
execsql {SELECT rowid FROM t1 WHERE content MATCH 'one two THREE'}
} {7 15 23 31}
do_test fts2a-1.11 {
execsql {SELECT rowid FROM t1 WHERE content MATCH ' ONE Two three '}
} {7 15 23 31}
do_test fts2a-2.1 {
execsql {SELECT rowid FROM t1 WHERE content MATCH '"one"'}
} {1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31}
do_test fts2a-2.2 {
execsql {SELECT rowid FROM t1 WHERE content MATCH '"one two"'}
} {3 7 11 15 19 23 27 31}
do_test fts2a-2.3 {
execsql {SELECT rowid FROM t1 WHERE content MATCH '"two one"'}
} {}
do_test fts2a-2.4 {
execsql {SELECT rowid FROM t1 WHERE content MATCH '"one two three"'}
} {7 15 23 31}
do_test fts2a-2.5 {
execsql {SELECT rowid FROM t1 WHERE content MATCH '"one three two"'}
} {}
do_test fts2a-2.6 {
execsql {SELECT rowid FROM t1 WHERE content MATCH '"one two three four"'}
} {15 31}
do_test fts2a-2.7 {
execsql {SELECT rowid FROM t1 WHERE content MATCH '"one three two four"'}
} {}
do_test fts2a-2.8 {
execsql {SELECT rowid FROM t1 WHERE content MATCH '"one three five"'}
} {21}
do_test fts2a-2.9 {
execsql {SELECT rowid FROM t1 WHERE content MATCH '"one three" five'}
} {21 29}
do_test fts2a-2.10 {
execsql {SELECT rowid FROM t1 WHERE content MATCH 'five "one three"'}
} {21 29}
do_test fts2a-2.11 {
execsql {SELECT rowid FROM t1 WHERE content MATCH 'five "one three" four'}
} {29}
do_test fts2a-2.12 {
execsql {SELECT rowid FROM t1 WHERE content MATCH 'five four "one three"'}
} {29}
do_test fts2a-2.13 {
execsql {SELECT rowid FROM t1 WHERE content MATCH '"one three" four five'}
} {29}
do_test fts2a-3.1 {
execsql {SELECT rowid FROM t1 WHERE content MATCH 'one'}
} {1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31}
do_test fts2a-3.2 {
execsql {SELECT rowid FROM t1 WHERE content MATCH 'one -two'}
} {1 5 9 13 17 21 25 29}
do_test fts2a-3.3 {
execsql {SELECT rowid FROM t1 WHERE content MATCH '-two one'}
} {1 5 9 13 17 21 25 29}
do_test fts2a-4.1 {
execsql {SELECT rowid FROM t1 WHERE content MATCH 'one OR two'}
} {1 2 3 5 6 7 9 10 11 13 14 15 17 18 19 21 22 23 25 26 27 29 30 31}
do_test fts2a-4.2 {
execsql {SELECT rowid FROM t1 WHERE content MATCH '"one two" OR three'}
} {3 4 5 6 7 11 12 13 14 15 19 20 21 22 23 27 28 29 30 31}
do_test fts2a-4.3 {
execsql {SELECT rowid FROM t1 WHERE content MATCH 'three OR "one two"'}
} {3 4 5 6 7 11 12 13 14 15 19 20 21 22 23 27 28 29 30 31}
do_test fts2a-4.4 {
execsql {SELECT rowid FROM t1 WHERE content MATCH 'one two OR three'}
} {3 5 7 11 13 15 19 21 23 27 29 31}
do_test fts2a-4.5 {
execsql {SELECT rowid FROM t1 WHERE content MATCH 'three OR two one'}
} {3 5 7 11 13 15 19 21 23 27 29 31}
do_test fts2a-4.6 {
execsql {SELECT rowid FROM t1 WHERE content MATCH 'one two OR three OR four'}
} {3 5 7 9 11 13 15 19 21 23 25 27 29 31}
do_test fts2a-4.7 {
execsql {SELECT rowid FROM t1 WHERE content MATCH 'two OR three OR four one'}
} {3 5 7 9 11 13 15 19 21 23 25 27 29 31}
# Test the ability to handle NULL content
#
do_test fts2a-5.1 {
execsql {INSERT INTO t1(content) VALUES(NULL)}
} {}
do_test fts2a-5.2 {
set rowid [db last_insert_rowid]
execsql {SELECT content FROM t1 WHERE rowid=$rowid}
} {{}}
do_test fts2a-5.3 {
execsql {SELECT rowid FROM t1 WHERE content MATCH NULL}
} {}
# Test the ability to handle non-positive rowids
#
do_test fts2a-6.0 {
execsql {INSERT INTO t1(rowid, content) VALUES(0, 'four five')}
} {}
do_test fts2a-6.1 {
execsql {SELECT content FROM t1 WHERE rowid = 0}
} {{four five}}
do_test fts2a-6.2 {
execsql {INSERT INTO t1(rowid, content) VALUES(-1, 'three four')}
} {}
do_test fts2a-6.3 {
execsql {SELECT content FROM t1 WHERE rowid = -1}
} {{three four}}
do_test fts2a-6.4 {
execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'four'}
} {-1 0 8 9 10 11 12 13 14 15 24 25 26 27 28 29 30 31}
finish_test

View File

@@ -1,147 +0,0 @@
# 2006 September 13
#
# 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 FTS2 module.
#
# $Id: fts2b.test,v 1.1 2006/10/19 23:36:26 shess Exp $
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
# If SQLITE_ENABLE_FTS2 is defined, omit this file.
ifcapable !fts2 {
finish_test
return
}
# Fill the full-text index "t1" with phrases in english, spanish,
# and german. For the i-th row, fill in the names for the bits
# that are set in the value of i. The least significant bit is
# 1. For example, the value 5 is 101 in binary which will be
# converted to "one three" in english.
#
proc fill_multilanguage_fulltext_t1 {} {
set english {one two three four five}
set spanish {un dos tres cuatro cinco}
set german {eine zwei drei vier funf}
for {set i 1} {$i<=31} {incr i} {
set cmd "INSERT INTO t1 VALUES"
set vset {}
foreach lang {english spanish german} {
set words {}
for {set j 0; set k 1} {$j<5} {incr j; incr k $k} {
if {$k&$i} {lappend words [lindex [set $lang] $j]}
}
lappend vset "'$words'"
}
set sql "INSERT INTO t1(english,spanish,german) VALUES([join $vset ,])"
# puts $sql
db eval $sql
}
}
# Construct a full-text search table containing five keywords:
# one, two, three, four, and five, in various combinations. The
# rowid for each will be a bitmask for the elements it contains.
#
db eval {
CREATE VIRTUAL TABLE t1 USING fts2(english,spanish,german);
}
fill_multilanguage_fulltext_t1
do_test fts2b-1.1 {
execsql {SELECT rowid FROM t1 WHERE english MATCH 'one'}
} {1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31}
do_test fts2b-1.2 {
execsql {SELECT rowid FROM t1 WHERE spanish MATCH 'one'}
} {}
do_test fts2b-1.3 {
execsql {SELECT rowid FROM t1 WHERE german MATCH 'one'}
} {}
do_test fts2b-1.4 {
execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'one'}
} {1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31}
do_test fts2b-1.5 {
execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'one dos drei'}
} {7 15 23 31}
do_test fts2b-1.6 {
execsql {SELECT english, spanish, german FROM t1 WHERE rowid=1}
} {one un eine}
do_test fts2b-1.7 {
execsql {SELECT rowid FROM t1 WHERE t1 MATCH '"one un"'}
} {}
do_test fts2b-2.1 {
execsql {
CREATE VIRTUAL TABLE t2 USING fts2(from,to);
INSERT INTO t2([from],[to]) VALUES ('one two three', 'four five six');
SELECT [from], [to] FROM t2
}
} {{one two three} {four five six}}
# Compute an SQL string that contains the words one, two, three,... to
# describe bits set in the value $i. Only the lower 5 bits are examined.
#
proc wordset {i} {
set x {}
for {set j 0; set k 1} {$j<5} {incr j; incr k $k} {
if {$k&$i} {lappend x [lindex {one two three four five} $j]}
}
return '$x'
}
# Create a new FTS table with three columns:
#
# norm: words for the bits of rowid
# plusone: words for the bits of rowid+1
# invert: words for the bits of ~rowid
#
db eval {
CREATE VIRTUAL TABLE t4 USING fts2([norm],'plusone',"invert");
}
for {set i 1} {$i<=15} {incr i} {
set vset [list [wordset $i] [wordset [expr {$i+1}]] [wordset [expr {~$i}]]]
db eval "INSERT INTO t4(norm,plusone,invert) VALUES([join $vset ,]);"
}
do_test fts2b-4.1 {
execsql {SELECT rowid FROM t4 WHERE t4 MATCH 'norm:one'}
} {1 3 5 7 9 11 13 15}
do_test fts2b-4.2 {
execsql {SELECT rowid FROM t4 WHERE norm MATCH 'one'}
} {1 3 5 7 9 11 13 15}
do_test fts2b-4.3 {
execsql {SELECT rowid FROM t4 WHERE t4 MATCH 'one'}
} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15}
do_test fts2b-4.4 {
execsql {SELECT rowid FROM t4 WHERE t4 MATCH 'plusone:one'}
} {2 4 6 8 10 12 14}
do_test fts2b-4.5 {
execsql {SELECT rowid FROM t4 WHERE plusone MATCH 'one'}
} {2 4 6 8 10 12 14}
do_test fts2b-4.6 {
execsql {SELECT rowid FROM t4 WHERE t4 MATCH 'norm:one plusone:two'}
} {1 5 9 13}
do_test fts2b-4.7 {
execsql {SELECT rowid FROM t4 WHERE t4 MATCH 'norm:one two'}
} {1 3 5 7 9 11 13 15}
do_test fts2b-4.8 {
execsql {SELECT rowid FROM t4 WHERE t4 MATCH 'plusone:two norm:one'}
} {1 5 9 13}
do_test fts2b-4.9 {
execsql {SELECT rowid FROM t4 WHERE t4 MATCH 'two norm:one'}
} {1 3 5 7 9 11 13 15}
finish_test

File diff suppressed because it is too large Load Diff

View File

@@ -1,65 +0,0 @@
# 2006 October 1
#
# 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 FTS2 module, and in particular
# the Porter stemmer.
#
# $Id: fts2d.test,v 1.1 2006/10/19 23:36:26 shess Exp $
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
# If SQLITE_ENABLE_FTS2 is defined, omit this file.
ifcapable !fts2 {
finish_test
return
}
do_test fts2d-1.1 {
execsql {
CREATE VIRTUAL TABLE t1 USING fts2(content, tokenize porter);
INSERT INTO t1(rowid, content) VALUES(1, 'running and jumping');
SELECT rowid FROM t1 WHERE content MATCH 'run jump';
}
} {1}
do_test fts2d-1.2 {
execsql {
SELECT snippet(t1) FROM t1 WHERE t1 MATCH 'run jump';
}
} {{<b>running</b> and <b>jumping</b>}}
do_test fts2d-1.3 {
execsql {
INSERT INTO t1(rowid, content)
VALUES(2, 'abcdefghijklmnopqrstuvwyxz');
SELECT rowid, snippet(t1) FROM t1 WHERE t1 MATCH 'abcdefghijqrstuvwyxz'
}
} {2 <b>abcdefghijklmnopqrstuvwyxz</b>}
do_test fts2d-1.4 {
execsql {
SELECT rowid, snippet(t1) FROM t1 WHERE t1 MATCH 'abcdefghijXXXXqrstuvwyxz'
}
} {2 <b>abcdefghijklmnopqrstuvwyxz</b>}
do_test fts2d-1.5 {
execsql {
INSERT INTO t1(rowid, content)
VALUES(3, 'The value is 123456789');
SELECT rowid, snippet(t1) FROM t1 WHERE t1 MATCH '123789'
}
} {3 {The value is <b>123456789</b>}}
do_test fts2d-1.6 {
execsql {
SELECT rowid, snippet(t1) FROM t1 WHERE t1 MATCH '123000000789'
}
} {3 {The value is <b>123456789</b>}}
finish_test

View File

@@ -1,85 +0,0 @@
# 2006 October 19
#
# The author disclaims copyright to this source code.
#
#*************************************************************************
# This file implements regression tests for SQLite library. The
# focus of this script is testing deletions in the FTS2 module.
#
# $Id: fts2e.test,v 1.1 2006/10/19 23:36:26 shess Exp $
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
# If SQLITE_ENABLE_FTS2 is defined, omit this file.
ifcapable !fts2 {
finish_test
return
}
# Construct a full-text search table containing keywords which are the
# ordinal numbers of the bit positions set for a sequence of integers,
# which are used for the rowid. There are a total of 30 INSERT and
# DELETE statements, so that we'll test both the segmentMerge() merge
# (over the first 16) and the termSelect() merge (over the level-1
# segment and 14 level-0 segments).
db eval {
CREATE VIRTUAL TABLE t1 USING fts2(content);
INSERT INTO t1 (rowid, content) VALUES(1, 'one');
INSERT INTO t1 (rowid, content) VALUES(2, 'two');
INSERT INTO t1 (rowid, content) VALUES(3, 'one two');
INSERT INTO t1 (rowid, content) VALUES(4, 'three');
DELETE FROM t1 WHERE rowid = 1;
INSERT INTO t1 (rowid, content) VALUES(5, 'one three');
INSERT INTO t1 (rowid, content) VALUES(6, 'two three');
INSERT INTO t1 (rowid, content) VALUES(7, 'one two three');
DELETE FROM t1 WHERE rowid = 4;
INSERT INTO t1 (rowid, content) VALUES(8, 'four');
INSERT INTO t1 (rowid, content) VALUES(9, 'one four');
INSERT INTO t1 (rowid, content) VALUES(10, 'two four');
DELETE FROM t1 WHERE rowid = 7;
INSERT INTO t1 (rowid, content) VALUES(11, 'one two four');
INSERT INTO t1 (rowid, content) VALUES(12, 'three four');
INSERT INTO t1 (rowid, content) VALUES(13, 'one three four');
DELETE FROM t1 WHERE rowid = 10;
INSERT INTO t1 (rowid, content) VALUES(14, 'two three four');
INSERT INTO t1 (rowid, content) VALUES(15, 'one two three four');
INSERT INTO t1 (rowid, content) VALUES(16, 'five');
DELETE FROM t1 WHERE rowid = 13;
INSERT INTO t1 (rowid, content) VALUES(17, 'one five');
INSERT INTO t1 (rowid, content) VALUES(18, 'two five');
INSERT INTO t1 (rowid, content) VALUES(19, 'one two five');
DELETE FROM t1 WHERE rowid = 16;
INSERT INTO t1 (rowid, content) VALUES(20, 'three five');
INSERT INTO t1 (rowid, content) VALUES(21, 'one three five');
INSERT INTO t1 (rowid, content) VALUES(22, 'two three five');
DELETE FROM t1 WHERE rowid = 19;
DELETE FROM t1 WHERE rowid = 22;
}
do_test fts2f-1.1 {
execsql {SELECT COUNT(*) FROM t1}
} {14}
do_test fts2e-2.1 {
execsql {SELECT rowid FROM t1 WHERE content MATCH 'one'}
} {3 5 9 11 15 17 21}
do_test fts2e-2.2 {
execsql {SELECT rowid FROM t1 WHERE content MATCH 'two'}
} {2 3 6 11 14 15 18}
do_test fts2e-2.3 {
execsql {SELECT rowid FROM t1 WHERE content MATCH 'three'}
} {5 6 12 14 15 20 21}
do_test fts2e-2.4 {
execsql {SELECT rowid FROM t1 WHERE content MATCH 'four'}
} {8 9 11 12 14 15}
do_test fts2e-2.5 {
execsql {SELECT rowid FROM t1 WHERE content MATCH 'five'}
} {17 18 20 21}
finish_test

View File

@@ -1,90 +0,0 @@
# 2006 October 19
#
# The author disclaims copyright to this source code.
#
#*************************************************************************
# This file implements regression tests for SQLite library. The
# focus of this script is testing updates in the FTS2 module.
#
# $Id: fts2f.test,v 1.2 2007/02/23 00:14:06 shess Exp $
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
# If SQLITE_ENABLE_FTS2 is defined, omit this file.
ifcapable !fts2 {
finish_test
return
}
# Construct a full-text search table containing keywords which are the
# ordinal numbers of the bit positions set for a sequence of integers,
# which are used for the rowid. There are a total of 31 INSERT,
# UPDATE, and DELETE statements, so that we'll test both the
# segmentMerge() merge (over the first 16) and the termSelect() merge
# (over the level-1 segment and 15 level-0 segments).
db eval {
CREATE VIRTUAL TABLE t1 USING fts2(content);
INSERT INTO t1 (rowid, content) VALUES(1, 'one');
INSERT INTO t1 (rowid, content) VALUES(2, 'two');
INSERT INTO t1 (rowid, content) VALUES(3, 'one two');
INSERT INTO t1 (rowid, content) VALUES(4, 'three');
INSERT INTO t1 (rowid, content) VALUES(5, 'one three');
INSERT INTO t1 (rowid, content) VALUES(6, 'two three');
INSERT INTO t1 (rowid, content) VALUES(7, 'one two three');
DELETE FROM t1 WHERE rowid = 4;
INSERT INTO t1 (rowid, content) VALUES(8, 'four');
UPDATE t1 SET content = 'update one three' WHERE rowid = 1;
INSERT INTO t1 (rowid, content) VALUES(9, 'one four');
INSERT INTO t1 (rowid, content) VALUES(10, 'two four');
DELETE FROM t1 WHERE rowid = 7;
INSERT INTO t1 (rowid, content) VALUES(11, 'one two four');
INSERT INTO t1 (rowid, content) VALUES(12, 'three four');
INSERT INTO t1 (rowid, content) VALUES(13, 'one three four');
DELETE FROM t1 WHERE rowid = 10;
INSERT INTO t1 (rowid, content) VALUES(14, 'two three four');
INSERT INTO t1 (rowid, content) VALUES(15, 'one two three four');
UPDATE t1 SET content = 'update two five' WHERE rowid = 8;
INSERT INTO t1 (rowid, content) VALUES(16, 'five');
DELETE FROM t1 WHERE rowid = 13;
INSERT INTO t1 (rowid, content) VALUES(17, 'one five');
INSERT INTO t1 (rowid, content) VALUES(18, 'two five');
INSERT INTO t1 (rowid, content) VALUES(19, 'one two five');
DELETE FROM t1 WHERE rowid = 16;
INSERT INTO t1 (rowid, content) VALUES(20, 'three five');
INSERT INTO t1 (rowid, content) VALUES(21, 'one three five');
INSERT INTO t1 (rowid, content) VALUES(22, 'two three five');
DELETE FROM t1 WHERE rowid = 19;
UPDATE t1 SET content = 'update' WHERE rowid = 15;
}
do_test fts2f-1.1 {
execsql {SELECT COUNT(*) FROM t1}
} {16}
do_test fts2f-2.0 {
execsql {SELECT rowid FROM t1 WHERE content MATCH 'update'}
} {1 8 15}
do_test fts2f-2.1 {
execsql {SELECT rowid FROM t1 WHERE content MATCH 'one'}
} {1 3 5 9 11 17 21}
do_test fts2f-2.2 {
execsql {SELECT rowid FROM t1 WHERE content MATCH 'two'}
} {2 3 6 8 11 14 18 22}
do_test fts2f-2.3 {
execsql {SELECT rowid FROM t1 WHERE content MATCH 'three'}
} {1 5 6 12 14 20 21 22}
do_test fts2f-2.4 {
execsql {SELECT rowid FROM t1 WHERE content MATCH 'four'}
} {9 11 12 14}
do_test fts2f-2.5 {
execsql {SELECT rowid FROM t1 WHERE content MATCH 'five'}
} {8 17 18 20 21 22}
finish_test

View File

@@ -1,93 +0,0 @@
# 2006 October 19
#
# The author disclaims copyright to this source code.
#
#*************************************************************************
# This file implements regression tests for SQLite library. The focus
# of this script is testing handling of edge cases for various doclist
# merging functions in the FTS2 module query logic.
#
# $Id: fts2g.test,v 1.3 2007/11/16 00:23:08 shess Exp $
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
# If SQLITE_ENABLE_FTS2 is defined, omit this file.
ifcapable !fts2 {
finish_test
return
}
db eval {
CREATE VIRTUAL TABLE t1 USING fts2(content);
INSERT INTO t1 (rowid, content) VALUES(1, 'this is a test');
INSERT INTO t1 (rowid, content) VALUES(2, 'also a test');
}
# No hits at all. Returns empty doclists from termSelect().
do_test fts2g-1.1 {
execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'something'}
} {}
# Empty left in docListExceptMerge().
do_test fts2g-1.2 {
execsql {SELECT rowid FROM t1 WHERE t1 MATCH '-this something'}
} {}
# Empty right in docListExceptMerge().
do_test fts2g-1.3 {
execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'this -something'}
} {1}
# Empty left in docListPhraseMerge().
do_test fts2g-1.4 {
execsql {SELECT rowid FROM t1 WHERE t1 MATCH '"this something"'}
} {}
# Empty right in docListPhraseMerge().
do_test fts2g-1.5 {
execsql {SELECT rowid FROM t1 WHERE t1 MATCH '"something is"'}
} {}
# Empty left in docListOrMerge().
do_test fts2g-1.6 {
execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'something OR this'}
} {1}
# Empty right in docListOrMerge().
do_test fts2g-1.7 {
execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'this OR something'}
} {1}
# Empty left in docListAndMerge().
do_test fts2g-1.8 {
execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'something this'}
} {}
# Empty right in docListAndMerge().
do_test fts2g-1.9 {
execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'this something'}
} {}
# No support for all-except queries.
do_test fts2g-1.10 {
catchsql {SELECT rowid FROM t1 WHERE t1 MATCH '-this -something'}
} {1 {SQL logic error}}
# Test that docListOrMerge() correctly handles reaching the end of one
# doclist before it reaches the end of the other.
do_test fts2g-1.11 {
execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'this OR also'}
} {1 2}
do_test fts2g-1.12 {
execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'also OR this'}
} {1 2}
# Empty left and right in docListOrMerge(). Each term matches neither
# row, and when combined there was an assertion failure.
do_test fts2g-1.13 {
execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'something OR nothing'}
} {}
finish_test

View File

@@ -1,76 +0,0 @@
# 2006 October 31 (scaaarey)
#
# The author disclaims copyright to this source code.
#
#*************************************************************************
# This file implements regression tests for SQLite library. The focus
# here is testing correct handling of excessively long terms.
#
# $Id: fts2h.test,v 1.1 2006/11/29 21:03:01 shess Exp $
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
# If SQLITE_ENABLE_FTS2 is defined, omit this file.
ifcapable !fts2 {
finish_test
return
}
# Generate a term of len copies of char.
proc bigterm {char len} {
for {set term ""} {$len>0} {incr len -1} {
append term $char
}
return $term
}
# Generate a document of bigterms based on characters from the list
# chars.
proc bigtermdoc {chars len} {
set doc ""
foreach char $chars {
append doc " " [bigterm $char $len]
}
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]
set aterm [bigterm a $len]
set bterm [bigterm b $len]
set xterm [bigterm x $len]
db eval {
CREATE VIRTUAL TABLE t1 USING fts2(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 fts2h-1.1 {
execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'something'}
} {}
do_test fts2h-1.2 {
execsql {SELECT rowid FROM t1 WHERE t1 MATCH $aterm}
} {1 3}
do_test fts2h-1.2 {
execsql {SELECT rowid FROM t1 WHERE t1 MATCH $xterm}
} {}
do_test fts2h-1.3 {
execsql "SELECT rowid FROM t1 WHERE t1 MATCH '$aterm -$xterm'"
} {1 3}
do_test fts2h-1.4 {
execsql "SELECT rowid FROM t1 WHERE t1 MATCH '\"$aterm $bterm\"'"
} {1}
finish_test

View File

@@ -1,87 +0,0 @@
# 2007 January 17
#
# The author disclaims copyright to this source code.
#
#*************************************************************************
# This file implements regression tests for SQLite fts2 library. The
# focus here is testing handling of UPDATE when using UTF-16-encoded
# databases.
#
# $Id: fts2i.test,v 1.2 2007/01/24 03:46:35 drh Exp $
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
# If SQLITE_ENABLE_FTS2 is defined, omit this file.
ifcapable !fts2 {
finish_test
return
}
# Return the UTF-16 representation of the supplied UTF-8 string $str.
# If $nt is true, append two 0x00 bytes as a nul terminator.
# NOTE(shess) Copied from capi3.test.
proc utf16 {str {nt 1}} {
set r [encoding convertto unicode $str]
if {$nt} {
append r "\x00\x00"
}
return $r
}
db eval {
PRAGMA encoding = "UTF-16le";
CREATE VIRTUAL TABLE t1 USING fts2(content);
}
do_test fts2i-1.0 {
execsql {PRAGMA encoding}
} {UTF-16le}
do_test fts2i-1.1 {
execsql {INSERT INTO t1 (rowid, content) VALUES(1, 'one')}
execsql {SELECT content FROM t1 WHERE rowid = 1}
} {one}
do_test fts2i-1.2 {
set sql "INSERT INTO t1 (rowid, content) VALUES(2, 'two')"
set STMT [sqlite3_prepare $DB $sql -1 TAIL]
sqlite3_step $STMT
sqlite3_finalize $STMT
execsql {SELECT content FROM t1 WHERE rowid = 2}
} {two}
do_test fts2i-1.3 {
set sql "INSERT INTO t1 (rowid, content) VALUES(3, 'three')"
set STMT [sqlite3_prepare $DB $sql -1 TAIL]
sqlite3_step $STMT
sqlite3_finalize $STMT
set sql "UPDATE t1 SET content = 'trois' WHERE rowid = 3"
set STMT [sqlite3_prepare $DB $sql -1 TAIL]
sqlite3_step $STMT
sqlite3_finalize $STMT
execsql {SELECT content FROM t1 WHERE rowid = 3}
} {trois}
do_test fts2i-1.4 {
set sql16 [utf16 {INSERT INTO t1 (rowid, content) VALUES(4, 'four')}]
set STMT [sqlite3_prepare16 $DB $sql16 -1 TAIL]
sqlite3_step $STMT
sqlite3_finalize $STMT
execsql {SELECT content FROM t1 WHERE rowid = 4}
} {four}
do_test fts2i-1.5 {
set sql16 [utf16 {INSERT INTO t1 (rowid, content) VALUES(5, 'five')}]
set STMT [sqlite3_prepare16 $DB $sql16 -1 TAIL]
sqlite3_step $STMT
sqlite3_finalize $STMT
set sql "UPDATE t1 SET content = 'cinq' WHERE rowid = 5"
set STMT [sqlite3_prepare $DB $sql -1 TAIL]
sqlite3_step $STMT
sqlite3_finalize $STMT
execsql {SELECT content FROM t1 WHERE rowid = 5}
} {cinq}
finish_test

View File

@@ -1,89 +0,0 @@
# 2007 February 6
#
# The author disclaims copyright to this source code.
#
#*************************************************************************
# This file implements regression tests for SQLite library. This
# tests creating fts2 tables in an attached database.
#
# $Id: fts2j.test,v 1.1 2007/02/07 01:01:18 shess Exp $
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
# If SQLITE_ENABLE_FTS2 is defined, omit this file.
ifcapable !fts2 {
finish_test
return
}
# Clean up anything left over from a previous pass.
forcedelete test2.db
forcedelete test2.db-journal
sqlite3 db2 test2.db
db eval {
CREATE VIRTUAL TABLE t3 USING fts2(content);
INSERT INTO t3 (rowid, content) VALUES(1, "hello world");
}
db2 eval {
CREATE VIRTUAL TABLE t1 USING fts2(content);
INSERT INTO t1 (rowid, content) VALUES(1, "hello world");
INSERT INTO t1 (rowid, content) VALUES(2, "hello there");
INSERT INTO t1 (rowid, content) VALUES(3, "cruel world");
}
# This has always worked because the t1_* tables used by fts2 will be
# the defaults.
do_test fts2j-1.1 {
execsql {
ATTACH DATABASE 'test2.db' AS two;
SELECT rowid FROM t1 WHERE t1 MATCH 'hello';
DETACH DATABASE two;
}
} {1 2}
# Make certain we're detached if there was an error.
catch {db eval {DETACH DATABASE two}}
# In older code, this appears to work fine, but the t2_* tables used
# by fts2 will be created in database 'main' instead of database
# 'two'. It appears to work fine because the tables end up being the
# defaults, but obviously is badly broken if you hope to use things
# other than in the exact same ATTACH setup.
do_test fts2j-1.2 {
execsql {
ATTACH DATABASE 'test2.db' AS two;
CREATE VIRTUAL TABLE two.t2 USING fts2(content);
INSERT INTO t2 (rowid, content) VALUES(1, "hello world");
INSERT INTO t2 (rowid, content) VALUES(2, "hello there");
INSERT INTO t2 (rowid, content) VALUES(3, "cruel world");
SELECT rowid FROM t2 WHERE t2 MATCH 'hello';
DETACH DATABASE two;
}
} {1 2}
catch {db eval {DETACH DATABASE two}}
# In older code, this broke because the fts2 code attempted to create
# t3_* tables in database 'main', but they already existed. Normally
# this wouldn't happen without t3 itself existing, in which case the
# fts2 code would never be called in the first place.
do_test fts2j-1.3 {
execsql {
ATTACH DATABASE 'test2.db' AS two;
CREATE VIRTUAL TABLE two.t3 USING fts2(content);
INSERT INTO two.t3 (rowid, content) VALUES(2, "hello there");
INSERT INTO two.t3 (rowid, content) VALUES(3, "cruel world");
SELECT rowid FROM two.t3 WHERE t3 MATCH 'hello';
DETACH DATABASE two;
} db2
} {2}
catch {db eval {DETACH DATABASE two}}
catch {db2 close}
forcedelete test2.db
finish_test

View File

@@ -1,105 +0,0 @@
# 2007 March 9
#
# The author disclaims copyright to this source code.
#
#*************************************************************************
# This file implements regression tests for SQLite library. These
# make sure that fts2 insertion buffering is fully transparent when
# using transactions.
#
# $Id: fts2k.test,v 1.2 2007/08/10 23:47:04 shess Exp $
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
# If SQLITE_ENABLE_FTS2 is defined, omit this file.
ifcapable !fts2 {
finish_test
return
}
db eval {
CREATE VIRTUAL TABLE t1 USING fts2(content);
INSERT INTO t1 (rowid, content) VALUES(1, "hello world");
INSERT INTO t1 (rowid, content) VALUES(2, "hello there");
INSERT INTO t1 (rowid, content) VALUES(3, "cruel world");
}
# Test that possibly-buffered inserts went through after commit.
do_test fts2k-1.1 {
execsql {
BEGIN TRANSACTION;
INSERT INTO t1 (rowid, content) VALUES(4, "false world");
INSERT INTO t1 (rowid, content) VALUES(5, "false door");
COMMIT TRANSACTION;
SELECT rowid FROM t1 WHERE t1 MATCH 'world';
}
} {1 3 4}
# Test that buffered inserts are seen by selects in the same
# transaction.
do_test fts2k-1.2 {
execsql {
BEGIN TRANSACTION;
INSERT INTO t1 (rowid, content) VALUES(6, "another world");
INSERT INTO t1 (rowid, content) VALUES(7, "another test");
SELECT rowid FROM t1 WHERE t1 MATCH 'world';
COMMIT TRANSACTION;
}
} {1 3 4 6}
# Test that buffered inserts are seen within a transaction. This is
# really the same test as 1.2.
do_test fts2k-1.3 {
execsql {
BEGIN TRANSACTION;
INSERT INTO t1 (rowid, content) VALUES(8, "second world");
INSERT INTO t1 (rowid, content) VALUES(9, "second sight");
SELECT rowid FROM t1 WHERE t1 MATCH 'world';
ROLLBACK TRANSACTION;
}
} {1 3 4 6 8}
# Double-check that the previous result doesn't persist past the
# rollback!
do_test fts2k-1.4 {
execsql {
SELECT rowid FROM t1 WHERE t1 MATCH 'world';
}
} {1 3 4 6}
# Test it all together.
do_test fts2k-1.5 {
execsql {
BEGIN TRANSACTION;
INSERT INTO t1 (rowid, content) VALUES(10, "second world");
INSERT INTO t1 (rowid, content) VALUES(11, "second sight");
ROLLBACK TRANSACTION;
SELECT rowid FROM t1 WHERE t1 MATCH 'world';
}
} {1 3 4 6}
# Test that the obvious case works.
do_test fts2k-1.6 {
execsql {
BEGIN;
INSERT INTO t1 (rowid, content) VALUES(12, "third world");
COMMIT;
SELECT rowid FROM t1 WHERE t1 MATCH 'third';
}
} {12}
# This is exactly the same as the previous test, except that older
# code loses the INSERT due to an SQLITE_SCHEMA error.
do_test fts2k-1.7 {
execsql {
BEGIN;
INSERT INTO t1 (rowid, content) VALUES(13, "third dimension");
CREATE TABLE x (c);
COMMIT;
SELECT rowid FROM t1 WHERE t1 MATCH 'dimension';
}
} {13}
finish_test

View File

@@ -1,69 +0,0 @@
# 2007 March 28
#
# The author disclaims copyright to this source code.
#
#*************************************************************************
# This file implements regression tests for SQLite library. The focus
# of this script is testing isspace/isalnum/tolower problems with the
# FTS2 module. Unfortunately, this code isn't a really principled set
# of tests, because it is impossible to know where new uses of these
# functions might appear.
#
# $Id: fts2l.test,v 1.2 2007/12/13 21:54:11 drh Exp $
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
# If SQLITE_ENABLE_FTS2 is defined, omit this file.
ifcapable !fts2 {
finish_test
return
}
# Tests that startsWith() (calls isspace, tolower, isalnum) can handle
# hi-bit chars. parseSpec() also calls isalnum here.
do_test fts2l-1.1 {
execsql "CREATE VIRTUAL TABLE t1 USING fts2(content, \x80)"
} {}
# Additionally tests isspace() call in getToken(), and isalnum() call
# in tokenListToIdList().
do_test fts2l-1.2 {
catch {
execsql "CREATE VIRTUAL TABLE t2 USING fts2(content, tokenize \x80)"
}
sqlite3_errmsg $DB
} "unknown tokenizer: \x80"
# Additionally test final isalnum() in startsWith().
do_test fts2l-1.3 {
execsql "CREATE VIRTUAL TABLE t3 USING fts2(content, tokenize\x80)"
} {}
# The snippet-generation code has calls to isspace() which are sort of
# hard to get to. It finds convenient breakpoints by starting ~40
# chars before and after the matched term, and scanning ~10 chars
# around that position for isspace() characters. The long word with
# embedded hi-bit chars causes one of these isspace() calls to be
# exercised. The version with a couple extra spaces should cause the
# other isspace() call to be exercised. [Both cases have been tested
# in the debugger, but I'm hoping to continue to catch it if simple
# constant changes change things slightly.
#
# The trailing and leading hi-bit chars help with code which tests for
# isspace() to coalesce multiple spaces.
set word "\x80xxxxx\x80xxxxx\x80xxxxx\x80xxxxx\x80xxxxx\x80xxxxx\x80"
set phrase1 "$word $word $word target $word $word $word"
set phrase2 "$word $word $word target $word $word $word"
db eval {CREATE VIRTUAL TABLE t4 USING fts2(content)}
db eval "INSERT INTO t4 (content) VALUES ('$phrase1')"
db eval "INSERT INTO t4 (content) VALUES ('$phrase2')"
do_test fts2l-1.4 {
execsql {SELECT rowid, length(snippet(t4)) FROM t4 WHERE t4 MATCH 'target'}
} {1 111 2 117}
finish_test

View File

@@ -1,65 +0,0 @@
# 2007 April 9
#
# The author disclaims copyright to this source code.
#
#*************************************************************************
# This file implements regression tests for SQLite library. fts2
# DELETE handling assumed all fields were non-null. This was not
# the intention at all.
#
# $Id: fts2m.test,v 1.1 2007/04/09 20:45:42 shess Exp $
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
# If SQLITE_ENABLE_FTS2 is defined, omit this file.
ifcapable !fts2 {
finish_test
return
}
db eval {
CREATE VIRTUAL TABLE t1 USING fts2(col_a, col_b);
INSERT INTO t1(rowid, col_a, col_b) VALUES(1, 'testing', 'testing');
INSERT INTO t1(rowid, col_a, col_b) VALUES(2, 'only a', null);
INSERT INTO t1(rowid, col_a, col_b) VALUES(3, null, 'only b');
INSERT INTO t1(rowid, col_a, col_b) VALUES(4, null, null);
}
do_test fts2m-1.0 {
execsql {
SELECT COUNT(col_a), COUNT(col_b), COUNT(*) FROM t1;
}
} {2 2 4}
do_test fts2m-1.1 {
execsql {
DELETE FROM t1 WHERE rowid = 1;
SELECT COUNT(col_a), COUNT(col_b), COUNT(*) FROM t1;
}
} {1 1 3}
do_test fts2m-1.2 {
execsql {
DELETE FROM t1 WHERE rowid = 2;
SELECT COUNT(col_a), COUNT(col_b), COUNT(*) FROM t1;
}
} {0 1 2}
do_test fts2m-1.3 {
execsql {
DELETE FROM t1 WHERE rowid = 3;
SELECT COUNT(col_a), COUNT(col_b), COUNT(*) FROM t1;
}
} {0 0 1}
do_test fts2m-1.4 {
execsql {
DELETE FROM t1 WHERE rowid = 4;
SELECT COUNT(col_a), COUNT(col_b), COUNT(*) FROM t1;
}
} {0 0 0}
finish_test

View File

@@ -1,196 +0,0 @@
# 2007 April 26
#
# The author disclaims copyright to this source code.
#
#*************************************************************************
# This file implements tests for prefix-searching in the fts2
# component of the SQLite library.
#
# $Id: fts2n.test,v 1.2 2007/12/13 21:54:11 drh Exp $
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
# If SQLITE_ENABLE_FTS2 is defined, omit this file.
ifcapable !fts2 {
finish_test
return
}
# A large string to prime the pump with.
set text {
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas
iaculis mollis ipsum. Praesent rhoncus placerat justo. Duis non quam
sed turpis posuere placerat. Curabitur et lorem in lorem porttitor
aliquet. Pellentesque bibendum tincidunt diam. Vestibulum blandit
ante nec elit. In sapien diam, facilisis eget, dictum sed, viverra
at, felis. Vestibulum magna. Sed magna dolor, vestibulum rhoncus,
ornare vel, vulputate sit amet, felis. Integer malesuada, tellus at
luctus gravida, diam nunc porta nibh, nec imperdiet massa metus eu
lectus. Aliquam nisi. Nunc fringilla nulla at lectus. Suspendisse
potenti. Cum sociis natoque penatibus et magnis dis parturient
montes, nascetur ridiculus mus. Pellentesque odio nulla, feugiat eu,
suscipit nec, consequat quis, risus.
}
db eval {
CREATE VIRTUAL TABLE t1 USING fts2(c);
INSERT INTO t1(rowid, c) VALUES(1, $text);
INSERT INTO t1(rowid, c) VALUES(2, 'Another lovely row');
}
# Exact match
do_test fts2n-1.1 {
execsql "SELECT rowid FROM t1 WHERE t1 MATCH 'lorem'"
} {1}
# And a prefix
do_test fts2n-1.2 {
execsql "SELECT rowid FROM t1 WHERE t1 MATCH 'lore*'"
} {1}
# Prefix includes exact match
do_test fts2n-1.3 {
execsql "SELECT rowid FROM t1 WHERE t1 MATCH 'lorem*'"
} {1}
# Make certain everything isn't considered a prefix!
do_test fts2n-1.4 {
execsql "SELECT rowid FROM t1 WHERE t1 MATCH 'lore'"
} {}
# Prefix across multiple rows.
do_test fts2n-1.5 {
execsql "SELECT rowid FROM t1 WHERE t1 MATCH 'lo*'"
} {1 2}
# Likewise, with multiple hits in one document.
do_test fts2n-1.6 {
execsql "SELECT rowid FROM t1 WHERE t1 MATCH 'l*'"
} {1 2}
# Prefix which should only hit one document.
do_test fts2n-1.7 {
execsql "SELECT rowid FROM t1 WHERE t1 MATCH 'lov*'"
} {2}
# * not at end is dropped.
do_test fts2n-1.8 {
execsql "SELECT rowid FROM t1 WHERE t1 MATCH 'lo *'"
} {}
# Stand-alone * is dropped.
do_test fts2n-1.9 {
execsql "SELECT rowid FROM t1 WHERE t1 MATCH '*'"
} {}
# Phrase-query prefix.
do_test fts2n-1.10 {
execsql "SELECT rowid FROM t1 WHERE t1 MATCH '\"lovely r*\"'"
} {2}
do_test fts2n-1.11 {
execsql "SELECT rowid FROM t1 WHERE t1 MATCH '\"lovely r\"'"
} {}
# Phrase query with multiple prefix matches.
do_test fts2n-1.12 {
execsql "SELECT rowid FROM t1 WHERE t1 MATCH '\"a* l*\"'"
} {1 2}
# Phrase query with multiple prefix matches.
do_test fts2n-1.13 {
execsql "SELECT rowid FROM t1 WHERE t1 MATCH '\"a* l* row\"'"
} {2}
# Test across updates (and, by implication, deletes).
# Version of text without "lorem".
regsub -all {[Ll]orem} $text '' ntext
db eval {
CREATE VIRTUAL TABLE t2 USING fts2(c);
INSERT INTO t2(rowid, c) VALUES(1, $text);
INSERT INTO t2(rowid, c) VALUES(2, 'Another lovely row');
UPDATE t2 SET c = $ntext WHERE rowid = 1;
}
# Can't see lorem as an exact match.
do_test fts2n-2.1 {
execsql "SELECT rowid FROM t2 WHERE t2 MATCH 'lorem'"
} {}
# Can't see a prefix of lorem, either.
do_test fts2n-2.2 {
execsql "SELECT rowid FROM t2 WHERE t2 MATCH 'lore*'"
} {}
# Can see lovely in the other document.
do_test fts2n-2.3 {
execsql "SELECT rowid FROM t2 WHERE t2 MATCH 'lo*'"
} {2}
# Can still see other hits.
do_test fts2n-2.4 {
execsql "SELECT rowid FROM t2 WHERE t2 MATCH 'l*'"
} {1 2}
# Prefix which should only hit one document.
do_test fts2n-2.5 {
execsql "SELECT rowid FROM t2 WHERE t2 MATCH 'lov*'"
} {2}
# Test with a segment which will have multiple levels in the tree.
# Build a big document with lots of unique terms.
set bigtext $text
foreach c {a b c d e} {
regsub -all {[A-Za-z]+} $bigtext "&$c" t
append bigtext $t
}
# Populate a table with many copies of the big document, so that we
# can test the number of hits found. Populate $ret with the expected
# hit counts for each row. offsets() returns 4 elements for every
# hit. We'll have 6 hits for row 1, 1 for row 2, and 6*(2^5)==192 for
# $bigtext.
set ret {6 1}
db eval {
BEGIN;
CREATE VIRTUAL TABLE t3 USING fts2(c);
INSERT INTO t3(rowid, c) VALUES(1, $text);
INSERT INTO t3(rowid, c) VALUES(2, 'Another lovely row');
}
for {set i 0} {$i<100} {incr i} {
db eval {INSERT INTO t3(rowid, c) VALUES(3+$i, $bigtext)}
lappend ret 192
}
db eval {COMMIT;}
# Test that we get the expected number of hits.
do_test fts2n-3.1 {
set t {}
db eval {SELECT offsets(t3) as o FROM t3 WHERE t3 MATCH 'l*'} {
set l [llength $o]
lappend t [expr {$l/4}]
}
set t
} $ret
# TODO(shess) It would be useful to test a couple edge cases, but I
# don't know if we have the precision to manage it from here at this
# time. Prefix hits can cross leaves, which the code above _should_
# hit by virtue of size. There are two variations on this. If the
# tree is 2 levels high, the code will find the leaf-node extent
# directly, but if its higher, the code will have to follow two
# separate interior branches down the tree. Both should be tested.
finish_test

View File

@@ -1,169 +0,0 @@
# 2007 June 20
#
# 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 FTS2 module.
#
# $Id: fts2o.test,v 1.4 2007/07/02 10:16:50 danielk1977 Exp $
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
# If SQLITE_ENABLE_FTS2 is not defined, omit this file.
ifcapable !fts2 {
finish_test
return
}
#---------------------------------------------------------------------
# These tests, fts2o-1.*, test that ticket #2429 is fixed.
#
db eval {
CREATE VIRTUAL TABLE t1 USING fts2(a, b, c);
INSERT INTO t1(a, b, c) VALUES('one three four', 'one four', 'one four two');
}
do_test fts2o-1.1 {
execsql {
SELECT rowid, snippet(t1) FROM t1 WHERE c MATCH 'four';
}
} {1 {one <b>four</b> two}}
do_test fts2o-1.2 {
execsql {
SELECT rowid, snippet(t1) FROM t1 WHERE b MATCH 'four';
}
} {1 {one <b>four</b>}}
do_test fts2o-1.3 {
execsql {
SELECT rowid, snippet(t1) FROM t1 WHERE a MATCH 'four';
}
} {1 {one three <b>four</b>}}
#---------------------------------------------------------------------
# Test that it is possible to rename an fts2 table.
#
do_test fts2o-2.1 {
execsql { SELECT tbl_name FROM sqlite_master WHERE type = 'table'}
} {t1 t1_content t1_segments t1_segdir}
do_test fts2o-2.2 {
execsql { ALTER TABLE t1 RENAME to fts_t1; }
} {}
do_test fts2o-2.3 {
execsql { SELECT rowid, snippet(fts_t1) FROM fts_t1 WHERE a MATCH 'four'; }
} {1 {one three <b>four</b>}}
do_test fts2o-2.4 {
execsql { SELECT tbl_name FROM sqlite_master WHERE type = 'table'}
} {fts_t1 fts_t1_content fts_t1_segments fts_t1_segdir}
# See what happens when renaming the fts2 table fails.
#
do_test fts2o-2.5 {
catchsql {
CREATE TABLE t1_segdir(a, b, c);
ALTER TABLE fts_t1 RENAME to t1;
}
} {1 {SQL logic error}}
do_test fts2o-2.6 {
execsql { SELECT rowid, snippet(fts_t1) FROM fts_t1 WHERE a MATCH 'four'; }
} {1 {one three <b>four</b>}}
do_test fts2o-2.7 {
execsql { SELECT tbl_name FROM sqlite_master WHERE type = 'table'}
} {fts_t1 fts_t1_content fts_t1_segments fts_t1_segdir t1_segdir}
# See what happens when renaming the fts2 table fails inside a transaction.
#
do_test fts2o-2.8 {
execsql {
BEGIN;
INSERT INTO fts_t1(a, b, c) VALUES('one two three', 'one four', 'one two');
}
} {}
do_test fts2o-2.9 {
catchsql {
ALTER TABLE fts_t1 RENAME to t1;
}
} {1 {SQL logic error}}
do_test fts2o-2.10 {
execsql { SELECT rowid, snippet(fts_t1) FROM fts_t1 WHERE a MATCH 'four'; }
} {1 {one three <b>four</b>}}
do_test fts2o-2.11 {
execsql { SELECT tbl_name FROM sqlite_master WHERE type = 'table'}
} {fts_t1 fts_t1_content fts_t1_segments fts_t1_segdir t1_segdir}
do_test fts2o-2.12 {
execsql COMMIT
execsql {SELECT a FROM fts_t1}
} {{one three four} {one two three}}
do_test fts2o-2.12 {
execsql { SELECT a, b, c FROM fts_t1 WHERE c MATCH 'four'; }
} {{one three four} {one four} {one four two}}
#-------------------------------------------------------------------
# Close, delete and reopen the database. The following test should
# be run on an initially empty db.
#
db close
forcedelete test.db test.db-journal
sqlite3 db test.db
do_test fts2o-3.1 {
execsql {
CREATE VIRTUAL TABLE t1 USING fts2(a, b, c);
INSERT INTO t1(a, b, c) VALUES('one three four', 'one four', 'one two');
SELECT a, b, c FROM t1 WHERE c MATCH 'two';
}
} {{one three four} {one four} {one two}}
# This test was crashing at one point.
#
do_test fts2o-3.2 {
execsql {
SELECT a, b, c FROM t1 WHERE c MATCH 'two';
CREATE TABLE t3(a, b, c);
SELECT a, b, c FROM t1 WHERE c MATCH 'two';
}
} {{one three four} {one four} {one two} {one three four} {one four} {one two}}
#---------------------------------------------------------------------
# Test that it is possible to rename an fts2 table in an attached
# database.
#
forcedelete test2.db test2.db-journal
do_test fts2o-3.1 {
execsql {
ATTACH 'test2.db' AS aux;
CREATE VIRTUAL TABLE aux.t1 USING fts2(a, b, c);
INSERT INTO aux.t1(a, b, c) VALUES(
'neung song sahm', 'neung see', 'neung see song'
);
}
} {}
do_test fts2o-3.2 {
execsql { SELECT a, b, c FROM aux.t1 WHERE a MATCH 'song'; }
} {{neung song sahm} {neung see} {neung see song}}
do_test fts2o-3.3 {
execsql { SELECT a, b, c FROM t1 WHERE c MATCH 'two'; }
} {{one three four} {one four} {one two}}
do_test fts2o-3.4 {
execsql { ALTER TABLE aux.t1 RENAME TO t2 }
} {}
do_test fts2o-3.2 {
execsql { SELECT a, b, c FROM t2 WHERE a MATCH 'song'; }
} {{neung song sahm} {neung see} {neung see song}}
do_test fts2o-3.3 {
execsql { SELECT a, b, c FROM t1 WHERE c MATCH 'two'; }
} {{one three four} {one four} {one two}}
finish_test

View File

@@ -1,357 +0,0 @@
# 2008 June 26
#
# 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 exercises some new testing functions in the FTS2 module,
# and then uses them to do some basic tests that FTS2 is internally
# working as expected.
#
# $Id: fts2p.test,v 1.1 2008/07/22 23:32:28 shess Exp $
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
# If SQLITE_ENABLE_FTS2 is not defined, omit this file.
ifcapable !fts2 {
finish_test
return
}
#*************************************************************************
# Probe to see if support for these functions is compiled in.
# TODO(shess): Change main.mk to do the right thing and remove this test.
db eval {
DROP TABLE IF EXISTS t1;
CREATE VIRTUAL TABLE t1 USING fts2(c);
INSERT INTO t1 (rowid, c) VALUES (1, 'x');
}
set s {SELECT dump_terms(t1, 1) FROM t1 LIMIT 1}
set r {1 {unable to use function dump_terms in the requested context}}
if {[catchsql $s]==$r} {
finish_test
return
}
#*************************************************************************
# Test that the new functions give appropriate errors.
do_test fts2p-0.0 {
catchsql {
SELECT dump_terms(t1, 1) FROM t1 LIMIT 1;
}
} {1 {dump_terms: incorrect arguments}}
do_test fts2p-0.1 {
catchsql {
SELECT dump_terms(t1, 0, 0, 0) FROM t1 LIMIT 1;
}
} {1 {dump_terms: incorrect arguments}}
do_test fts2p-0.2 {
catchsql {
SELECT dump_terms(1, t1) FROM t1 LIMIT 1;
}
} {1 {unable to use function dump_terms in the requested context}}
do_test fts2p-0.3 {
catchsql {
SELECT dump_terms(t1, 16, 16) FROM t1 LIMIT 1;
}
} {1 {dump_terms: segment not found}}
do_test fts2p-0.4 {
catchsql {
SELECT dump_doclist(t1) FROM t1 LIMIT 1;
}
} {1 {dump_doclist: incorrect arguments}}
do_test fts2p-0.5 {
catchsql {
SELECT dump_doclist(t1, NULL) FROM t1 LIMIT 1;
}
} {1 {dump_doclist: empty second argument}}
do_test fts2p-0.6 {
catchsql {
SELECT dump_doclist(t1, '') FROM t1 LIMIT 1;
}
} {1 {dump_doclist: empty second argument}}
do_test fts2p-0.7 {
catchsql {
SELECT dump_doclist(t1, 'a', 0) FROM t1 LIMIT 1;
}
} {1 {dump_doclist: incorrect arguments}}
do_test fts2p-0.8 {
catchsql {
SELECT dump_doclist(t1, 'a', 0, 0, 0) FROM t1 LIMIT 1;
}
} {1 {dump_doclist: incorrect arguments}}
do_test fts2p-0.9 {
catchsql {
SELECT dump_doclist(t1, 'a', 16, 16) FROM t1 LIMIT 1;
}
} {1 {dump_doclist: segment not found}}
#*************************************************************************
# Utility function to check for the expected terms in the segment
# level/index. _all version does same but for entire index.
proc check_terms {test level index terms} {
# TODO(shess): Figure out why uplevel in do_test can't catch
# $level and $index directly.
set ::level $level
set ::index $index
do_test $test.terms {
execsql {
SELECT dump_terms(t1, $::level, $::index) FROM t1 LIMIT 1;
}
} [list $terms]
}
proc check_terms_all {test terms} {
do_test $test.terms {
execsql {
SELECT dump_terms(t1) FROM t1 LIMIT 1;
}
} [list $terms]
}
# Utility function to check for the expected doclist for the term in
# segment level/index. _all version does same for entire index.
proc check_doclist {test level index term doclist} {
# TODO(shess): Again, why can't the non-:: versions work?
set ::term $term
set ::level $level
set ::index $index
do_test $test {
execsql {
SELECT dump_doclist(t1, $::term, $::level, $::index) FROM t1 LIMIT 1;
}
} [list $doclist]
}
proc check_doclist_all {test term doclist} {
set ::term $term
do_test $test {
execsql {
SELECT dump_doclist(t1, $::term) FROM t1 LIMIT 1;
}
} [list $doclist]
}
#*************************************************************************
# Test the segments resulting from straight-forward inserts.
db eval {
DROP TABLE IF EXISTS t1;
CREATE VIRTUAL TABLE t1 USING fts2(c);
INSERT INTO t1 (rowid, c) VALUES (1, 'This is a test');
INSERT INTO t1 (rowid, c) VALUES (2, 'That was a test');
INSERT INTO t1 (rowid, c) VALUES (3, 'This is a test');
}
# Check for expected segments and expected matches.
do_test fts2p-1.0.segments {
execsql {
SELECT level, idx FROM t1_segdir ORDER BY level, idx;
}
} {0 0 0 1 0 2}
do_test fts2p-1.0.matches {
execsql {
SELECT OFFSETS(t1) FROM t1
WHERE t1 MATCH 'this OR that OR was OR a OR is OR test' ORDER BY rowid;
}
} [list {0 0 0 4 0 4 5 2 0 3 8 1 0 5 10 4} \
{0 1 0 4 0 2 5 3 0 3 9 1 0 5 11 4} \
{0 0 0 4 0 4 5 2 0 3 8 1 0 5 10 4}]
# Check the specifics of the segments constructed.
# Logical view of entire index.
check_terms_all fts2p-1.0.1 {a is test that this was}
check_doclist_all fts2p-1.0.1.1 a {[1 0[2]] [2 0[2]] [3 0[2]]}
check_doclist_all fts2p-1.0.1.2 is {[1 0[1]] [3 0[1]]}
check_doclist_all fts2p-1.0.1.3 test {[1 0[3]] [2 0[3]] [3 0[3]]}
check_doclist_all fts2p-1.0.1.4 that {[2 0[0]]}
check_doclist_all fts2p-1.0.1.5 this {[1 0[0]] [3 0[0]]}
check_doclist_all fts2p-1.0.1.6 was {[2 0[1]]}
# Segment 0,0
check_terms fts2p-1.0.2 0 0 {a is test this}
check_doclist fts2p-1.0.2.1 0 0 a {[1 0[2]]}
check_doclist fts2p-1.0.2.2 0 0 is {[1 0[1]]}
check_doclist fts2p-1.0.2.3 0 0 test {[1 0[3]]}
check_doclist fts2p-1.0.2.4 0 0 this {[1 0[0]]}
# Segment 0,1
check_terms fts2p-1.0.3 0 1 {a test that was}
check_doclist fts2p-1.0.3.1 0 1 a {[2 0[2]]}
check_doclist fts2p-1.0.3.2 0 1 test {[2 0[3]]}
check_doclist fts2p-1.0.3.3 0 1 that {[2 0[0]]}
check_doclist fts2p-1.0.3.4 0 1 was {[2 0[1]]}
# Segment 0,2
check_terms fts2p-1.0.4 0 2 {a is test this}
check_doclist fts2p-1.0.4.1 0 2 a {[3 0[2]]}
check_doclist fts2p-1.0.4.2 0 2 is {[3 0[1]]}
check_doclist fts2p-1.0.4.3 0 2 test {[3 0[3]]}
check_doclist fts2p-1.0.4.4 0 2 this {[3 0[0]]}
#*************************************************************************
# Test the segments resulting from inserts followed by a delete.
db eval {
DROP TABLE IF EXISTS t1;
CREATE VIRTUAL TABLE t1 USING fts2(c);
INSERT INTO t1 (rowid, c) VALUES (1, 'This is a test');
INSERT INTO t1 (rowid, c) VALUES (2, 'That was a test');
INSERT INTO t1 (rowid, c) VALUES (3, 'This is a test');
DELETE FROM t1 WHERE rowid = 1;
}
do_test fts2p-1.1.segments {
execsql {
SELECT level, idx FROM t1_segdir ORDER BY level, idx;
}
} {0 0 0 1 0 2 0 3}
do_test fts2p-1.1.matches {
execsql {
SELECT OFFSETS(t1) FROM t1
WHERE t1 MATCH 'this OR that OR was OR a OR is OR test' ORDER BY rowid;
}
} {{0 1 0 4 0 2 5 3 0 3 9 1 0 5 11 4} {0 0 0 4 0 4 5 2 0 3 8 1 0 5 10 4}}
check_terms_all fts2p-1.1.1 {a is test that this was}
check_doclist_all fts2p-1.1.1.1 a {[2 0[2]] [3 0[2]]}
check_doclist_all fts2p-1.1.1.2 is {[3 0[1]]}
check_doclist_all fts2p-1.1.1.3 test {[2 0[3]] [3 0[3]]}
check_doclist_all fts2p-1.1.1.4 that {[2 0[0]]}
check_doclist_all fts2p-1.1.1.5 this {[3 0[0]]}
check_doclist_all fts2p-1.1.1.6 was {[2 0[1]]}
check_terms fts2p-1.1.2 0 0 {a is test this}
check_doclist fts2p-1.1.2.1 0 0 a {[1 0[2]]}
check_doclist fts2p-1.1.2.2 0 0 is {[1 0[1]]}
check_doclist fts2p-1.1.2.3 0 0 test {[1 0[3]]}
check_doclist fts2p-1.1.2.4 0 0 this {[1 0[0]]}
check_terms fts2p-1.1.3 0 1 {a test that was}
check_doclist fts2p-1.1.3.1 0 1 a {[2 0[2]]}
check_doclist fts2p-1.1.3.2 0 1 test {[2 0[3]]}
check_doclist fts2p-1.1.3.3 0 1 that {[2 0[0]]}
check_doclist fts2p-1.1.3.4 0 1 was {[2 0[1]]}
check_terms fts2p-1.1.4 0 2 {a is test this}
check_doclist fts2p-1.1.4.1 0 2 a {[3 0[2]]}
check_doclist fts2p-1.1.4.2 0 2 is {[3 0[1]]}
check_doclist fts2p-1.1.4.3 0 2 test {[3 0[3]]}
check_doclist fts2p-1.1.4.4 0 2 this {[3 0[0]]}
check_terms fts2p-1.1.5 0 3 {a is test this}
check_doclist fts2p-1.1.5.1 0 3 a {[1]}
check_doclist fts2p-1.1.5.2 0 3 is {[1]}
check_doclist fts2p-1.1.5.3 0 3 test {[1]}
check_doclist fts2p-1.1.5.4 0 3 this {[1]}
#*************************************************************************
# Test results when all references to certain tokens are deleted.
db eval {
DROP TABLE IF EXISTS t1;
CREATE VIRTUAL TABLE t1 USING fts2(c);
INSERT INTO t1 (rowid, c) VALUES (1, 'This is a test');
INSERT INTO t1 (rowid, c) VALUES (2, 'That was a test');
INSERT INTO t1 (rowid, c) VALUES (3, 'This is a test');
DELETE FROM t1 WHERE rowid IN (1,3);
}
# Still 4 segments because 0,3 will contain deletes for rowid 1 and 3.
do_test fts2p-1.2.segments {
execsql {
SELECT level, idx FROM t1_segdir ORDER BY level, idx;
}
} {0 0 0 1 0 2 0 3}
do_test fts2p-1.2.matches {
execsql {
SELECT OFFSETS(t1) FROM t1
WHERE t1 MATCH 'this OR that OR was OR a OR is OR test' ORDER BY rowid;
}
} {{0 1 0 4 0 2 5 3 0 3 9 1 0 5 11 4}}
check_terms_all fts2p-1.2.1 {a is test that this was}
check_doclist_all fts2p-1.2.1.1 a {[2 0[2]]}
check_doclist_all fts2p-1.2.1.2 is {}
check_doclist_all fts2p-1.2.1.3 test {[2 0[3]]}
check_doclist_all fts2p-1.2.1.4 that {[2 0[0]]}
check_doclist_all fts2p-1.2.1.5 this {}
check_doclist_all fts2p-1.2.1.6 was {[2 0[1]]}
check_terms fts2p-1.2.2 0 0 {a is test this}
check_doclist fts2p-1.2.2.1 0 0 a {[1 0[2]]}
check_doclist fts2p-1.2.2.2 0 0 is {[1 0[1]]}
check_doclist fts2p-1.2.2.3 0 0 test {[1 0[3]]}
check_doclist fts2p-1.2.2.4 0 0 this {[1 0[0]]}
check_terms fts2p-1.2.3 0 1 {a test that was}
check_doclist fts2p-1.2.3.1 0 1 a {[2 0[2]]}
check_doclist fts2p-1.2.3.2 0 1 test {[2 0[3]]}
check_doclist fts2p-1.2.3.3 0 1 that {[2 0[0]]}
check_doclist fts2p-1.2.3.4 0 1 was {[2 0[1]]}
check_terms fts2p-1.2.4 0 2 {a is test this}
check_doclist fts2p-1.2.4.1 0 2 a {[3 0[2]]}
check_doclist fts2p-1.2.4.2 0 2 is {[3 0[1]]}
check_doclist fts2p-1.2.4.3 0 2 test {[3 0[3]]}
check_doclist fts2p-1.2.4.4 0 2 this {[3 0[0]]}
check_terms fts2p-1.2.5 0 3 {a is test this}
check_doclist fts2p-1.2.5.1 0 3 a {[1] [3]}
check_doclist fts2p-1.2.5.2 0 3 is {[1] [3]}
check_doclist fts2p-1.2.5.3 0 3 test {[1] [3]}
check_doclist fts2p-1.2.5.4 0 3 this {[1] [3]}
#*************************************************************************
# Test results when everything is optimized manually.
db eval {
DROP TABLE IF EXISTS t1;
CREATE VIRTUAL TABLE t1 USING fts2(c);
INSERT INTO t1 (rowid, c) VALUES (1, 'This is a test');
INSERT INTO t1 (rowid, c) VALUES (2, 'That was a test');
INSERT INTO t1 (rowid, c) VALUES (3, 'This is a test');
DELETE FROM t1 WHERE rowid IN (1,3);
DROP TABLE IF EXISTS t1old;
ALTER TABLE t1 RENAME TO t1old;
CREATE VIRTUAL TABLE t1 USING fts2(c);
INSERT INTO t1 (rowid, c) SELECT rowid, c FROM t1old;
DROP TABLE t1old;
}
# Should be a single optimal segment with the same logical results.
do_test fts2p-1.3.segments {
execsql {
SELECT level, idx FROM t1_segdir ORDER BY level, idx;
}
} {0 0}
do_test fts2p-1.3.matches {
execsql {
SELECT OFFSETS(t1) FROM t1
WHERE t1 MATCH 'this OR that OR was OR a OR is OR test' ORDER BY rowid;
}
} {{0 1 0 4 0 2 5 3 0 3 9 1 0 5 11 4}}
check_terms_all fts2p-1.3.1 {a test that was}
check_doclist_all fts2p-1.3.1.1 a {[2 0[2]]}
check_doclist_all fts2p-1.3.1.2 test {[2 0[3]]}
check_doclist_all fts2p-1.3.1.3 that {[2 0[0]]}
check_doclist_all fts2p-1.3.1.4 was {[2 0[1]]}
check_terms fts2p-1.3.2 0 0 {a test that was}
check_doclist fts2p-1.3.2.1 0 0 a {[2 0[2]]}
check_doclist fts2p-1.3.2.2 0 0 test {[2 0[3]]}
check_doclist fts2p-1.3.2.3 0 0 that {[2 0[0]]}
check_doclist fts2p-1.3.2.4 0 0 was {[2 0[1]]}
finish_test

View File

@@ -1,346 +0,0 @@
# 2008 June 26
#
# 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 FTS2 module's optimize() function.
#
# $Id: fts2q.test,v 1.2 2008/07/22 23:49:44 shess Exp $
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
# If SQLITE_ENABLE_FTS2 is not defined, omit this file.
ifcapable !fts2 {
finish_test
return
}
#*************************************************************************
# Probe to see if support for the FTS2 dump_* functions is compiled in.
# TODO(shess): Change main.mk to do the right thing and remove this test.
db eval {
DROP TABLE IF EXISTS t1;
CREATE VIRTUAL TABLE t1 USING fts2(c);
INSERT INTO t1 (rowid, c) VALUES (1, 'x');
}
set s {SELECT dump_terms(t1, 1) FROM t1 LIMIT 1}
set r {1 {unable to use function dump_terms in the requested context}}
if {[catchsql $s]==$r} {
finish_test
return
}
#*************************************************************************
# Utility function to check for the expected terms in the segment
# level/index. _all version does same but for entire index.
proc check_terms {test level index terms} {
# TODO(shess): Figure out why uplevel in do_test can't catch
# $level and $index directly.
set ::level $level
set ::index $index
do_test $test.terms {
execsql {
SELECT dump_terms(t1, $::level, $::index) FROM t1 LIMIT 1;
}
} [list $terms]
}
proc check_terms_all {test terms} {
do_test $test.terms {
execsql {
SELECT dump_terms(t1) FROM t1 LIMIT 1;
}
} [list $terms]
}
# Utility function to check for the expected doclist for the term in
# segment level/index. _all version does same for entire index.
proc check_doclist {test level index term doclist} {
# TODO(shess): Again, why can't the non-:: versions work?
set ::term $term
set ::level $level
set ::index $index
do_test $test {
execsql {
SELECT dump_doclist(t1, $::term, $::level, $::index) FROM t1 LIMIT 1;
}
} [list $doclist]
}
proc check_doclist_all {test term doclist} {
set ::term $term
do_test $test {
execsql {
SELECT dump_doclist(t1, $::term) FROM t1 LIMIT 1;
}
} [list $doclist]
}
#*************************************************************************
# Test results when all rows are deleted and one is added back.
# Previously older segments would continue to exist, but now the index
# should be dropped when the table is empty. The results should look
# exactly like we never added the earlier rows in the first place.
db eval {
DROP TABLE IF EXISTS t1;
CREATE VIRTUAL TABLE t1 USING fts2(c);
INSERT INTO t1 (rowid, c) VALUES (1, 'This is a test');
INSERT INTO t1 (rowid, c) VALUES (2, 'That was a test');
INSERT INTO t1 (rowid, c) VALUES (3, 'This is a test');
DELETE FROM t1 WHERE 1=1; -- Delete each row rather than dropping table.
INSERT INTO t1 (rowid, c) VALUES (1, 'This is a test');
}
# Should be a single initial segment.
do_test fts2q-1.segments {
execsql {
SELECT level, idx FROM t1_segdir ORDER BY level, idx;
}
} {0 0}
do_test fts2q-1.matches {
execsql {
SELECT OFFSETS(t1) FROM t1
WHERE t1 MATCH 'this OR that OR was OR a OR is OR test' ORDER BY rowid;
}
} {{0 0 0 4 0 4 5 2 0 3 8 1 0 5 10 4}}
check_terms_all fts2q-1.1 {a is test this}
check_doclist_all fts2q-1.1.1 a {[1 0[2]]}
check_doclist_all fts2q-1.1.2 is {[1 0[1]]}
check_doclist_all fts2q-1.1.3 test {[1 0[3]]}
check_doclist_all fts2q-1.1.4 this {[1 0[0]]}
check_terms fts2q-1.2 0 0 {a is test this}
check_doclist fts2q-1.2.1 0 0 a {[1 0[2]]}
check_doclist fts2q-1.2.2 0 0 is {[1 0[1]]}
check_doclist fts2q-1.2.3 0 0 test {[1 0[3]]}
check_doclist fts2q-1.2.4 0 0 this {[1 0[0]]}
#*************************************************************************
# Test results when everything is optimized manually.
# NOTE(shess): This is a copy of fts2c-1.3. I've pulled a copy here
# because fts2q-2 and fts2q-3 should have identical results.
db eval {
DROP TABLE IF EXISTS t1;
CREATE VIRTUAL TABLE t1 USING fts2(c);
INSERT INTO t1 (rowid, c) VALUES (1, 'This is a test');
INSERT INTO t1 (rowid, c) VALUES (2, 'That was a test');
INSERT INTO t1 (rowid, c) VALUES (3, 'This is a test');
DELETE FROM t1 WHERE rowid IN (1,3);
DROP TABLE IF EXISTS t1old;
ALTER TABLE t1 RENAME TO t1old;
CREATE VIRTUAL TABLE t1 USING fts2(c);
INSERT INTO t1 (rowid, c) SELECT rowid, c FROM t1old;
DROP TABLE t1old;
}
# Should be a single optimal segment with the same logical results.
do_test fts2q-2.segments {
execsql {
SELECT level, idx FROM t1_segdir ORDER BY level, idx;
}
} {0 0}
do_test fts2q-2.matches {
execsql {
SELECT OFFSETS(t1) FROM t1
WHERE t1 MATCH 'this OR that OR was OR a OR is OR test' ORDER BY rowid;
}
} {{0 1 0 4 0 2 5 3 0 3 9 1 0 5 11 4}}
check_terms_all fts2q-2.1 {a test that was}
check_doclist_all fts2q-2.1.1 a {[2 0[2]]}
check_doclist_all fts2q-2.1.2 test {[2 0[3]]}
check_doclist_all fts2q-2.1.3 that {[2 0[0]]}
check_doclist_all fts2q-2.1.4 was {[2 0[1]]}
check_terms fts2q-2.2 0 0 {a test that was}
check_doclist fts2q-2.2.1 0 0 a {[2 0[2]]}
check_doclist fts2q-2.2.2 0 0 test {[2 0[3]]}
check_doclist fts2q-2.2.3 0 0 that {[2 0[0]]}
check_doclist fts2q-2.2.4 0 0 was {[2 0[1]]}
#*************************************************************************
# Test results when everything is optimized via optimize().
db eval {
DROP TABLE IF EXISTS t1;
CREATE VIRTUAL TABLE t1 USING fts2(c);
INSERT INTO t1 (rowid, c) VALUES (1, 'This is a test');
INSERT INTO t1 (rowid, c) VALUES (2, 'That was a test');
INSERT INTO t1 (rowid, c) VALUES (3, 'This is a test');
DELETE FROM t1 WHERE rowid IN (1,3);
SELECT OPTIMIZE(t1) FROM t1 LIMIT 1;
}
# Should be a single optimal segment with the same logical results.
do_test fts2q-3.segments {
execsql {
SELECT level, idx FROM t1_segdir ORDER BY level, idx;
}
} {0 0}
do_test fts2q-3.matches {
execsql {
SELECT OFFSETS(t1) FROM t1
WHERE t1 MATCH 'this OR that OR was OR a OR is OR test' ORDER BY rowid;
}
} {{0 1 0 4 0 2 5 3 0 3 9 1 0 5 11 4}}
check_terms_all fts2q-3.1 {a test that was}
check_doclist_all fts2q-3.1.1 a {[2 0[2]]}
check_doclist_all fts2q-3.1.2 test {[2 0[3]]}
check_doclist_all fts2q-3.1.3 that {[2 0[0]]}
check_doclist_all fts2q-3.1.4 was {[2 0[1]]}
check_terms fts2q-3.2 0 0 {a test that was}
check_doclist fts2q-3.2.1 0 0 a {[2 0[2]]}
check_doclist fts2q-3.2.2 0 0 test {[2 0[3]]}
check_doclist fts2q-3.2.3 0 0 that {[2 0[0]]}
check_doclist fts2q-3.2.4 0 0 was {[2 0[1]]}
#*************************************************************************
# Test optimize() against a table involving segment merges.
# NOTE(shess): Since there's no transaction, each of the INSERT/UPDATE
# statements generates a segment.
db eval {
DROP TABLE IF EXISTS t1;
CREATE VIRTUAL TABLE t1 USING fts2(c);
INSERT INTO t1 (rowid, c) VALUES (1, 'This is a test');
INSERT INTO t1 (rowid, c) VALUES (2, 'That was a test');
INSERT INTO t1 (rowid, c) VALUES (3, 'This is a test');
UPDATE t1 SET c = 'This is a test one' WHERE rowid = 1;
UPDATE t1 SET c = 'That was a test one' WHERE rowid = 2;
UPDATE t1 SET c = 'This is a test one' WHERE rowid = 3;
UPDATE t1 SET c = 'This is a test two' WHERE rowid = 1;
UPDATE t1 SET c = 'That was a test two' WHERE rowid = 2;
UPDATE t1 SET c = 'This is a test two' WHERE rowid = 3;
UPDATE t1 SET c = 'This is a test three' WHERE rowid = 1;
UPDATE t1 SET c = 'That was a test three' WHERE rowid = 2;
UPDATE t1 SET c = 'This is a test three' WHERE rowid = 3;
UPDATE t1 SET c = 'This is a test four' WHERE rowid = 1;
UPDATE t1 SET c = 'That was a test four' WHERE rowid = 2;
UPDATE t1 SET c = 'This is a test four' WHERE rowid = 3;
UPDATE t1 SET c = 'This is a test' WHERE rowid = 1;
UPDATE t1 SET c = 'That was a test' WHERE rowid = 2;
UPDATE t1 SET c = 'This is a test' WHERE rowid = 3;
}
# 2 segments in level 0, 1 in level 1 (18 segments created, 16
# merged).
do_test fts2q-4.segments {
execsql {
SELECT level, idx FROM t1_segdir ORDER BY level, idx;
}
} {0 0 0 1 1 0}
do_test fts2q-4.matches {
execsql {
SELECT OFFSETS(t1) FROM t1
WHERE t1 MATCH 'this OR that OR was OR a OR is OR test' ORDER BY rowid;
}
} [list {0 0 0 4 0 4 5 2 0 3 8 1 0 5 10 4} \
{0 1 0 4 0 2 5 3 0 3 9 1 0 5 11 4} \
{0 0 0 4 0 4 5 2 0 3 8 1 0 5 10 4}]
check_terms_all fts2q-4.1 {a four is one test that this three two was}
check_doclist_all fts2q-4.1.1 a {[1 0[2]] [2 0[2]] [3 0[2]]}
check_doclist_all fts2q-4.1.2 four {}
check_doclist_all fts2q-4.1.3 is {[1 0[1]] [3 0[1]]}
check_doclist_all fts2q-4.1.4 one {}
check_doclist_all fts2q-4.1.5 test {[1 0[3]] [2 0[3]] [3 0[3]]}
check_doclist_all fts2q-4.1.6 that {[2 0[0]]}
check_doclist_all fts2q-4.1.7 this {[1 0[0]] [3 0[0]]}
check_doclist_all fts2q-4.1.8 three {}
check_doclist_all fts2q-4.1.9 two {}
check_doclist_all fts2q-4.1.10 was {[2 0[1]]}
check_terms fts2q-4.2 0 0 {a four test that was}
check_doclist fts2q-4.2.1 0 0 a {[2 0[2]]}
check_doclist fts2q-4.2.2 0 0 four {[2]}
check_doclist fts2q-4.2.3 0 0 test {[2 0[3]]}
check_doclist fts2q-4.2.4 0 0 that {[2 0[0]]}
check_doclist fts2q-4.2.5 0 0 was {[2 0[1]]}
check_terms fts2q-4.3 0 1 {a four is test this}
check_doclist fts2q-4.3.1 0 1 a {[3 0[2]]}
check_doclist fts2q-4.3.2 0 1 four {[3]}
check_doclist fts2q-4.3.3 0 1 is {[3 0[1]]}
check_doclist fts2q-4.3.4 0 1 test {[3 0[3]]}
check_doclist fts2q-4.3.5 0 1 this {[3 0[0]]}
check_terms fts2q-4.4 1 0 {a four is one test that this three two was}
check_doclist fts2q-4.4.1 1 0 a {[1 0[2]] [2 0[2]] [3 0[2]]}
check_doclist fts2q-4.4.2 1 0 four {[1] [2 0[4]] [3 0[4]]}
check_doclist fts2q-4.4.3 1 0 is {[1 0[1]] [3 0[1]]}
check_doclist fts2q-4.4.4 1 0 one {[1] [2] [3]}
check_doclist fts2q-4.4.5 1 0 test {[1 0[3]] [2 0[3]] [3 0[3]]}
check_doclist fts2q-4.4.6 1 0 that {[2 0[0]]}
check_doclist fts2q-4.4.7 1 0 this {[1 0[0]] [3 0[0]]}
check_doclist fts2q-4.4.8 1 0 three {[1] [2] [3]}
check_doclist fts2q-4.4.9 1 0 two {[1] [2] [3]}
check_doclist fts2q-4.4.10 1 0 was {[2 0[1]]}
# Optimize should leave the result in the level of the highest-level
# prior segment.
do_test fts2q-4.5 {
execsql {
SELECT OPTIMIZE(t1) FROM t1 LIMIT 1;
SELECT level, idx FROM t1_segdir ORDER BY level, idx;
}
} {{Index optimized} 1 0}
# Identical to fts2q-4.matches.
do_test fts2q-4.5.matches {
execsql {
SELECT OFFSETS(t1) FROM t1
WHERE t1 MATCH 'this OR that OR was OR a OR is OR test' ORDER BY rowid;
}
} [list {0 0 0 4 0 4 5 2 0 3 8 1 0 5 10 4} \
{0 1 0 4 0 2 5 3 0 3 9 1 0 5 11 4} \
{0 0 0 4 0 4 5 2 0 3 8 1 0 5 10 4}]
check_terms_all fts2q-4.5.1 {a is test that this was}
check_doclist_all fts2q-4.5.1.1 a {[1 0[2]] [2 0[2]] [3 0[2]]}
check_doclist_all fts2q-4.5.1.2 is {[1 0[1]] [3 0[1]]}
check_doclist_all fts2q-4.5.1.3 test {[1 0[3]] [2 0[3]] [3 0[3]]}
check_doclist_all fts2q-4.5.1.4 that {[2 0[0]]}
check_doclist_all fts2q-4.5.1.5 this {[1 0[0]] [3 0[0]]}
check_doclist_all fts2q-4.5.1.6 was {[2 0[1]]}
check_terms fts2q-4.5.2 1 0 {a is test that this was}
check_doclist fts2q-4.5.2.1 1 0 a {[1 0[2]] [2 0[2]] [3 0[2]]}
check_doclist fts2q-4.5.2.2 1 0 is {[1 0[1]] [3 0[1]]}
check_doclist fts2q-4.5.2.3 1 0 test {[1 0[3]] [2 0[3]] [3 0[3]]}
check_doclist fts2q-4.5.2.4 1 0 that {[2 0[0]]}
check_doclist fts2q-4.5.2.5 1 0 this {[1 0[0]] [3 0[0]]}
check_doclist fts2q-4.5.2.6 1 0 was {[2 0[1]]}
# Re-optimizing does nothing.
do_test fts2q-5.0 {
execsql {
SELECT OPTIMIZE(t1) FROM t1 LIMIT 1;
SELECT level, idx FROM t1_segdir ORDER BY level, idx;
}
} {{Index already optimal} 1 0}
# Even if we move things around, still does nothing.
do_test fts2q-5.1 {
execsql {
UPDATE t1_segdir SET level = 2 WHERE level = 1 AND idx = 0;
SELECT OPTIMIZE(t1) FROM t1 LIMIT 1;
SELECT level, idx FROM t1_segdir ORDER BY level, idx;
}
} {{Index already optimal} 2 0}
finish_test

View File

@@ -1,121 +0,0 @@
# 2008 July 29
#
# 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.
#
#*************************************************************************
# These tests exercise the various types of fts2 cursors.
#
# $Id: fts2r.test,v 1.1 2008/07/29 20:38:18 shess Exp $
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
# If SQLITE_ENABLE_FTS2 is not defined, omit this file.
ifcapable !fts2 {
finish_test
return
}
#*************************************************************************
# Test table scan (QUERY_GENERIC). This kind of query happens for
# queries with no WHERE clause, or for WHERE clauses which cannot be
# satisfied by an index.
db eval {
DROP TABLE IF EXISTS t1;
CREATE VIRTUAL TABLE t1 USING fts2(c);
INSERT INTO t1 (rowid, c) VALUES (1, 'This is a test');
INSERT INTO t1 (rowid, c) VALUES (2, 'That was a test');
INSERT INTO t1 (rowid, c) VALUES (3, 'This is a test');
}
do_test fts2e-1.1 {
execsql {
SELECT rowid FROM t1 ORDER BY rowid;
}
} {1 2 3}
do_test fts2e-1.2 {
execsql {
SELECT rowid FROM t1 WHERE c LIKE '%test' ORDER BY rowid;
}
} {1 2 3}
do_test fts2e-1.3 {
execsql {
SELECT rowid FROM t1 WHERE c LIKE 'That%' ORDER BY rowid;
}
} {2}
#*************************************************************************
# Test lookup by rowid (QUERY_ROWID). This kind of query happens for
# queries which select by the rowid implicit index.
db eval {
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
CREATE VIRTUAL TABLE t1 USING fts2(c);
CREATE TABLE t2(id INTEGER PRIMARY KEY AUTOINCREMENT, weight INTEGER UNIQUE);
INSERT INTO t2 VALUES (null, 10);
INSERT INTO t1 (rowid, c) VALUES (last_insert_rowid(), 'This is a test');
INSERT INTO t2 VALUES (null, 5);
INSERT INTO t1 (rowid, c) VALUES (last_insert_rowid(), 'That was a test');
INSERT INTO t2 VALUES (null, 20);
INSERT INTO t1 (rowid, c) VALUES (last_insert_rowid(), 'This is a test');
}
# TODO(shess): This actually is doing QUERY_GENERIC? I'd have
# expected QUERY_ROWID in this case, as for a very large table the
# full scan is less efficient.
do_test fts2e-2.1 {
execsql {
SELECT rowid FROM t1 WHERE rowid in (1, 2, 10);
}
} {1 2}
do_test fts2e-2.2 {
execsql {
SELECT t1.rowid, weight FROM t1, t2 WHERE t2.id = t1.rowid ORDER BY weight;
}
} {2 5 1 10 3 20}
do_test fts2e-2.3 {
execsql {
SELECT t1.rowid, weight FROM t1, t2
WHERE t2.weight>5 AND t2.id = t1.rowid ORDER BY weight;
}
} {1 10 3 20}
#*************************************************************************
# Test lookup by MATCH (QUERY_FULLTEXT). This is the fulltext index.
db eval {
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
CREATE VIRTUAL TABLE t1 USING fts2(c);
CREATE TABLE t2(id INTEGER PRIMARY KEY AUTOINCREMENT, weight INTEGER UNIQUE);
INSERT INTO t2 VALUES (null, 10);
INSERT INTO t1 (rowid, c) VALUES (last_insert_rowid(), 'This is a test');
INSERT INTO t2 VALUES (null, 5);
INSERT INTO t1 (rowid, c) VALUES (last_insert_rowid(), 'That was a test');
INSERT INTO t2 VALUES (null, 20);
INSERT INTO t1 (rowid, c) VALUES (last_insert_rowid(), 'This is a test');
}
do_test fts2e-3.1 {
execsql {
SELECT rowid FROM t1 WHERE t1 MATCH 'this' ORDER BY rowid;
}
} {1 3}
do_test fts2e-3.2 {
execsql {
SELECT t1.rowid, weight FROM t1, t2
WHERE t1 MATCH 'this' AND t1.rowid = t2.id ORDER BY weight;
}
} {1 10 3 20}
finish_test

View File

@@ -1,174 +0,0 @@
# 2007 June 21
#
# 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 pluggable tokeniser feature of the
# FTS2 module.
#
# $Id: fts2token.test,v 1.3 2007/06/25 12:05:40 danielk1977 Exp $
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
# If SQLITE_ENABLE_FTS2 is defined, omit this file.
ifcapable !fts2 {
finish_test
return
}
proc escape_string {str} {
set out ""
foreach char [split $str ""] {
scan $char %c i
if {$i<=127} {
append out $char
} else {
append out [format {\x%.4x} $i]
}
}
set out
}
#--------------------------------------------------------------------------
# Test cases fts2token-1.* are the warm-body test for the SQL scalar
# function fts2_tokenizer(). The procedure is as follows:
#
# 1: Verify that there is no such fts2 tokenizer as 'blah'.
#
# 2: Query for the built-in tokenizer 'simple'. Insert a copy of the
# retrieved value as tokenizer 'blah'.
#
# 3: Test that the value returned for tokenizer 'blah' is now the
# same as that retrieved for 'simple'.
#
# 4: Test that it is now possible to create an fts2 table using
# tokenizer 'blah' (it was not possible in step 1).
#
# 5: Test that the table created to use tokenizer 'blah' is usable.
#
do_test fts2token-1.1 {
catchsql {
CREATE VIRTUAL TABLE t1 USING fts2(content, tokenize blah);
}
} {1 {unknown tokenizer: blah}}
do_test fts2token-1.2 {
execsql {
SELECT fts2_tokenizer('blah', fts2_tokenizer('simple')) IS NULL;
}
} {0}
do_test fts2token-1.3 {
execsql {
SELECT fts2_tokenizer('blah') == fts2_tokenizer('simple');
}
} {1}
do_test fts2token-1.4 {
catchsql {
CREATE VIRTUAL TABLE t1 USING fts2(content, tokenize blah);
}
} {0 {}}
do_test fts2token-1.5 {
execsql {
INSERT INTO t1(content) VALUES('There was movement at the station');
INSERT INTO t1(content) VALUES('For the word has passed around');
INSERT INTO t1(content) VALUES('That the colt from ol regret had got away');
SELECT content FROM t1 WHERE content MATCH 'movement'
}
} {{There was movement at the station}}
#--------------------------------------------------------------------------
# Test cases fts2token-2.* test error cases in the scalar function based
# API for getting and setting tokenizers.
#
do_test fts2token-2.1 {
catchsql {
SELECT fts2_tokenizer('nosuchtokenizer');
}
} {1 {unknown tokenizer: nosuchtokenizer}}
#--------------------------------------------------------------------------
# Test cases fts2token-3.* test the three built-in tokenizers with a
# simple input string via the built-in test function. This is as much
# to test the test function as the tokenizer implementations.
#
do_test fts2token-3.1 {
execsql {
SELECT fts2_tokenizer_test('simple', 'I don''t see how');
}
} {{0 i I 1 don don 2 t t 3 see see 4 how how}}
do_test fts2token-3.2 {
execsql {
SELECT fts2_tokenizer_test('porter', 'I don''t see how');
}
} {{0 i I 1 don don 2 t t 3 see see 4 how how}}
ifcapable icu {
do_test fts2token-3.3 {
execsql {
SELECT fts2_tokenizer_test('icu', 'I don''t see how');
}
} {{0 i I 1 don't don't 2 see see 3 how how}}
}
#--------------------------------------------------------------------------
# Test cases fts2token-4.* test the ICU tokenizer. In practice, this
# tokenizer only has two modes - "thai" and "everybody else". Some other
# Asian languages (Lao, Khmer etc.) require the same special treatment as
# Thai, but ICU doesn't support them yet.
#
ifcapable icu {
proc do_icu_test {name locale input output} {
set ::out [db eval { SELECT fts2_tokenizer_test('icu', $locale, $input) }]
do_test $name {
lindex $::out 0
} $output
}
do_icu_test fts2token-4.1 en_US {} {}
do_icu_test fts2token-4.2 en_US {Test cases fts2} [list \
0 test Test 1 cases cases 2 fts2 fts2
]
# The following test shows that ICU is smart enough to recognise
# Thai chararacters, even when the locale is set to English/United
# States.
#
set input "\u0e2d\u0e30\u0e44\u0e23\u0e19\u0e30\u0e04\u0e23\u0e31\u0e1a"
set output "0 \u0e2d\u0e30\u0e44\u0e23 \u0e2d\u0e30\u0e44\u0e23 "
append output "1 \u0e19\u0e30 \u0e19\u0e30 "
append output "2 \u0e04\u0e23\u0e31\u0e1a \u0e04\u0e23\u0e31\u0e1a"
do_icu_test fts2token-4.3 th_TH $input $output
do_icu_test fts2token-4.4 en_US $input $output
# ICU handles an unknown locale by falling back to the default.
# So this is not an error.
do_icu_test fts2token-4.5 MiddleOfTheOcean $input $output
set longtoken "AReallyReallyLongTokenOneThatWillSurelyRequire"
append longtoken "AReallocInTheIcuTokenizerCode"
set input "short tokens then "
append input $longtoken
set output "0 short short "
append output "1 tokens tokens "
append output "2 then then "
append output "3 [string tolower $longtoken] $longtoken"
do_icu_test fts2token-4.6 MiddleOfTheOcean $input $output
do_icu_test fts2token-4.7 th_TH $input $output
do_icu_test fts2token-4.8 en_US $input $output
}
do_test fts2token-internal {
execsql { SELECT fts2_tokenizer_internal_test() }
} {ok}
finish_test