sl@0
|
1 |
# 2006 October 19
|
sl@0
|
2 |
#
|
sl@0
|
3 |
# The author disclaims copyright to this source code.
|
sl@0
|
4 |
#
|
sl@0
|
5 |
#*************************************************************************
|
sl@0
|
6 |
# This file implements regression tests for SQLite library. The focus
|
sl@0
|
7 |
# of this script is testing handling of edge cases for various doclist
|
sl@0
|
8 |
# merging functions in the FTS2 module query logic.
|
sl@0
|
9 |
#
|
sl@0
|
10 |
# $Id: fts2g.test,v 1.3 2007/11/16 00:23:08 shess Exp $
|
sl@0
|
11 |
#
|
sl@0
|
12 |
|
sl@0
|
13 |
set testdir [file dirname $argv0]
|
sl@0
|
14 |
source $testdir/tester.tcl
|
sl@0
|
15 |
|
sl@0
|
16 |
# If SQLITE_ENABLE_FTS2 is defined, omit this file.
|
sl@0
|
17 |
ifcapable !fts2 {
|
sl@0
|
18 |
finish_test
|
sl@0
|
19 |
return
|
sl@0
|
20 |
}
|
sl@0
|
21 |
|
sl@0
|
22 |
db eval {
|
sl@0
|
23 |
CREATE VIRTUAL TABLE t1 USING fts2(content);
|
sl@0
|
24 |
INSERT INTO t1 (rowid, content) VALUES(1, 'this is a test');
|
sl@0
|
25 |
INSERT INTO t1 (rowid, content) VALUES(2, 'also a test');
|
sl@0
|
26 |
}
|
sl@0
|
27 |
|
sl@0
|
28 |
# No hits at all. Returns empty doclists from termSelect().
|
sl@0
|
29 |
do_test fts2g-1.1 {
|
sl@0
|
30 |
execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'something'}
|
sl@0
|
31 |
} {}
|
sl@0
|
32 |
|
sl@0
|
33 |
# Empty left in docListExceptMerge().
|
sl@0
|
34 |
do_test fts2g-1.2 {
|
sl@0
|
35 |
execsql {SELECT rowid FROM t1 WHERE t1 MATCH '-this something'}
|
sl@0
|
36 |
} {}
|
sl@0
|
37 |
|
sl@0
|
38 |
# Empty right in docListExceptMerge().
|
sl@0
|
39 |
do_test fts2g-1.3 {
|
sl@0
|
40 |
execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'this -something'}
|
sl@0
|
41 |
} {1}
|
sl@0
|
42 |
|
sl@0
|
43 |
# Empty left in docListPhraseMerge().
|
sl@0
|
44 |
do_test fts2g-1.4 {
|
sl@0
|
45 |
execsql {SELECT rowid FROM t1 WHERE t1 MATCH '"this something"'}
|
sl@0
|
46 |
} {}
|
sl@0
|
47 |
|
sl@0
|
48 |
# Empty right in docListPhraseMerge().
|
sl@0
|
49 |
do_test fts2g-1.5 {
|
sl@0
|
50 |
execsql {SELECT rowid FROM t1 WHERE t1 MATCH '"something is"'}
|
sl@0
|
51 |
} {}
|
sl@0
|
52 |
|
sl@0
|
53 |
# Empty left in docListOrMerge().
|
sl@0
|
54 |
do_test fts2g-1.6 {
|
sl@0
|
55 |
execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'something OR this'}
|
sl@0
|
56 |
} {1}
|
sl@0
|
57 |
|
sl@0
|
58 |
# Empty right in docListOrMerge().
|
sl@0
|
59 |
do_test fts2g-1.7 {
|
sl@0
|
60 |
execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'this OR something'}
|
sl@0
|
61 |
} {1}
|
sl@0
|
62 |
|
sl@0
|
63 |
# Empty left in docListAndMerge().
|
sl@0
|
64 |
do_test fts2g-1.8 {
|
sl@0
|
65 |
execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'something this'}
|
sl@0
|
66 |
} {}
|
sl@0
|
67 |
|
sl@0
|
68 |
# Empty right in docListAndMerge().
|
sl@0
|
69 |
do_test fts2g-1.9 {
|
sl@0
|
70 |
execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'this something'}
|
sl@0
|
71 |
} {}
|
sl@0
|
72 |
|
sl@0
|
73 |
# No support for all-except queries.
|
sl@0
|
74 |
do_test fts2g-1.10 {
|
sl@0
|
75 |
catchsql {SELECT rowid FROM t1 WHERE t1 MATCH '-this -something'}
|
sl@0
|
76 |
} {1 {SQL logic error or missing database}}
|
sl@0
|
77 |
|
sl@0
|
78 |
# Test that docListOrMerge() correctly handles reaching the end of one
|
sl@0
|
79 |
# doclist before it reaches the end of the other.
|
sl@0
|
80 |
do_test fts2g-1.11 {
|
sl@0
|
81 |
execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'this OR also'}
|
sl@0
|
82 |
} {1 2}
|
sl@0
|
83 |
do_test fts2g-1.12 {
|
sl@0
|
84 |
execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'also OR this'}
|
sl@0
|
85 |
} {1 2}
|
sl@0
|
86 |
|
sl@0
|
87 |
# Empty left and right in docListOrMerge(). Each term matches neither
|
sl@0
|
88 |
# row, and when combined there was an assertion failure.
|
sl@0
|
89 |
do_test fts2g-1.13 {
|
sl@0
|
90 |
execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'something OR nothing'}
|
sl@0
|
91 |
} {}
|
sl@0
|
92 |
|
sl@0
|
93 |
finish_test
|