3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing:
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.
10 #*************************************************************************
11 # This file implements regression tests for SQLite library.
14 set testdir [file dirname $argv0]
15 source $testdir/tester.tcl
16 source $testdir/fts3_common.tcl
17 set ::testprefix fts4merge4
19 ifcapable !fts3||!shared_cache {
24 set ::enable_shared_cache [sqlite3_enable_shared_cache 1]
26 do_execsql_test 1.1 { CREATE VIRTUAL TABLE t1 USING fts4 }
29 for {set i 0} {$i < 2000} {incr i} {
30 execsql {INSERT INTO t1 VALUES('a b c d e f g h i j k l');}
36 for {set i 0} {$i < 2000} {incr i} {
37 execsql {INSERT INTO t1 VALUES('a b c d e f g h i j k l');}
40 INSERT INTO t1(t1) VALUES('merge=8,50');
46 do_execsql_test 2.0 { CREATE VIRTUAL TABLE t1 USING fts4 }
48 for {set i 0} {$i < 2000} {incr i} {
49 execsql {INSERT INTO t1 VALUES('a b c d e f g h i j k l');}
52 do_execsql_test 2.2 { SELECT count(*) FROM t1_segdir; } 35
53 do_execsql_test 2.3 { INSERT INTO t1(t1) VALUES('optimize') } {}
54 do_execsql_test 2.4 { SELECT count(*) FROM t1_segdir; } 1
56 #-------------------------------------------------------------------------
57 # Now test that the automerge=? option appears to work.
59 do_execsql_test 2.1 { CREATE VIRTUAL TABLE t2 USING fts4; }
62 foreach c1 "a b c d e f g h i j" {
63 foreach c2 "a b c d e f g h i j" {
64 foreach c3 "a b c d e f g h i j" {
65 lappend doc "$c1$c2$c3"
69 set doc [string repeat $doc 10]
71 foreach {tn am expected} {
72 1 {automerge=2} {1 1 2 1 4 1 6 1}
73 2 {automerge=4} {1 2 2 1 3 1}
74 3 {automerge=8} {0 4 1 3 2 1}
75 4 {automerge=1} {0 4 1 3 2 1}
77 foreach {tn2 openclose} {1 {} 2 { db close ; sqlite3 db test.db }} {
78 do_test 2.2.$tn.$tn2 {
79 execsql { DELETE FROM t2 }
80 execsql { INSERT INTO t2(t2) VALUES($am) };
84 for {set i 0} {$i < 100} {incr i} {
87 INSERT INTO t2 VALUES($doc);
88 INSERT INTO t2 VALUES($doc);
89 INSERT INTO t2 VALUES($doc);
90 INSERT INTO t2 VALUES($doc);
91 INSERT INTO t2 VALUES($doc);
96 execsql { SELECT level, count(*) FROM t2_segdir GROUP BY level }
101 sqlite3_enable_shared_cache $::enable_shared_cache