diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 14:07:11 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 14:07:11 +0000 |
commit | 63847496f14c813a5d80efd5b7de0f1294ffe1e3 (patch) | |
tree | 01c7571c7c762ceee70638549a99834fdd7c411b /test/bind2.test | |
parent | Initial commit. (diff) | |
download | sqlite3-63847496f14c813a5d80efd5b7de0f1294ffe1e3.tar.xz sqlite3-63847496f14c813a5d80efd5b7de0f1294ffe1e3.zip |
Adding upstream version 3.45.1.upstream/3.45.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test/bind2.test')
-rw-r--r-- | test/bind2.test | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/test/bind2.test b/test/bind2.test new file mode 100644 index 0000000..1ebf35c --- /dev/null +++ b/test/bind2.test @@ -0,0 +1,63 @@ +# 2022 Feb 10 +# +# 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. +# +#*********************************************************************** +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl +set testprefix bind2 + + +# Test that using bind_value() on a REAL sqlite3_value that was stored +# as an INTEGER works properly. +# +# 1.1: An IntReal value read from a table, +# 1.2: IntReal values obtained via the sqlite3_preupdate_old|new() +# interfaces. +# +do_execsql_test 1.0 { + CREATE TABLE t1(a REAL); + INSERT INTO t1 VALUES(42.0); + SELECT * FROM t1; +} {42.0} + +do_test 1.1 { + set stmt [sqlite3_prepare db "SELECT ?" -1 tail] + sqlite3_bind_value_from_select $stmt 1 "SELECT a FROM t1" + sqlite3_step $stmt + sqlite3_column_text $stmt 0 +} {42.0} +sqlite3_finalize $stmt + +ifcapable !preupdate { + finish_test + return +} + +proc preup {args} { + set stmt [sqlite3_prepare db "SELECT ?" -1 tail] + sqlite3_bind_value_from_preupdate $stmt 1 old 0 + sqlite3_step $stmt + lappend ::reslist [sqlite3_column_text $stmt 0] + sqlite3_reset $stmt + sqlite3_bind_value_from_preupdate $stmt 1 new 0 + sqlite3_step $stmt + lappend ::reslist [sqlite3_column_text $stmt 0] + sqlite3_finalize $stmt +} +db preupdate hook preup + +do_test 1.2 { + set ::reslist [list] + execsql { UPDATE t1 SET a=43; } + set ::reslist +} {42.0 43.0} + +finish_test |