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