xref: /sqlite-3.40.0/test/bind.test (revision ff4fa772)
182a4851aSdrh# 2003 September 6
282a4851aSdrh#
382a4851aSdrh# The author disclaims copyright to this source code.  In place of
482a4851aSdrh# a legal notice, here is a blessing:
582a4851aSdrh#
682a4851aSdrh#    May you do good and not evil.
782a4851aSdrh#    May you find forgiveness for yourself and forgive others.
882a4851aSdrh#    May you share freely, never taking more than you give.
982a4851aSdrh#
1082a4851aSdrh#***********************************************************************
1182a4851aSdrh# This file implements regression tests for SQLite library.  The
1282a4851aSdrh# focus of this script testing the sqlite_bind API.
1382a4851aSdrh#
14257d9dc7Sdanielk1977# $Id: bind.test,v 1.48 2009/07/22 07:27:57 danielk1977 Exp $
1582a4851aSdrh#
1682a4851aSdrh
1782a4851aSdrhset testdir [file dirname $argv0]
1882a4851aSdrhsource $testdir/tester.tcl
1982a4851aSdrh
2017240fd9Sdanielk1977proc sqlite_step {stmt N VALS COLS} {
2117240fd9Sdanielk1977  upvar VALS vals
2217240fd9Sdanielk1977  upvar COLS cols
2317240fd9Sdanielk1977  set vals [list]
2417240fd9Sdanielk1977  set cols [list]
2517240fd9Sdanielk1977
2617240fd9Sdanielk1977  set rc [sqlite3_step $stmt]
2717240fd9Sdanielk1977  for {set i 0} {$i < [sqlite3_column_count $stmt]} {incr i} {
2817240fd9Sdanielk1977    lappend cols [sqlite3_column_name $stmt $i]
2917240fd9Sdanielk1977  }
3017240fd9Sdanielk1977  for {set i 0} {$i < [sqlite3_data_count $stmt]} {incr i} {
31eb2e176aSdrh    lappend vals [sqlite3_column_text $stmt $i]
3217240fd9Sdanielk1977  }
3317240fd9Sdanielk1977
3417240fd9Sdanielk1977  return $rc
3517240fd9Sdanielk1977}
3617240fd9Sdanielk1977
3782a4851aSdrhdo_test bind-1.1 {
38dddca286Sdrh  set DB [sqlite3_connection_pointer db]
392c6674cfSdrh  execsql {CREATE TABLE t1(a,b,c);}
402c6674cfSdrh  set VM [sqlite3_prepare $DB {INSERT INTO t1 VALUES(:1,?,:abc)} -1 TAIL]
4182a4851aSdrh  set TAIL
4282a4851aSdrh} {}
4375f6a032Sdrhdo_test bind-1.1.1 {
4475f6a032Sdrh  sqlite3_bind_parameter_count $VM
4575f6a032Sdrh} 3
46895d7472Sdrhdo_test bind-1.1.2 {
47895d7472Sdrh  sqlite3_bind_parameter_name $VM 1
482c6674cfSdrh} {:1}
49895d7472Sdrhdo_test bind-1.1.3 {
50895d7472Sdrh  sqlite3_bind_parameter_name $VM 2
51895d7472Sdrh} {}
52895d7472Sdrhdo_test bind-1.1.4 {
53895d7472Sdrh  sqlite3_bind_parameter_name $VM 3
542c6674cfSdrh} {:abc}
5582a4851aSdrhdo_test bind-1.2 {
5682a4851aSdrh  sqlite_step $VM N VALUES COLNAMES
5782a4851aSdrh} {SQLITE_DONE}
5882a4851aSdrhdo_test bind-1.3 {
5982a4851aSdrh  execsql {SELECT rowid, * FROM t1}
6082a4851aSdrh} {1 {} {} {}}
6182a4851aSdrhdo_test bind-1.4 {
62106bb236Sdanielk1977  sqlite3_reset $VM
6382a4851aSdrh  sqlite_bind $VM 1 {test value 1} normal
6482a4851aSdrh  sqlite_step $VM N VALUES COLNAMES
6582a4851aSdrh} SQLITE_DONE
6682a4851aSdrhdo_test bind-1.5 {
6782a4851aSdrh  execsql {SELECT rowid, * FROM t1}
6882a4851aSdrh} {1 {} {} {} 2 {test value 1} {} {}}
6982a4851aSdrhdo_test bind-1.6 {
70106bb236Sdanielk1977  sqlite3_reset $VM
7182a4851aSdrh  sqlite_bind $VM 3 {'test value 2'} normal
7282a4851aSdrh  sqlite_step $VM N VALUES COLNAMES
7382a4851aSdrh} SQLITE_DONE
7482a4851aSdrhdo_test bind-1.7 {
7582a4851aSdrh  execsql {SELECT rowid, * FROM t1}
7682a4851aSdrh} {1 {} {} {} 2 {test value 1} {} {} 3 {test value 1} {} {'test value 2'}}
7782a4851aSdrhdo_test bind-1.8 {
78106bb236Sdanielk1977  sqlite3_reset $VM
7982a4851aSdrh  set sqlite_static_bind_value 123
8082a4851aSdrh  sqlite_bind $VM 1 {} static
8182a4851aSdrh  sqlite_bind $VM 2 {abcdefg} normal
8282a4851aSdrh  sqlite_bind $VM 3 {} null
8382a4851aSdrh  execsql {DELETE FROM t1}
8482a4851aSdrh  sqlite_step $VM N VALUES COLNAMES
8582a4851aSdrh  execsql {SELECT rowid, * FROM t1}
8682a4851aSdrh} {1 123 abcdefg {}}
8782a4851aSdrhdo_test bind-1.9 {
88106bb236Sdanielk1977  sqlite3_reset $VM
8982a4851aSdrh  sqlite_bind $VM 1 {456} normal
9082a4851aSdrh  sqlite_step $VM N VALUES COLNAMES
9182a4851aSdrh  execsql {SELECT rowid, * FROM t1}
9282a4851aSdrh} {1 123 abcdefg {} 2 456 abcdefg {}}
9382a4851aSdrh
94fb45d8c5Sdrhdo_test bind-1.10 {
95fb45d8c5Sdrh   set rc [catch {
96fb45d8c5Sdrh     sqlite3_prepare db {INSERT INTO t1 VALUES($abc:123,?,:abc)} -1 TAIL
97fb45d8c5Sdrh   } msg]
98fb45d8c5Sdrh   lappend rc $msg
99fb45d8c5Sdrh} {1 {(1) near ":123": syntax error}}
100fb45d8c5Sdrhdo_test bind-1.11 {
101fb45d8c5Sdrh   set rc [catch {
102fb45d8c5Sdrh     sqlite3_prepare db {INSERT INTO t1 VALUES(@abc:xyz,?,:abc)} -1 TAIL
103fb45d8c5Sdrh   } msg]
104fb45d8c5Sdrh   lappend rc $msg
105fb45d8c5Sdrh} {1 {(1) near ":xyz": syntax error}}
106fb45d8c5Sdrh
10782a4851aSdrhdo_test bind-1.99 {
108106bb236Sdanielk1977  sqlite3_finalize $VM
1093cf86063Sdanielk1977} SQLITE_OK
11082a4851aSdrh
1116bf89570Sdrh# Prepare the statement in different ways depending on whether or not
1126bf89570Sdrh# the $var processing is compiled into the library.
1136bf89570Sdrh#
1146bf89570Sdrhifcapable {tclvar} {
11551e3d8e2Sdanielk1977  do_test bind-2.1 {
11651e3d8e2Sdanielk1977    execsql {
11751e3d8e2Sdanielk1977      DELETE FROM t1;
11851e3d8e2Sdanielk1977    }
119288d37f1Sdrh    set VM [sqlite3_prepare $DB {INSERT INTO t1 VALUES($one,$::two,$x(-z-))}\
12048e5aa27Sdrh            -1 TX]
1216bf89570Sdrh    set TX
12251e3d8e2Sdanielk1977  } {}
1236bf89570Sdrh  set v1 {$one}
1246bf89570Sdrh  set v2 {$::two}
125288d37f1Sdrh  set v3 {$x(-z-)}
1266bf89570Sdrh}
1276bf89570Sdrhifcapable {!tclvar} {
1286bf89570Sdrh  do_test bind-2.1 {
1296bf89570Sdrh    execsql {
1306bf89570Sdrh      DELETE FROM t1;
1316bf89570Sdrh    }
1326bf89570Sdrh    set VM [sqlite3_prepare $DB {INSERT INTO t1 VALUES(:one,:two,:_)} -1 TX]
1336bf89570Sdrh    set TX
1346bf89570Sdrh  } {}
1356bf89570Sdrh  set v1 {:one}
1366bf89570Sdrh  set v2 {:two}
1376bf89570Sdrh  set v3 {:_}
1386bf89570Sdrh}
1396bf89570Sdrh
140895d7472Sdrhdo_test bind-2.1.1 {
141895d7472Sdrh  sqlite3_bind_parameter_count $VM
142895d7472Sdrh} 3
143895d7472Sdrhdo_test bind-2.1.2 {
144895d7472Sdrh  sqlite3_bind_parameter_name $VM 1
1456bf89570Sdrh} $v1
146895d7472Sdrhdo_test bind-2.1.3 {
147895d7472Sdrh  sqlite3_bind_parameter_name $VM 2
1486bf89570Sdrh} $v2
149895d7472Sdrhdo_test bind-2.1.4 {
150895d7472Sdrh  sqlite3_bind_parameter_name $VM 3
1516bf89570Sdrh} $v3
152fa6bc000Sdrhdo_test bind-2.1.5 {
1536bf89570Sdrh  sqlite3_bind_parameter_index $VM $v1
154fa6bc000Sdrh} 1
155fa6bc000Sdrhdo_test bind-2.1.6 {
1566bf89570Sdrh  sqlite3_bind_parameter_index $VM $v2
157fa6bc000Sdrh} 2
158fa6bc000Sdrhdo_test bind-2.1.7 {
1596bf89570Sdrh  sqlite3_bind_parameter_index $VM $v3
160fa6bc000Sdrh} 3
161fa6bc000Sdrhdo_test bind-2.1.8 {
162fa6bc000Sdrh  sqlite3_bind_parameter_index $VM {:hi}
163fa6bc000Sdrh} 0
16451e3d8e2Sdanielk1977
16551e3d8e2Sdanielk1977# 32 bit Integers
16651e3d8e2Sdanielk1977do_test bind-2.2 {
167241db313Sdrh  sqlite3_bind_int $VM 1 123
168241db313Sdrh  sqlite3_bind_int $VM 2 456
169241db313Sdrh  sqlite3_bind_int $VM 3 789
17051e3d8e2Sdanielk1977  sqlite_step $VM N VALUES COLNAMES
171106bb236Sdanielk1977  sqlite3_reset $VM
17251e3d8e2Sdanielk1977  execsql {SELECT rowid, * FROM t1}
17351e3d8e2Sdanielk1977} {1 123 456 789}
17451e3d8e2Sdanielk1977do_test bind-2.3 {
175241db313Sdrh  sqlite3_bind_int $VM 2 -2000000000
176241db313Sdrh  sqlite3_bind_int $VM 3 2000000000
17751e3d8e2Sdanielk1977  sqlite_step $VM N VALUES COLNAMES
178106bb236Sdanielk1977  sqlite3_reset $VM
17951e3d8e2Sdanielk1977  execsql {SELECT rowid, * FROM t1}
18051e3d8e2Sdanielk1977} {1 123 456 789 2 123 -2000000000 2000000000}
18151e3d8e2Sdanielk1977do_test bind-2.4 {
18235bb9d02Sdanielk1977  execsql {SELECT typeof(a), typeof(b), typeof(c) FROM t1}
18335bb9d02Sdanielk1977} {integer integer integer integer integer integer}
18451e3d8e2Sdanielk1977do_test bind-2.5 {
18551e3d8e2Sdanielk1977  execsql {
18651e3d8e2Sdanielk1977    DELETE FROM t1;
18751e3d8e2Sdanielk1977  }
18851e3d8e2Sdanielk1977} {}
18951e3d8e2Sdanielk1977
19051e3d8e2Sdanielk1977# 64 bit Integers
19151e3d8e2Sdanielk1977do_test bind-3.1 {
19251e3d8e2Sdanielk1977  sqlite3_bind_int64 $VM 1 32
19351e3d8e2Sdanielk1977  sqlite3_bind_int64 $VM 2 -2000000000000
19451e3d8e2Sdanielk1977  sqlite3_bind_int64 $VM 3 2000000000000
19551e3d8e2Sdanielk1977  sqlite_step $VM N VALUES COLNAMES
196106bb236Sdanielk1977  sqlite3_reset $VM
19751e3d8e2Sdanielk1977  execsql {SELECT rowid, * FROM t1}
19851e3d8e2Sdanielk1977} {1 32 -2000000000000 2000000000000}
19951e3d8e2Sdanielk1977do_test bind-3.2 {
20035bb9d02Sdanielk1977  execsql {SELECT typeof(a), typeof(b), typeof(c) FROM t1}
20135bb9d02Sdanielk1977} {integer integer integer}
20251e3d8e2Sdanielk1977do_test bind-3.3 {
20351e3d8e2Sdanielk1977  execsql {
20451e3d8e2Sdanielk1977    DELETE FROM t1;
20551e3d8e2Sdanielk1977  }
20651e3d8e2Sdanielk1977} {}
20751e3d8e2Sdanielk1977
20851e3d8e2Sdanielk1977# Doubles
20951e3d8e2Sdanielk1977do_test bind-4.1 {
21051e3d8e2Sdanielk1977  sqlite3_bind_double $VM 1 1234.1234
21151e3d8e2Sdanielk1977  sqlite3_bind_double $VM 2 0.00001
21251e3d8e2Sdanielk1977  sqlite3_bind_double $VM 3 123456789
21351e3d8e2Sdanielk1977  sqlite_step $VM N VALUES COLNAMES
214106bb236Sdanielk1977  sqlite3_reset $VM
215ab34b8f6Sdrh  set x [execsql {SELECT rowid, * FROM t1}]
216ab34b8f6Sdrh  regsub {1e-005} $x {1e-05} y
217ab34b8f6Sdrh  set y
21892febd92Sdrh} {1 1234.1234 1e-05 123456789.0}
21951e3d8e2Sdanielk1977do_test bind-4.2 {
22035bb9d02Sdanielk1977  execsql {SELECT typeof(a), typeof(b), typeof(c) FROM t1}
22135bb9d02Sdanielk1977} {real real real}
22251e3d8e2Sdanielk1977do_test bind-4.3 {
22351e3d8e2Sdanielk1977  execsql {
22451e3d8e2Sdanielk1977    DELETE FROM t1;
22551e3d8e2Sdanielk1977  }
22651e3d8e2Sdanielk1977} {}
22753c14021Sdrhdo_test bind-4.4 {
22853c14021Sdrh  sqlite3_bind_double $VM 1 NaN
22953c14021Sdrh  sqlite3_bind_double $VM 2 1e300
23053c14021Sdrh  sqlite3_bind_double $VM 3 -1e-300
23153c14021Sdrh  sqlite_step $VM N VALUES COLNAMES
23253c14021Sdrh  sqlite3_reset $VM
23353c14021Sdrh  set x [execsql {SELECT rowid, * FROM t1}]
23453c14021Sdrh  regsub {1e-005} $x {1e-05} y
23553c14021Sdrh  set y
23653c14021Sdrh} {1 {} 1e+300 -1e-300}
23753c14021Sdrhdo_test bind-4.5 {
23853c14021Sdrh  execsql {SELECT typeof(a), typeof(b), typeof(c) FROM t1}
23953c14021Sdrh} {null real real}
24053c14021Sdrhdo_test bind-4.6 {
24153c14021Sdrh  execsql {
24253c14021Sdrh    DELETE FROM t1;
24353c14021Sdrh  }
24453c14021Sdrh} {}
24551e3d8e2Sdanielk1977
24651e3d8e2Sdanielk1977# NULL
24751e3d8e2Sdanielk1977do_test bind-5.1 {
24851e3d8e2Sdanielk1977  sqlite3_bind_null $VM 1
24951e3d8e2Sdanielk1977  sqlite3_bind_null $VM 2
25051e3d8e2Sdanielk1977  sqlite3_bind_null $VM 3
25151e3d8e2Sdanielk1977  sqlite_step $VM N VALUES COLNAMES
252106bb236Sdanielk1977  sqlite3_reset $VM
25351e3d8e2Sdanielk1977  execsql {SELECT rowid, * FROM t1}
25451e3d8e2Sdanielk1977} {1 {} {} {}}
25551e3d8e2Sdanielk1977do_test bind-5.2 {
25635bb9d02Sdanielk1977  execsql {SELECT typeof(a), typeof(b), typeof(c) FROM t1}
25735bb9d02Sdanielk1977} {null null null}
25851e3d8e2Sdanielk1977do_test bind-5.3 {
25951e3d8e2Sdanielk1977  execsql {
26051e3d8e2Sdanielk1977    DELETE FROM t1;
26151e3d8e2Sdanielk1977  }
26251e3d8e2Sdanielk1977} {}
26351e3d8e2Sdanielk1977
26451e3d8e2Sdanielk1977# UTF-8 text
26551e3d8e2Sdanielk1977do_test bind-6.1 {
26651e3d8e2Sdanielk1977  sqlite3_bind_text $VM 1 hellothere 5
267c572ef7fSdanielk1977  sqlite3_bind_text $VM 2 ".." 1
26810dfbbb5Sdrh  sqlite3_bind_text $VM 3 world\000 -1
26951e3d8e2Sdanielk1977  sqlite_step $VM N VALUES COLNAMES
270106bb236Sdanielk1977  sqlite3_reset $VM
27151e3d8e2Sdanielk1977  execsql {SELECT rowid, * FROM t1}
27251e3d8e2Sdanielk1977} {1 hello . world}
27351e3d8e2Sdanielk1977do_test bind-6.2 {
27435bb9d02Sdanielk1977  execsql {SELECT typeof(a), typeof(b), typeof(c) FROM t1}
27535bb9d02Sdanielk1977} {text text text}
27651e3d8e2Sdanielk1977do_test bind-6.3 {
27751e3d8e2Sdanielk1977  execsql {
27851e3d8e2Sdanielk1977    DELETE FROM t1;
27951e3d8e2Sdanielk1977  }
28051e3d8e2Sdanielk1977} {}
28151e3d8e2Sdanielk1977
28210dfbbb5Sdrh# Make sure zeros in a string work.
28310dfbbb5Sdrh#
28410dfbbb5Sdrhdo_test bind-6.4 {
28510dfbbb5Sdrh  db eval {DELETE FROM t1}
28610dfbbb5Sdrh  sqlite3_bind_text $VM 1 hello\000there\000 12
28710dfbbb5Sdrh  sqlite3_bind_text $VM 2 hello\000there\000 11
28810dfbbb5Sdrh  sqlite3_bind_text $VM 3 hello\000there\000 -1
28910dfbbb5Sdrh  sqlite_step $VM N VALUES COLNAMES
29010dfbbb5Sdrh  sqlite3_reset $VM
29110dfbbb5Sdrh  execsql {SELECT * FROM t1}
29210dfbbb5Sdrh} {hello hello hello}
29378ddb7ceSdrhset enc [db eval {PRAGMA encoding}]
294257d9dc7Sdanielk1977if {$enc=="UTF-8" || $enc==""} {
29578ddb7ceSdrh  do_test bind-6.5 {
29678ddb7ceSdrh    execsql {SELECT  hex(a), hex(b), hex(c) FROM t1}
29778ddb7ceSdrh  } {68656C6C6F00746865726500 68656C6C6F007468657265 68656C6C6F}
29878ddb7ceSdrh} elseif {$enc=="UTF-16le"} {
29978ddb7ceSdrh  do_test bind-6.5 {
30078ddb7ceSdrh    execsql {SELECT  hex(a), hex(b), hex(c) FROM t1}
30178ddb7ceSdrh  } {680065006C006C006F000000740068006500720065000000 680065006C006C006F00000074006800650072006500 680065006C006C006F00}
30278ddb7ceSdrh} elseif {$enc=="UTF-16be"} {
30378ddb7ceSdrh  do_test bind-6.5 {
30478ddb7ceSdrh    execsql {SELECT  hex(a), hex(b), hex(c) FROM t1}
30578ddb7ceSdrh  } {00680065006C006C006F0000007400680065007200650000 00680065006C006C006F000000740068006500720065 00680065006C006C006F}
30678ddb7ceSdrh} else {
30778ddb7ceSdrh  do_test bind-6.5 {
30878ddb7ceSdrh    set "Unknown database encoding: $::enc"
30978ddb7ceSdrh  } {}
31078ddb7ceSdrh}
31110dfbbb5Sdrhdo_test bind-6.6 {
31210dfbbb5Sdrh  execsql {SELECT typeof(a), typeof(b), typeof(c) FROM t1}
31310dfbbb5Sdrh} {text text text}
31410dfbbb5Sdrhdo_test bind-6.7 {
31510dfbbb5Sdrh  execsql {
31610dfbbb5Sdrh    DELETE FROM t1;
31710dfbbb5Sdrh  }
31810dfbbb5Sdrh} {}
31910dfbbb5Sdrh
32051e3d8e2Sdanielk1977# UTF-16 text
3216c62608fSdrhifcapable {utf16} {
32251e3d8e2Sdanielk1977  do_test bind-7.1 {
32351e3d8e2Sdanielk1977    sqlite3_bind_text16 $VM 1 [encoding convertto unicode hellothere] 10
32451e3d8e2Sdanielk1977    sqlite3_bind_text16 $VM 2 [encoding convertto unicode ""] 0
32551e3d8e2Sdanielk1977    sqlite3_bind_text16 $VM 3 [encoding convertto unicode world] 10
32651e3d8e2Sdanielk1977    sqlite_step $VM N VALUES COLNAMES
327106bb236Sdanielk1977    sqlite3_reset $VM
32851e3d8e2Sdanielk1977    execsql {SELECT rowid, * FROM t1}
32951e3d8e2Sdanielk1977  } {1 hello {} world}
33051e3d8e2Sdanielk1977  do_test bind-7.2 {
33135bb9d02Sdanielk1977    execsql {SELECT typeof(a), typeof(b), typeof(c) FROM t1}
33235bb9d02Sdanielk1977  } {text text text}
33351e3d8e2Sdanielk1977  do_test bind-7.3 {
33410dfbbb5Sdrh    db eval {DELETE FROM t1}
33510dfbbb5Sdrh    sqlite3_bind_text16 $VM 1 [encoding convertto unicode hi\000yall\000] 16
33610dfbbb5Sdrh    sqlite3_bind_text16 $VM 2 [encoding convertto unicode hi\000yall\000] 14
33710dfbbb5Sdrh    sqlite3_bind_text16 $VM 3 [encoding convertto unicode hi\000yall\000] -1
33810dfbbb5Sdrh    sqlite_step $VM N VALUES COLNAMES
33910dfbbb5Sdrh    sqlite3_reset $VM
34010dfbbb5Sdrh    execsql {SELECT * FROM t1}
34110dfbbb5Sdrh  } {hi hi hi}
34278ddb7ceSdrh  if {$enc=="UTF-8"} {
34310dfbbb5Sdrh    do_test bind-7.4 {
34410dfbbb5Sdrh      execsql {SELECT hex(a), hex(b), hex(c) FROM t1}
34510dfbbb5Sdrh    } {68690079616C6C00 68690079616C6C 6869}
34678ddb7ceSdrh  } elseif {$enc=="UTF-16le"} {
34778ddb7ceSdrh    do_test bind-7.4 {
34878ddb7ceSdrh      execsql {SELECT hex(a), hex(b), hex(c) FROM t1}
34978ddb7ceSdrh    } {680069000000790061006C006C000000 680069000000790061006C006C00 68006900}
35078ddb7ceSdrh  } elseif {$enc=="UTF-16be"} {
35178ddb7ceSdrh    do_test bind-7.4 {
35278ddb7ceSdrh      execsql {SELECT hex(a), hex(b), hex(c) FROM t1}
35378ddb7ceSdrh    } {00680069000000790061006C006C0000 00680069000000790061006C006C 00680069}
35478ddb7ceSdrh  }
35510dfbbb5Sdrh  do_test bind-7.5 {
35610dfbbb5Sdrh    execsql {SELECT typeof(a), typeof(b), typeof(c) FROM t1}
35710dfbbb5Sdrh  } {text text text}
35851e3d8e2Sdanielk1977}
35910dfbbb5Sdrhdo_test bind-7.99 {
36010dfbbb5Sdrh  execsql {DELETE FROM t1;}
36151e3d8e2Sdanielk1977} {}
36251e3d8e2Sdanielk1977
3636622cce3Sdanielk1977# Test that the 'out of range' error works.
3646622cce3Sdanielk1977do_test bind-8.1 {
3656622cce3Sdanielk1977  catch { sqlite3_bind_null $VM 0 }
3666622cce3Sdanielk1977} {1}
3676622cce3Sdanielk1977do_test bind-8.2 {
3686622cce3Sdanielk1977  sqlite3_errmsg $DB
369*ff4fa772Sdrh} {column index out of range}
3706c62608fSdrhifcapable {utf16} {
3716622cce3Sdanielk1977  do_test bind-8.3 {
3726622cce3Sdanielk1977    encoding convertfrom unicode [sqlite3_errmsg16 $DB]
373*ff4fa772Sdrh  } {column index out of range}
3746c62608fSdrh}
3756622cce3Sdanielk1977do_test bind-8.4 {
3766622cce3Sdanielk1977  sqlite3_bind_null $VM 1
3776622cce3Sdanielk1977  sqlite3_errmsg $DB
3786622cce3Sdanielk1977} {not an error}
3796622cce3Sdanielk1977do_test bind-8.5 {
3806622cce3Sdanielk1977  catch { sqlite3_bind_null $VM 4 }
3816622cce3Sdanielk1977} {1}
3826622cce3Sdanielk1977do_test bind-8.6 {
3836622cce3Sdanielk1977  sqlite3_errmsg $DB
384*ff4fa772Sdrh} {column index out of range}
3856c62608fSdrhifcapable {utf16} {
3866622cce3Sdanielk1977  do_test bind-8.7 {
3876622cce3Sdanielk1977    encoding convertfrom unicode [sqlite3_errmsg16 $DB]
388*ff4fa772Sdrh  } {column index out of range}
3896c62608fSdrh}
3906622cce3Sdanielk1977
391f4618891Sdanielk1977do_test bind-8.8 {
392f4618891Sdanielk1977  catch { sqlite3_bind_blob $VM 0 "abc" 3 }
393f4618891Sdanielk1977} {1}
394f4618891Sdanielk1977do_test bind-8.9 {
395f4618891Sdanielk1977  catch { sqlite3_bind_blob $VM 4 "abc" 3 }
396f4618891Sdanielk1977} {1}
397f4618891Sdanielk1977do_test bind-8.10 {
398f4618891Sdanielk1977  catch { sqlite3_bind_text $VM 0 "abc" 3 }
399f4618891Sdanielk1977} {1}
4006c62608fSdrhifcapable {utf16} {
401f4618891Sdanielk1977  do_test bind-8.11 {
402f4618891Sdanielk1977    catch { sqlite3_bind_text16 $VM 4 "abc" 2 }
403f4618891Sdanielk1977  } {1}
4046c62608fSdrh}
405f4618891Sdanielk1977do_test bind-8.12 {
406f4618891Sdanielk1977  catch { sqlite3_bind_int $VM 0 5 }
407f4618891Sdanielk1977} {1}
408f4618891Sdanielk1977do_test bind-8.13 {
409f4618891Sdanielk1977  catch { sqlite3_bind_int $VM 4 5 }
410f4618891Sdanielk1977} {1}
411f4618891Sdanielk1977do_test bind-8.14 {
412f4618891Sdanielk1977  catch { sqlite3_bind_double $VM 0 5.0 }
413f4618891Sdanielk1977} {1}
414f4618891Sdanielk1977do_test bind-8.15 {
415f4618891Sdanielk1977  catch { sqlite3_bind_double $VM 4 6.0 }
416f4618891Sdanielk1977} {1}
4176622cce3Sdanielk1977
418fa6bc000Sdrhdo_test bind-8.99 {
419106bb236Sdanielk1977  sqlite3_finalize $VM
4203cf86063Sdanielk1977} SQLITE_OK
42151e3d8e2Sdanielk1977
42298c40828Sdanielk1977set iMaxVar $SQLITE_MAX_VARIABLE_NUMBER
42398c40828Sdanielk1977set zError "(1) variable number must be between ?1 and ?$iMaxVar"
424fa6bc000Sdrhdo_test bind-9.1 {
425fa6bc000Sdrh  execsql {
426fa6bc000Sdrh    CREATE TABLE t2(a,b,c,d,e,f);
427fa6bc000Sdrh  }
428fa6bc000Sdrh  set rc [catch {
429fa6bc000Sdrh    sqlite3_prepare $DB {
430fa6bc000Sdrh      INSERT INTO t2(a) VALUES(?0)
431fa6bc000Sdrh    } -1 TAIL
432fa6bc000Sdrh  } msg]
433fa6bc000Sdrh  lappend rc $msg
43498c40828Sdanielk1977} [list 1 $zError]
435fa6bc000Sdrhdo_test bind-9.2 {
436fa6bc000Sdrh  set rc [catch {
43798c40828Sdanielk1977    sqlite3_prepare $DB "INSERT INTO t2(a) VALUES(?[expr $iMaxVar+1])" -1 TAIL
438fa6bc000Sdrh  } msg]
439fa6bc000Sdrh  lappend rc $msg
44098c40828Sdanielk1977} [list 1 $zError]
441e49b146fSdrhdo_test bind-9.3.1 {
442fa6bc000Sdrh  set VM [
44398c40828Sdanielk1977    sqlite3_prepare $DB "
44498c40828Sdanielk1977      INSERT INTO t2(a,b) VALUES(?1,?$iMaxVar)
44598c40828Sdanielk1977    " -1 TAIL
446fa6bc000Sdrh  ]
447fa6bc000Sdrh  sqlite3_bind_parameter_count $VM
44898c40828Sdanielk1977} $iMaxVar
449fa6bc000Sdrhcatch {sqlite3_finalize $VM}
450e49b146fSdrhdo_test bind-9.3.2 {
451e49b146fSdrh  set VM [
45298c40828Sdanielk1977    sqlite3_prepare $DB "
45398c40828Sdanielk1977      INSERT INTO t2(a,b) VALUES(?2,?[expr $iMaxVar - 1])
45498c40828Sdanielk1977    " -1 TAIL
455e49b146fSdrh  ]
456e49b146fSdrh  sqlite3_bind_parameter_count $VM
45798c40828Sdanielk1977} [expr {$iMaxVar - 1}]
458e49b146fSdrhcatch {sqlite3_finalize $VM}
459fa6bc000Sdrhdo_test bind-9.4 {
460fa6bc000Sdrh  set VM [
46198c40828Sdanielk1977    sqlite3_prepare $DB "
46298c40828Sdanielk1977      INSERT INTO t2(a,b,c,d) VALUES(?1,?[expr $iMaxVar - 2],?,?)
46398c40828Sdanielk1977    " -1 TAIL
464fa6bc000Sdrh  ]
465fa6bc000Sdrh  sqlite3_bind_parameter_count $VM
46698c40828Sdanielk1977} $iMaxVar
467fa6bc000Sdrhdo_test bind-9.5 {
468fa6bc000Sdrh  sqlite3_bind_int $VM 1 1
46998c40828Sdanielk1977  sqlite3_bind_int $VM [expr $iMaxVar - 2] 999
47098c40828Sdanielk1977  sqlite3_bind_int $VM [expr $iMaxVar - 1] 1000
47198c40828Sdanielk1977  sqlite3_bind_int $VM $iMaxVar 1001
472fa6bc000Sdrh  sqlite3_step $VM
473fa6bc000Sdrh} SQLITE_DONE
474fa6bc000Sdrhdo_test bind-9.6 {
475fa6bc000Sdrh  sqlite3_finalize $VM
476fa6bc000Sdrh} SQLITE_OK
477fa6bc000Sdrhdo_test bind-9.7 {
478fa6bc000Sdrh  execsql {SELECT * FROM t2}
479fa6bc000Sdrh} {1 999 1000 1001 {} {}}
48051e3d8e2Sdanielk1977
4816bf89570Sdrhifcapable {tclvar} {
482fa6bc000Sdrh  do_test bind-10.1 {
483fa6bc000Sdrh    set VM [
484fa6bc000Sdrh      sqlite3_prepare $DB {
485fa6bc000Sdrh        INSERT INTO t2(a,b,c,d,e,f) VALUES(:abc,$abc,:abc,$ab,$abc,:abc)
486fa6bc000Sdrh      } -1 TAIL
487fa6bc000Sdrh    ]
488fa6bc000Sdrh    sqlite3_bind_parameter_count $VM
489fa6bc000Sdrh  } 3
4906bf89570Sdrh  set v1 {$abc}
4916bf89570Sdrh  set v2 {$ab}
4926bf89570Sdrh}
4936bf89570Sdrhifcapable {!tclvar} {
4946bf89570Sdrh  do_test bind-10.1 {
4956bf89570Sdrh    set VM [
4966bf89570Sdrh      sqlite3_prepare $DB {
4976bf89570Sdrh        INSERT INTO t2(a,b,c,d,e,f) VALUES(:abc,:xyz,:abc,:xy,:xyz,:abc)
4986bf89570Sdrh      } -1 TAIL
4996bf89570Sdrh    ]
5006bf89570Sdrh    sqlite3_bind_parameter_count $VM
5016bf89570Sdrh  } 3
5026bf89570Sdrh  set v1 {:xyz}
5036bf89570Sdrh  set v2 {:xy}
5046bf89570Sdrh}
505fa6bc000Sdrhdo_test bind-10.2 {
506fa6bc000Sdrh  sqlite3_bind_parameter_index $VM :abc
507fa6bc000Sdrh} 1
508fa6bc000Sdrhdo_test bind-10.3 {
5096bf89570Sdrh  sqlite3_bind_parameter_index $VM $v1
510fa6bc000Sdrh} 2
511fa6bc000Sdrhdo_test bind-10.4 {
5126bf89570Sdrh  sqlite3_bind_parameter_index $VM $v2
513fa6bc000Sdrh} 3
514fa6bc000Sdrhdo_test bind-10.5 {
515fa6bc000Sdrh  sqlite3_bind_parameter_name $VM 1
516fa6bc000Sdrh} :abc
517fa6bc000Sdrhdo_test bind-10.6 {
518fa6bc000Sdrh  sqlite3_bind_parameter_name $VM 2
5196bf89570Sdrh} $v1
520fa6bc000Sdrhdo_test bind-10.7 {
521fa6bc000Sdrh  sqlite3_bind_parameter_name $VM 3
5226bf89570Sdrh} $v2
523c5cdca61Sdrhdo_test bind-10.7.1 {
524c5cdca61Sdrh  sqlite3_bind_parameter_name 0 1   ;# Ignore if VM is NULL
525c5cdca61Sdrh} {}
526c5cdca61Sdrhdo_test bind-10.7.2 {
527c5cdca61Sdrh  sqlite3_bind_parameter_name $VM 0 ;# Ignore if index too small
528c5cdca61Sdrh} {}
529c5cdca61Sdrhdo_test bind-10.7.3 {
530c5cdca61Sdrh  sqlite3_bind_parameter_name $VM 4 ;# Ignore if index is too big
531c5cdca61Sdrh} {}
532fa6bc000Sdrhdo_test bind-10.8 {
533fa6bc000Sdrh  sqlite3_bind_int $VM 1 1
534fa6bc000Sdrh  sqlite3_bind_int $VM 2 2
535fa6bc000Sdrh  sqlite3_bind_int $VM 3 3
536fa6bc000Sdrh  sqlite3_step $VM
537fa6bc000Sdrh} SQLITE_DONE
538c5cdca61Sdrhdo_test bind-10.8.1 {
539c5cdca61Sdrh  # Binding attempts after program start should fail
540c5cdca61Sdrh  set rc [catch {
541c5cdca61Sdrh    sqlite3_bind_int $VM 1 1
542c5cdca61Sdrh  } msg]
543c5cdca61Sdrh  lappend rc $msg
544c5cdca61Sdrh} {1 {}}
545fa6bc000Sdrhdo_test bind-10.9 {
546fa6bc000Sdrh  sqlite3_finalize $VM
547fa6bc000Sdrh} SQLITE_OK
548fa6bc000Sdrhdo_test bind-10.10 {
549fa6bc000Sdrh  execsql {SELECT * FROM t2}
550fa6bc000Sdrh} {1 999 1000 1001 {} {} 1 2 1 3 2 1}
55182a4851aSdrh
552971a7c87Sdrh# Ticket #918
553971a7c87Sdrh#
554971a7c87Sdrhdo_test bind-10.11 {
555a86a5b6cSdrh  # catch {sqlite3_finalize $VM}
556971a7c87Sdrh  set VM [
557971a7c87Sdrh    sqlite3_prepare $DB {
558971a7c87Sdrh      INSERT INTO t2(a,b,c,d,e,f) VALUES(:abc,?,?4,:pqr,:abc,?4)
559971a7c87Sdrh    } -1 TAIL
560971a7c87Sdrh  ]
561971a7c87Sdrh  sqlite3_bind_parameter_count $VM
562971a7c87Sdrh} 5
563c5cdca61Sdrhdo_test bind-10.11.1 {
564c5cdca61Sdrh  sqlite3_bind_parameter_index 0 :xyz  ;# ignore NULL VM arguments
565c5cdca61Sdrh} 0
566971a7c87Sdrhdo_test bind-10.12 {
567971a7c87Sdrh  sqlite3_bind_parameter_index $VM :xyz
568971a7c87Sdrh} 0
569971a7c87Sdrhdo_test bind-10.13 {
570971a7c87Sdrh  sqlite3_bind_parameter_index $VM {}
571971a7c87Sdrh} 0
572971a7c87Sdrhdo_test bind-10.14 {
573971a7c87Sdrh  sqlite3_bind_parameter_index $VM :pqr
574971a7c87Sdrh} 5
575971a7c87Sdrhdo_test bind-10.15 {
576971a7c87Sdrh  sqlite3_bind_parameter_index $VM ?4
577971a7c87Sdrh} 4
578971a7c87Sdrhdo_test bind-10.16 {
579971a7c87Sdrh  sqlite3_bind_parameter_name $VM 1
580971a7c87Sdrh} :abc
581b3bce662Sdanielk1977do_test bind-10.17 {
582971a7c87Sdrh  sqlite3_bind_parameter_name $VM 2
583971a7c87Sdrh} {}
584b3bce662Sdanielk1977do_test bind-10.18 {
585971a7c87Sdrh  sqlite3_bind_parameter_name $VM 3
586971a7c87Sdrh} {}
587b3bce662Sdanielk1977do_test bind-10.19 {
588971a7c87Sdrh  sqlite3_bind_parameter_name $VM 4
589971a7c87Sdrh} {?4}
590b3bce662Sdanielk1977do_test bind-10.20 {
591971a7c87Sdrh  sqlite3_bind_parameter_name $VM 5
592971a7c87Sdrh} :pqr
593971a7c87Sdrhcatch {sqlite3_finalize $VM}
594971a7c87Sdrh
59548e5aa27Sdrh# Make sure we catch an unterminated "(" in a Tcl-style variable name
59648e5aa27Sdrh#
5974489f9bdSdanielk1977ifcapable tclvar {
59848e5aa27Sdrh  do_test bind-11.1 {
59948e5aa27Sdrh    catchsql {SELECT * FROM sqlite_master WHERE name=$abc(123 and sql NOT NULL;}
60048e5aa27Sdrh  } {1 {unrecognized token: "$abc(123"}}
6014489f9bdSdanielk1977}
60248e5aa27Sdrh
603e57c06fdSdrhif {[execsql {pragma encoding}]=="UTF-8"} {
604bf8aa2a6Sdrh  # Test the ability to bind text that contains embedded '\000' characters.
605f9cb7f58Sdrh  # Make sure we can recover the entire input string.
606bf8aa2a6Sdrh  #
607bf8aa2a6Sdrh  do_test bind-12.1 {
608bf8aa2a6Sdrh    execsql {
609bf8aa2a6Sdrh      CREATE TABLE t3(x BLOB);
610bf8aa2a6Sdrh    }
611bf8aa2a6Sdrh    set VM [sqlite3_prepare $DB {INSERT INTO t3 VALUES(?)} -1 TAIL]
612bf8aa2a6Sdrh    sqlite_bind  $VM 1 not-used blob10
613bf8aa2a6Sdrh    sqlite3_step $VM
614bf8aa2a6Sdrh    sqlite3_finalize $VM
615bf8aa2a6Sdrh    execsql {
616bf8aa2a6Sdrh      SELECT typeof(x), length(x), quote(x),
617bf8aa2a6Sdrh             length(cast(x AS BLOB)), quote(cast(x AS BLOB)) FROM t3
618bf8aa2a6Sdrh    }
619bf8aa2a6Sdrh  } {text 3 'abc' 10 X'6162630078797A007071'}
6205c434b72Sdrh  do_test bind-12.2 {
6215c434b72Sdrh    sqlite3_create_function $DB
6225c434b72Sdrh    execsql {
6235c434b72Sdrh      SELECT quote(cast(x_coalesce(x) AS blob)) FROM t3
6245c434b72Sdrh    }
6255c434b72Sdrh  } {X'6162630078797A007071'}
626e57c06fdSdrh}
627bf8aa2a6Sdrh
628f9cb7f58Sdrh# Test the operation of sqlite3_clear_bindings
629f9cb7f58Sdrh#
630f9cb7f58Sdrhdo_test bind-13.1 {
631f9cb7f58Sdrh  set VM [sqlite3_prepare $DB {SELECT ?,?,?} -1 TAIL]
632f9cb7f58Sdrh  sqlite3_step $VM
633f9cb7f58Sdrh  list [sqlite3_column_type $VM 0] [sqlite3_column_type $VM 1] \
634f9cb7f58Sdrh               [sqlite3_column_type $VM 2]
635f9cb7f58Sdrh} {NULL NULL NULL}
636f9cb7f58Sdrhdo_test bind-13.2 {
637f9cb7f58Sdrh  sqlite3_reset $VM
638f9cb7f58Sdrh  sqlite3_bind_int $VM 1 1
639f9cb7f58Sdrh  sqlite3_bind_int $VM 2 2
640f9cb7f58Sdrh  sqlite3_bind_int $VM 3 3
641f9cb7f58Sdrh  sqlite3_step $VM
642f9cb7f58Sdrh  list [sqlite3_column_type $VM 0] [sqlite3_column_type $VM 1] \
643f9cb7f58Sdrh               [sqlite3_column_type $VM 2]
644f9cb7f58Sdrh} {INTEGER INTEGER INTEGER}
645f9cb7f58Sdrhdo_test bind-13.3 {
646f9cb7f58Sdrh  sqlite3_reset $VM
647f9cb7f58Sdrh  sqlite3_step $VM
648f9cb7f58Sdrh  list [sqlite3_column_type $VM 0] [sqlite3_column_type $VM 1] \
649f9cb7f58Sdrh               [sqlite3_column_type $VM 2]
650f9cb7f58Sdrh} {INTEGER INTEGER INTEGER}
651f9cb7f58Sdrhdo_test bind-13.4 {
652f9cb7f58Sdrh  sqlite3_reset $VM
653f9cb7f58Sdrh  sqlite3_clear_bindings $VM
654f9cb7f58Sdrh  sqlite3_step $VM
655f9cb7f58Sdrh  list [sqlite3_column_type $VM 0] [sqlite3_column_type $VM 1] \
656f9cb7f58Sdrh               [sqlite3_column_type $VM 2]
657f9cb7f58Sdrh} {NULL NULL NULL}
658f9cb7f58Sdrhsqlite3_finalize $VM
659f9cb7f58Sdrh
66053b6028bSdanielk1977#--------------------------------------------------------------------
66153b6028bSdanielk1977# These tests attempt to reproduce bug #3463.
66253b6028bSdanielk1977#
66353b6028bSdanielk1977proc param_names {db zSql} {
66453b6028bSdanielk1977  set ret [list]
66553b6028bSdanielk1977  set VM [sqlite3_prepare db $zSql -1 TAIL]
66653b6028bSdanielk1977  for {set ii 1} {$ii <= [sqlite3_bind_parameter_count $VM]} {incr ii} {
66753b6028bSdanielk1977    lappend ret [sqlite3_bind_parameter_name $VM $ii]
66853b6028bSdanielk1977  }
66953b6028bSdanielk1977  sqlite3_finalize $VM
67053b6028bSdanielk1977  set ret
67153b6028bSdanielk1977}
67253b6028bSdanielk1977
67353b6028bSdanielk1977do_test bind-14.1 {
67453b6028bSdanielk1977  param_names db { SELECT @a, @b }
67553b6028bSdanielk1977} {@a @b}
67653b6028bSdanielk1977do_test bind-14.2 {
67753b6028bSdanielk1977  param_names db { SELECT NULL FROM (SELECT NULL) WHERE @a = @b }
67853b6028bSdanielk1977} {@a @b}
67953b6028bSdanielk1977do_test bind-14.3 {
68053b6028bSdanielk1977  param_names db { SELECT @a FROM (SELECT NULL) WHERE 1 = @b }
68153b6028bSdanielk1977} {@a @b}
68253b6028bSdanielk1977do_test bind-14.4 {
68353b6028bSdanielk1977  param_names db { SELECT @a, @b FROM (SELECT NULL) }
68453b6028bSdanielk1977} {@a @b}
68553b6028bSdanielk1977
68608de1490Sdrh#--------------------------------------------------------------------------
68708de1490Sdrh# Tests of the OP_Variable opcode where P3>1
68808de1490Sdrh#
68908de1490Sdrhdo_test bind-15.1 {
69008de1490Sdrh  db eval {CREATE TABLE t4(a,b,c,d,e,f,g,h);}
69108de1490Sdrh  set VM [sqlite3_prepare db {
69208de1490Sdrh       INSERT INTO t4(a,b,c,d,f,g,h,e) VALUES(?,?,?,?,?,?,?,?)
69308de1490Sdrh  } -1 TAIL]
69408de1490Sdrh  sqlite3_bind_int $VM 1 1
69508de1490Sdrh  sqlite3_bind_int $VM 2 2
69608de1490Sdrh  sqlite3_bind_int $VM 3 3
69708de1490Sdrh  sqlite3_bind_int $VM 4 4
69808de1490Sdrh  sqlite3_bind_int $VM 5 5
69908de1490Sdrh  sqlite3_bind_int $VM 6 6
70008de1490Sdrh  sqlite3_bind_int $VM 7 7
70108de1490Sdrh  sqlite3_bind_int $VM 8 8
70208de1490Sdrh  sqlite3_step $VM
70308de1490Sdrh  sqlite3_finalize $VM
70408de1490Sdrh  db eval {SELECT * FROM t4}
70508de1490Sdrh} {1 2 3 4 8 5 6 7}
70608de1490Sdrhdo_test bind-15.2 {
70708de1490Sdrh  db eval {DELETE FROM t4}
70808de1490Sdrh  set VM [sqlite3_prepare db {
70908de1490Sdrh       INSERT INTO t4(a,b,c,d,e,f,g,h) VALUES(?,?,?,?,?,?,?,?)
71008de1490Sdrh  } -1 TAIL]
71108de1490Sdrh  sqlite3_bind_int $VM 1 1
71208de1490Sdrh  sqlite3_bind_int $VM 2 2
71308de1490Sdrh  sqlite3_bind_int $VM 3 3
71408de1490Sdrh  sqlite3_bind_int $VM 4 4
71508de1490Sdrh  sqlite3_bind_int $VM 5 5
71608de1490Sdrh  sqlite3_bind_int $VM 6 6
71708de1490Sdrh  sqlite3_bind_int $VM 7 7
71808de1490Sdrh  sqlite3_bind_int $VM 8 8
71908de1490Sdrh  sqlite3_step $VM
72008de1490Sdrh  sqlite3_finalize $VM
72108de1490Sdrh  db eval {SELECT * FROM t4}
72208de1490Sdrh} {1 2 3 4 5 6 7 8}
72308de1490Sdrhdo_test bind-15.3 {
72408de1490Sdrh  db eval {DELETE FROM t4}
72508de1490Sdrh  set VM [sqlite3_prepare db {
72608de1490Sdrh       INSERT INTO t4(h,g,f,e,d,c,b,a) VALUES(?,?,?,?,?,?,?,?)
72708de1490Sdrh  } -1 TAIL]
72808de1490Sdrh  sqlite3_bind_int $VM 1 1
72908de1490Sdrh  sqlite3_bind_int $VM 2 2
73008de1490Sdrh  sqlite3_bind_int $VM 3 3
73108de1490Sdrh  sqlite3_bind_int $VM 4 4
73208de1490Sdrh  sqlite3_bind_int $VM 5 5
73308de1490Sdrh  sqlite3_bind_int $VM 6 6
73408de1490Sdrh  sqlite3_bind_int $VM 7 7
73508de1490Sdrh  sqlite3_bind_int $VM 8 8
73608de1490Sdrh  sqlite3_step $VM
73708de1490Sdrh  sqlite3_finalize $VM
73808de1490Sdrh  db eval {SELECT * FROM t4}
73908de1490Sdrh} {8 7 6 5 4 3 2 1}
74008de1490Sdrhdo_test bind-15.4 {
74108de1490Sdrh  db eval {DELETE FROM t4}
74208de1490Sdrh  set VM [sqlite3_prepare db {
74308de1490Sdrh       INSERT INTO t4(a,b,c,d,e,f,g,h) VALUES(?,?,?,?4,?,?6,?,?)
74408de1490Sdrh  } -1 TAIL]
74508de1490Sdrh  sqlite3_bind_int $VM 1 1
74608de1490Sdrh  sqlite3_bind_int $VM 2 2
74708de1490Sdrh  sqlite3_bind_int $VM 3 3
74808de1490Sdrh  sqlite3_bind_int $VM 4 4
74908de1490Sdrh  sqlite3_bind_int $VM 5 5
75008de1490Sdrh  sqlite3_bind_int $VM 6 6
75108de1490Sdrh  sqlite3_bind_int $VM 7 7
75208de1490Sdrh  sqlite3_bind_int $VM 8 8
75308de1490Sdrh  sqlite3_step $VM
75408de1490Sdrh  sqlite3_finalize $VM
75508de1490Sdrh  db eval {SELECT * FROM t4}
75608de1490Sdrh} {1 2 3 4 5 6 7 8}
75708de1490Sdrh
75882a4851aSdrhfinish_test
759