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