mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-29 08:01:23 +03:00
Add a single-argument form to the CARRAY table-valued function, with
content bound using the sqlite3_carray_bind() interface that is included with the extension. FossilOrigin-Name: 7b229cb1202be203a87b8f47d284313f357deb1e6dfeb94bba7b46744c33512e
This commit is contained in:
100
test/carray01.test
Normal file
100
test/carray01.test
Normal file
@ -0,0 +1,100 @@
|
||||
# 2020-11-17
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
#***********************************************************************
|
||||
#
|
||||
# This file implements tests for CARRAY extension
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
set testprefix carray01
|
||||
|
||||
ifcapable !vtab {
|
||||
finish_test
|
||||
return
|
||||
}
|
||||
load_static_extension db carray
|
||||
|
||||
# Parameter $stmt must be a prepared statement created using
|
||||
# the sqlite3_prepare_v2 command and with parameters fullly bound.
|
||||
# This routine simply runs the statement, gathers the result, and
|
||||
# returns a list containing the result.
|
||||
#
|
||||
# If the optional second argument is true, then the stmt is finalized
|
||||
# after it is run.
|
||||
#
|
||||
proc run_stmt {stmt {finalizeFlag 0}} {
|
||||
set r {}
|
||||
while {[sqlite3_step $stmt]=="SQLITE_ROW"} {
|
||||
for {set i 0} {$i<[sqlite3_data_count $stmt]} {incr i} {
|
||||
lappend r [sqlite3_column_text $stmt $i]
|
||||
}
|
||||
}
|
||||
if {$finalizeFlag} {
|
||||
sqlite3_finalize $stmt
|
||||
} else {
|
||||
sqlite3_reset $stmt
|
||||
}
|
||||
return $r
|
||||
}
|
||||
|
||||
do_test 100 {
|
||||
set STMT [sqlite3_prepare_v2 db {SELECT 5 IN carray(?3)} -1]
|
||||
sqlite3_carray_bind $STMT 3 1 2 3 4 5 6 7
|
||||
run_stmt $STMT 0
|
||||
} {1}
|
||||
do_test 101 {
|
||||
sqlite3_carray_bind -static $STMT 3 1 2 3 4 5 6 7
|
||||
run_stmt $STMT 0
|
||||
} {1}
|
||||
do_test 110 {
|
||||
sqlite3_carray_bind $STMT 3 1 2 3 4 6 7
|
||||
run_stmt $STMT 0
|
||||
} {0}
|
||||
do_test 120 {
|
||||
sqlite3_carray_bind -int64 $STMT 3 1 2 3 4 5 6 7
|
||||
run_stmt $STMT 0
|
||||
} {1}
|
||||
do_test 130 {
|
||||
sqlite3_carray_bind -int64 $STMT 3 1 2 3 4 6 7
|
||||
run_stmt $STMT 0
|
||||
} {0}
|
||||
do_test 131 {
|
||||
sqlite3_carray_bind -int64 -static $STMT 3 1 2 3 4 6 7
|
||||
run_stmt $STMT 0
|
||||
} {0}
|
||||
do_test 140 {
|
||||
sqlite3_carray_bind -double $STMT 3 1 2 3 4 5 6 7
|
||||
run_stmt $STMT 0
|
||||
} {1}
|
||||
do_test 150 {
|
||||
sqlite3_carray_bind -double $STMT 3 1 2 3 4 6 7
|
||||
run_stmt $STMT 0
|
||||
} {0}
|
||||
do_test 160 {
|
||||
sqlite3_carray_bind -double $STMT 3 1 2 3 4 5 6 7
|
||||
run_stmt $STMT 0
|
||||
} {1}
|
||||
do_test 170 {
|
||||
sqlite3_carray_bind -text -static $STMT 3 1 2 3 4 6 7
|
||||
run_stmt $STMT 0
|
||||
} {0}
|
||||
do_test 180 {
|
||||
sqlite3_carray_bind -text -transient $STMT 3 1 2 3 4 5 6 7
|
||||
run_stmt $STMT 0
|
||||
} {0}
|
||||
do_test 190 {
|
||||
sqlite3_carray_bind $STMT 3
|
||||
run_stmt $STMT 0
|
||||
} {0}
|
||||
|
||||
sqlite3_finalize $STMT
|
||||
|
||||
finish_test
|
Reference in New Issue
Block a user