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

Side by Side Diff: third_party/sqlite/src/test/stat.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
« no previous file with comments | « third_party/sqlite/src/test/sqllog.test ('k') | third_party/sqlite/src/test/stmt.test » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 set testprefix stat
17 18
18 ifcapable !vtab||!compound { 19 ifcapable !vtab||!compound {
19 finish_test 20 finish_test
20 return 21 return
21 } 22 }
22 23
24 # This module uses hard-coded results that depend on exact measurements of
25 # pages sizes at the byte level, and hence will not work if the reserved_bytes
26 # value is nonzero.
27 if {[nonzero_reserved_bytes]} {finish_test; return;}
23 28
24 set ::asc 1 29 set ::asc 1
25 proc a_string {n} { string range [string repeat [incr ::asc]. $n] 1 $n } 30 proc a_string {n} { string range [string repeat [incr ::asc]. $n] 1 $n }
26 db func a_string a_string 31 db func a_string a_string
27 32
28 register_dbstat_vtab db 33 register_dbstat_vtab db
29 do_execsql_test stat-0.0 { 34 do_execsql_test stat-0.0 {
35 PRAGMA table_info(dbstat);
36 } {/0 name TEXT .* 1 path TEXT .* 9 pgsize INTEGER/}
37
38 # Attempts to drop an eponymous virtual table are a no-op.
39 do_execsql_test stat-0.1 {
40 DROP TABLE dbstat;
41 PRAGMA table_info=dbstat;
42 } {/0 name TEXT .* 1 path TEXT .* 9 pgsize INTEGER/}
43
44 db close
45 forcedelete test.db
46 sqlite3 db test.db
47 db func a_string a_string
48 register_dbstat_vtab db
49 do_execsql_test stat-0.2 {
30 PRAGMA auto_vacuum = OFF; 50 PRAGMA auto_vacuum = OFF;
31 CREATE VIRTUAL TABLE temp.stat USING dbstat; 51 CREATE VIRTUAL TABLE temp.stat USING dbstat;
32 SELECT * FROM stat; 52 SELECT * FROM stat;
33 } {} 53 } {}
34 54
35 ifcapable wal { 55
56 if {[wal_is_capable]} {
36 do_execsql_test stat-0.1 { 57 do_execsql_test stat-0.1 {
37 PRAGMA journal_mode = WAL; 58 PRAGMA journal_mode = WAL;
38 PRAGMA journal_mode = delete; 59 PRAGMA journal_mode = delete;
39 SELECT name, path, pageno, pagetype, ncell, payload, unused, mx_payload 60 SELECT name, path, pageno, pagetype, ncell, payload, unused, mx_payload
40 FROM stat; 61 FROM stat;
41 } {wal delete sqlite_master / 1 leaf 0 0 916 0} 62 } {wal delete sqlite_master / 1 leaf 0 0 916 0}
42 } 63 }
43 64
44 do_test stat-1.0 { 65 do_test stat-1.0 {
45 execsql { 66 execsql {
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 } [list \ 198 } [list \
178 t1 / 2 leaf 2 993 5 1517 \ 199 t1 / 2 leaf 2 993 5 1517 \
179 t1 /000+000000 3 overflow 0 1020 0 0 \ 200 t1 /000+000000 3 overflow 0 1020 0 0 \
180 t1 /001+000000 4 overflow 0 1020 0 0 \ 201 t1 /001+000000 4 overflow 0 1020 0 0 \
181 ] 202 ]
182 203
183 do_catchsql_test stat-6.1 { 204 do_catchsql_test stat-6.1 {
184 CREATE VIRTUAL TABLE temp.s2 USING dbstat(mainx); 205 CREATE VIRTUAL TABLE temp.s2 USING dbstat(mainx);
185 } {1 {no such database: mainx}} 206 } {1 {no such database: mainx}}
186 207
208 #-------------------------------------------------------------------------
209 # Test that the argument passed to the dbstat constructor is dequoted
210 # before it is matched against the names of attached databases.
211 #
212 forcedelete test.db2
213 do_execsql_test 7.1 {
214 ATTACH 'test.db2' AS '123';
215 PRAGMA "123".auto_vacuum = OFF;
216 CREATE TABLE "123".x1(a, b);
217 INSERT INTO x1 VALUES(1, 2);
218 }
219
220 do_execsql_test 7.1.1 {
221 SELECT * FROM dbstat('123');
222 } {
223 sqlite_master / 1 leaf 1 37 875 37 0 1024
224 x1 / 2 leaf 1 4 1008 4 1024 1024
225 }
226 do_execsql_test 7.1.2 {
227 SELECT * FROM dbstat(123);
228 } {
229 sqlite_master / 1 leaf 1 37 875 37 0 1024
230 x1 / 2 leaf 1 4 1008 4 1024 1024
231 }
232 do_execsql_test 7.1.3 {
233 CREATE VIRTUAL TABLE x2 USING dbstat('123');
234 SELECT * FROM x2;
235 } {
236 sqlite_master / 1 leaf 1 37 875 37 0 1024
237 x1 / 2 leaf 1 4 1008 4 1024 1024
238 }
239 do_execsql_test 7.1.4 {
240 CREATE VIRTUAL TABLE x3 USING dbstat(123);
241 SELECT * FROM x3;
242 } {
243 sqlite_master / 1 leaf 1 37 875 37 0 1024
244 x1 / 2 leaf 1 4 1008 4 1024 1024
245 }
246
247 do_execsql_test 7.2 {
248 DETACH 123;
249 DROP TABLE x2;
250 DROP TABLE x3;
251 ATTACH 'test.db2' AS '123corp';
252 }
253 do_execsql_test 7.2.1 {
254 SELECT * FROM dbstat('123corp');
255 } {
256 sqlite_master / 1 leaf 1 37 875 37 0 1024
257 x1 / 2 leaf 1 4 1008 4 1024 1024
258 }
259 do_catchsql_test 7.2.2 {
260 SELECT * FROM dbstat(123corp);
261 } {1 {unrecognized token: "123corp"}}
262 do_execsql_test 7.2.3 {
263 CREATE VIRTUAL TABLE x2 USING dbstat('123corp');
264 SELECT * FROM x2;
265 } {
266 sqlite_master / 1 leaf 1 37 875 37 0 1024
267 x1 / 2 leaf 1 4 1008 4 1024 1024
268 }
269 do_catchsql_test 7.2.4 {
270 CREATE VIRTUAL TABLE x3 USING dbstat(123corp);
271 SELECT * FROM x3;
272 } {1 {unrecognized token: "123corp"}}
273
187 finish_test 274 finish_test
OLDNEW
« no previous file with comments | « third_party/sqlite/src/test/sqllog.test ('k') | third_party/sqlite/src/test/stmt.test » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698