CoolFace
Modelpublic

AryaWu/sqlite

sourceHugging Faceupdated 9mo agoView on Hugging Face
0likes
stmtvtab1.test83 linesDownload Raw Back to test
1# 2017-06-292#3# The author disclaims copyright to this source code.  In place of4# 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 and15# SQLITE_STMTSTATUS_RUN values for sqlite3_stmt_status().16#17 18set testdir [file dirname $argv0]19source $testdir/tester.tcl20 21ifcapable !stmtvtab {22  finish_test23  return24}25 26db cache flush27db cache size 2028unset -nocomplain x y z29set x giraffe30set y mango31set z alabama32do_execsql_test stmtvtab1-100 {33  CREATE TABLE t1(a,b,c);34  INSERT INTO t1 VALUES($a,$b,$c);35  CREATE INDEX t1a ON t1(a);36  SELECT run, sql FROM sqlite_stmt ORDER BY 1;37} {1 {SELECT run, sql FROM sqlite_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);}}38set x neon39set y event40set z future41do_execsql_test stmtvtab1-110 {42  INSERT INTO t1 VALUES($a,$b,$c);43  SELECT reprep,run,SQL FROM sqlite_stmt WHERE sql LIKE '%INSERT%' AND NOT busy;44} {1 2 {INSERT INTO t1 VALUES($a,$b,$c);}}45set x network46set y fit47set z metal48do_execsql_test stmtvtab1-120 {49  INSERT INTO t1 VALUES($a,$b,$c);50  SELECT reprep,run,SQL FROM sqlite_stmt WHERE sql LIKE '%INSERT%' AND NOT busy;51} {1 3 {INSERT INTO t1 VALUES($a,$b,$c);}}52set x history53set y detail54set z grace55do_execsql_test stmtvtab1-130 {56  CREATE INDEX t1b ON t1(b);57  INSERT INTO t1 VALUES($a,$b,$c);58  SELECT reprep,run,SQL FROM sqlite_stmt WHERE sql LIKE '%INSERT%' AND NOT busy;59} {2 4 {INSERT INTO t1 VALUES($a,$b,$c);}}60 61# All statements are still in cache62#63do_execsql_test stmtvtab1-140 {64  SELECT count(*) FROM sqlite_stmt WHERE NOT busy;65} {6}66 67# None of the prepared statements should use more than a couple thousand68# bytes of memory69#70#db eval {SELECT mem, sql FROM sqlite_stmt} {puts [format {%5d %s} $mem $sql]}71do_execsql_test stmtvtab1-150 {72  SELECT count(*) FROM sqlite_stmt WHERE mem>5000;73} {0}74 75# Flushing the cache clears all of the prepared statements.76#77db cache flush78do_execsql_test stmtvtab1-160 {79  SELECT * FROM sqlite_stmt WHERE NOT busy;80} {}81 82finish_test83