| 1 |
# 2014 Dec 20 |
| 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 |
# |
| 12 |
# Test that focus on incremental merges of segments. |
| 13 |
# |
| 14 |
|
| 15 |
source [file join [file dirname [info script]] fts5_common.tcl] |
| 16 |
set testprefix fts5merge2 |
| 17 |
return_if_no_fts5 |
| 18 |
|
| 19 |
proc dump_structure {} { |
| 20 |
db eval {SELECT fts5_decode(id, block) AS t FROM t1_data WHERE id=10} { |
| 21 |
foreach lvl [lrange $t 1 end] { |
| 22 |
set seg [string repeat . [expr [llength $lvl]-2]] |
| 23 |
puts "[lrange $lvl 0 1] $seg" |
| 24 |
} |
| 25 |
} |
| 26 |
} |
| 27 |
|
| 28 |
foreach_detail_mode $testprefix { |
| 29 |
|
| 30 |
do_execsql_test 1.0 { |
| 31 |
CREATE VIRTUAL TABLE t1 USING fts5(x, detail=%DETAIL%); |
| 32 |
INSERT INTO t1(t1, rank) VALUES('pgsz', 32); |
| 33 |
INSERT INTO t1(t1, rank) VALUES('crisismerge', 2); |
| 34 |
INSERT INTO t1 VALUES('1 2 3 4'); |
| 35 |
} |
| 36 |
|
| 37 |
expr srand(0) |
| 38 |
db func rnddoc fts5_rnddoc |
| 39 |
do_test 1.1 { |
| 40 |
for {set i 0} {$i < 100} {incr i} { |
| 41 |
execsql { |
| 42 |
BEGIN; |
| 43 |
DELETE FROM t1 WHERE rowid = 1; |
| 44 |
INSERT INTO t1(rowid, x) VALUES(1, '1 2 3 4'); |
| 45 |
INSERT INTO t1 VALUES(rnddoc(10)); |
| 46 |
COMMIT; |
| 47 |
} |
| 48 |
} |
| 49 |
} {} |
| 50 |
|
| 51 |
do_execsql_test 1.2 { |
| 52 |
INSERT INTO t1(t1) VALUES('integrity-check'); |
| 53 |
} |
| 54 |
|
| 55 |
} |
| 56 |
|
| 57 |
finish_test |