}
if( rc==SQLITE_OK ){
- if( ii!=pPhrase->nToken && pCsr->eEvalmode==FTS3_EVAL_FILTER ){
+ if( ii!=pPhrase->nToken ){
assert( pCsr->eEvalmode==FTS3_EVAL_FILTER && isReqPos==0 );
fts3DoclistStripPositions(pOut, &nOut);
}
){
int rc = SQLITE_OK; /* Return code */
- assert( pCsr->eEvalmode!=FTS3_EVAL_MATCHINFO );
- if( pCsr->eEvalmode==FTS3_EVAL_NEXT ) return SQLITE_OK;
+ assert( pCsr->eEvalmode==FTS3_EVAL_FILTER );
if( pnExpr && pExpr->eType!=FTSQUERY_AND ){
(*pnExpr)++;
pnExpr = 0;
|| pExpr->eType==FTSQUERY_AND || pExpr->eType==FTSQUERY_NOT
|| pExpr->eType==FTSQUERY_PHRASE
);
- assert( pExpr->eType==FTSQUERY_PHRASE
- || pExpr->eType==FTSQUERY_NEAR
- || isReqPos==0
- );
+ assert( pExpr->eType==FTSQUERY_PHRASE || isReqPos==0 );
if( pExpr->eType==FTSQUERY_PHRASE ){
rc = fts3PhraseSelect(p, pExpr->pPhrase,
rc = fts3ExprAllocateSegReaders(p, pExpr, &nExpr);
if( rc==SQLITE_OK ){
+ assert( nExpr>1 );
aExpr = sqlite3_malloc(sizeof(ExprAndCost) * nExpr);
if( !aExpr ) rc = SQLITE_NOMEM;
}
if( ii==0 ){
aRet = aNew;
nRet = nNew;
- if( nExpr>1 ){
- nDoc = fts3DoclistCountDocids(0, aRet, nRet);
- }
+ nDoc = fts3DoclistCountDocids(0, aRet, nRet);
}else{
fts3DoclistMerge(
MERGE_AND, 0, 0, aRet, &nRet, aRet, nRet, aNew, nNew, &nDoc
case FTSQUERY_NEAR: {
Fts3Expr *pLeft;
Fts3Expr *pRight;
- int mergetype = isReqPos ? MERGE_POS_NEAR : MERGE_NEAR;
-
+ int mergetype = MERGE_NEAR;
if( pExpr->pParent && pExpr->pParent->eType==FTSQUERY_NEAR ){
mergetype = MERGE_POS_NEAR;
}
if( rc!=SQLITE_OK ) return rc;
pCsr->pNextId = pCsr->aDoclist;
pCsr->iPrevId = 0;
- if( pCsr->nDoclist<0 ){
- assert( pCsr->aDoclist==0 );
- idxNum = FTS3_FULLSCAN_SEARCH;
- }
}
/* Compile a SELECT statement for this cursor. For a full-table-scan, the
sqlite3_context *pContext, /* SQL function call context */
const char *zFunc, /* Function name */
sqlite3_value *pVal, /* argv[0] passed to function */
- Fts3Cursor **ppCsr /* OUT: Store cursor handle here */
+ Fts3Cursor **ppCsr /* OUT: Store cursor handle here */
){
Fts3Cursor *pRet;
if( sqlite3_value_type(pVal)!=SQLITE_BLOB
sqlite3_value **apVal /* Array of arguments */
){
Fts3Cursor *pCsr; /* Cursor handle passed through apVal[0] */
-
- if( nVal!=1 ){
- sqlite3_result_error(pContext,
- "wrong number of arguments to function matchinfo()", -1);
- return;
- }
-
+ assert( nVal==1 );
if( SQLITE_OK==fts3FunctionArg(pContext, "matchinfo", apVal[0], &pCsr) ){
sqlite3Fts3Matchinfo(pContext, pCsr);
}
"ALTER TABLE %Q.'%q_content' RENAME TO '%q_content';",
p->zDb, p->zName, zName
);
- if( rc==SQLITE_ERROR ) rc = SQLITE_OK;
if( p->bHasDocsize ){
fts3DbExec(&rc, db,
"ALTER TABLE %Q.'%q_docsize' RENAME TO '%q_docsize';",
&& SQLITE_OK==(rc = sqlite3Fts3InitHashTable(db, pHash, "fts3_tokenizer"))
&& SQLITE_OK==(rc = sqlite3_overload_function(db, "snippet", -1))
&& SQLITE_OK==(rc = sqlite3_overload_function(db, "offsets", 1))
- && SQLITE_OK==(rc = sqlite3_overload_function(db, "matchinfo", -1))
+ && SQLITE_OK==(rc = sqlite3_overload_function(db, "matchinfo", 1))
&& SQLITE_OK==(rc = sqlite3_overload_function(db, "optimize", 1))
){
rc = sqlite3_create_module_v2(
-C Add\stest\sfor\smatchinfo\swhen\sa\sphrase\sincludes\ssome\scommon\stokens.
-D 2010-10-25T09:01:57
+C Test\scoverage\simprovements\sfor\sfts3.c.
+D 2010-10-25T12:47:43
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in 2c8cefd962eca0147132c7cf9eaa4bb24c656f3f
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
F ext/fts3/README.syntax a19711dc5458c20734b8e485e75fb1981ec2427a
F ext/fts3/README.tokenizers 998756696647400de63d5ba60e9655036cb966e9
F ext/fts3/README.txt 8c18f41574404623b76917b9da66fcb0ab38328d
-F ext/fts3/fts3.c b7442369abecdda3cb58dc0ed482e7d1e852028f
+F ext/fts3/fts3.c 8a3b4144b604e18a6736eb3a5812d07e5bc2cfef
F ext/fts3/fts3.h 3a10a0af180d502cecc50df77b1b22df142817fe
F ext/fts3/fts3Int.h 11fa12ce041bacbc6ac53db127eb0bcc0538af51
F ext/fts3/fts3_expr.c ee48b9278b8b2432a05a03320fbcacba151dbaa5
F test/fts3al.test 07d64326e79bbdbab20ee87fc3328fbf01641c9f
F test/fts3am.test 218aa6ba0dfc50c7c16b2022aac5c6be593d08d8
F test/fts3an.test a49ccadc07a2f7d646ec1b81bc09da2d85a85b18
-F test/fts3ao.test 8fee868a0e131b98ce3e8907dc69936278e8b29a
+F test/fts3ao.test b83f99f70e9eec85f27d75801a974b3f820e01f9
F test/fts3atoken.test 25c2070e1e8755d414bf9c8200427b277a9f99fa
F test/fts3b.test e93bbb653e52afde110ad53bbd793f14fe7a8984
F test/fts3c.test fc723a9cf10b397fdfc2b32e73c53c8b1ec02958
F test/fts3cov.test 54cf1f98c72abee246447cd688590898c9ecbaf7
F test/fts3d.test 95fb3c862cbc4297c93fceb9a635543744e9ef52
-F test/fts3defer.test cf66bf69afcc2fb8373d3aed31c55399409e83f2
+F test/fts3defer.test bfd84a3110bf336c3799607c9708e171979736e5
F test/fts3defer2.test 1a9f213ca79509b60d81460febc7e4e5b64af95c
F test/fts3e.test 1f6c6ac9cc8b772ca256e6b22aaeed50c9350851
F test/fts3expr.test 5e745b2b6348499d9ef8d59015de3182072c564c
F test/fts3expr2.test 18da930352e5693eaa163a3eacf96233b7290d1a
-F test/fts3malloc.test 059592c4f37ccd30138bbf8e3e5b7982cb5c8f2e
+F test/fts3malloc.test 9c8cc3f885bb4dfc66d0460c52f68f45e4710d1b
F test/fts3near.test 2e318ee434d32babd27c167142e2b94ddbab4844
-F test/fts3query.test 2468caf7938dbc3be2e049524320ce4faf2227b3
+F test/fts3query.test 464bc03de219f9601d94e37872fae4a763a0e9a8
F test/fts3rnd.test 707533ce943f490443ce5e696236bb1675a37635
F test/fts3shared.test 8bb266521d7c5495c0ae522bb4d376ad5387d4a2
-F test/fts3snippet.test d0c09e76f66baaa6cd7a5d3a5e0583ede68668a7
+F test/fts3snippet.test a12f22a3ba4dd59751a57c79b031d07ab5f51ddd
F test/fts4aa.test eadf85621c0a113d4c7ad3ccbf8441130e007b8f
F test/func.test 6c5ce11e3a0021ca3c0649234e2d4454c89110ca
F test/func2.test 772d66227e4e6684b86053302e2d74a2500e1e0f
F test/mallocI.test a88c2b9627c8506bf4703d8397420043a786cdb6
F test/mallocJ.test b5d1839da331d96223e5f458856f8ffe1366f62e
F test/mallocK.test d79968641d1b70d88f6c01bdb9a7eb4a55582cc9
-F test/malloc_common.tcl 9dfb33f12173f9a8b029dae0443c569b59b980b6
+F test/malloc_common.tcl 053003b3d925a4dbfd5159819a542266e5c8ed84
F test/manydb.test b3d3bc4c25657e7f68d157f031eb4db7b3df0d3c
F test/memdb.test 0825155b2290e900264daaaf0334b6dfe69ea498
F test/memleak.test 10b9c6c57e19fc68c32941495e9ba1c50123f6e2
F test/pagesize.test 76aa9f23ecb0741a4ed9d2e16c5fa82671f28efb
F test/pcache.test 4118a183908ecaed343a06fcef3ba82e87e0129d
F test/pcache2.test 0d85f2ab6963aee28c671d4c71bec038c00a1d16
-F test/permutations.test e134e3383425bec6ef14438bff8c2c34248bff9e
+F test/permutations.test da40da6433f050b50e65a8ae37265ab6c89f876c
F test/pragma.test fdfc09067ea104a0c247a1a79d8093b56656f850
F test/pragma2.test 5364893491b9231dd170e3459bfc2e2342658b47
F test/printf.test 05970cde31b1a9f54bd75af60597be75a5c54fea
F test/tempdb.test 19d0f66e2e3eeffd68661a11c83ba5e6ace9128c
F test/temptable.test f42121a0d29a62f00f93274464164177ab1cc24a
F test/temptrigger.test b0273db072ce5f37cf19140ceb1f0d524bbe9f05
-F test/tester.tcl 0c6264937643072fdc3cfa893b10e3cc61b27e3b
+F test/tester.tcl b9c732d1228f0daab41bbbeddd6d0861394b23aa
F test/thread001.test a3e6a7254d1cb057836cb3145b60c10bf5b7e60f
F test/thread002.test afd20095e6e845b405df4f2c920cb93301ca69db
F test/thread003.test b824d4f52b870ae39fc5bae4d8070eca73085dca
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
-P deb80eac9112d21835dfd3cee08ed8f09d975bf7
-R a3866e5a9d1a2e794f6f1ae62b6efaeb
+P 80a54ebc41e4224ab93d92cb390524db1c398155
+R 6df91aa7490a2de6b071469ff6d77a7d
U dan
-Z 940f99ae4559dd7b55d33211cd923bc7
+Z 56215669c25140b5bc6688ab1e20262b
-80a54ebc41e4224ab93d92cb390524db1c398155
\ No newline at end of file
+a8b1d99899678b72c2a487909eabed321593d55f
\ No newline at end of file
return
}
+set ::testprefix fts3ao
+
#---------------------------------------------------------------------
# These tests, fts3ao-1.*, test that ticket #2429 is fixed.
#
}
} {{the quick brown fox} {jumped over the} {lazy dog}}
+# Test that it is possible to rename an FTS4 table. Renaming an FTS4 table
+# involves renaming the extra %_docsize and %_stat tables.
+#
+do_execsql_test 5.1 {
+ CREATE VIRTUAL TABLE t7 USING FTS4;
+ INSERT INTO t7 VALUES('coined by a German clinician');
+ SELECT count(*) FROM sqlite_master WHERE name LIKE 't7%';
+ SELECT count(*) FROM sqlite_master WHERE name LIKE 't8%';
+} {6 0}
+do_execsql_test 5.2 {
+ ALTER TABLE t7 RENAME TO t8;
+ SELECT count(*) FROM sqlite_master WHERE name LIKE 't7%';
+ SELECT count(*) FROM sqlite_master WHERE name LIKE 't8%';
+} {0 6}
+
finish_test
{0 1 17 2 0 1 20 2 0 1 26 2 0 0 29 9 0 2 39 8}
}
+ do_select_test 4.3 {
+ SELECT offsets(t1) FROM t1
+ WHERE t1 MATCH 'vgsld (hrlipdm OR (aapmve NEAR duszemmzl))'
+ } {{0 0 0 5 0 1 15 7 0 0 36 5}}
+
# The following block of tests runs normally with FTS3 or FTS4 without the
# long doclists zeroed. And with OOM-injection for FTS4 with long doclists
# zeroed. Change this by messing with the [set dmt_modes] commands above.
} {
{0 0 0 2 0 0 6 2 0 0 9 2 0 1 12 8}
}
+
+ set DO_MALLOC_TEST 0
}
+
+ do_select_test 6.1 {
+ SELECT rowid FROM t1
+ WHERE t1 MATCH 'vgsld (hrlipdm OR (aayxpmve duszemmzl))'
+ } {10}
}
set ret
}
-
do_write_test fts3_malloc-1.1 sqlite_master {
CREATE VIRTUAL TABLE ft1 USING fts3(a, b)
}
source $testdir/fts3_common.tcl
set DO_MALLOC_TEST 0
+set testprefix fts3query
+
do_test fts3query-1.1 {
execsql {
CREATE VIRTUAL TABLE t1 USING fts3(x);
} {0 1 {TABLE t1 WITH INDEX i1 ORDER BY} 1 0 {TABLE bt USING PRIMARY KEY}}
+# Test that calling matchinfo() with the wrong number of arguments, or with
+# an invalid argument returns an error.
+#
+do_execsql_test 5.1 {
+ CREATE VIRTUAL TABLE t2 USING FTS4;
+ INSERT INTO t2 VALUES('it was the first time in history');
+}
+do_select_tests 5.2 -errorformat {
+ wrong number of arguments to function %s()
+} {
+ 1 "SELECT matchinfo() FROM t2 WHERE t2 MATCH 'history'" matchinfo
+ 2 "SELECT matchinfo(t2, t2) FROM t2 WHERE t2 MATCH 'history'" matchinfo
+
+ 3 "SELECT snippet(t2, 1, 2, 3, 4, 5, 6) FROM t2 WHERE t2 MATCH 'history'"
+ snippet
+}
+do_select_tests 5.3 -errorformat {
+ illegal first argument to %s
+} {
+ 1 "SELECT matchinfo(content) FROM t2 WHERE t2 MATCH 'history'" matchinfo
+ 2 "SELECT offsets(content) FROM t2 WHERE t2 MATCH 'history'" offsets
+ 3 "SELECT snippet(content) FROM t2 WHERE t2 MATCH 'history'" snippet
+ 4 "SELECT optimize(content) FROM t2 WHERE t2 MATCH 'history'" optimize
+}
+do_execsql_test 5.4.0 { UPDATE t2_content SET c0content = X'1234' }
+do_select_tests 5.4 -errorformat {
+ illegal first argument to %s
+} {
+ 1 "SELECT matchinfo(content) FROM t2 WHERE t2 MATCH 'history'" matchinfo
+ 2 "SELECT offsets(content) FROM t2 WHERE t2 MATCH 'history'" offsets
+ 3 "SELECT snippet(content) FROM t2 WHERE t2 MATCH 'history'" snippet
+ 4 "SELECT optimize(content) FROM t2 WHERE t2 MATCH 'history'" optimize
+}
+do_execsql_test 5.5 { DROP TABLE t2 }
+
+# Test the snippet() function with 1 to 6 arguments.
+#
+do_execsql_test 6.1 {
+ CREATE VIRTUAL TABLE t3 USING FTS4(a, b);
+ INSERT INTO t3 VALUES('no gestures', 'another intriguing discovery by observing the hand gestures (called beats) people make while speaking. Research has shown that such gestures do more than add visual emphasis to our words (many people gesture while they''re on the telephone, for example); it seems they actually help our brains find words');
+}
+
+do_select_tests 6.2 {
+ 1 "SELECT snippet(t3) FROM t3 WHERE t3 MATCH 'gestures'"
+ {{<b>...</b>hand <b>gestures</b> (called beats) people make while speaking. Research has shown that such <b>gestures</b> do<b>...</b>}}
+
+ 2 "SELECT snippet(t3, 'XXX') FROM t3 WHERE t3 MATCH 'gestures'"
+ {{<b>...</b>hand XXXgestures</b> (called beats) people make while speaking. Research has shown that such XXXgestures</b> do<b>...</b>}}
+
+ 3 "SELECT snippet(t3, 'XXX', 'YYY') FROM t3 WHERE t3 MATCH 'gestures'"
+ {{<b>...</b>hand XXXgesturesYYY (called beats) people make while speaking. Research has shown that such XXXgesturesYYY do<b>...</b>}}
+
+ 4 "SELECT snippet(t3, 'XXX', 'YYY', 'ZZZ') FROM t3 WHERE t3 MATCH 'gestures'"
+ {{ZZZhand XXXgesturesYYY (called beats) people make while speaking. Research has shown that such XXXgesturesYYY doZZZ}}
+
+ 5 "SELECT snippet(t3, 'XXX', 'YYY', 'ZZZ', 1) FROM t3 WHERE t3 MATCH 'gestures'"
+ {{ZZZhand XXXgesturesYYY (called beats) people make while speaking. Research has shown that such XXXgesturesYYY doZZZ}}
+
+ 6 "SELECT snippet(t3, 'XXX', 'YYY', 'ZZZ', 0) FROM t3 WHERE t3 MATCH 'gestures'"
+ {{no XXXgesturesYYY}}
+
+ 7 "SELECT snippet(t3, 'XXX', 'YYY', 'ZZZ', 1, 5) FROM t3 WHERE t3 MATCH 'gestures'"
+ {{ZZZthe hand XXXgesturesYYY (called beatsZZZ}}
+}
+
finish_test
# If SQLITE_ENABLE_FTS3 is not defined, omit this file.
ifcapable !fts3 { finish_test ; return }
source $testdir/fts3_common.tcl
-source $testdir/malloc_common.tcl
set sqlite_fts3_enable_parentheses 1
set DO_MALLOC_TEST 0
} {0 blob}
}
-
set sqlite_fts3_enable_parentheses 0
finish_test
set DEFAULT(-body) ""
set DEFAULT(-test) ""
+ fix_testname name
+
array set O [array get DEFAULT]
array set O $args
foreach o [array names O] {
}
test_suite "fts3" -prefix "" -description {
- All FTS3 tests except fts3malloc.test and fts3rnd.test.
+ All FTS3 tests except fts3rnd.test.
} -files {
fts3aa.test fts3ab.test fts3ac.test fts3ad.test fts3ae.test
fts3af.test fts3ag.test fts3ah.test fts3ai.test fts3aj.test
fts3ak.test fts3al.test fts3am.test fts3an.test fts3ao.test
fts3atoken.test fts3b.test fts3c.test fts3cov.test fts3d.test
- fts3e.test fts3expr.test fts3expr2.test fts3near.test
- fts3query.test fts3snippet.test fts3defer.test fts3defer2.test
+ fts3defer.test fts3defer2.test fts3e.test fts3expr.test fts3expr2.test
+ fts3near.test fts3query.test fts3shared.test fts3snippet.test
+
+ fts3fault.test fts3malloc.test
}
set AUTOVACUUM $sqlite_options(default_autovacuum)
source $testdir/thread_common.tcl
+source $testdir/malloc_common.tcl