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

Side by Side Diff: third_party/sqlite/src/test/e_reindex.test

Issue 901033002: Import SQLite 3.8.7.4. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Chromium changes to support SQLite 3.8.7.4. Created 5 years, 10 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 # 2010 September 24 1 # 2010 September 24
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 # This file implements tests to verify that the "testable statements" in 12 # This file implements tests to verify that the "testable statements" in
13 # the lang_reindex.html document are correct. 13 # the lang_reindex.html document are correct.
14 # 14 #
15 15
16 set testdir [file dirname $argv0] 16 set testdir [file dirname $argv0]
17 source $testdir/tester.tcl 17 source $testdir/tester.tcl
18 18
19 proc do_reindex_tests {args} { 19 proc do_reindex_tests {args} {
20 uplevel do_select_tests $args 20 uplevel do_select_tests $args
21 } 21 }
22 22
23 do_execsql_test e_reindex-0.0 { 23 do_execsql_test e_reindex-0.0 {
24 CREATE TABLE t1(a, b); 24 CREATE TABLE t1(a, b);
25 CREATE INDEX i1 ON t1(a, b); 25 CREATE INDEX i1 ON t1(a, b);
26 CREATE INDEX i2 ON t1(b, a); 26 CREATE INDEX i2 ON t1(b, a);
27 } {} 27 } {}
28 28
29 # EVIDENCE-OF: R-57021-15304 -- syntax diagram reindex-stmt 29 # -- syntax diagram reindex-stmt
30 # 30 #
31 do_reindex_tests e_reindex-0.1 { 31 do_reindex_tests e_reindex-0.1 {
32 1 "REINDEX" {} 32 1 "REINDEX" {}
33 2 "REINDEX nocase" {} 33 2 "REINDEX nocase" {}
34 3 "REINDEX binary" {} 34 3 "REINDEX binary" {}
35 4 "REINDEX t1" {} 35 4 "REINDEX t1" {}
36 5 "REINDEX main.t1" {} 36 5 "REINDEX main.t1" {}
37 4 "REINDEX i1" {} 37 6 "REINDEX i1" {}
38 5 "REINDEX main.i1" {} 38 7 "REINDEX main.i1" {}
39 } 39 }
40 40
41 # EVIDENCE-OF: R-52173-44778 The REINDEX command is used to delete and 41 # EVIDENCE-OF: R-52173-44778 The REINDEX command is used to delete and
42 # recreate indices from scratch. 42 # recreate indices from scratch.
43 # 43 #
44 # Test this by corrupting some database indexes, running REINDEX, and 44 # Test this by corrupting some database indexes, running REINDEX, and
45 # observing that the corruption is gone. 45 # observing that the corruption is gone.
46 # 46 #
47 do_execsql_test e_reindex-1.1 { 47 do_execsql_test e_reindex-1.1 {
48 INSERT INTO t1 VALUES(1, 2); 48 INSERT INTO t1 VALUES(1, 2);
(...skipping 11 matching lines...) Expand all
60 INSERT INTO t1 VALUES(9, 10); 60 INSERT INTO t1 VALUES(9, 10);
61 PRAGMA writable_schema = 1; 61 PRAGMA writable_schema = 1;
62 UPDATE sqlite_master SET sql = substr(sql, 4) WHERE type = 'index'; 62 UPDATE sqlite_master SET sql = substr(sql, 4) WHERE type = 'index';
63 } {} 63 } {}
64 64
65 db close 65 db close
66 sqlite3 db test.db 66 sqlite3 db test.db
67 do_execsql_test e_reindex-1.3 { 67 do_execsql_test e_reindex-1.3 {
68 PRAGMA integrity_check; 68 PRAGMA integrity_check;
69 } [list \ 69 } [list \
70 {rowid 4 missing from index i2} \ 70 {row 3 missing from index i2} \
71 {rowid 4 missing from index i1} \ 71 {row 3 missing from index i1} \
72 {rowid 5 missing from index i2} \ 72 {row 4 missing from index i2} \
73 {rowid 5 missing from index i1} \ 73 {row 4 missing from index i1} \
74 {wrong # of entries in index i2} \ 74 {wrong # of entries in index i2} \
75 {wrong # of entries in index i1} 75 {wrong # of entries in index i1}
76 ] 76 ]
77 77
78 do_execsql_test e_reindex-1.4 { 78 do_execsql_test e_reindex-1.4 {
79 REINDEX; 79 REINDEX;
80 PRAGMA integrity_check; 80 PRAGMA integrity_check;
81 } {ok} 81 } {ok}
82 82
83 #------------------------------------------------------------------------- 83 #-------------------------------------------------------------------------
84 # The remaining tests in this file focus on testing that the REINDEX 84 # The remaining tests in this file focus on testing that the REINDEX
85 # command reindexes the correct subset of the indexes in the database. 85 # command reindexes the correct subset of the indexes in the database.
86 # They all use the following dataset. 86 # They all use the following dataset.
87 # 87 #
88 db close 88 db close
89 forcedelete test.db2 89 forcedelete test.db2
90 forcedelete test.db 90 forcedelete test.db
91 sqlite3 db test.db 91 sqlite3 db test.db
92 92
93 proc sort_by_length {lhs rhs} { 93 proc sort_by_length {lhs rhs} {
94 set res [expr {[string length $lhs] - [string length $rhs]}] 94 set res [expr {[string length $lhs] - [string length $rhs]}]
95 if {$res!=0} {return $res} 95 if {$res!=0} {return $res}
96 return [string compare $lhs $rhs] 96 return [string compare $lhs $rhs]
97 } 97 }
98 array set V {one 1 two 2 three 3 four 4 five 5 six 6 seven 7 eight 8} 98 array set V {one 1 two 2 three 3 four 4 five 5 six 6 seven 7 eight 8}
99 proc sort_by_value {lhs rhs} { 99 proc sort_by_value {lhs rhs} {
100 global V 100 global V
101 set res [expr {$V($lhs) - $V(rhs)}] 101 set res [expr {$V($lhs) - $V($rhs)}]
102 if {$res!=0} {return $res} 102 if {$res!=0} {return $res}
103 return [string compare $lhs $rhs] 103 return [string compare $lhs $rhs]
104 } 104 }
105 105
106 db collate collA sort_by_length 106 db collate collA sort_by_length
107 db collate collB sort_by_value 107 db collate collB sort_by_value
108 108
109 set BY(length) {one six two five four eight seven three} 109 set BY(length) {one six two five four eight seven three}
110 set BY(value) {one two three four five six seven eight} 110 set BY(value) {one two three four five six seven eight}
111 111
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 do_execsql_test e_reindex-2.6.3 "REINDEX main.collA" {} 285 do_execsql_test e_reindex-2.6.3 "REINDEX main.collA" {}
286 test_index 6.4 collA collA length 286 test_index 6.4 collA collA length
287 test_index 6.5 collA collB value 287 test_index 6.5 collA collB value
288 288
289 set_collations value length 289 set_collations value length
290 do_execsql_test e_reindex-2.6.6 "REINDEX main.collA" {} 290 do_execsql_test e_reindex-2.6.6 "REINDEX main.collA" {}
291 test_index 6.7 collA collA value 291 test_index 6.7 collA collA value
292 test_index 6.8 collA collB length 292 test_index 6.8 collA collB length
293 293
294 finish_test 294 finish_test
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698