Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(89)

Side by Side Diff: third_party/sqlite/src/ext/fts5/test/fts5optimize.test

Issue 2751253002: [sql] Import SQLite 3.17.0. (Closed)
Patch Set: also clang on Linux i386 Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # 2014 Dec 20 1 # 2014 Dec 20
2 # 2 #
3 # The author disclaims copyright to this source code. In place of 3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing: 4 # a legal notice, here is a blessing:
5 # 5 #
6 # May you do good and not evil. 6 # May you do good and not evil.
7 # May you find forgiveness for yourself and forgive others. 7 # May you find forgiveness for yourself and forgive others.
8 # May you share freely, never taking more than you give. 8 # May you share freely, never taking more than you give.
9 # 9 #
10 #*********************************************************************** 10 #***********************************************************************
11 # 11 #
12 # 12 #
13 13
14 source [file join [file dirname [info script]] fts5_common.tcl] 14 source [file join [file dirname [info script]] fts5_common.tcl]
15 set testprefix fts5optimize 15 set testprefix fts5optimize
16 16
17 # If SQLITE_ENABLE_FTS5 is defined, omit this file. 17 # If SQLITE_ENABLE_FTS5 is defined, omit this file.
18 ifcapable !fts5 { 18 ifcapable !fts5 {
19 finish_test 19 finish_test
20 return 20 return
21 } 21 }
22 22
23 #
24 # 1.* - Warm body tests for index optimization using ('optimize')
25 #
26 # 2.* - Warm body tests for index optimization using ('merge', -1)
27 #
28
23 proc rnddoc {nWord} { 29 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} 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}
25 set nVocab [llength $vocab] 31 set nVocab [llength $vocab]
26 set ret [list] 32 set ret [list]
27 for {set i 0} {$i < $nWord} {incr i} { 33 for {set i 0} {$i < $nWord} {incr i} {
28 lappend ret [lindex $vocab [expr {int(rand() * $nVocab)}]] 34 lappend ret [lindex $vocab [expr {int(rand() * $nVocab)}]]
29 } 35 }
30 return $ret 36 return $ret
31 } 37 }
32 38
33
34 foreach {tn nStep} { 39 foreach {tn nStep} {
35 1 2 40 1 2
36 2 10 41 2 10
37 3 50 42 3 50
38 4 500 43 4 500
39 } { 44 } {
40 if {$tn!=4} continue
41 reset_db 45 reset_db
42 db func rnddoc rnddoc 46 db func rnddoc rnddoc
43 do_execsql_test 1.$tn.1 { 47 do_execsql_test 1.$tn.1 {
44 CREATE VIRTUAL TABLE t1 USING fts5(x, y); 48 CREATE VIRTUAL TABLE t1 USING fts5(x, y);
45 } 49 }
46 do_test 1.$tn.2 { 50 do_test 1.$tn.2 {
47 for {set i 0} {$i < $nStep} {incr i} { 51 for {set i 0} {$i < $nStep} {incr i} {
48 execsql { INSERT INTO t1 VALUES( rnddoc(5), rnddoc(5) ) } 52 execsql { INSERT INTO t1 VALUES( rnddoc(5), rnddoc(5) ) }
49 } 53 }
50 } {} 54 } {}
51 55
52 do_execsql_test 1.$tn.3 { 56 do_execsql_test 1.$tn.3 {
53 INSERT INTO t1(t1) VALUES('integrity-check'); 57 INSERT INTO t1(t1) VALUES('integrity-check');
54 } 58 }
55 59
56 do_execsql_test 1.$tn.4 { 60 do_execsql_test 1.$tn.4 {
57 INSERT INTO t1(t1) VALUES('optimize'); 61 INSERT INTO t1(t1) VALUES('optimize');
58 } 62 }
59 63
60 do_execsql_test 1.$tn.5 { 64 do_execsql_test 1.$tn.5 {
61 INSERT INTO t1(t1) VALUES('integrity-check'); 65 INSERT INTO t1(t1) VALUES('integrity-check');
62 } 66 }
67
68 do_test 1.$tn.6 { fts5_segcount t1 } 1
63 } 69 }
64 70
71 foreach {tn nStep} {
72 1 2
73 2 10
74 3 50
75 4 500
76 } {
77 reset_db
78 db func rnddoc rnddoc
79 do_execsql_test 1.$tn.1 {
80 CREATE VIRTUAL TABLE t1 USING fts5(x, y);
81 }
82 do_test 2.$tn.2 {
83 for {set i 0} {$i < $nStep} {incr i} {
84 execsql { INSERT INTO t1 VALUES( rnddoc(5), rnddoc(5) ) }
85 }
86 } {}
87
88 do_execsql_test 2.$tn.3 {
89 INSERT INTO t1(t1) VALUES('integrity-check');
90 }
91
92 do_test 2.$tn.4 {
93 execsql { INSERT INTO t1(t1, rank) VALUES('merge', -1) }
94 while 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]
98 if {$c<2} break
99 }
100 } {}
101
102 do_execsql_test 2.$tn.5 {
103 INSERT INTO t1(t1) VALUES('integrity-check');
104 }
105
106 do_test 2.$tn.6 { fts5_segcount t1 } 1
107 }
65 finish_test 108 finish_test
66 109
OLDNEW
« no previous file with comments | « third_party/sqlite/src/ext/fts5/test/fts5multiclient.test ('k') | third_party/sqlite/src/ext/fts5/test/fts5prefix.test » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698