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 updates in the FTS2 module.
|
sl@0
|
8 |
#
|
sl@0
|
9 |
# $Id: fts2f.test,v 1.2 2007/02/23 00:14:06 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 31 INSERT,
|
sl@0
|
24 |
# UPDATE, and DELETE statements, so that we'll test both the
|
sl@0
|
25 |
# segmentMerge() merge (over the first 16) and the termSelect() merge
|
sl@0
|
26 |
# (over the level-1 segment and 15 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 |
INSERT INTO t1 (rowid, content) VALUES(5, 'one three');
|
sl@0
|
34 |
INSERT INTO t1 (rowid, content) VALUES(6, 'two three');
|
sl@0
|
35 |
INSERT INTO t1 (rowid, content) VALUES(7, 'one two three');
|
sl@0
|
36 |
DELETE FROM t1 WHERE rowid = 4;
|
sl@0
|
37 |
INSERT INTO t1 (rowid, content) VALUES(8, 'four');
|
sl@0
|
38 |
UPDATE t1 SET content = 'update one three' WHERE rowid = 1;
|
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 |
UPDATE t1 SET content = 'update two five' WHERE rowid = 8;
|
sl@0
|
49 |
INSERT INTO t1 (rowid, content) VALUES(16, 'five');
|
sl@0
|
50 |
DELETE FROM t1 WHERE rowid = 13;
|
sl@0
|
51 |
INSERT INTO t1 (rowid, content) VALUES(17, 'one five');
|
sl@0
|
52 |
INSERT INTO t1 (rowid, content) VALUES(18, 'two five');
|
sl@0
|
53 |
INSERT INTO t1 (rowid, content) VALUES(19, 'one two five');
|
sl@0
|
54 |
DELETE FROM t1 WHERE rowid = 16;
|
sl@0
|
55 |
INSERT INTO t1 (rowid, content) VALUES(20, 'three five');
|
sl@0
|
56 |
INSERT INTO t1 (rowid, content) VALUES(21, 'one three five');
|
sl@0
|
57 |
INSERT INTO t1 (rowid, content) VALUES(22, 'two three five');
|
sl@0
|
58 |
DELETE FROM t1 WHERE rowid = 19;
|
sl@0
|
59 |
UPDATE t1 SET content = 'update' WHERE rowid = 15;
|
sl@0
|
60 |
}
|
sl@0
|
61 |
|
sl@0
|
62 |
do_test fts2f-1.1 {
|
sl@0
|
63 |
execsql {SELECT COUNT(*) FROM t1}
|
sl@0
|
64 |
} {16}
|
sl@0
|
65 |
|
sl@0
|
66 |
do_test fts2f-2.0 {
|
sl@0
|
67 |
execsql {SELECT rowid FROM t1 WHERE content MATCH 'update'}
|
sl@0
|
68 |
} {1 8 15}
|
sl@0
|
69 |
|
sl@0
|
70 |
do_test fts2f-2.1 {
|
sl@0
|
71 |
execsql {SELECT rowid FROM t1 WHERE content MATCH 'one'}
|
sl@0
|
72 |
} {1 3 5 9 11 17 21}
|
sl@0
|
73 |
|
sl@0
|
74 |
do_test fts2f-2.2 {
|
sl@0
|
75 |
execsql {SELECT rowid FROM t1 WHERE content MATCH 'two'}
|
sl@0
|
76 |
} {2 3 6 8 11 14 18 22}
|
sl@0
|
77 |
|
sl@0
|
78 |
do_test fts2f-2.3 {
|
sl@0
|
79 |
execsql {SELECT rowid FROM t1 WHERE content MATCH 'three'}
|
sl@0
|
80 |
} {1 5 6 12 14 20 21 22}
|
sl@0
|
81 |
|
sl@0
|
82 |
do_test fts2f-2.4 {
|
sl@0
|
83 |
execsql {SELECT rowid FROM t1 WHERE content MATCH 'four'}
|
sl@0
|
84 |
} {9 11 12 14}
|
sl@0
|
85 |
|
sl@0
|
86 |
do_test fts2f-2.5 {
|
sl@0
|
87 |
execsql {SELECT rowid FROM t1 WHERE content MATCH 'five'}
|
sl@0
|
88 |
} {8 17 18 20 21 22}
|
sl@0
|
89 |
|
sl@0
|
90 |
finish_test
|