/ Check-in [bf4fc088]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix test_stat.c so that it does not cause compilation errors if SQLITE_OMIT_VIRTUALTABLE is defined.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: bf4fc0888705108aab997e1cb491fc7f9c64c443
User & Date: dan 2010-07-12 18:12:41
Context
2010-07-12
20:46
Updates to comments and code organization to reflect changes in os_unix.c; Updated winShmLock() with logic changes from unixShmLock(); Modified IO error returns in winShmMap() to match those in unixShmMap(); check-in: b73fe275 user: shaneh tags: trunk
18:12
Fix test_stat.c so that it does not cause compilation errors if SQLITE_OMIT_VIRTUALTABLE is defined. check-in: bf4fc088 user: dan tags: trunk
16:47
Fix makefiles so that they build sqlite3_analyzer again. Tweaks to comments in test_stat.c. Fix tclsqlite.c to build the sqlite3_analyzer again. check-in: e6cd1545 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/test_stat.c.

    16     16   ** information from an SQLite database in order to implement the
    17     17   ** "sqlite3_analyzer" utility.  See the ../tool/spaceanal.tcl script
    18     18   ** for an example implementation.
    19     19   */
    20     20   
    21     21   #include "sqliteInt.h"
    22     22   
           23  +#ifndef SQLITE_OMIT_VIRTUALTABLE
           24  +
    23     25   /*
    24     26   ** Page paths:
    25     27   ** 
    26     28   **   The value of the 'path' column describes the path taken from the 
    27     29   **   root-node of the b-tree structure to each page. The value of the 
    28     30   **   root-node path is '/'.
    29     31   **
................................................................................
   561    563       0,                            /* xRollback */
   562    564       0,                            /* xFindMethod */
   563    565       0,                            /* xRename */
   564    566     };
   565    567     sqlite3_create_module(db, "dbstat", &dbstat_module, 0);
   566    568     return SQLITE_OK;
   567    569   }
          570  +
          571  +#endif
   568    572   
   569    573   #ifdef SQLITE_TEST
   570    574   #include <tcl.h>
   571    575   
   572    576   static int test_dbstat(
   573    577     void *clientData,
   574    578     Tcl_Interp *interp,

Added test/stat.test.

            1  +# 2010 July 09
            2  +#
            3  +# The author disclaims copyright to this source code.  In place of
            4  +# a legal notice, here is a blessing:
            5  +#
            6  +#    May you do good and not evil.
            7  +#    May you find forgiveness for yourself and forgive others.
            8  +#    May you share freely, never taking more than you give.
            9  +#
           10  +#***********************************************************************
           11  +# This file implements regression tests for SQLite library.  The
           12  +# focus of this file is testing the SELECT statement.
           13  +#
           14  +
           15  +set testdir [file dirname $argv0]
           16  +source $testdir/tester.tcl
           17  +
           18  +ifcapable !vtab {
           19  +  finish_test
           20  +  return
           21  +}
           22  +
           23  +
           24  +set ::asc 1
           25  +proc a_string {n} { string range [string repeat [incr ::asc]. $n] 1 $n }
           26  +db func a_string a_string
           27  +
           28  +register_dbstat_vtab db
           29  +do_execsql_test stat-0.0 {
           30  +  CREATE VIRTUAL TABLE temp.stat USING dbstat;
           31  +  SELECT * FROM stat;
           32  +} {}
           33  +do_execsql_test stat-0.1 {
           34  +  PRAGMA journal_mode = WAL;
           35  +  PRAGMA journal_mode = delete;
           36  +  SELECT * FROM stat;
           37  +} {wal delete sqlite_master / 1 leaf 0 0 916 0}
           38  +
           39  +do_test stat-1.0 {
           40  +  execsql {
           41  +    CREATE TABLE t1(a, b);
           42  +    CREATE INDEX i1 ON t1(b);
           43  +    INSERT INTO t1 VALUES(1, 2);
           44  +    INSERT INTO t1 VALUES(3, 4);
           45  +  }
           46  +} {}
           47  +do_test stat-1.1 {
           48  +  execsql {
           49  +    SELECT * FROM stat WHERE name = 't1';
           50  +  }
           51  +} {t1 / 2 leaf 2 10 998 5}
           52  +do_test stat-1.2 {
           53  +  execsql {
           54  +    SELECT * FROM stat WHERE name = 'i1';
           55  +  }
           56  +} {i1 / 3 leaf 2 10 1000 5}
           57  +do_test stat-1.3 {
           58  +  execsql {
           59  +    SELECT * FROM stat WHERE name = 'sqlite_master';
           60  +  }
           61  +} {sqlite_master / 1 leaf 2 77 831 40}
           62  +do_test stat-1.4 {
           63  +  execsql {
           64  +    DROP TABLE t1;
           65  +  }
           66  +} {}
           67  +
           68  +do_execsql_test stat-2.1 {
           69  +  CREATE TABLE t3(a PRIMARY KEY, b);
           70  +  INSERT INTO t3 VALUES(a_string(111), a_string(222));
           71  +  INSERT INTO t3 SELECT a_string(111+rowid), a_string(222+rowid) FROM t3;
           72  +  INSERT INTO t3 SELECT a_string(111+rowid), a_string(222+rowid) FROM t3;
           73  +  INSERT INTO t3 SELECT a_string(111+rowid), a_string(222+rowid) FROM t3;
           74  +  INSERT INTO t3 SELECT a_string(111+rowid), a_string(222+rowid) FROM t3;
           75  +  INSERT INTO t3 SELECT a_string(111+rowid), a_string(222+rowid) FROM t3;
           76  +  SELECT * FROM stat WHERE name != 'sqlite_master';
           77  +} [list \
           78  +  sqlite_autoindex_t3_1 / 3 internal 3 368 623 125       \
           79  +  sqlite_autoindex_t3_1 /000/ 8 leaf 8 946 46 123        \
           80  +  sqlite_autoindex_t3_1 /001/ 9 leaf 8 988 2 131         \
           81  +  sqlite_autoindex_t3_1 /002/ 15 leaf 7 857 137 132      \
           82  +  sqlite_autoindex_t3_1 /003/ 20 leaf 6 739 257 129      \
           83  +  t3 / 2 internal 15 0 907 0                             \
           84  +  t3 /000/ 4 leaf 2 678 328 340                          \
           85  +  t3 /001/ 5 leaf 2 682 324 342                          \
           86  +  t3 /002/ 6 leaf 2 682 324 342                          \
           87  +  t3 /003/ 7 leaf 2 690 316 346                          \
           88  +  t3 /004/ 10 leaf 2 682 324 342                         \
           89  +  t3 /005/ 11 leaf 2 690 316 346                         \
           90  +  t3 /006/ 12 leaf 2 698 308 350                         \
           91  +  t3 /007/ 13 leaf 2 706 300 354                         \
           92  +  t3 /008/ 14 leaf 2 682 324 342                         \
           93  +  t3 /009/ 16 leaf 2 690 316 346                         \
           94  +  t3 /00a/ 17 leaf 2 698 308 350                         \
           95  +  t3 /00b/ 18 leaf 2 706 300 354                         \
           96  +  t3 /00c/ 19 leaf 2 714 292 358                         \
           97  +  t3 /00d/ 21 leaf 2 722 284 362                         \
           98  +  t3 /00e/ 22 leaf 2 730 276 366                         \
           99  +  t3 /00f/ 23 leaf 2 738 268 370                         \
          100  +]
          101  +do_execsql_test stat-2.2 { DROP TABLE t3 } {}
          102  +
          103  +do_execsql_test stat-3.1 {
          104  +  CREATE TABLE t4(x);
          105  +  CREATE INDEX i4 ON t4(x);
          106  +  INSERT INTO t4 VALUES(a_string(7777));
          107  +  SELECT * FROM stat WHERE name != 'sqlite_master';
          108  +} [list \
          109  +  i4 / 3 leaf 1 103 905 7782                 \
          110  +  i4 /000+000000 9 overflow 0 1020 0 0       \
          111  +  i4 /000+000001 10 overflow 0 1020 0 0      \
          112  +  i4 /000+000002 11 overflow 0 1020 0 0      \
          113  +  i4 /000+000003 12 overflow 0 1020 0 0      \
          114  +  i4 /000+000004 13 overflow 0 1020 0 0      \
          115  +  i4 /000+000005 14 overflow 0 1020 0 0      \
          116  +  i4 /000+000006 15 overflow 0 1020 0 0      \
          117  +  i4 /000+000007 16 overflow 0 539 481 0     \
          118  +  t4 / 2 leaf 1 640 367 7780                 \
          119  +  t4 /000+000000 22 overflow 0 1020 0 0      \
          120  +  t4 /000+000001 23 overflow 0 1020 0 0      \
          121  +  t4 /000+000002 21 overflow 0 1020 0 0      \
          122  +  t4 /000+000003 20 overflow 0 1020 0 0      \
          123  +  t4 /000+000004 19 overflow 0 1020 0 0      \
          124  +  t4 /000+000005 18 overflow 0 1020 0 0      \
          125  +  t4 /000+000006 17 overflow 0 1020 0 0      \
          126  +]
          127  +
          128  +do_execsql_test stat-4.1 {
          129  +  CREATE TABLE t5(x);
          130  +  CREATE INDEX i5 ON t5(x);
          131  +  SELECT * FROM stat WHERE name = 't5' OR name = 'i5';
          132  +} [list  \
          133  +  i5 / 5 leaf 0 0 1016 0 \
          134  +  t5 / 4 leaf 0 0 1016 0 \
          135  +]
          136  +
          137  +db close
          138  +file delete -force test.db
          139  +sqlite3 db test.db
          140  +register_dbstat_vtab db
          141  +breakpoint
          142  +do_execsql_test stat-5.1 {
          143  +  CREATE VIRTUAL TABLE temp.stat USING dbstat;
          144  +  CREATE TABLE t1(x);
          145  +  INSERT INTO t1 VALUES(zeroblob(1513));
          146  +  INSERT INTO t1 VALUES(zeroblob(1514));
          147  +  SELECT * FROM stat WHERE name = 't1';
          148  +} [list \
          149  +  t1 / 2 leaf 2 993 5 1517                \
          150  +  t1 /000+000000 3 overflow 0 1020 0 0    \
          151  +  t1 /001+000000 4 overflow 0 1020 0 0    \
          152  +]
          153  +
          154  +finish_test