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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/sqlite/src/test/stat.test
diff --git a/third_party/sqlite/src/test/stat.test b/third_party/sqlite/src/test/stat.test
index 57c1b9eae166b684cd579dda324cd46d53b683fc..66ca5e2f2b3635c31dede821070cec6c3ce867b1 100644
--- a/third_party/sqlite/src/test/stat.test
+++ b/third_party/sqlite/src/test/stat.test
@@ -14,12 +14,17 @@
set testdir [file dirname $argv0]
source $testdir/tester.tcl
+set testprefix stat
ifcapable !vtab||!compound {
finish_test
return
}
+# This module uses hard-coded results that depend on exact measurements of
+# pages sizes at the byte level, and hence will not work if the reserved_bytes
+# value is nonzero.
+if {[nonzero_reserved_bytes]} {finish_test; return;}
set ::asc 1
proc a_string {n} { string range [string repeat [incr ::asc]. $n] 1 $n }
@@ -27,12 +32,28 @@ db func a_string a_string
register_dbstat_vtab db
do_execsql_test stat-0.0 {
+ PRAGMA table_info(dbstat);
+} {/0 name TEXT .* 1 path TEXT .* 9 pgsize INTEGER/}
+
+# Attempts to drop an eponymous virtual table are a no-op.
+do_execsql_test stat-0.1 {
+ DROP TABLE dbstat;
+ PRAGMA table_info=dbstat;
+} {/0 name TEXT .* 1 path TEXT .* 9 pgsize INTEGER/}
+
+db close
+forcedelete test.db
+sqlite3 db test.db
+db func a_string a_string
+register_dbstat_vtab db
+do_execsql_test stat-0.2 {
PRAGMA auto_vacuum = OFF;
CREATE VIRTUAL TABLE temp.stat USING dbstat;
SELECT * FROM stat;
} {}
-ifcapable wal {
+
+if {[wal_is_capable]} {
do_execsql_test stat-0.1 {
PRAGMA journal_mode = WAL;
PRAGMA journal_mode = delete;
@@ -184,4 +205,70 @@ do_catchsql_test stat-6.1 {
CREATE VIRTUAL TABLE temp.s2 USING dbstat(mainx);
} {1 {no such database: mainx}}
+#-------------------------------------------------------------------------
+# Test that the argument passed to the dbstat constructor is dequoted
+# before it is matched against the names of attached databases.
+#
+forcedelete test.db2
+do_execsql_test 7.1 {
+ ATTACH 'test.db2' AS '123';
+ PRAGMA "123".auto_vacuum = OFF;
+ CREATE TABLE "123".x1(a, b);
+ INSERT INTO x1 VALUES(1, 2);
+}
+
+do_execsql_test 7.1.1 {
+ SELECT * FROM dbstat('123');
+} {
+ sqlite_master / 1 leaf 1 37 875 37 0 1024
+ x1 / 2 leaf 1 4 1008 4 1024 1024
+}
+do_execsql_test 7.1.2 {
+ SELECT * FROM dbstat(123);
+} {
+ sqlite_master / 1 leaf 1 37 875 37 0 1024
+ x1 / 2 leaf 1 4 1008 4 1024 1024
+}
+do_execsql_test 7.1.3 {
+ CREATE VIRTUAL TABLE x2 USING dbstat('123');
+ SELECT * FROM x2;
+} {
+ sqlite_master / 1 leaf 1 37 875 37 0 1024
+ x1 / 2 leaf 1 4 1008 4 1024 1024
+}
+do_execsql_test 7.1.4 {
+ CREATE VIRTUAL TABLE x3 USING dbstat(123);
+ SELECT * FROM x3;
+} {
+ sqlite_master / 1 leaf 1 37 875 37 0 1024
+ x1 / 2 leaf 1 4 1008 4 1024 1024
+}
+
+do_execsql_test 7.2 {
+ DETACH 123;
+ DROP TABLE x2;
+ DROP TABLE x3;
+ ATTACH 'test.db2' AS '123corp';
+}
+do_execsql_test 7.2.1 {
+ SELECT * FROM dbstat('123corp');
+} {
+ sqlite_master / 1 leaf 1 37 875 37 0 1024
+ x1 / 2 leaf 1 4 1008 4 1024 1024
+}
+do_catchsql_test 7.2.2 {
+ SELECT * FROM dbstat(123corp);
+} {1 {unrecognized token: "123corp"}}
+do_execsql_test 7.2.3 {
+ CREATE VIRTUAL TABLE x2 USING dbstat('123corp');
+ SELECT * FROM x2;
+} {
+ sqlite_master / 1 leaf 1 37 875 37 0 1024
+ x1 / 2 leaf 1 4 1008 4 1024 1024
+}
+do_catchsql_test 7.2.4 {
+ CREATE VIRTUAL TABLE x3 USING dbstat(123corp);
+ SELECT * FROM x3;
+} {1 {unrecognized token: "123corp"}}
+
finish_test
« 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