From 8f3e1ce80995c42a200db98fbfe02e4a60771c26 Mon Sep 17 00:00:00 2001 From: Steve Bennett Date: Sun, 10 Jan 2021 13:12:36 +1000 Subject: package: add ABI version checking jim.h now includes JIM_ABI_VERSION that should be incremented whenever the ABI changes. Then all loadable modules should call Jim_CheckAbiVersion() to make sure they are loaded against the correct version. Add Jim_PackageProvideCheck() that does both Jim_CheckAbiVersion() and Jim_PackageProvide() to simplify the implementation of loadable extensions. Also rename the "big" sqlite3 extension to just sqlite to avoid a naming conflict with the smaller jim-sqlite3 extension. Signed-off-by: Steve Bennett --- sqlite3/test-sqlite.tcl | 51 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 sqlite3/test-sqlite.tcl (limited to 'sqlite3/test-sqlite.tcl') diff --git a/sqlite3/test-sqlite.tcl b/sqlite3/test-sqlite.tcl new file mode 100644 index 0000000..82cce40 --- /dev/null +++ b/sqlite3/test-sqlite.tcl @@ -0,0 +1,51 @@ +# A simple test of the "big" sqlite extension + +set auto_path [list . {*}$auto_path] + +package require sqlite + +# Create an in-memory database and add some data +sqlite db :memory: +db eval {CREATE TABLE history (type, time, value)} +foreach t [range 1 50] { + set temp [rand 100] + db eval {INSERT INTO history (type, time, value) VALUES ('temp', :t, :temp)} +} +foreach t [range 2 50 2] { + set v $([rand 200] / 10.0 + 5) + db eval {INSERT INTO history (type, time, value) VALUES ('voltage', :t, :v)} +} + +# Output some data in SVG format. +puts "\nSVG Example\n" + +set points {} +db eval {SELECT time,value FROM history + WHERE (time >= 10 and time <= 30) and type = 'voltage' + ORDER BY time DESC} row { + lappend points $row(time),$row(value) +} +puts "" + +# And tabular format with a self outer join +puts "\nTabular Self Outer Join Example\n" + +proc showrow {args} { + puts [format "%-12s %-12s %-12s" {*}$args] +} + +showrow Time Temp Voltage +showrow ---- ---- ------- +db eval {SELECT * FROM (SELECT time, value AS temp FROM history WHERE type = 'temp') AS A + LEFT OUTER JOIN (SELECT time, value AS voltage FROM history WHERE type = 'voltage') AS B + USING (time) + WHERE time >= 10 AND time <= 30 + ORDER BY time} row { + showrow $row(time) $row(temp) $row(voltage) +} +set maxtemp [db eval {SELECT max(value) FROM history WHERE type = 'temp'}] +set maxvolt [db eval {SELECT max(value) AS maxvolt FROM history WHERE type = 'voltage'}] +showrow ---- ---- ------- +showrow max $maxtemp $maxvolt + +db close -- cgit v1.1