| 1 |
# 2014 May 12 |
| 2 |
# |
| 3 |
# The author disclaims copyright to this source code. In place of |
| 4 |
# a legal notice, here is a blessing: |
| 5 |
# |
| 6 |
# May you do good and not evil. |
| 7 |
# May you find forgiveness for yourself and forgive others. |
| 8 |
# May you share freely, never taking more than you give. |
| 9 |
# |
| 10 |
#************************************************************************* |
| 11 |
# This file implements regression tests for SQLite library. The |
| 12 |
# focus of this script is testing the FTS4 module. |
| 13 |
# |
| 14 |
# |
| 15 |
|
| 16 |
set testdir [file dirname $argv0] |
| 17 |
source $testdir/tester.tcl |
| 18 |
set testprefix fts4growth2 |
| 19 |
|
| 20 |
# If SQLITE_ENABLE_FTS3 is defined, omit this file. |
| 21 |
ifcapable !fts3 { |
| 22 |
finish_test |
| 23 |
return |
| 24 |
} |
| 25 |
|
| 26 |
source $testdir/genesis.tcl |
| 27 |
|
| 28 |
do_execsql_test 1.0 { CREATE TABLE t1(docid, words); } |
| 29 |
fts_kjv_genesis |
| 30 |
|
| 31 |
proc structure {} { |
| 32 |
puts [ db eval {SELECT level, count(*) FROM x1_segdir GROUP BY level} ] |
| 33 |
} |
| 34 |
|
| 35 |
proc tt {val} { |
| 36 |
execsql { |
| 37 |
DELETE FROM x1 |
| 38 |
WHERE docid IN (SELECT docid FROM t1 WHERE (rowid-1)%4==$val+0); |
| 39 |
} |
| 40 |
execsql { |
| 41 |
INSERT INTO x1(docid, content) |
| 42 |
SELECT docid, words FROM t1 WHERE (rowid%4)==$val+0; |
| 43 |
} |
| 44 |
} |
| 45 |
|
| 46 |
do_execsql_test 1.1 { |
| 47 |
CREATE VIRTUAL TABLE x1 USING fts4; |
| 48 |
INSERT INTO x1(x1) VALUES('automerge=2'); |
| 49 |
} |
| 50 |
|
| 51 |
do_test 1.2 { |
| 52 |
for {set i 0} {$i < 40} {incr i} { |
| 53 |
tt 0 ; tt 1 ; tt 2 ; tt 3 |
| 54 |
} |
| 55 |
execsql { |
| 56 |
SELECT max(level) FROM x1_segdir; |
| 57 |
SELECT count(*) FROM x1_segdir WHERE level=2; |
| 58 |
} |
| 59 |
} {2 1} |
| 60 |
|
| 61 |
do_test 1.3 { |
| 62 |
for {set i 0} {$i < 40} {incr i} { |
| 63 |
tt 0 ; tt 1 ; tt 2 ; tt 3 |
| 64 |
} |
| 65 |
execsql { |
| 66 |
SELECT max(level) FROM x1_segdir; |
| 67 |
SELECT count(*) FROM x1_segdir WHERE level=2; |
| 68 |
} |
| 69 |
} {2 1} |
| 70 |
|
| 71 |
#------------------------------------------------------------------------- |
| 72 |
# |
| 73 |
do_execsql_test 2.1 { |
| 74 |
DELETE FROM t1 WHERE rowid>16; |
| 75 |
DROP TABLE IF EXISTS x1; |
| 76 |
CREATE VIRTUAL TABLE x1 USING fts4; |
| 77 |
} |
| 78 |
|
| 79 |
db func second second |
| 80 |
proc second {L} {lindex $L 1} |
| 81 |
|
| 82 |
for {set tn 0} {$tn < 40} {incr tn} { |
| 83 |
do_test 2.2.$tn { |
| 84 |
for {set i 0} {$i < 100} {incr i} { |
| 85 |
tt 0 ; tt 1 ; tt 2 ; tt 3 |
| 86 |
} |
| 87 |
execsql { SELECT max(level) FROM x1_segdir } |
| 88 |
} {1} |
| 89 |
} |
| 90 |
|
| 91 |
|
| 92 |
finish_test |