Snapshot of upstream SQLite 3.11.0
[sqlcipher.git] / ext / fts5 / test / fts5optimize.test
blob984af8c532326b8a8cd57756a19f5e631e5cd208
1 # 2014 Dec 20
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.
18 ifcapable !fts5 {
19   finish_test
20   return
23 proc rnddoc {nWord} {
24   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}
25   set nVocab [llength $vocab]
26   set ret [list]
27   for {set i 0} {$i < $nWord} {incr i} {
28     lappend ret [lindex $vocab [expr {int(rand() * $nVocab)}]]
29   }
30   return $ret
34 foreach {tn nStep} {
35   1 2
36   2 10
37   3 50
38   4 500
39 } {
40 if {$tn!=4} continue
41   reset_db
42   db func rnddoc rnddoc
43   do_execsql_test 1.$tn.1 {
44     CREATE VIRTUAL TABLE t1 USING fts5(x, y);
45   }
46   do_test 1.$tn.2 {
47     for {set i 0} {$i < $nStep} {incr i} {
48       execsql { INSERT INTO t1 VALUES( rnddoc(5), rnddoc(5) ) }
49     }
50   } {}
52   do_execsql_test 1.$tn.3 {
53     INSERT INTO t1(t1) VALUES('integrity-check');
54   }
56   do_execsql_test 1.$tn.4 {
57     INSERT INTO t1(t1) VALUES('optimize');
58   }
60   do_execsql_test 1.$tn.5 {
61     INSERT INTO t1(t1) VALUES('integrity-check');
62   }
65 finish_test