/ Check-in [a26e17ee]
Login

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

Overview
Comment:Some simple tests for the STMT virtual table.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: a26e17ee56d3c019fc4772fcf95480b4515eea6cfc74c3d494be0d1941e49666
User & Date: drh 2017-06-29 20:31:01
Context
2017-06-29
21:11
Remove the ".explain" command from the ".help" output of the command-line shell, though keep the implementation around for backwards compatibility. check-in: 7782c04e user: drh tags: trunk
20:31
Some simple tests for the STMT virtual table. check-in: a26e17ee user: drh tags: trunk
20:23
Avoid reading or writing the 32 locking bytes at the end of the first meta-page of an LSM database. check-in: 3ed6877f user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Added test/stmtvtab1.test.

            1  +# 2017-06-29
            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  +#
           12  +# Testing of the STMT virtual table.
           13  +#
           14  +# This also validates the SQLITE_STMTSTATUS_REPREPARE and
           15  +# SQLITE_STMTSTATUS_RUN values for sqlite3_stmt_status().
           16  +#
           17  +
           18  +set testdir [file dirname $argv0]
           19  +source $testdir/tester.tcl
           20  +
           21  +ifcapable !stmtvtab {
           22  +  finish_test
           23  +  return
           24  +}
           25  +
           26  +db cache size 20
           27  +unset -nocomplain x y z
           28  +set x giraffe
           29  +set y mango
           30  +set z alabama
           31  +do_execsql_test stmtvtab1-100 {
           32  +  CREATE TABLE t1(a,b,c);
           33  +  INSERT INTO t1 VALUES($a,$b,$c);
           34  +  CREATE INDEX t1a ON t1(a);
           35  +  SELECT run, sql FROM stmt ORDER BY 1;
           36  +} {1 {SELECT run, sql FROM stmt ORDER BY 1;} 1 {CREATE INDEX t1a ON t1(a);} 1 {INSERT INTO t1 VALUES($a,$b,$c);} 1 {CREATE TABLE t1(a,b,c);}}
           37  +set x neon
           38  +set y event
           39  +set z future
           40  +do_execsql_test stmtvtab1-110 {
           41  +  INSERT INTO t1 VALUES($a,$b,$c);
           42  +  SELECT reprep,run,SQL FROM stmt WHERE sql LIKE '%INSERT%' AND NOT busy;
           43  +} {1 2 {INSERT INTO t1 VALUES($a,$b,$c);}}
           44  +set x network
           45  +set y fit
           46  +set z metal
           47  +do_execsql_test stmtvtab1-120 {
           48  +  INSERT INTO t1 VALUES($a,$b,$c);
           49  +  SELECT reprep,run,SQL FROM stmt WHERE sql LIKE '%INSERT%' AND NOT busy;
           50  +} {1 3 {INSERT INTO t1 VALUES($a,$b,$c);}}
           51  +set x history
           52  +set y detail
           53  +set z grace
           54  +do_execsql_test stmtvtab1-130 {
           55  +  CREATE INDEX t1b ON t1(b);
           56  +  INSERT INTO t1 VALUES($a,$b,$c);
           57  +  SELECT reprep,run,SQL FROM stmt WHERE sql LIKE '%INSERT%' AND NOT busy;
           58  +} {2 4 {INSERT INTO t1 VALUES($a,$b,$c);}}
           59  +
           60  +# All statements are still in cache
           61  +#
           62  +do_execsql_test stmtvtab1-140 {
           63  +  SELECT count(*) FROM stmt WHERE NOT busy;
           64  +} {6}
           65  +
           66  +# None of the prepared statements should use more than a couple thousand
           67  +# bytes of memory
           68  +#
           69  +#db eval {SELECT mem, sql FROM stmt} {puts [format {%5d %s} $mem $sql]}
           70  +do_execsql_test stmtvtab1-150 {
           71  +  SELECT count(*) FROM stmt WHERE mem>5000;
           72  +} {0}
           73  +
           74  +# Flushing the cache clears all of the prepared statements.
           75  +#
           76  +db cache flush
           77  +do_execsql_test stmtvtab1-160 {
           78  +  SELECT * FROM stmt WHERE NOT busy;
           79  +} {}