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

Side by Side Diff: third_party/sqlite/src/test/stat.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 July 09 1 # 2010 July 09
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 # This file implements regression tests for SQLite library. The 11 # This file implements regression tests for SQLite library. The
12 # focus of this file is testing the SELECT statement. 12 # focus of this file is testing the SELECT statement.
13 # 13 #
14 14
15 set testdir [file dirname $argv0] 15 set testdir [file dirname $argv0]
16 source $testdir/tester.tcl 16 source $testdir/tester.tcl
17 17
18 ifcapable !vtab { 18 ifcapable !vtab||!compound {
19 finish_test 19 finish_test
20 return 20 return
21 } 21 }
22 22
23 23
24 set ::asc 1 24 set ::asc 1
25 proc a_string {n} { string range [string repeat [incr ::asc]. $n] 1 $n } 25 proc a_string {n} { string range [string repeat [incr ::asc]. $n] 1 $n }
26 db func a_string a_string 26 db func a_string a_string
27 27
28 register_dbstat_vtab db 28 register_dbstat_vtab db
29 do_execsql_test stat-0.0 { 29 do_execsql_test stat-0.0 {
30 PRAGMA auto_vacuum = OFF; 30 PRAGMA auto_vacuum = OFF;
31 CREATE VIRTUAL TABLE temp.stat USING dbstat; 31 CREATE VIRTUAL TABLE temp.stat USING dbstat;
32 SELECT * FROM stat; 32 SELECT * FROM stat;
33 } {} 33 } {}
34 34
35 ifcapable wal { 35 ifcapable wal {
36 do_execsql_test stat-0.1 { 36 do_execsql_test stat-0.1 {
37 PRAGMA journal_mode = WAL; 37 PRAGMA journal_mode = WAL;
38 PRAGMA journal_mode = delete; 38 PRAGMA journal_mode = delete;
39 SELECT * FROM stat; 39 SELECT name, path, pageno, pagetype, ncell, payload, unused, mx_payload
40 FROM stat;
40 } {wal delete sqlite_master / 1 leaf 0 0 916 0} 41 } {wal delete sqlite_master / 1 leaf 0 0 916 0}
41 } 42 }
42 43
43 do_test stat-1.0 { 44 do_test stat-1.0 {
44 execsql { 45 execsql {
45 CREATE TABLE t1(a, b); 46 CREATE TABLE t1(a, b);
46 CREATE INDEX i1 ON t1(b); 47 CREATE INDEX i1 ON t1(b);
47 INSERT INTO t1(rowid, a, b) VALUES(2, 2, 3); 48 INSERT INTO t1(rowid, a, b) VALUES(2, 2, 3);
48 INSERT INTO t1(rowid, a, b) VALUES(3, 4, 5); 49 INSERT INTO t1(rowid, a, b) VALUES(3, 4, 5);
49 } 50 }
50 } {} 51 } {}
51 do_test stat-1.1 { 52 do_test stat-1.1 {
52 execsql { 53 execsql {
53 SELECT * FROM stat WHERE name = 't1'; 54 SELECT name, path, pageno, pagetype, ncell, payload, unused, mx_payload
55 FROM stat WHERE name = 't1';
54 } 56 }
55 } {t1 / 2 leaf 2 10 998 5} 57 } {t1 / 2 leaf 2 10 998 5}
56 do_test stat-1.2 { 58 do_test stat-1.2 {
57 execsql { 59 execsql {
58 SELECT * FROM stat WHERE name = 'i1'; 60 SELECT name, path, pageno, pagetype, ncell, payload, unused, mx_payload
61 FROM stat WHERE name = 'i1';
59 } 62 }
60 } {i1 / 3 leaf 2 10 1000 5} 63 } {i1 / 3 leaf 2 10 1000 5}
61 do_test stat-1.3 { 64 do_test stat-1.3 {
62 execsql { 65 execsql {
63 SELECT * FROM stat WHERE name = 'sqlite_master'; 66 SELECT name, path, pageno, pagetype, ncell, payload, unused, mx_payload
67 FROM stat WHERE name = 'sqlite_master';
64 } 68 }
65 } {sqlite_master / 1 leaf 2 77 831 40} 69 } {sqlite_master / 1 leaf 2 77 831 40}
66 do_test stat-1.4 { 70 do_test stat-1.4 {
67 execsql { 71 execsql {
68 DROP TABLE t1; 72 DROP TABLE t1;
69 } 73 }
70 } {} 74 } {}
71 75
72 do_execsql_test stat-2.1 { 76 do_execsql_test stat-2.1 {
73 CREATE TABLE t3(a PRIMARY KEY, b); 77 CREATE TABLE t3(a PRIMARY KEY, b);
74 INSERT INTO t3(rowid, a, b) VALUES(2, a_string(111), a_string(222)); 78 INSERT INTO t3(rowid, a, b) VALUES(2, a_string(111), a_string(222));
75 INSERT INTO t3 SELECT a_string(110+rowid), a_string(221+rowid) FROM t3; 79 INSERT INTO t3 SELECT a_string(110+rowid), a_string(221+rowid) FROM t3
76 INSERT INTO t3 SELECT a_string(110+rowid), a_string(221+rowid) FROM t3; 80 ORDER BY rowid;
77 INSERT INTO t3 SELECT a_string(110+rowid), a_string(221+rowid) FROM t3; 81 INSERT INTO t3 SELECT a_string(110+rowid), a_string(221+rowid) FROM t3
78 INSERT INTO t3 SELECT a_string(110+rowid), a_string(221+rowid) FROM t3; 82 ORDER BY rowid;
79 INSERT INTO t3 SELECT a_string(110+rowid), a_string(221+rowid) FROM t3; 83 INSERT INTO t3 SELECT a_string(110+rowid), a_string(221+rowid) FROM t3
80 SELECT * FROM stat WHERE name != 'sqlite_master'; 84 ORDER BY rowid;
85 INSERT INTO t3 SELECT a_string(110+rowid), a_string(221+rowid) FROM t3
86 ORDER BY rowid;
87 INSERT INTO t3 SELECT a_string(110+rowid), a_string(221+rowid) FROM t3
88 ORDER BY rowid;
89 SELECT name, path, pageno, pagetype, ncell, payload, unused, mx_payload
90 FROM stat WHERE name != 'sqlite_master';
81 } [list \ 91 } [list \
82 sqlite_autoindex_t3_1 / 3 internal 3 368 623 125 \ 92 sqlite_autoindex_t3_1 / 3 internal 3 368 623 125 \
83 sqlite_autoindex_t3_1 /000/ 8 leaf 8 946 46 123 \ 93 sqlite_autoindex_t3_1 /000/ 8 leaf 8 946 46 123 \
84 sqlite_autoindex_t3_1 /001/ 9 leaf 8 988 2 131 \ 94 sqlite_autoindex_t3_1 /001/ 9 leaf 8 988 2 131 \
85 sqlite_autoindex_t3_1 /002/ 15 leaf 7 857 137 132 \ 95 sqlite_autoindex_t3_1 /002/ 15 leaf 7 857 137 132 \
86 sqlite_autoindex_t3_1 /003/ 20 leaf 6 739 257 129 \ 96 sqlite_autoindex_t3_1 /003/ 20 leaf 6 739 257 129 \
87 t3 / 2 internal 15 0 907 0 \ 97 t3 / 2 internal 15 0 907 0 \
88 t3 /000/ 4 leaf 2 678 328 340 \ 98 t3 /000/ 4 leaf 2 678 328 340 \
89 t3 /001/ 5 leaf 2 682 324 342 \ 99 t3 /001/ 5 leaf 2 682 324 342 \
90 t3 /002/ 6 leaf 2 682 324 342 \ 100 t3 /002/ 6 leaf 2 682 324 342 \
91 t3 /003/ 7 leaf 2 690 316 346 \ 101 t3 /003/ 7 leaf 2 690 316 346 \
92 t3 /004/ 10 leaf 2 682 324 342 \ 102 t3 /004/ 10 leaf 2 682 324 342 \
93 t3 /005/ 11 leaf 2 690 316 346 \ 103 t3 /005/ 11 leaf 2 690 316 346 \
94 t3 /006/ 12 leaf 2 698 308 350 \ 104 t3 /006/ 12 leaf 2 698 308 350 \
95 t3 /007/ 13 leaf 2 706 300 354 \ 105 t3 /007/ 13 leaf 2 706 300 354 \
96 t3 /008/ 14 leaf 2 682 324 342 \ 106 t3 /008/ 14 leaf 2 682 324 342 \
97 t3 /009/ 16 leaf 2 690 316 346 \ 107 t3 /009/ 16 leaf 2 690 316 346 \
98 t3 /00a/ 17 leaf 2 698 308 350 \ 108 t3 /00a/ 17 leaf 2 698 308 350 \
99 t3 /00b/ 18 leaf 2 706 300 354 \ 109 t3 /00b/ 18 leaf 2 706 300 354 \
100 t3 /00c/ 19 leaf 2 714 292 358 \ 110 t3 /00c/ 19 leaf 2 714 292 358 \
101 t3 /00d/ 21 leaf 2 722 284 362 \ 111 t3 /00d/ 21 leaf 2 722 284 362 \
102 t3 /00e/ 22 leaf 2 730 276 366 \ 112 t3 /00e/ 22 leaf 2 730 276 366 \
103 t3 /00f/ 23 leaf 2 738 268 370 \ 113 t3 /00f/ 23 leaf 2 738 268 370 \
104 ] 114 ]
105 do_execsql_test stat-2.2 { DROP TABLE t3 } {} 115
116 # With every index entry overflowing, make sure no pages are missed
117 # (other than the locking page which is 64 in this test build.)
118 #
119 do_execsql_test stat-2.2 {
120 UPDATE t3 SET a=a||hex(randomblob(700));
121 VACUUM;
122 SELECT pageno FROM stat EXCEPT SELECT pageno-1 FROM stat;
123 } {64 136}
124
125 do_execsql_test stat-2.3 { DROP TABLE t3; VACUUM; } {}
106 126
107 do_execsql_test stat-3.1 { 127 do_execsql_test stat-3.1 {
108 CREATE TABLE t4(x); 128 CREATE TABLE t4(x);
109 CREATE INDEX i4 ON t4(x); 129 CREATE INDEX i4 ON t4(x);
110 INSERT INTO t4(rowid, x) VALUES(2, a_string(7777)); 130 INSERT INTO t4(rowid, x) VALUES(2, a_string(7777));
111 SELECT * FROM stat WHERE name != 'sqlite_master'; 131 SELECT name, path, pageno, pagetype, ncell, payload, unused, mx_payload
132 FROM stat WHERE name != 'sqlite_master';
112 } [list \ 133 } [list \
113 i4 / 3 leaf 1 103 905 7782 \ 134 i4 / 3 leaf 1 103 905 7782 \
114 i4 /000+000000 9 overflow 0 1020 0 0 \ 135 i4 /000+000000 4 overflow 0 1020 0 0 \
115 i4 /000+000001 10 overflow 0 1020 0 0 \ 136 i4 /000+000001 5 overflow 0 1020 0 0 \
116 i4 /000+000002 11 overflow 0 1020 0 0 \ 137 i4 /000+000002 6 overflow 0 1020 0 0 \
117 i4 /000+000003 12 overflow 0 1020 0 0 \ 138 i4 /000+000003 7 overflow 0 1020 0 0 \
118 i4 /000+000004 13 overflow 0 1020 0 0 \ 139 i4 /000+000004 8 overflow 0 1020 0 0 \
119 i4 /000+000005 14 overflow 0 1020 0 0 \ 140 i4 /000+000005 9 overflow 0 1020 0 0 \
120 i4 /000+000006 15 overflow 0 1020 0 0 \ 141 i4 /000+000006 10 overflow 0 1020 0 0 \
121 i4 /000+000007 16 overflow 0 539 481 0 \ 142 i4 /000+000007 11 overflow 0 539 481 0 \
122 t4 / 2 leaf 1 640 367 7780 \ 143 t4 / 2 leaf 1 640 367 7780 \
123 t4 /000+000000 22 overflow 0 1020 0 0 \ 144 t4 /000+000000 12 overflow 0 1020 0 0 \
124 t4 /000+000001 23 overflow 0 1020 0 0 \ 145 t4 /000+000001 13 overflow 0 1020 0 0 \
125 t4 /000+000002 21 overflow 0 1020 0 0 \ 146 t4 /000+000002 14 overflow 0 1020 0 0 \
126 t4 /000+000003 20 overflow 0 1020 0 0 \ 147 t4 /000+000003 15 overflow 0 1020 0 0 \
127 t4 /000+000004 19 overflow 0 1020 0 0 \ 148 t4 /000+000004 16 overflow 0 1020 0 0 \
128 t4 /000+000005 18 overflow 0 1020 0 0 \ 149 t4 /000+000005 17 overflow 0 1020 0 0 \
129 t4 /000+000006 17 overflow 0 1020 0 0 \ 150 t4 /000+000006 18 overflow 0 1020 0 0 \
130 ] 151 ]
131 152
132 do_execsql_test stat-4.1 { 153 do_execsql_test stat-4.1 {
133 CREATE TABLE t5(x); 154 CREATE TABLE t5(x);
134 CREATE INDEX i5 ON t5(x); 155 CREATE INDEX i5 ON t5(x);
135 SELECT * FROM stat WHERE name = 't5' OR name = 'i5'; 156 SELECT name, path, pageno, pagetype, ncell, payload, unused, mx_payload
157 FROM stat WHERE name = 't5' OR name = 'i5';
136 } [list \ 158 } [list \
137 i5 / 5 leaf 0 0 1016 0 \ 159 i5 / 20 leaf 0 0 1016 0 \
138 t5 / 4 leaf 0 0 1016 0 \ 160 t5 / 19 leaf 0 0 1016 0 \
139 ] 161 ]
140 162
141 db close 163 db close
142 file delete -force test.db 164 forcedelete test.db
143 sqlite3 db test.db 165 sqlite3 db test.db
144 register_dbstat_vtab db 166 register_dbstat_vtab db
145 breakpoint
146 do_execsql_test stat-5.1 { 167 do_execsql_test stat-5.1 {
147 PRAGMA auto_vacuum = OFF; 168 PRAGMA auto_vacuum = OFF;
148 CREATE VIRTUAL TABLE temp.stat USING dbstat; 169 CREATE VIRTUAL TABLE temp.stat USING dbstat;
149 CREATE TABLE t1(x); 170 CREATE TABLE t1(x);
150 INSERT INTO t1 VALUES(zeroblob(1513)); 171 INSERT INTO t1 VALUES(zeroblob(1513));
151 INSERT INTO t1 VALUES(zeroblob(1514)); 172 INSERT INTO t1 VALUES(zeroblob(1514));
152 SELECT * FROM stat WHERE name = 't1'; 173 SELECT name, path, pageno, pagetype, ncell, payload, unused, mx_payload
174 FROM stat WHERE name = 't1';
153 } [list \ 175 } [list \
154 t1 / 2 leaf 2 993 5 1517 \ 176 t1 / 2 leaf 2 993 5 1517 \
155 t1 /000+000000 3 overflow 0 1020 0 0 \ 177 t1 /000+000000 3 overflow 0 1020 0 0 \
156 t1 /001+000000 4 overflow 0 1020 0 0 \ 178 t1 /001+000000 4 overflow 0 1020 0 0 \
157 ] 179 ]
158 180
159 finish_test 181 finish_test
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698