SQLite

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 Unified Diffs Ignore Whitespace Patch

Added test/stmtvtab1.test.































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# 2017-06-29
#
# 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.
#
#***********************************************************************
#
# Testing of the STMT virtual table.
#
# This also validates the SQLITE_STMTSTATUS_REPREPARE and
# SQLITE_STMTSTATUS_RUN values for sqlite3_stmt_status().
#

set testdir [file dirname $argv0]
source $testdir/tester.tcl

ifcapable !stmtvtab {
  finish_test
  return
}

db cache size 20
unset -nocomplain x y z
set x giraffe
set y mango
set z alabama
do_execsql_test stmtvtab1-100 {
  CREATE TABLE t1(a,b,c);
  INSERT INTO t1 VALUES($a,$b,$c);
  CREATE INDEX t1a ON t1(a);
  SELECT run, sql FROM stmt ORDER BY 1;
} {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);}}
set x neon
set y event
set z future
do_execsql_test stmtvtab1-110 {
  INSERT INTO t1 VALUES($a,$b,$c);
  SELECT reprep,run,SQL FROM stmt WHERE sql LIKE '%INSERT%' AND NOT busy;
} {1 2 {INSERT INTO t1 VALUES($a,$b,$c);}}
set x network
set y fit
set z metal
do_execsql_test stmtvtab1-120 {
  INSERT INTO t1 VALUES($a,$b,$c);
  SELECT reprep,run,SQL FROM stmt WHERE sql LIKE '%INSERT%' AND NOT busy;
} {1 3 {INSERT INTO t1 VALUES($a,$b,$c);}}
set x history
set y detail
set z grace
do_execsql_test stmtvtab1-130 {
  CREATE INDEX t1b ON t1(b);
  INSERT INTO t1 VALUES($a,$b,$c);
  SELECT reprep,run,SQL FROM stmt WHERE sql LIKE '%INSERT%' AND NOT busy;
} {2 4 {INSERT INTO t1 VALUES($a,$b,$c);}}

# All statements are still in cache
#
do_execsql_test stmtvtab1-140 {
  SELECT count(*) FROM stmt WHERE NOT busy;
} {6}

# None of the prepared statements should use more than a couple thousand
# bytes of memory
#
#db eval {SELECT mem, sql FROM stmt} {puts [format {%5d %s} $mem $sql]}
do_execsql_test stmtvtab1-150 {
  SELECT count(*) FROM stmt WHERE mem>5000;
} {0}

# Flushing the cache clears all of the prepared statements.
#
db cache flush
do_execsql_test stmtvtab1-160 {
  SELECT * FROM stmt WHERE NOT busy;
} {}