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
|
sl@0
|
7 |
# focus of this script is testing deletions in the FTS2 module.
|
sl@0
|
8 |
#
|
sl@0
|
9 |
# $Id: fts2e.test,v 1.1 2006/10/19 23:36:26 shess Exp $
|
sl@0
|
10 |
#
|
sl@0
|
11 |
|
sl@0
|
12 |
set testdir [file dirname $argv0]
|
sl@0
|
13 |
source $testdir/tester.tcl
|
sl@0
|
14 |
|
sl@0
|
15 |
# If SQLITE_ENABLE_FTS2 is defined, omit this file.
|
sl@0
|
16 |
ifcapable !fts2 {
|
sl@0
|
17 |
finish_test
|
sl@0
|
18 |
return
|
sl@0
|
19 |
}
|
sl@0
|
20 |
|
sl@0
|
21 |
# Construct a full-text search table containing keywords which are the
|
sl@0
|
22 |
# ordinal numbers of the bit positions set for a sequence of integers,
|
sl@0
|
23 |
# which are used for the rowid. There are a total of 30 INSERT and
|
sl@0
|
24 |
# DELETE statements, so that we'll test both the segmentMerge() merge
|
sl@0
|
25 |
# (over the first 16) and the termSelect() merge (over the level-1
|
sl@0
|
26 |
# segment and 14 level-0 segments).
|
sl@0
|
27 |
db eval {
|
sl@0
|
28 |
CREATE VIRTUAL TABLE t1 USING fts2(content);
|
sl@0
|
29 |
INSERT INTO t1 (rowid, content) VALUES(1, 'one');
|
sl@0
|
30 |
INSERT INTO t1 (rowid, content) VALUES(2, 'two');
|
sl@0
|
31 |
INSERT INTO t1 (rowid, content) VALUES(3, 'one two');
|
sl@0
|
32 |
INSERT INTO t1 (rowid, content) VALUES(4, 'three');
|
sl@0
|
33 |
DELETE FROM t1 WHERE rowid = 1;
|
sl@0
|
34 |
INSERT INTO t1 (rowid, content) VALUES(5, 'one three');
|
sl@0
|
35 |
INSERT INTO t1 (rowid, content) VALUES(6, 'two three');
|
sl@0
|
36 |
INSERT INTO t1 (rowid, content) VALUES(7, 'one two three');
|
sl@0
|
37 |
DELETE FROM t1 WHERE rowid = 4;
|
sl@0
|
38 |
INSERT INTO t1 (rowid, content) VALUES(8, 'four');
|
sl@0
|
39 |
INSERT INTO t1 (rowid, content) VALUES(9, 'one four');
|
sl@0
|
40 |
INSERT INTO t1 (rowid, content) VALUES(10, 'two four');
|
sl@0
|
41 |
DELETE FROM t1 WHERE rowid = 7;
|
sl@0
|
42 |
INSERT INTO t1 (rowid, content) VALUES(11, 'one two four');
|
sl@0
|
43 |
INSERT INTO t1 (rowid, content) VALUES(12, 'three four');
|
sl@0
|
44 |
INSERT INTO t1 (rowid, content) VALUES(13, 'one three four');
|
sl@0
|
45 |
DELETE FROM t1 WHERE rowid = 10;
|
sl@0
|
46 |
INSERT INTO t1 (rowid, content) VALUES(14, 'two three four');
|
sl@0
|
47 |
INSERT INTO t1 (rowid, content) VALUES(15, 'one two three four');
|
sl@0
|
48 |
INSERT INTO t1 (rowid, content) VALUES(16, 'five');
|
sl@0
|
49 |
DELETE FROM t1 WHERE rowid = 13;
|
sl@0
|
50 |
INSERT INTO t1 (rowid, content) VALUES(17, 'one five');
|
sl@0
|
51 |
INSERT INTO t1 (rowid, content) VALUES(18, 'two five');
|
sl@0
|
52 |
INSERT INTO t1 (rowid, content) VALUES(19, 'one two five');
|
sl@0
|
53 |
DELETE FROM t1 WHERE rowid = 16;
|
sl@0
|
54 |
INSERT INTO t1 (rowid, content) VALUES(20, 'three five');
|
sl@0
|
55 |
INSERT INTO t1 (rowid, content) VALUES(21, 'one three five');
|
sl@0
|
56 |
INSERT INTO t1 (rowid, content) VALUES(22, 'two three five');
|
sl@0
|
57 |
DELETE FROM t1 WHERE rowid = 19;
|
sl@0
|
58 |
DELETE FROM t1 WHERE rowid = 22;
|
sl@0
|
59 |
}
|
sl@0
|
60 |
|
sl@0
|
61 |
do_test fts2f-1.1 {
|
sl@0
|
62 |
execsql {SELECT COUNT(*) FROM t1}
|
sl@0
|
63 |
} {14}
|
sl@0
|
64 |
|
sl@0
|
65 |
do_test fts2e-2.1 {
|
sl@0
|
66 |
execsql {SELECT rowid FROM t1 WHERE content MATCH 'one'}
|
sl@0
|
67 |
} {3 5 9 11 15 17 21}
|
sl@0
|
68 |
|
sl@0
|
69 |
do_test fts2e-2.2 {
|
sl@0
|
70 |
execsql {SELECT rowid FROM t1 WHERE content MATCH 'two'}
|
sl@0
|
71 |
} {2 3 6 11 14 15 18}
|
sl@0
|
72 |
|
sl@0
|
73 |
do_test fts2e-2.3 {
|
sl@0
|
74 |
execsql {SELECT rowid FROM t1 WHERE content MATCH 'three'}
|
sl@0
|
75 |
} {5 6 12 14 15 20 21}
|
sl@0
|
76 |
|
sl@0
|
77 |
do_test fts2e-2.4 {
|
sl@0
|
78 |
execsql {SELECT rowid FROM t1 WHERE content MATCH 'four'}
|
sl@0
|
79 |
} {8 9 11 12 14 15}
|
sl@0
|
80 |
|
sl@0
|
81 |
do_test fts2e-2.5 {
|
sl@0
|
82 |
execsql {SELECT rowid FROM t1 WHERE content MATCH 'five'}
|
sl@0
|
83 |
} {17 18 20 21}
|
sl@0
|
84 |
|
sl@0
|
85 |
finish_test
|