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 #***********************************************************************
14 source [file join [file dirname [info script]] fts5_common.tcl]
15 set testprefix fts5optimize
17 # If SQLITE_ENABLE_FTS5 is defined, omit this file.
24 # 1.* - Warm body tests for index optimization using ('optimize')
26 # 2.* - Warm body tests for index optimization using ('merge', -1)
30 set vocab {a b c d e f g h i j k l m n o p q r s t u v w x y z}
31 set nVocab [llength $vocab]
33 for {set i 0} {$i < $nWord} {incr i} {
34 lappend ret [lindex $vocab [expr {int(rand() * $nVocab)}]]
47 do_execsql_test 1.$tn.1 {
48 CREATE VIRTUAL TABLE t1 USING fts5(x, y);
51 for {set i 0} {$i < $nStep} {incr i} {
52 execsql { INSERT INTO t1 VALUES( rnddoc(5), rnddoc(5) ) }
56 do_execsql_test 1.$tn.3 {
57 INSERT INTO t1(t1) VALUES('integrity-check');
60 do_execsql_test 1.$tn.4 {
61 INSERT INTO t1(t1) VALUES('optimize');
64 do_execsql_test 1.$tn.5 {
65 INSERT INTO t1(t1) VALUES('integrity-check');
68 do_test 1.$tn.6 { fts5_segcount t1 } 1
79 do_execsql_test 1.$tn.1 {
80 CREATE VIRTUAL TABLE t1 USING fts5(x, y);
83 for {set i 0} {$i < $nStep} {incr i} {
84 execsql { INSERT INTO t1 VALUES( rnddoc(5), rnddoc(5) ) }
88 do_execsql_test 2.$tn.3 {
89 INSERT INTO t1(t1) VALUES('integrity-check');
93 execsql { INSERT INTO t1(t1, rank) VALUES('merge', -1) }
95 set c [db total_changes]
96 execsql { INSERT INTO t1(t1, rank) VALUES('merge', 1) }
97 set c [expr [db total_changes]-$c]
102 do_execsql_test 2.$tn.5 {
103 INSERT INTO t1(t1) VALUES('integrity-check');
106 do_test 2.$tn.6 { fts5_segcount t1 } 1