]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Fix test_stat.c so that it does not cause compilation errors if SQLITE_OMIT_VIRTUALTA...
authordan <dan@noemail.net>
Mon, 12 Jul 2010 18:12:41 +0000 (18:12 +0000)
committerdan <dan@noemail.net>
Mon, 12 Jul 2010 18:12:41 +0000 (18:12 +0000)
FossilOrigin-Name: bf4fc0888705108aab997e1cb491fc7f9c64c443

manifest
manifest.uuid
src/test_stat.c
test/stat.test [new file with mode: 0644]

index 9f75c56157fc93aa63560efd231013cf253300b1..521173deeaccc3d7106769f9be1a13ec09ce2a8c 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,8 +1,5 @@
------BEGIN PGP SIGNED MESSAGE-----
-Hash: SHA1
-
-C Fix\smakefiles\sso\sthat\sthey\sbuild\ssqlite3_analyzer\sagain.\s\sTweaks\sto\scomments\nin\stest_stat.c.\s\sFix\stclsqlite.c\sto\sbuild\sthe\ssqlite3_analyzer\sagain.
-D 2010-07-12T16:47:49
+C Fix\stest_stat.c\sso\sthat\sit\sdoes\snot\scause\scompilation\serrors\sif\sSQLITE_OMIT_VIRTUALTABLE\sis\sdefined.
+D 2010-07-12T18:12:41
 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
 F Makefile.in ec08dc838fd8110fe24c92e5130bcd91cbb1ff2e
 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -210,7 +207,7 @@ F src/test_osinst.c 700a39f4b7d3959fb65b1a97a5503a9b6d952c6b
 F src/test_pcache.c 7bf828972ac0d2403f5cfa4cd14da41f8ebe73d8
 F src/test_schema.c 8c06ef9ddb240c7a0fcd31bc221a6a2aade58bf0
 F src/test_server.c bbba05c144b5fc4b52ff650a4328027b3fa5fcc6
-F src/test_stat.c 43fbdefb11cef9ffe0d68358a53f0d5b73ce7a03
+F src/test_stat.c 6ebaf2a86d01ccda24e49c148f1d33e8badda06e
 F src/test_tclvar.c f4dc67d5f780707210d6bb0eb6016a431c04c7fa
 F src/test_thread.c bedd05cad673dba53326f3aa468cc803038896c0
 F src/test_vfs.c bea0f0bdee9b033a62d057bf3451c25760b0414d
@@ -608,6 +605,7 @@ F test/speed4.test abc0ad3399dcf9703abed2fff8705e4f8e416715
 F test/speed4p.explain 6b5f104ebeb34a038b2f714150f51d01143e59aa
 F test/speed4p.test 0e51908951677de5a969b723e03a27a1c45db38b
 F test/sqllimits1.test e90a0ed94452076f6a10209d378e06b5f75ef0a0
+F test/stat.test 16b170b62617c79e534ab482364255d2b7b0c3c8
 F test/stmt.test 7915bd3e8380b956c095f40f41a775a30716e649
 F test/subquery.test b524f57c9574b2c0347045b4510ef795d4686796
 F test/subselect.test d24fd8757daf97dafd2e889c73ea4c4272dcf4e4
@@ -836,14 +834,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
 F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
-P 15a190dc5769beb53b89254543e744a964cd86ed
-R b03ba0baa83ecbd1443fe1ae924d6bf5
-U drh
-Z 04b286182088f92bee4d811b7155ecc4
------BEGIN PGP SIGNATURE-----
-Version: GnuPG v1.4.6 (GNU/Linux)
-
-iD8DBQFMO0c4oxKgR168RlERAoTDAKCCtvm0lsyE0VQBBwpBriE6MEfmCwCgiZ6l
-E2dmMrqBg49MZkPjgXnYW64=
-=t01V
------END PGP SIGNATURE-----
+P e6cd15451d8c47bfc86d07565655920134b494fe
+R 1f9d6ed2ba44f2915e3c41809f76e2bf
+U dan
+Z c74a18dab14d1190c93da6ff3459824a
index ad6f07158515218487ef8cb16a27e98c356f9418..c179331e7313cf1e3778060e735e89b9b4130cab 100644 (file)
@@ -1 +1 @@
-e6cd15451d8c47bfc86d07565655920134b494fe
\ No newline at end of file
+bf4fc0888705108aab997e1cb491fc7f9c64c443
\ No newline at end of file
index 527c8b323ead134763030a7de33a1957f5e3342e..894be80ecb9eb2023e507c0a8c1e597668b05345 100644 (file)
@@ -20,6 +20,8 @@
 
 #include "sqliteInt.h"
 
+#ifndef SQLITE_OMIT_VIRTUALTABLE
+
 /*
 ** Page paths:
 ** 
@@ -566,6 +568,8 @@ int sqlite3_dbstat_register(sqlite3 *db){
   return SQLITE_OK;
 }
 
+#endif
+
 #ifdef SQLITE_TEST
 #include <tcl.h>
 
diff --git a/test/stat.test b/test/stat.test
new file mode 100644 (file)
index 0000000..7ec148e
--- /dev/null
@@ -0,0 +1,154 @@
+# 2010 July 09
+#
+# The author disclaims copyright to this source code.  In place of
+# a legal notice, here is a blessing:
+#
+#    May you do good and not evil.
+#    May you find forgiveness for yourself and forgive others.
+#    May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.  The
+# focus of this file is testing the SELECT statement.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !vtab {
+  finish_test
+  return
+}
+
+
+set ::asc 1
+proc a_string {n} { string range [string repeat [incr ::asc]. $n] 1 $n }
+db func a_string a_string
+
+register_dbstat_vtab db
+do_execsql_test stat-0.0 {
+  CREATE VIRTUAL TABLE temp.stat USING dbstat;
+  SELECT * FROM stat;
+} {}
+do_execsql_test stat-0.1 {
+  PRAGMA journal_mode = WAL;
+  PRAGMA journal_mode = delete;
+  SELECT * FROM stat;
+} {wal delete sqlite_master / 1 leaf 0 0 916 0}
+
+do_test stat-1.0 {
+  execsql {
+    CREATE TABLE t1(a, b);
+    CREATE INDEX i1 ON t1(b);
+    INSERT INTO t1 VALUES(1, 2);
+    INSERT INTO t1 VALUES(3, 4);
+  }
+} {}
+do_test stat-1.1 {
+  execsql {
+    SELECT * FROM stat WHERE name = 't1';
+  }
+} {t1 / 2 leaf 2 10 998 5}
+do_test stat-1.2 {
+  execsql {
+    SELECT * FROM stat WHERE name = 'i1';
+  }
+} {i1 / 3 leaf 2 10 1000 5}
+do_test stat-1.3 {
+  execsql {
+    SELECT * FROM stat WHERE name = 'sqlite_master';
+  }
+} {sqlite_master / 1 leaf 2 77 831 40}
+do_test stat-1.4 {
+  execsql {
+    DROP TABLE t1;
+  }
+} {}
+
+do_execsql_test stat-2.1 {
+  CREATE TABLE t3(a PRIMARY KEY, b);
+  INSERT INTO t3 VALUES(a_string(111), a_string(222));
+  INSERT INTO t3 SELECT a_string(111+rowid), a_string(222+rowid) FROM t3;
+  INSERT INTO t3 SELECT a_string(111+rowid), a_string(222+rowid) FROM t3;
+  INSERT INTO t3 SELECT a_string(111+rowid), a_string(222+rowid) FROM t3;
+  INSERT INTO t3 SELECT a_string(111+rowid), a_string(222+rowid) FROM t3;
+  INSERT INTO t3 SELECT a_string(111+rowid), a_string(222+rowid) FROM t3;
+  SELECT * FROM stat WHERE name != 'sqlite_master';
+} [list \
+  sqlite_autoindex_t3_1 / 3 internal 3 368 623 125       \
+  sqlite_autoindex_t3_1 /000/ 8 leaf 8 946 46 123        \
+  sqlite_autoindex_t3_1 /001/ 9 leaf 8 988 2 131         \
+  sqlite_autoindex_t3_1 /002/ 15 leaf 7 857 137 132      \
+  sqlite_autoindex_t3_1 /003/ 20 leaf 6 739 257 129      \
+  t3 / 2 internal 15 0 907 0                             \
+  t3 /000/ 4 leaf 2 678 328 340                          \
+  t3 /001/ 5 leaf 2 682 324 342                          \
+  t3 /002/ 6 leaf 2 682 324 342                          \
+  t3 /003/ 7 leaf 2 690 316 346                          \
+  t3 /004/ 10 leaf 2 682 324 342                         \
+  t3 /005/ 11 leaf 2 690 316 346                         \
+  t3 /006/ 12 leaf 2 698 308 350                         \
+  t3 /007/ 13 leaf 2 706 300 354                         \
+  t3 /008/ 14 leaf 2 682 324 342                         \
+  t3 /009/ 16 leaf 2 690 316 346                         \
+  t3 /00a/ 17 leaf 2 698 308 350                         \
+  t3 /00b/ 18 leaf 2 706 300 354                         \
+  t3 /00c/ 19 leaf 2 714 292 358                         \
+  t3 /00d/ 21 leaf 2 722 284 362                         \
+  t3 /00e/ 22 leaf 2 730 276 366                         \
+  t3 /00f/ 23 leaf 2 738 268 370                         \
+]
+do_execsql_test stat-2.2 { DROP TABLE t3 } {}
+
+do_execsql_test stat-3.1 {
+  CREATE TABLE t4(x);
+  CREATE INDEX i4 ON t4(x);
+  INSERT INTO t4 VALUES(a_string(7777));
+  SELECT * FROM stat WHERE name != 'sqlite_master';
+} [list \
+  i4 / 3 leaf 1 103 905 7782                 \
+  i4 /000+000000 9 overflow 0 1020 0 0       \
+  i4 /000+000001 10 overflow 0 1020 0 0      \
+  i4 /000+000002 11 overflow 0 1020 0 0      \
+  i4 /000+000003 12 overflow 0 1020 0 0      \
+  i4 /000+000004 13 overflow 0 1020 0 0      \
+  i4 /000+000005 14 overflow 0 1020 0 0      \
+  i4 /000+000006 15 overflow 0 1020 0 0      \
+  i4 /000+000007 16 overflow 0 539 481 0     \
+  t4 / 2 leaf 1 640 367 7780                 \
+  t4 /000+000000 22 overflow 0 1020 0 0      \
+  t4 /000+000001 23 overflow 0 1020 0 0      \
+  t4 /000+000002 21 overflow 0 1020 0 0      \
+  t4 /000+000003 20 overflow 0 1020 0 0      \
+  t4 /000+000004 19 overflow 0 1020 0 0      \
+  t4 /000+000005 18 overflow 0 1020 0 0      \
+  t4 /000+000006 17 overflow 0 1020 0 0      \
+]
+
+do_execsql_test stat-4.1 {
+  CREATE TABLE t5(x);
+  CREATE INDEX i5 ON t5(x);
+  SELECT * FROM stat WHERE name = 't5' OR name = 'i5';
+} [list  \
+  i5 / 5 leaf 0 0 1016 0 \
+  t5 / 4 leaf 0 0 1016 0 \
+]
+
+db close
+file delete -force test.db
+sqlite3 db test.db
+register_dbstat_vtab db
+breakpoint
+do_execsql_test stat-5.1 {
+  CREATE VIRTUAL TABLE temp.stat USING dbstat;
+  CREATE TABLE t1(x);
+  INSERT INTO t1 VALUES(zeroblob(1513));
+  INSERT INTO t1 VALUES(zeroblob(1514));
+  SELECT * FROM stat WHERE name = 't1';
+} [list \
+  t1 / 2 leaf 2 993 5 1517                \
+  t1 /000+000000 3 overflow 0 1020 0 0    \
+  t1 /001+000000 4 overflow 0 1020 0 0    \
+]
+
+finish_test