diff options
author | dan <dan@noemail.net> | 2013-09-30 18:14:45 +0000 |
---|---|---|
committer | dan <dan@noemail.net> | 2013-09-30 18:14:45 +0000 |
commit | 1f03e609ff2e02493bfa274872837d47e47ee4a8 (patch) | |
tree | 5c531ddfc0bd32ab45b5defc526f99b452d0e82d /test/fts3snippet.test | |
parent | 92054fefcd5a6a97043ac4525d76a0ed10631ad4 (diff) | |
download | sqlite-1f03e609ff2e02493bfa274872837d47e47ee4a8.tar.gz sqlite-1f03e609ff2e02493bfa274872837d47e47ee4a8.zip |
Fix a performance problem in the FTS4 auxiliary functions triggered by an OR clause in the full-text query.
FossilOrigin-Name: fa0f2f0e3e79ae653118b901e1cca7725dfaf249
Diffstat (limited to 'test/fts3snippet.test')
-rw-r--r-- | test/fts3snippet.test | 63 |
1 files changed, 62 insertions, 1 deletions
diff --git a/test/fts3snippet.test b/test/fts3snippet.test index f19db925b..415251dcc 100644 --- a/test/fts3snippet.test +++ b/test/fts3snippet.test @@ -16,6 +16,7 @@ set testdir [file dirname $argv0] source $testdir/tester.tcl +set testprefix fts3snippet # If SQLITE_ENABLE_FTS3 is not defined, omit this file. ifcapable !fts3 { finish_test ; return } @@ -138,7 +139,7 @@ foreach {DO_MALLOC_TEST enc} { # Set variable $T to the test name prefix for this iteration of the loop. # - set T "fts3snippet-$enc" + set T "fts3snippet-1.$enc" ########################################################################## # Test the offset function. @@ -459,5 +460,65 @@ foreach {DO_MALLOC_TEST enc} { } {0 blob} } +#------------------------------------------------------------------------- +# Test an interaction between the snippet() function and OR clauses. +# +do_execsql_test 2.1 { + CREATE VIRTUAL TABLE t2 USING fts4; + INSERT INTO t2 VALUES('one two three four five'); + INSERT INTO t2 VALUES('two three four five one'); + INSERT INTO t2 VALUES('three four five one two'); + INSERT INTO t2 VALUES('four five one two three'); + INSERT INTO t2 VALUES('five one two three four'); +} + +do_execsql_test 2.2 { + SELECT snippet(t2, '[', ']') FROM t2 WHERE t2 MATCH 'one OR (four AND six)' +} { + {[one] two three [four] five} + {two three [four] five [one]} + {three [four] five [one] two} + {[four] five [one] two three} + {five [one] two three [four]} +} + +do_execsql_test 2.3 { + SELECT snippet(t2, '[', ']') FROM t2 + WHERE t2 MATCH 'one OR (four AND six)' + ORDER BY docid DESC +} { + {five [one] two three [four]} + {[four] five [one] two three} + {three [four] five [one] two} + {two three [four] five [one]} + {[one] two three [four] five} +} + +do_execsql_test 2.4 { + INSERT INTO t2 VALUES('six'); +} + +do_execsql_test 2.5 { + SELECT snippet(t2, '[', ']') FROM t2 WHERE t2 MATCH 'one OR (four AND six)' +} { + {[one] two three [four] five} + {two three [four] five [one]} + {three [four] five [one] two} + {[four] five [one] two three} + {five [one] two three [four]} +} + +do_execsql_test 2.6 { + SELECT snippet(t2, '[', ']') FROM t2 + WHERE t2 MATCH 'one OR (four AND six)' + ORDER BY docid DESC +} { + {five [one] two three [four]} + {[four] five [one] two three} + {three [four] five [one] two} + {two three [four] five [one]} + {[one] two three [four] five} +} + set sqlite_fts3_enable_parentheses 0 finish_test |