Replicate the fts2*.test files as fts3a*.test, and convert fts2 to
fts3 in the text of the files. (CVS 4251) FossilOrigin-Name: 24739f148e7687532fd04794a041aade8626c630
This commit is contained in:
parent
69c4ae2413
commit
db00b6aebb
27
manifest
27
manifest
@ -1,5 +1,5 @@
|
||||
C Add\ssupport\sfor\sbuilding\swith\sfts3.\s(CVS\s4250)
|
||||
D 2007-08-20T17:37:48
|
||||
C Replicate\sthe\sfts2*.test\sfiles\sas\sfts3a*.test,\sand\sconvert\sfts2\sto\nfts3\sin\sthe\stext\sof\sthe\sfiles.\s(CVS\s4251)
|
||||
D 2007-08-20T17:38:42
|
||||
F Makefile.in 0c0e53720f658c7a551046442dd7afba0b72bfbe
|
||||
F Makefile.linux-gcc 65241babba6faf1152bf86574477baab19190499
|
||||
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
|
||||
@ -278,6 +278,23 @@ F test/fts2m.test 4b30142ead6f3ed076e880a2a464064c5ad58c51
|
||||
F test/fts2n.test a70357e72742681eaebfdbe9007b87ff3b771638
|
||||
F test/fts2o.test c6a79567d85403dc4d15b89f3f9799a0a0aef065
|
||||
F test/fts2token.test d8070b241a15ff13592a9ae4a8b7c171af6f445a
|
||||
F test/fts3aa.test 432d1d5c41939bb5405d4d6c80a9ec759b363393
|
||||
F test/fts3ab.test 7f6cf260ae80dda064023df8e8e503e9a412b91f
|
||||
F test/fts3ac.test 356280144a2c92aa7b11474afadfe62a437fcd69
|
||||
F test/fts3ad.test 32a114c6f214081f244f642bde9fd5517938788e
|
||||
F test/fts3ae.test 31d8137fc7c14b5b991e3c4fa041ad2ac1255c7b
|
||||
F test/fts3af.test d394978c534eabf22dd0837e718b913fd66b499c
|
||||
F test/fts3ag.test 107664eed6c42cf6886f2cdcd3afbf3950370b8b
|
||||
F test/fts3ah.test ba181d6a3dee0c929f0d69df67cac9c47cda6bff
|
||||
F test/fts3ai.test d29cee6ed653e30de478066881cec8aa766531b2
|
||||
F test/fts3aj.test 584facbc9ac4381a7ec624bfde677340ffc2a5a4
|
||||
F test/fts3ak.test bd14deafe9d1586e8e9bf032411026ac4f8c925d
|
||||
F test/fts3al.test 00b5cfe4d463e98e15ea1e8123bec2a8574586f4
|
||||
F test/fts3am.test 218aa6ba0dfc50c7c16b2022aac5c6be593d08d8
|
||||
F test/fts3an.test 2da4df52fe8ea8389f6fa7a01e4c1a0f091118d6
|
||||
F test/fts3ao.test 0aa29dd4fc1c8d46b1f7cfe5926f7ac97551bea9
|
||||
F test/fts3ap.test 0cf3cc99155f68d5d8c9bdbe7571b2bffe4da27e
|
||||
F test/fts3atoken.test 25c2070e1e8755d414bf9c8200427b277a9f99fa
|
||||
F test/func.test 605989453d1b42cec1d05c17aa232dc98e3e04e6
|
||||
F test/fuzz.test 62fc19dd36a427777fd671b569df07166548628a
|
||||
F test/fuzz2.test ea38692ce2da99ad79fe0be5eb1a452c1c4d37bb
|
||||
@ -541,7 +558,7 @@ F www/tclsqlite.tcl 8be95ee6dba05eabcd27a9d91331c803f2ce2130
|
||||
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
|
||||
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
|
||||
F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
|
||||
P 216c91d2fc49792d9ff53596746f1162f5b7f8d4
|
||||
R 2c4f6435b19caee2352f00347c6724cc
|
||||
P 95ef963232ab1f15a7c42229819d33d3571a753e
|
||||
R d1d5263c19598614a8f875927a21fd65
|
||||
U shess
|
||||
Z fc4df19e02ea94b7a6ecca752c10e7ee
|
||||
Z 1aa55194173606959745629a53728042
|
||||
|
@ -1 +1 @@
|
||||
95ef963232ab1f15a7c42229819d33d3571a753e
|
||||
24739f148e7687532fd04794a041aade8626c630
|
202
test/fts3aa.test
Normal file
202
test/fts3aa.test
Normal file
@ -0,0 +1,202 @@
|
||||
# 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 FTS3 module.
|
||||
#
|
||||
# $Id: fts3aa.test,v 1.1 2007/08/20 17:38:42 shess Exp $
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
|
||||
# If SQLITE_ENABLE_FTS3 is defined, omit this file.
|
||||
ifcapable !fts3 {
|
||||
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 fts3(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 fts3aa-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 fts3aa-1.2 {
|
||||
execsql {SELECT rowid FROM t1 WHERE content MATCH 'one two'}
|
||||
} {3 7 11 15 19 23 27 31}
|
||||
do_test fts3aa-1.3 {
|
||||
execsql {SELECT rowid FROM t1 WHERE content MATCH 'two one'}
|
||||
} {3 7 11 15 19 23 27 31}
|
||||
do_test fts3aa-1.4 {
|
||||
execsql {SELECT rowid FROM t1 WHERE content MATCH 'one two three'}
|
||||
} {7 15 23 31}
|
||||
do_test fts3aa-1.5 {
|
||||
execsql {SELECT rowid FROM t1 WHERE content MATCH 'one three two'}
|
||||
} {7 15 23 31}
|
||||
do_test fts3aa-1.6 {
|
||||
execsql {SELECT rowid FROM t1 WHERE content MATCH 'two three one'}
|
||||
} {7 15 23 31}
|
||||
do_test fts3aa-1.7 {
|
||||
execsql {SELECT rowid FROM t1 WHERE content MATCH 'two one three'}
|
||||
} {7 15 23 31}
|
||||
do_test fts3aa-1.8 {
|
||||
execsql {SELECT rowid FROM t1 WHERE content MATCH 'three one two'}
|
||||
} {7 15 23 31}
|
||||
do_test fts3aa-1.9 {
|
||||
execsql {SELECT rowid FROM t1 WHERE content MATCH 'three two one'}
|
||||
} {7 15 23 31}
|
||||
do_test fts3aa-1.10 {
|
||||
execsql {SELECT rowid FROM t1 WHERE content MATCH 'one two THREE'}
|
||||
} {7 15 23 31}
|
||||
do_test fts3aa-1.11 {
|
||||
execsql {SELECT rowid FROM t1 WHERE content MATCH ' ONE Two three '}
|
||||
} {7 15 23 31}
|
||||
|
||||
do_test fts3aa-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 fts3aa-2.2 {
|
||||
execsql {SELECT rowid FROM t1 WHERE content MATCH '"one two"'}
|
||||
} {3 7 11 15 19 23 27 31}
|
||||
do_test fts3aa-2.3 {
|
||||
execsql {SELECT rowid FROM t1 WHERE content MATCH '"two one"'}
|
||||
} {}
|
||||
do_test fts3aa-2.4 {
|
||||
execsql {SELECT rowid FROM t1 WHERE content MATCH '"one two three"'}
|
||||
} {7 15 23 31}
|
||||
do_test fts3aa-2.5 {
|
||||
execsql {SELECT rowid FROM t1 WHERE content MATCH '"one three two"'}
|
||||
} {}
|
||||
do_test fts3aa-2.6 {
|
||||
execsql {SELECT rowid FROM t1 WHERE content MATCH '"one two three four"'}
|
||||
} {15 31}
|
||||
do_test fts3aa-2.7 {
|
||||
execsql {SELECT rowid FROM t1 WHERE content MATCH '"one three two four"'}
|
||||
} {}
|
||||
do_test fts3aa-2.8 {
|
||||
execsql {SELECT rowid FROM t1 WHERE content MATCH '"one three five"'}
|
||||
} {21}
|
||||
do_test fts3aa-2.9 {
|
||||
execsql {SELECT rowid FROM t1 WHERE content MATCH '"one three" five'}
|
||||
} {21 29}
|
||||
do_test fts3aa-2.10 {
|
||||
execsql {SELECT rowid FROM t1 WHERE content MATCH 'five "one three"'}
|
||||
} {21 29}
|
||||
do_test fts3aa-2.11 {
|
||||
execsql {SELECT rowid FROM t1 WHERE content MATCH 'five "one three" four'}
|
||||
} {29}
|
||||
do_test fts3aa-2.12 {
|
||||
execsql {SELECT rowid FROM t1 WHERE content MATCH 'five four "one three"'}
|
||||
} {29}
|
||||
do_test fts3aa-2.13 {
|
||||
execsql {SELECT rowid FROM t1 WHERE content MATCH '"one three" four five'}
|
||||
} {29}
|
||||
|
||||
do_test fts3aa-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 fts3aa-3.2 {
|
||||
execsql {SELECT rowid FROM t1 WHERE content MATCH 'one -two'}
|
||||
} {1 5 9 13 17 21 25 29}
|
||||
do_test fts3aa-3.3 {
|
||||
execsql {SELECT rowid FROM t1 WHERE content MATCH '-two one'}
|
||||
} {1 5 9 13 17 21 25 29}
|
||||
|
||||
do_test fts3aa-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 fts3aa-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 fts3aa-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 fts3aa-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 fts3aa-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 fts3aa-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 fts3aa-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 fts3aa-5.1 {
|
||||
execsql {INSERT INTO t1(content) VALUES(NULL)}
|
||||
} {}
|
||||
do_test fts3aa-5.2 {
|
||||
set rowid [db last_insert_rowid]
|
||||
execsql {SELECT content FROM t1 WHERE rowid=$rowid}
|
||||
} {{}}
|
||||
do_test fts3aa-5.3 {
|
||||
execsql {SELECT rowid FROM t1 WHERE content MATCH NULL}
|
||||
} {}
|
||||
|
||||
# Test the ability to handle non-positive rowids
|
||||
#
|
||||
do_test fts3aa-6.0 {
|
||||
execsql {INSERT INTO t1(rowid, content) VALUES(0, 'four five')}
|
||||
} {}
|
||||
do_test fts3aa-6.1 {
|
||||
execsql {SELECT content FROM t1 WHERE rowid = 0}
|
||||
} {{four five}}
|
||||
do_test fts3aa-6.2 {
|
||||
execsql {INSERT INTO t1(rowid, content) VALUES(-1, 'three four')}
|
||||
} {}
|
||||
do_test fts3aa-6.3 {
|
||||
execsql {SELECT content FROM t1 WHERE rowid = -1}
|
||||
} {{three four}}
|
||||
do_test fts3aa-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
|
147
test/fts3ab.test
Normal file
147
test/fts3ab.test
Normal file
@ -0,0 +1,147 @@
|
||||
# 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 FTS3 module.
|
||||
#
|
||||
# $Id: fts3ab.test,v 1.1 2007/08/20 17:38:42 shess Exp $
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
|
||||
# If SQLITE_ENABLE_FTS3 is defined, omit this file.
|
||||
ifcapable !fts3 {
|
||||
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 fts3(english,spanish,german);
|
||||
}
|
||||
fill_multilanguage_fulltext_t1
|
||||
|
||||
do_test fts3ab-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 fts3ab-1.2 {
|
||||
execsql {SELECT rowid FROM t1 WHERE spanish MATCH 'one'}
|
||||
} {}
|
||||
do_test fts3ab-1.3 {
|
||||
execsql {SELECT rowid FROM t1 WHERE german MATCH 'one'}
|
||||
} {}
|
||||
do_test fts3ab-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 fts3ab-1.5 {
|
||||
execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'one dos drei'}
|
||||
} {7 15 23 31}
|
||||
do_test fts3ab-1.6 {
|
||||
execsql {SELECT english, spanish, german FROM t1 WHERE rowid=1}
|
||||
} {one un eine}
|
||||
do_test fts3ab-1.7 {
|
||||
execsql {SELECT rowid FROM t1 WHERE t1 MATCH '"one un"'}
|
||||
} {}
|
||||
|
||||
do_test fts3ab-2.1 {
|
||||
execsql {
|
||||
CREATE VIRTUAL TABLE t2 USING fts3(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 fts3([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 fts3ab-4.1 {
|
||||
execsql {SELECT rowid FROM t4 WHERE t4 MATCH 'norm:one'}
|
||||
} {1 3 5 7 9 11 13 15}
|
||||
do_test fts3ab-4.2 {
|
||||
execsql {SELECT rowid FROM t4 WHERE norm MATCH 'one'}
|
||||
} {1 3 5 7 9 11 13 15}
|
||||
do_test fts3ab-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 fts3ab-4.4 {
|
||||
execsql {SELECT rowid FROM t4 WHERE t4 MATCH 'plusone:one'}
|
||||
} {2 4 6 8 10 12 14}
|
||||
do_test fts3ab-4.5 {
|
||||
execsql {SELECT rowid FROM t4 WHERE plusone MATCH 'one'}
|
||||
} {2 4 6 8 10 12 14}
|
||||
do_test fts3ab-4.6 {
|
||||
execsql {SELECT rowid FROM t4 WHERE t4 MATCH 'norm:one plusone:two'}
|
||||
} {1 5 9 13}
|
||||
do_test fts3ab-4.7 {
|
||||
execsql {SELECT rowid FROM t4 WHERE t4 MATCH 'norm:one two'}
|
||||
} {1 3 5 7 9 11 13 15}
|
||||
do_test fts3ab-4.8 {
|
||||
execsql {SELECT rowid FROM t4 WHERE t4 MATCH 'plusone:two norm:one'}
|
||||
} {1 5 9 13}
|
||||
do_test fts3ab-4.9 {
|
||||
execsql {SELECT rowid FROM t4 WHERE t4 MATCH 'two norm:one'}
|
||||
} {1 3 5 7 9 11 13 15}
|
||||
|
||||
|
||||
finish_test
|
1213
test/fts3ac.test
Normal file
1213
test/fts3ac.test
Normal file
File diff suppressed because it is too large
Load Diff
65
test/fts3ad.test
Normal file
65
test/fts3ad.test
Normal file
@ -0,0 +1,65 @@
|
||||
# 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 FTS3 module, and in particular
|
||||
# the Porter stemmer.
|
||||
#
|
||||
# $Id: fts3ad.test,v 1.1 2007/08/20 17:38:42 shess Exp $
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
|
||||
# If SQLITE_ENABLE_FTS3 is defined, omit this file.
|
||||
ifcapable !fts3 {
|
||||
finish_test
|
||||
return
|
||||
}
|
||||
|
||||
do_test fts3ad-1.1 {
|
||||
execsql {
|
||||
CREATE VIRTUAL TABLE t1 USING fts3(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 fts3ad-1.2 {
|
||||
execsql {
|
||||
SELECT snippet(t1) FROM t1 WHERE t1 MATCH 'run jump';
|
||||
}
|
||||
} {{<b>running</b> and <b>jumping</b>}}
|
||||
do_test fts3ad-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 fts3ad-1.4 {
|
||||
execsql {
|
||||
SELECT rowid, snippet(t1) FROM t1 WHERE t1 MATCH 'abcdefghijXXXXqrstuvwyxz'
|
||||
}
|
||||
} {2 <b>abcdefghijklmnopqrstuvwyxz</b>}
|
||||
do_test fts3ad-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 fts3ad-1.6 {
|
||||
execsql {
|
||||
SELECT rowid, snippet(t1) FROM t1 WHERE t1 MATCH '123000000789'
|
||||
}
|
||||
} {3 {The value is <b>123456789</b>}}
|
||||
|
||||
|
||||
finish_test
|
85
test/fts3ae.test
Normal file
85
test/fts3ae.test
Normal file
@ -0,0 +1,85 @@
|
||||
# 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 FTS3 module.
|
||||
#
|
||||
# $Id: fts3ae.test,v 1.1 2007/08/20 17:38:42 shess Exp $
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
|
||||
# If SQLITE_ENABLE_FTS3 is defined, omit this file.
|
||||
ifcapable !fts3 {
|
||||
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 fts3(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 fts3af-1.1 {
|
||||
execsql {SELECT COUNT(*) FROM t1}
|
||||
} {14}
|
||||
|
||||
do_test fts3ae-2.1 {
|
||||
execsql {SELECT rowid FROM t1 WHERE content MATCH 'one'}
|
||||
} {3 5 9 11 15 17 21}
|
||||
|
||||
do_test fts3ae-2.2 {
|
||||
execsql {SELECT rowid FROM t1 WHERE content MATCH 'two'}
|
||||
} {2 3 6 11 14 15 18}
|
||||
|
||||
do_test fts3ae-2.3 {
|
||||
execsql {SELECT rowid FROM t1 WHERE content MATCH 'three'}
|
||||
} {5 6 12 14 15 20 21}
|
||||
|
||||
do_test fts3ae-2.4 {
|
||||
execsql {SELECT rowid FROM t1 WHERE content MATCH 'four'}
|
||||
} {8 9 11 12 14 15}
|
||||
|
||||
do_test fts3ae-2.5 {
|
||||
execsql {SELECT rowid FROM t1 WHERE content MATCH 'five'}
|
||||
} {17 18 20 21}
|
||||
|
||||
finish_test
|
90
test/fts3af.test
Normal file
90
test/fts3af.test
Normal file
@ -0,0 +1,90 @@
|
||||
# 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 FTS3 module.
|
||||
#
|
||||
# $Id: fts3af.test,v 1.1 2007/08/20 17:38:42 shess Exp $
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
|
||||
# If SQLITE_ENABLE_FTS3 is defined, omit this file.
|
||||
ifcapable !fts3 {
|
||||
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 fts3(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 fts3af-1.1 {
|
||||
execsql {SELECT COUNT(*) FROM t1}
|
||||
} {16}
|
||||
|
||||
do_test fts3af-2.0 {
|
||||
execsql {SELECT rowid FROM t1 WHERE content MATCH 'update'}
|
||||
} {1 8 15}
|
||||
|
||||
do_test fts3af-2.1 {
|
||||
execsql {SELECT rowid FROM t1 WHERE content MATCH 'one'}
|
||||
} {1 3 5 9 11 17 21}
|
||||
|
||||
do_test fts3af-2.2 {
|
||||
execsql {SELECT rowid FROM t1 WHERE content MATCH 'two'}
|
||||
} {2 3 6 8 11 14 18 22}
|
||||
|
||||
do_test fts3af-2.3 {
|
||||
execsql {SELECT rowid FROM t1 WHERE content MATCH 'three'}
|
||||
} {1 5 6 12 14 20 21 22}
|
||||
|
||||
do_test fts3af-2.4 {
|
||||
execsql {SELECT rowid FROM t1 WHERE content MATCH 'four'}
|
||||
} {9 11 12 14}
|
||||
|
||||
do_test fts3af-2.5 {
|
||||
execsql {SELECT rowid FROM t1 WHERE content MATCH 'five'}
|
||||
} {8 17 18 20 21 22}
|
||||
|
||||
finish_test
|
87
test/fts3ag.test
Normal file
87
test/fts3ag.test
Normal file
@ -0,0 +1,87 @@
|
||||
# 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 FTS3 module query logic.
|
||||
#
|
||||
# $Id: fts3ag.test,v 1.1 2007/08/20 17:38:42 shess Exp $
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
|
||||
# If SQLITE_ENABLE_FTS3 is defined, omit this file.
|
||||
ifcapable !fts3 {
|
||||
finish_test
|
||||
return
|
||||
}
|
||||
|
||||
db eval {
|
||||
CREATE VIRTUAL TABLE t1 USING fts3(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 fts3ag-1.1 {
|
||||
execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'something'}
|
||||
} {}
|
||||
|
||||
# Empty left in docListExceptMerge().
|
||||
do_test fts3ag-1.2 {
|
||||
execsql {SELECT rowid FROM t1 WHERE t1 MATCH '-this something'}
|
||||
} {}
|
||||
|
||||
# Empty right in docListExceptMerge().
|
||||
do_test fts3ag-1.3 {
|
||||
execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'this -something'}
|
||||
} {1}
|
||||
|
||||
# Empty left in docListPhraseMerge().
|
||||
do_test fts3ag-1.4 {
|
||||
execsql {SELECT rowid FROM t1 WHERE t1 MATCH '"this something"'}
|
||||
} {}
|
||||
|
||||
# Empty right in docListPhraseMerge().
|
||||
do_test fts3ag-1.5 {
|
||||
execsql {SELECT rowid FROM t1 WHERE t1 MATCH '"something is"'}
|
||||
} {}
|
||||
|
||||
# Empty left in docListOrMerge().
|
||||
do_test fts3ag-1.6 {
|
||||
execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'something OR this'}
|
||||
} {1}
|
||||
|
||||
# Empty right in docListOrMerge().
|
||||
do_test fts3ag-1.7 {
|
||||
execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'this OR something'}
|
||||
} {1}
|
||||
|
||||
# Empty left in docListAndMerge().
|
||||
do_test fts3ag-1.8 {
|
||||
execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'something this'}
|
||||
} {}
|
||||
|
||||
# Empty right in docListAndMerge().
|
||||
do_test fts3ag-1.9 {
|
||||
execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'this something'}
|
||||
} {}
|
||||
|
||||
# No support for all-except queries.
|
||||
do_test fts3ag-1.10 {
|
||||
catchsql {SELECT rowid FROM t1 WHERE t1 MATCH '-this -something'}
|
||||
} {1 {SQL logic error or missing database}}
|
||||
|
||||
# Test that docListOrMerge() correctly handles reaching the end of one
|
||||
# doclist before it reaches the end of the other.
|
||||
do_test fts3ag-1.11 {
|
||||
execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'this OR also'}
|
||||
} {1 2}
|
||||
do_test fts3ag-1.12 {
|
||||
execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'also OR this'}
|
||||
} {1 2}
|
||||
|
||||
finish_test
|
76
test/fts3ah.test
Normal file
76
test/fts3ah.test
Normal file
@ -0,0 +1,76 @@
|
||||
# 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: fts3ah.test,v 1.1 2007/08/20 17:38:42 shess Exp $
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
|
||||
# If SQLITE_ENABLE_FTS3 is defined, omit this file.
|
||||
ifcapable !fts3 {
|
||||
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 fts3(content);
|
||||
INSERT INTO t1 (rowid, content) VALUES(1, $doc1);
|
||||
INSERT INTO t1 (rowid, content) VALUES(2, $doc2);
|
||||
INSERT INTO t1 (rowid, content) VALUES(3, $doc3);
|
||||
}
|
||||
|
||||
# No hits at all. Returns empty doclists from termSelect().
|
||||
do_test fts3ah-1.1 {
|
||||
execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'something'}
|
||||
} {}
|
||||
|
||||
do_test fts3ah-1.2 {
|
||||
execsql {SELECT rowid FROM t1 WHERE t1 MATCH $aterm}
|
||||
} {1 3}
|
||||
|
||||
do_test fts3ah-1.2 {
|
||||
execsql {SELECT rowid FROM t1 WHERE t1 MATCH $xterm}
|
||||
} {}
|
||||
|
||||
do_test fts3ah-1.3 {
|
||||
execsql "SELECT rowid FROM t1 WHERE t1 MATCH '$aterm -$xterm'"
|
||||
} {1 3}
|
||||
|
||||
do_test fts3ah-1.4 {
|
||||
execsql "SELECT rowid FROM t1 WHERE t1 MATCH '\"$aterm $bterm\"'"
|
||||
} {1}
|
||||
|
||||
finish_test
|
87
test/fts3ai.test
Normal file
87
test/fts3ai.test
Normal file
@ -0,0 +1,87 @@
|
||||
# 2007 January 17
|
||||
#
|
||||
# The author disclaims copyright to this source code.
|
||||
#
|
||||
#*************************************************************************
|
||||
# This file implements regression tests for SQLite fts3 library. The
|
||||
# focus here is testing handling of UPDATE when using UTF-16-encoded
|
||||
# databases.
|
||||
#
|
||||
# $Id: fts3ai.test,v 1.1 2007/08/20 17:38:42 shess Exp $
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
|
||||
# If SQLITE_ENABLE_FTS3 is defined, omit this file.
|
||||
ifcapable !fts3 {
|
||||
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 fts3(content);
|
||||
}
|
||||
|
||||
do_test fts3ai-1.0 {
|
||||
execsql {PRAGMA encoding}
|
||||
} {UTF-16le}
|
||||
|
||||
do_test fts3ai-1.1 {
|
||||
execsql {INSERT INTO t1 (rowid, content) VALUES(1, 'one')}
|
||||
execsql {SELECT content FROM t1 WHERE rowid = 1}
|
||||
} {one}
|
||||
|
||||
do_test fts3ai-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 fts3ai-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 fts3ai-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 fts3ai-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
|
89
test/fts3aj.test
Normal file
89
test/fts3aj.test
Normal file
@ -0,0 +1,89 @@
|
||||
# 2007 February 6
|
||||
#
|
||||
# The author disclaims copyright to this source code.
|
||||
#
|
||||
#*************************************************************************
|
||||
# This file implements regression tests for SQLite library. This
|
||||
# tests creating fts3 tables in an attached database.
|
||||
#
|
||||
# $Id: fts3aj.test,v 1.1 2007/08/20 17:38:42 shess Exp $
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
|
||||
# If SQLITE_ENABLE_FTS3 is defined, omit this file.
|
||||
ifcapable !fts3 {
|
||||
finish_test
|
||||
return
|
||||
}
|
||||
|
||||
# Clean up anything left over from a previous pass.
|
||||
file delete -force test2.db
|
||||
file delete -force test2.db-journal
|
||||
sqlite3 db2 test2.db
|
||||
|
||||
db eval {
|
||||
CREATE VIRTUAL TABLE t3 USING fts3(content);
|
||||
INSERT INTO t3 (rowid, content) VALUES(1, "hello world");
|
||||
}
|
||||
|
||||
db2 eval {
|
||||
CREATE VIRTUAL TABLE t1 USING fts3(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 fts3 will be
|
||||
# the defaults.
|
||||
do_test fts3aj-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 fts3 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 fts3aj-1.2 {
|
||||
execsql {
|
||||
ATTACH DATABASE 'test2.db' AS two;
|
||||
CREATE VIRTUAL TABLE two.t2 USING fts3(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 fts3 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
|
||||
# fts3 code would never be called in the first place.
|
||||
do_test fts3aj-1.3 {
|
||||
execsql {
|
||||
ATTACH DATABASE 'test2.db' AS two;
|
||||
|
||||
CREATE VIRTUAL TABLE two.t3 USING fts3(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}
|
||||
file delete -force test2.db
|
||||
|
||||
finish_test
|
105
test/fts3ak.test
Normal file
105
test/fts3ak.test
Normal file
@ -0,0 +1,105 @@
|
||||
# 2007 March 9
|
||||
#
|
||||
# The author disclaims copyright to this source code.
|
||||
#
|
||||
#*************************************************************************
|
||||
# This file implements regression tests for SQLite library. These
|
||||
# make sure that fts3 insertion buffering is fully transparent when
|
||||
# using transactions.
|
||||
#
|
||||
# $Id: fts3ak.test,v 1.1 2007/08/20 17:38:42 shess Exp $
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
|
||||
# If SQLITE_ENABLE_FTS3 is defined, omit this file.
|
||||
ifcapable !fts3 {
|
||||
finish_test
|
||||
return
|
||||
}
|
||||
|
||||
db eval {
|
||||
CREATE VIRTUAL TABLE t1 USING fts3(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 fts3ak-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 fts3ak-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 fts3ak-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 fts3ak-1.4 {
|
||||
execsql {
|
||||
SELECT rowid FROM t1 WHERE t1 MATCH 'world';
|
||||
}
|
||||
} {1 3 4 6}
|
||||
|
||||
# Test it all together.
|
||||
do_test fts3ak-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 fts3ak-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 fts3ak-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
|
69
test/fts3al.test
Normal file
69
test/fts3al.test
Normal file
@ -0,0 +1,69 @@
|
||||
# 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
|
||||
# FTS3 module. Unfortunately, this code isn't a really principled set
|
||||
# of tests, because it's impossible to know where new uses of these
|
||||
# functions might appear.
|
||||
#
|
||||
# $Id: fts3al.test,v 1.1 2007/08/20 17:38:42 shess Exp $
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
|
||||
# If SQLITE_ENABLE_FTS3 is defined, omit this file.
|
||||
ifcapable !fts3 {
|
||||
finish_test
|
||||
return
|
||||
}
|
||||
|
||||
# Tests that startsWith() (calls isspace, tolower, isalnum) can handle
|
||||
# hi-bit chars. parseSpec() also calls isalnum here.
|
||||
do_test fts3al-1.1 {
|
||||
execsql "CREATE VIRTUAL TABLE t1 USING fts3(content, \x80)"
|
||||
} {}
|
||||
|
||||
# Additionally tests isspace() call in getToken(), and isalnum() call
|
||||
# in tokenListToIdList().
|
||||
do_test fts3al-1.2 {
|
||||
catch {
|
||||
execsql "CREATE VIRTUAL TABLE t2 USING fts3(content, tokenize \x80)"
|
||||
}
|
||||
sqlite3_errmsg $DB
|
||||
} "unknown tokenizer: \x80"
|
||||
|
||||
# Additionally test final isalnum() in startsWith().
|
||||
do_test fts3al-1.3 {
|
||||
execsql "CREATE VIRTUAL TABLE t3 USING fts3(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 fts3(content)}
|
||||
db eval "INSERT INTO t4 (content) VALUES ('$phrase1')"
|
||||
db eval "INSERT INTO t4 (content) VALUES ('$phrase2')"
|
||||
|
||||
do_test fts3al-1.4 {
|
||||
execsql {SELECT rowid, length(snippet(t4)) FROM t4 WHERE t4 MATCH 'target'}
|
||||
} {1 111 2 117}
|
||||
|
||||
finish_test
|
65
test/fts3am.test
Normal file
65
test/fts3am.test
Normal file
@ -0,0 +1,65 @@
|
||||
# 2007 April 9
|
||||
#
|
||||
# The author disclaims copyright to this source code.
|
||||
#
|
||||
#*************************************************************************
|
||||
# This file implements regression tests for SQLite library. fts3
|
||||
# DELETE handling assumed all fields were non-null. This was not
|
||||
# the intention at all.
|
||||
#
|
||||
# $Id: fts3am.test,v 1.1 2007/08/20 17:38:42 shess Exp $
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
|
||||
# If SQLITE_ENABLE_FTS3 is defined, omit this file.
|
||||
ifcapable !fts3 {
|
||||
finish_test
|
||||
return
|
||||
}
|
||||
|
||||
db eval {
|
||||
CREATE VIRTUAL TABLE t1 USING fts3(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 fts3am-1.0 {
|
||||
execsql {
|
||||
SELECT COUNT(col_a), COUNT(col_b), COUNT(*) FROM t1;
|
||||
}
|
||||
} {2 2 4}
|
||||
|
||||
do_test fts3am-1.1 {
|
||||
execsql {
|
||||
DELETE FROM t1 WHERE rowid = 1;
|
||||
SELECT COUNT(col_a), COUNT(col_b), COUNT(*) FROM t1;
|
||||
}
|
||||
} {1 1 3}
|
||||
|
||||
do_test fts3am-1.2 {
|
||||
execsql {
|
||||
DELETE FROM t1 WHERE rowid = 2;
|
||||
SELECT COUNT(col_a), COUNT(col_b), COUNT(*) FROM t1;
|
||||
}
|
||||
} {0 1 2}
|
||||
|
||||
do_test fts3am-1.3 {
|
||||
execsql {
|
||||
DELETE FROM t1 WHERE rowid = 3;
|
||||
SELECT COUNT(col_a), COUNT(col_b), COUNT(*) FROM t1;
|
||||
}
|
||||
} {0 0 1}
|
||||
|
||||
do_test fts3am-1.4 {
|
||||
execsql {
|
||||
DELETE FROM t1 WHERE rowid = 4;
|
||||
SELECT COUNT(col_a), COUNT(col_b), COUNT(*) FROM t1;
|
||||
}
|
||||
} {0 0 0}
|
||||
|
||||
finish_test
|
196
test/fts3an.test
Normal file
196
test/fts3an.test
Normal file
@ -0,0 +1,196 @@
|
||||
# 2007 April 26
|
||||
#
|
||||
# The author disclaims copyright to this source code.
|
||||
#
|
||||
#*************************************************************************
|
||||
# This file implements tests for prefix-searching in the fts3
|
||||
# component of the SQLite library.
|
||||
#
|
||||
# $Id: fts3an.test,v 1.1 2007/08/20 17:38:42 shess Exp $
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
|
||||
# If SQLITE_ENABLE_FTS3 is defined, omit this file.
|
||||
ifcapable !fts3 {
|
||||
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 fts3(c);
|
||||
|
||||
INSERT INTO t1(rowid, c) VALUES(1, $text);
|
||||
INSERT INTO t1(rowid, c) VALUES(2, 'Another lovely row');
|
||||
}
|
||||
|
||||
# Exact match
|
||||
do_test fts3an-1.1 {
|
||||
execsql "SELECT rowid FROM t1 WHERE t1 MATCH 'lorem'"
|
||||
} {1}
|
||||
|
||||
# And a prefix
|
||||
do_test fts3an-1.2 {
|
||||
execsql "SELECT rowid FROM t1 WHERE t1 MATCH 'lore*'"
|
||||
} {1}
|
||||
|
||||
# Prefix includes exact match
|
||||
do_test fts3an-1.3 {
|
||||
execsql "SELECT rowid FROM t1 WHERE t1 MATCH 'lorem*'"
|
||||
} {1}
|
||||
|
||||
# Make certain everything isn't considered a prefix!
|
||||
do_test fts3an-1.4 {
|
||||
execsql "SELECT rowid FROM t1 WHERE t1 MATCH 'lore'"
|
||||
} {}
|
||||
|
||||
# Prefix across multiple rows.
|
||||
do_test fts3an-1.5 {
|
||||
execsql "SELECT rowid FROM t1 WHERE t1 MATCH 'lo*'"
|
||||
} {1 2}
|
||||
|
||||
# Likewise, with multiple hits in one document.
|
||||
do_test fts3an-1.6 {
|
||||
execsql "SELECT rowid FROM t1 WHERE t1 MATCH 'l*'"
|
||||
} {1 2}
|
||||
|
||||
# Prefix which should only hit one document.
|
||||
do_test fts3an-1.7 {
|
||||
execsql "SELECT rowid FROM t1 WHERE t1 MATCH 'lov*'"
|
||||
} {2}
|
||||
|
||||
# * not at end is dropped.
|
||||
do_test fts3an-1.8 {
|
||||
execsql "SELECT rowid FROM t1 WHERE t1 MATCH 'lo *'"
|
||||
} {}
|
||||
|
||||
# Stand-alone * is dropped.
|
||||
do_test fts3an-1.9 {
|
||||
execsql "SELECT rowid FROM t1 WHERE t1 MATCH '*'"
|
||||
} {}
|
||||
|
||||
# Phrase-query prefix.
|
||||
do_test fts3an-1.10 {
|
||||
execsql "SELECT rowid FROM t1 WHERE t1 MATCH '\"lovely r*\"'"
|
||||
} {2}
|
||||
do_test fts3an-1.11 {
|
||||
execsql "SELECT rowid FROM t1 WHERE t1 MATCH '\"lovely r\"'"
|
||||
} {}
|
||||
|
||||
# Phrase query with multiple prefix matches.
|
||||
do_test fts3an-1.12 {
|
||||
execsql "SELECT rowid FROM t1 WHERE t1 MATCH '\"a* l*\"'"
|
||||
} {1 2}
|
||||
|
||||
# Phrase query with multiple prefix matches.
|
||||
do_test fts3an-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 fts3(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 fts3an-2.1 {
|
||||
execsql "SELECT rowid FROM t2 WHERE t2 MATCH 'lorem'"
|
||||
} {}
|
||||
|
||||
# Can't see a prefix of lorem, either.
|
||||
do_test fts3an-2.2 {
|
||||
execsql "SELECT rowid FROM t2 WHERE t2 MATCH 'lore*'"
|
||||
} {}
|
||||
|
||||
# Can see lovely in the other document.
|
||||
do_test fts3an-2.3 {
|
||||
execsql "SELECT rowid FROM t2 WHERE t2 MATCH 'lo*'"
|
||||
} {2}
|
||||
|
||||
# Can still see other hits.
|
||||
do_test fts3an-2.4 {
|
||||
execsql "SELECT rowid FROM t2 WHERE t2 MATCH 'l*'"
|
||||
} {1 2}
|
||||
|
||||
# Prefix which should only hit one document.
|
||||
do_test fts3an-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 fts3(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 fts3an-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 it's higher, the code will have to follow two
|
||||
# separate interior branches down the tree. Both should be tested.
|
||||
|
||||
finish_test
|
169
test/fts3ao.test
Normal file
169
test/fts3ao.test
Normal file
@ -0,0 +1,169 @@
|
||||
# 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 FTS3 module.
|
||||
#
|
||||
# $Id: fts3ao.test,v 1.1 2007/08/20 17:38:42 shess Exp $
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
|
||||
# If SQLITE_ENABLE_FTS3 is not defined, omit this file.
|
||||
ifcapable !fts3 {
|
||||
finish_test
|
||||
return
|
||||
}
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# These tests, fts3ao-1.*, test that ticket #2429 is fixed.
|
||||
#
|
||||
db eval {
|
||||
CREATE VIRTUAL TABLE t1 USING fts3(a, b, c);
|
||||
INSERT INTO t1(a, b, c) VALUES('one three four', 'one four', 'one four two');
|
||||
}
|
||||
do_test fts3ao-1.1 {
|
||||
execsql {
|
||||
SELECT rowid, snippet(t1) FROM t1 WHERE c MATCH 'four';
|
||||
}
|
||||
} {1 {one <b>four</b> two}}
|
||||
do_test fts3ao-1.2 {
|
||||
execsql {
|
||||
SELECT rowid, snippet(t1) FROM t1 WHERE b MATCH 'four';
|
||||
}
|
||||
} {1 {one <b>four</b>}}
|
||||
do_test fts3ao-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 fts3 table.
|
||||
#
|
||||
do_test fts3ao-2.1 {
|
||||
execsql { SELECT tbl_name FROM sqlite_master WHERE type = 'table'}
|
||||
} {t1 t1_content t1_segments t1_segdir}
|
||||
do_test fts3ao-2.2 {
|
||||
execsql { ALTER TABLE t1 RENAME to fts_t1; }
|
||||
} {}
|
||||
do_test fts3ao-2.3 {
|
||||
execsql { SELECT rowid, snippet(fts_t1) FROM fts_t1 WHERE a MATCH 'four'; }
|
||||
} {1 {one three <b>four</b>}}
|
||||
do_test fts3ao-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 fts3 table fails.
|
||||
#
|
||||
do_test fts3ao-2.5 {
|
||||
catchsql {
|
||||
CREATE TABLE t1_segdir(a, b, c);
|
||||
ALTER TABLE fts_t1 RENAME to t1;
|
||||
}
|
||||
} {1 {SQL logic error or missing database}}
|
||||
do_test fts3ao-2.6 {
|
||||
execsql { SELECT rowid, snippet(fts_t1) FROM fts_t1 WHERE a MATCH 'four'; }
|
||||
} {1 {one three <b>four</b>}}
|
||||
do_test fts3ao-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 fts3 table fails inside a transaction.
|
||||
#
|
||||
do_test fts3ao-2.8 {
|
||||
execsql {
|
||||
BEGIN;
|
||||
INSERT INTO fts_t1(a, b, c) VALUES('one two three', 'one four', 'one two');
|
||||
}
|
||||
} {}
|
||||
do_test fts3ao-2.9 {
|
||||
catchsql {
|
||||
ALTER TABLE fts_t1 RENAME to t1;
|
||||
}
|
||||
} {1 {SQL logic error or missing database}}
|
||||
do_test fts3ao-2.10 {
|
||||
execsql { SELECT rowid, snippet(fts_t1) FROM fts_t1 WHERE a MATCH 'four'; }
|
||||
} {1 {one three <b>four</b>}}
|
||||
do_test fts3ao-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 fts3ao-2.12 {
|
||||
execsql COMMIT
|
||||
execsql {SELECT a FROM fts_t1}
|
||||
} {{one three four} {one two three}}
|
||||
do_test fts3ao-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
|
||||
file delete -force test.db test.db-journal
|
||||
sqlite3 db test.db
|
||||
|
||||
do_test fts3ao-3.1 {
|
||||
execsql {
|
||||
CREATE VIRTUAL TABLE t1 USING fts3(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 fts3ao-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 fts3 table in an attached
|
||||
# database.
|
||||
#
|
||||
file delete -force test2.db test2.db-journal
|
||||
|
||||
do_test fts3ao-3.1 {
|
||||
execsql {
|
||||
ATTACH 'test2.db' AS aux;
|
||||
CREATE VIRTUAL TABLE aux.t1 USING fts3(a, b, c);
|
||||
INSERT INTO aux.t1(a, b, c) VALUES(
|
||||
'neung song sahm', 'neung see', 'neung see song'
|
||||
);
|
||||
}
|
||||
} {}
|
||||
|
||||
do_test fts3ao-3.2 {
|
||||
execsql { SELECT a, b, c FROM aux.t1 WHERE a MATCH 'song'; }
|
||||
} {{neung song sahm} {neung see} {neung see song}}
|
||||
|
||||
do_test fts3ao-3.3 {
|
||||
execsql { SELECT a, b, c FROM t1 WHERE c MATCH 'two'; }
|
||||
} {{one three four} {one four} {one two}}
|
||||
|
||||
do_test fts3ao-3.4 {
|
||||
execsql { ALTER TABLE aux.t1 RENAME TO t2 }
|
||||
} {}
|
||||
|
||||
do_test fts3ao-3.2 {
|
||||
execsql { SELECT a, b, c FROM t2 WHERE a MATCH 'song'; }
|
||||
} {{neung song sahm} {neung see} {neung see song}}
|
||||
|
||||
do_test fts3ao-3.3 {
|
||||
execsql { SELECT a, b, c FROM t1 WHERE c MATCH 'two'; }
|
||||
} {{one three four} {one four} {one two}}
|
||||
|
||||
finish_test
|
44
test/fts3ap.test
Normal file
44
test/fts3ap.test
Normal file
@ -0,0 +1,44 @@
|
||||
# 2007 August 9
|
||||
#
|
||||
# The author disclaims copyright to this source code.
|
||||
#
|
||||
#*************************************************************************
|
||||
# This file implements regression tests for SQLite library. The
|
||||
# DELETE handling required the current data to not contain nulls.
|
||||
# This verifies that we don't add that assumption back in.
|
||||
#
|
||||
# $Id: fts3ap.test,v 1.1 2007/08/20 17:38:42 shess Exp $
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
|
||||
# If SQLITE_ENABLE_FTS3 is defined, omit this file.
|
||||
ifcapable !fts3 {
|
||||
finish_test
|
||||
return
|
||||
}
|
||||
|
||||
db eval {
|
||||
CREATE VIRTUAL TABLE t1 USING fts3(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);
|
||||
|
||||
INSERT INTO t1(rowid, col_a, col_b) VALUES(5, 'testing', 'testing');
|
||||
INSERT INTO t1(rowid, col_a, col_b) VALUES(6, 'only a', null);
|
||||
INSERT INTO t1(rowid, col_a, col_b) VALUES(7, null, 'only b');
|
||||
INSERT INTO t1(rowid, col_a, col_b) VALUES(8, null, null);
|
||||
}
|
||||
|
||||
do_test fts3an-1.1 {
|
||||
execsql "-- REPLACE INTO t1 (rowid, col_a, col_b) VALUES (1, 'text', 'text')"
|
||||
} {}
|
||||
|
||||
do_test fts3an-1.2 {
|
||||
execsql "-- INSERT OR REPLACE INTO t1 (rowid, col_a, col_b) VALUES (1, 'text', 'text')"
|
||||
} {}
|
||||
|
||||
finish_test
|
174
test/fts3atoken.test
Normal file
174
test/fts3atoken.test
Normal file
@ -0,0 +1,174 @@
|
||||
# 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
|
||||
# FTS3 module.
|
||||
#
|
||||
# $Id: fts3atoken.test,v 1.1 2007/08/20 17:38:42 shess Exp $
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
|
||||
# If SQLITE_ENABLE_FTS3 is defined, omit this file.
|
||||
ifcapable !fts3 {
|
||||
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 fts3token-1.* are the warm-body test for the SQL scalar
|
||||
# function fts3_tokenizer(). The procedure is as follows:
|
||||
#
|
||||
# 1: Verify that there is no such fts3 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 fts3 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 fts3token-1.1 {
|
||||
catchsql {
|
||||
CREATE VIRTUAL TABLE t1 USING fts3(content, tokenize blah);
|
||||
}
|
||||
} {1 {unknown tokenizer: blah}}
|
||||
do_test fts3token-1.2 {
|
||||
execsql {
|
||||
SELECT fts3_tokenizer('blah', fts3_tokenizer('simple')) IS NULL;
|
||||
}
|
||||
} {0}
|
||||
do_test fts3token-1.3 {
|
||||
execsql {
|
||||
SELECT fts3_tokenizer('blah') == fts3_tokenizer('simple');
|
||||
}
|
||||
} {1}
|
||||
do_test fts3token-1.4 {
|
||||
catchsql {
|
||||
CREATE VIRTUAL TABLE t1 USING fts3(content, tokenize blah);
|
||||
}
|
||||
} {0 {}}
|
||||
do_test fts3token-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 fts3token-2.* test error cases in the scalar function based
|
||||
# API for getting and setting tokenizers.
|
||||
#
|
||||
do_test fts3token-2.1 {
|
||||
catchsql {
|
||||
SELECT fts3_tokenizer('nosuchtokenizer');
|
||||
}
|
||||
} {1 {unknown tokenizer: nosuchtokenizer}}
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
# Test cases fts3token-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 fts3token-3.1 {
|
||||
execsql {
|
||||
SELECT fts3_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 fts3token-3.2 {
|
||||
execsql {
|
||||
SELECT fts3_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 fts3token-3.3 {
|
||||
execsql {
|
||||
SELECT fts3_tokenizer_test('icu', 'I don''t see how');
|
||||
}
|
||||
} {{0 i I 1 don't don't 2 see see 3 how how}}
|
||||
}
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
# Test cases fts3token-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 fts3_tokenizer_test('icu', $locale, $input) }]
|
||||
do_test $name {
|
||||
lindex $::out 0
|
||||
} $output
|
||||
}
|
||||
|
||||
do_icu_test fts3token-4.1 en_US {} {}
|
||||
do_icu_test fts3token-4.2 en_US {Test cases fts3} [list \
|
||||
0 test Test 1 cases cases 2 fts3 fts3
|
||||
]
|
||||
|
||||
# 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 fts3token-4.3 th_TH $input $output
|
||||
do_icu_test fts3token-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 fts3token-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 fts3token-4.6 MiddleOfTheOcean $input $output
|
||||
do_icu_test fts3token-4.7 th_TH $input $output
|
||||
do_icu_test fts3token-4.8 en_US $input $output
|
||||
}
|
||||
|
||||
do_test fts3token-internal {
|
||||
execsql { SELECT fts3_tokenizer_internal_test() }
|
||||
} {ok}
|
||||
|
||||
finish_test
|
Loading…
Reference in New Issue
Block a user