CoolFace
Modelpublic

AryaWu/sqlite

sourceHugging Faceupdated 9mo agoView on Hugging Face
0likes
bind.test759 linesDownload Raw Back to test
1# 2003 September 62#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# This file implements regression tests for SQLite library.  The12# focus of this script testing the sqlite_bind API.13#14# $Id: bind.test,v 1.48 2009/07/22 07:27:57 danielk1977 Exp $15#16 17set testdir [file dirname $argv0]18source $testdir/tester.tcl19 20proc sqlite_step {stmt N VALS COLS} {21  upvar VALS vals22  upvar COLS cols23  set vals [list]24  set cols [list]25 26  set rc [sqlite3_step $stmt]27  for {set i 0} {$i < [sqlite3_column_count $stmt]} {incr i} {28    lappend cols [sqlite3_column_name $stmt $i]29  }30  for {set i 0} {$i < [sqlite3_data_count $stmt]} {incr i} {31    lappend vals [sqlite3_column_text $stmt $i]32  }33 34  return $rc35}36 37do_test bind-1.1 {38  set DB [sqlite3_connection_pointer db]39  execsql {CREATE TABLE t1(a,b,c);}40  set VM [sqlite3_prepare $DB {INSERT INTO t1 VALUES(:1,?,:abc)} -1 TAIL]41  set TAIL42} {}43do_test bind-1.1.1 {44  sqlite3_bind_parameter_count $VM45} 346do_test bind-1.1.2 {47  sqlite3_bind_parameter_name $VM 148} {:1}49do_test bind-1.1.3 {50  sqlite3_bind_parameter_name $VM 251} {}52do_test bind-1.1.4 {53  sqlite3_bind_parameter_name $VM 354} {:abc}55do_test bind-1.2 {56  sqlite_step $VM N VALUES COLNAMES57} {SQLITE_DONE}58do_test bind-1.3 {59  execsql {SELECT rowid, * FROM t1}60} {1 {} {} {}}61do_test bind-1.4 {62  sqlite3_reset $VM63  sqlite_bind $VM 1 {test value 1} normal64  sqlite_step $VM N VALUES COLNAMES65} SQLITE_DONE66do_test bind-1.5 {67  execsql {SELECT rowid, * FROM t1}68} {1 {} {} {} 2 {test value 1} {} {}}69do_test bind-1.6 {70  sqlite3_reset $VM71  sqlite_bind $VM 3 {'test value 2'} normal72  sqlite_step $VM N VALUES COLNAMES73} SQLITE_DONE74do_test bind-1.7 {75  execsql {SELECT rowid, * FROM t1}76} {1 {} {} {} 2 {test value 1} {} {} 3 {test value 1} {} {'test value 2'}}77do_test bind-1.8 {78  sqlite3_reset $VM79  set sqlite_static_bind_value 12380  sqlite_bind $VM 1 {} static81  sqlite_bind $VM 2 {abcdefg} normal82  sqlite_bind $VM 3 {} null83  execsql {DELETE FROM t1}84  sqlite_step $VM N VALUES COLNAMES85  execsql {SELECT rowid, * FROM t1}86} {1 123 abcdefg {}}87do_test bind-1.9 {88  sqlite3_reset $VM89  sqlite_bind $VM 1 {456} normal90  sqlite_step $VM N VALUES COLNAMES91  execsql {SELECT rowid, * FROM t1}92} {1 123 abcdefg {} 2 456 abcdefg {}}93 94do_test bind-1.10 {95   set rc [catch {96     sqlite3_prepare db {INSERT INTO t1 VALUES($abc:123,?,:abc)} -1 TAIL97   } msg]98   lappend rc $msg99} {1 {(1) near ":123": syntax error}}100do_test bind-1.11 {101   set rc [catch {102     sqlite3_prepare db {INSERT INTO t1 VALUES(@abc:xyz,?,:abc)} -1 TAIL103   } msg]104   lappend rc $msg105} {1 {(1) near ":xyz": syntax error}}106 107do_test bind-1.99 {108  sqlite3_finalize $VM109} SQLITE_OK110 111# Prepare the statement in different ways depending on whether or not112# the $var processing is compiled into the library.113#114ifcapable {tclvar} {115  do_test bind-2.1 {116    execsql {117      DELETE FROM t1;118    }119    set VM [sqlite3_prepare $DB {INSERT INTO t1 VALUES($one,$::two,$x(-z-))}\120            -1 TX]121    set TX122  } {}123  set v1 {$one}124  set v2 {$::two}125  set v3 {$x(-z-)}126}127ifcapable {!tclvar} {128  do_test bind-2.1 {129    execsql {130      DELETE FROM t1;131    }132    set VM [sqlite3_prepare $DB {INSERT INTO t1 VALUES(:one,:two,:_)} -1 TX]133    set TX134  } {}135  set v1 {:one}136  set v2 {:two}137  set v3 {:_}138}139 140do_test bind-2.1.1 {141  sqlite3_bind_parameter_count $VM142} 3143do_test bind-2.1.2 {144  sqlite3_bind_parameter_name $VM 1145} $v1146do_test bind-2.1.3 {147  sqlite3_bind_parameter_name $VM 2148} $v2149do_test bind-2.1.4 {150  sqlite3_bind_parameter_name $VM 3151} $v3152do_test bind-2.1.5 {153  sqlite3_bind_parameter_index $VM $v1154} 1155do_test bind-2.1.6 {156  sqlite3_bind_parameter_index $VM $v2157} 2158do_test bind-2.1.7 {159  sqlite3_bind_parameter_index $VM $v3160} 3161do_test bind-2.1.8 {162  sqlite3_bind_parameter_index $VM {:hi}163} 0164 165# 32 bit Integers166do_test bind-2.2 {167  sqlite3_bind_int $VM 1 123168  sqlite3_bind_int $VM 2 456169  sqlite3_bind_int $VM 3 789170  sqlite_step $VM N VALUES COLNAMES171  sqlite3_reset $VM172  execsql {SELECT rowid, * FROM t1}173} {1 123 456 789}174do_test bind-2.3 {175  sqlite3_bind_int $VM 2 -2000000000176  sqlite3_bind_int $VM 3 2000000000177  sqlite_step $VM N VALUES COLNAMES178  sqlite3_reset $VM179  execsql {SELECT rowid, * FROM t1}180} {1 123 456 789 2 123 -2000000000 2000000000}181do_test bind-2.4 {182  execsql {SELECT typeof(a), typeof(b), typeof(c) FROM t1}183} {integer integer integer integer integer integer}184do_test bind-2.5 {185  execsql {186    DELETE FROM t1;187  }188} {}189 190# 64 bit Integers191do_test bind-3.1 {192  sqlite3_bind_int64 $VM 1 32193  sqlite3_bind_int64 $VM 2 -2000000000000194  sqlite3_bind_int64 $VM 3 2000000000000195  sqlite_step $VM N VALUES COLNAMES196  sqlite3_reset $VM197  execsql {SELECT rowid, * FROM t1}198} {1 32 -2000000000000 2000000000000}199do_test bind-3.2 {200  execsql {SELECT typeof(a), typeof(b), typeof(c) FROM t1}201} {integer integer integer}202do_test bind-3.3 {203  execsql {204    DELETE FROM t1;205  }206} {}207 208# Doubles209do_test bind-4.1 {210  sqlite3_bind_double $VM 1 1234.1234211  sqlite3_bind_double $VM 2 0.00001212  sqlite3_bind_double $VM 3 123456789213  sqlite_step $VM N VALUES COLNAMES214  sqlite3_reset $VM215  set x [execsql {SELECT rowid, * FROM t1}]216  regsub {1e-005} $x {1e-05} y217  set y218} {1 1234.1234 1e-05 123456789.0}219do_test bind-4.2 {220  execsql {SELECT typeof(a), typeof(b), typeof(c) FROM t1}221} {real real real}222do_test bind-4.3 {223  execsql {224    DELETE FROM t1;225  }226} {}227do_test bind-4.4 {228  sqlite3_bind_double $VM 1 NaN229  sqlite3_bind_double $VM 2 1e300230  sqlite3_bind_double $VM 3 -1e-300231  sqlite_step $VM N VALUES COLNAMES232  sqlite3_reset $VM233  set x [execsql {SELECT rowid, * FROM t1}]234  regsub {1e-005} $x {1e-05} y235  set y236} {1 {} 1e+300 -1e-300}237do_test bind-4.5 {238  execsql {SELECT typeof(a), typeof(b), typeof(c) FROM t1}239} {null real real}240do_test bind-4.6 {241  execsql {242    DELETE FROM t1;243  }244} {}245 246# NULL247do_test bind-5.1 {248  sqlite3_bind_null $VM 1249  sqlite3_bind_null $VM 2250  sqlite3_bind_null $VM 3 251  sqlite_step $VM N VALUES COLNAMES252  sqlite3_reset $VM253  execsql {SELECT rowid, * FROM t1}254} {1 {} {} {}}255do_test bind-5.2 {256  execsql {SELECT typeof(a), typeof(b), typeof(c) FROM t1}257} {null null null}258do_test bind-5.3 {259  execsql {260    DELETE FROM t1;261  }262} {}263 264# UTF-8 text265do_test bind-6.1 {266  sqlite3_bind_text $VM 1 hellothere 5267  sqlite3_bind_text $VM 2 ".." 1268  sqlite3_bind_text $VM 3 world\000 -1269  sqlite_step $VM N VALUES COLNAMES270  sqlite3_reset $VM271  execsql {SELECT rowid, * FROM t1}272} {1 hello . world}273do_test bind-6.2 {274  execsql {SELECT typeof(a), typeof(b), typeof(c) FROM t1}275} {text text text}276do_test bind-6.3 {277  execsql {278    DELETE FROM t1;279  }280} {}281 282# Make sure zeros in a string work.283#284do_test bind-6.4 {285  db eval {DELETE FROM t1}286  sqlite3_bind_text $VM 1 hello\000there\000 12287  sqlite3_bind_text $VM 2 hello\000there\000 11288  sqlite3_bind_text $VM 3 hello\000there\000 -1289  sqlite_step $VM N VALUES COLNAMES290  sqlite3_reset $VM291  execsql {SELECT * FROM t1}292} {hello hello hello}293set enc [db eval {PRAGMA encoding}]294if {$enc=="UTF-8" || $enc==""} {295  do_test bind-6.5 {296    execsql {SELECT  hex(a), hex(b), hex(c) FROM t1}297  } {68656C6C6F00746865726500 68656C6C6F007468657265 68656C6C6F}298} elseif {$enc=="UTF-16le"} {299  do_test bind-6.5 {300    execsql {SELECT  hex(a), hex(b), hex(c) FROM t1}301  } {680065006C006C006F000000740068006500720065000000 680065006C006C006F00000074006800650072006500 680065006C006C006F00}302} elseif {$enc=="UTF-16be"} {303  do_test bind-6.5 {304    execsql {SELECT  hex(a), hex(b), hex(c) FROM t1}305  } {00680065006C006C006F0000007400680065007200650000 00680065006C006C006F000000740068006500720065 00680065006C006C006F}306} else {307  do_test bind-6.5 {308    set "Unknown database encoding: $::enc"309  } {}310}311do_test bind-6.6 {312  execsql {SELECT typeof(a), typeof(b), typeof(c) FROM t1}313} {text text text}314do_test bind-6.7 {315  execsql {316    DELETE FROM t1;317  }318} {}319 320# UTF-16 text321ifcapable {utf16} {322  do_test bind-7.1 {323    sqlite3_bind_text16 $VM 1 [encoding convertto unicode hellothere] 10324    sqlite3_bind_text16 $VM 2 [encoding convertto unicode ""] 0325    sqlite3_bind_text16 $VM 3 [encoding convertto unicode world] 10326    sqlite_step $VM N VALUES COLNAMES327    sqlite3_reset $VM328    execsql {SELECT rowid, * FROM t1}329  } {1 hello {} world}330  do_test bind-7.2 {331    execsql {SELECT typeof(a), typeof(b), typeof(c) FROM t1}332  } {text text text}333  do_test bind-7.3 {334    db eval {DELETE FROM t1}335    sqlite3_bind_text16 $VM 1 [encoding convertto unicode hi\000yall\000] 16336    sqlite3_bind_text16 $VM 2 [encoding convertto unicode hi\000yall\000] 14337    sqlite3_bind_text16 $VM 3 [encoding convertto unicode hi\000yall\000] -1338    sqlite_step $VM N VALUES COLNAMES339    sqlite3_reset $VM340    execsql {SELECT * FROM t1}341  } {hi hi hi}342  if {$enc=="UTF-8"} {343    do_test bind-7.4 {344      execsql {SELECT hex(a), hex(b), hex(c) FROM t1}345    } {68690079616C6C00 68690079616C6C 6869}346  } elseif {$enc=="UTF-16le"} {347    do_test bind-7.4 {348      execsql {SELECT hex(a), hex(b), hex(c) FROM t1}349    } {680069000000790061006C006C000000 680069000000790061006C006C00 68006900}350  } elseif {$enc=="UTF-16be"} {351    do_test bind-7.4 {352      execsql {SELECT hex(a), hex(b), hex(c) FROM t1}353    } {00680069000000790061006C006C0000 00680069000000790061006C006C 00680069}354  }355  do_test bind-7.5 {356    execsql {SELECT typeof(a), typeof(b), typeof(c) FROM t1}357  } {text text text}358}359do_test bind-7.99 {360  execsql {DELETE FROM t1;}361} {}362 363# Test that the 'out of range' error works.364do_test bind-8.1 {365  catch { sqlite3_bind_null $VM 0 }366} {1}367do_test bind-8.2 {368  sqlite3_errmsg $DB369} {column index out of range}370ifcapable {utf16} {371  do_test bind-8.3 {372    encoding convertfrom unicode [sqlite3_errmsg16 $DB]373  } {column index out of range}374}375do_test bind-8.4 {376  sqlite3_bind_null $VM 1 377  sqlite3_errmsg $DB378} {not an error}379do_test bind-8.5 {380  catch { sqlite3_bind_null $VM 4 }381} {1}382do_test bind-8.6 {383  sqlite3_errmsg $DB384} {column index out of range}385ifcapable {utf16} {386  do_test bind-8.7 {387    encoding convertfrom unicode [sqlite3_errmsg16 $DB]388  } {column index out of range}389}390 391do_test bind-8.8 {392  catch { sqlite3_bind_blob $VM 0 "abc" 3 }393} {1}394do_test bind-8.9 {395  catch { sqlite3_bind_blob $VM 4 "abc" 3 }396} {1}397do_test bind-8.10 {398  catch { sqlite3_bind_text $VM 0 "abc" 3 }399} {1}400ifcapable {utf16} {401  do_test bind-8.11 {402    catch { sqlite3_bind_text16 $VM 4 "abc" 2 }403  } {1}404}405do_test bind-8.12 {406  catch { sqlite3_bind_int $VM 0 5 }407} {1}408do_test bind-8.13 {409  catch { sqlite3_bind_int $VM 4 5 }410} {1}411do_test bind-8.14 {412  catch { sqlite3_bind_double $VM 0 5.0 }413} {1}414do_test bind-8.15 {415  catch { sqlite3_bind_double $VM 4 6.0 }416} {1}417 418do_test bind-8.99 {419  sqlite3_finalize $VM420} SQLITE_OK421 422set iMaxVar $SQLITE_MAX_VARIABLE_NUMBER423set zError "(1) variable number must be between ?1 and ?$iMaxVar"424do_test bind-9.1 {425  execsql {426    CREATE TABLE t2(a,b,c,d,e,f);427  }428  set rc [catch {429    sqlite3_prepare $DB {430      INSERT INTO t2(a) VALUES(?0)431    } -1 TAIL432  } msg]433  lappend rc $msg434} [list 1 $zError]435do_test bind-9.2 {436  set rc [catch {437    sqlite3_prepare $DB "INSERT INTO t2(a) VALUES(?[expr $iMaxVar+1])" -1 TAIL438  } msg]439  lappend rc $msg440} [list 1 $zError]441do_test bind-9.3.1 {442  set VM [443    sqlite3_prepare $DB "444      INSERT INTO t2(a,b) VALUES(?1,?$iMaxVar)445    " -1 TAIL446  ]447  sqlite3_bind_parameter_count $VM448} $iMaxVar449catch {sqlite3_finalize $VM}450do_test bind-9.3.2 {451  set VM [452    sqlite3_prepare $DB "453      INSERT INTO t2(a,b) VALUES(?2,?[expr $iMaxVar - 1])454    " -1 TAIL455  ]456  sqlite3_bind_parameter_count $VM457} [expr {$iMaxVar - 1}]458catch {sqlite3_finalize $VM}459do_test bind-9.4 {460  set VM [461    sqlite3_prepare $DB "462      INSERT INTO t2(a,b,c,d) VALUES(?1,?[expr $iMaxVar - 2],?,?)463    " -1 TAIL464  ]465  sqlite3_bind_parameter_count $VM466} $iMaxVar467do_test bind-9.5 {468  sqlite3_bind_int $VM 1 1469  sqlite3_bind_int $VM [expr $iMaxVar - 2] 999470  sqlite3_bind_int $VM [expr $iMaxVar - 1] 1000471  sqlite3_bind_int $VM $iMaxVar 1001472  sqlite3_step $VM473} SQLITE_DONE474do_test bind-9.6 {475  sqlite3_finalize $VM476} SQLITE_OK477do_test bind-9.7 {478  execsql {SELECT * FROM t2}479} {1 999 1000 1001 {} {}}480 481ifcapable {tclvar} {482  do_test bind-10.1 {483    set VM [484      sqlite3_prepare $DB {485        INSERT INTO t2(a,b,c,d,e,f) VALUES(:abc,$abc,:abc,$ab,$abc,:abc)486      } -1 TAIL487    ]488    sqlite3_bind_parameter_count $VM489  } 3490  set v1 {$abc}491  set v2 {$ab}492}493ifcapable {!tclvar} {494  do_test bind-10.1 {495    set VM [496      sqlite3_prepare $DB {497        INSERT INTO t2(a,b,c,d,e,f) VALUES(:abc,:xyz,:abc,:xy,:xyz,:abc)498      } -1 TAIL499    ]500    sqlite3_bind_parameter_count $VM501  } 3502  set v1 {:xyz}503  set v2 {:xy}504}505do_test bind-10.2 {506  sqlite3_bind_parameter_index $VM :abc507} 1508do_test bind-10.3 {509  sqlite3_bind_parameter_index $VM $v1510} 2511do_test bind-10.4 {512  sqlite3_bind_parameter_index $VM $v2513} 3514do_test bind-10.5 {515  sqlite3_bind_parameter_name $VM 1516} :abc517do_test bind-10.6 {518  sqlite3_bind_parameter_name $VM 2519} $v1520do_test bind-10.7 {521  sqlite3_bind_parameter_name $VM 3522} $v2523do_test bind-10.7.1 {524  sqlite3_bind_parameter_name 0 1   ;# Ignore if VM is NULL525} {}526do_test bind-10.7.2 {527  sqlite3_bind_parameter_name $VM 0 ;# Ignore if index too small528} {}529do_test bind-10.7.3 {530  sqlite3_bind_parameter_name $VM 4 ;# Ignore if index is too big531} {}532do_test bind-10.8 {533  sqlite3_bind_int $VM 1 1534  sqlite3_bind_int $VM 2 2535  sqlite3_bind_int $VM 3 3536  sqlite3_step $VM537} SQLITE_DONE538do_test bind-10.8.1 {539  # Binding attempts after program start should fail540  set rc [catch {541    sqlite3_bind_int $VM 1 1542  } msg]543  lappend rc $msg544} {1 {}}545do_test bind-10.9 {546  sqlite3_finalize $VM547} SQLITE_OK548do_test bind-10.10 {549  execsql {SELECT * FROM t2}550} {1 999 1000 1001 {} {} 1 2 1 3 2 1}551 552# Ticket #918553#554do_test bind-10.11 {555  # catch {sqlite3_finalize $VM}556  set VM [557    sqlite3_prepare $DB {558      INSERT INTO t2(a,b,c,d,e,f) VALUES(:abc,?,?4,:pqr,:abc,?4)559    } -1 TAIL560  ]561  sqlite3_bind_parameter_count $VM562} 5563do_test bind-10.11.1 {564  sqlite3_bind_parameter_index 0 :xyz  ;# ignore NULL VM arguments565} 0566do_test bind-10.12 {567  sqlite3_bind_parameter_index $VM :xyz568} 0569do_test bind-10.13 {570  sqlite3_bind_parameter_index $VM {}571} 0572do_test bind-10.14 {573  sqlite3_bind_parameter_index $VM :pqr574} 5575do_test bind-10.15 {576  sqlite3_bind_parameter_index $VM ?4577} 4578do_test bind-10.16 {579  sqlite3_bind_parameter_name $VM 1580} :abc581do_test bind-10.17 {582  sqlite3_bind_parameter_name $VM 2583} {}584do_test bind-10.18 {585  sqlite3_bind_parameter_name $VM 3586} {}587do_test bind-10.19 {588  sqlite3_bind_parameter_name $VM 4589} {?4}590do_test bind-10.20 {591  sqlite3_bind_parameter_name $VM 5592} :pqr593catch {sqlite3_finalize $VM}594 595# Make sure we catch an unterminated "(" in a Tcl-style variable name596#597ifcapable tclvar {598  do_test bind-11.1 {599    catchsql {SELECT * FROM sqlite_master WHERE name=$abc(123 and sql NOT NULL;}600  } {1 {unrecognized token: "$abc(123"}}601}602 603if {[execsql {pragma encoding}]=="UTF-8"} {604  # Test the ability to bind text that contains embedded '\000' characters.605  # Make sure we can recover the entire input string.606  #607  do_test bind-12.1 {608    execsql {609      CREATE TABLE t3(x BLOB);610    }611    set VM [sqlite3_prepare $DB {INSERT INTO t3 VALUES(?)} -1 TAIL]612    sqlite_bind  $VM 1 not-used blob10613    sqlite3_step $VM614    sqlite3_finalize $VM615    execsql {616      SELECT typeof(x), length(x), quote(x),617             length(cast(x AS BLOB)), quote(cast(x AS BLOB)) FROM t3618    }619  } {text 3 'abc' 10 X'6162630078797A007071'}620  do_test bind-12.2 {621    sqlite3_create_function $DB622    execsql {623      SELECT quote(cast(x_coalesce(x) AS blob)) FROM t3624    }625  } {X'6162630078797A007071'}626}627 628# Test the operation of sqlite3_clear_bindings629#630do_test bind-13.1 {631  set VM [sqlite3_prepare $DB {SELECT ?,?,?} -1 TAIL]632  sqlite3_step $VM633  list [sqlite3_column_type $VM 0] [sqlite3_column_type $VM 1] \634               [sqlite3_column_type $VM 2]635} {NULL NULL NULL}636do_test bind-13.2 {637  sqlite3_reset $VM638  sqlite3_bind_int $VM 1 1639  sqlite3_bind_int $VM 2 2640  sqlite3_bind_int $VM 3 3641  sqlite3_step $VM642  list [sqlite3_column_type $VM 0] [sqlite3_column_type $VM 1] \643               [sqlite3_column_type $VM 2]644} {INTEGER INTEGER INTEGER}645do_test bind-13.3 {646  sqlite3_reset $VM647  sqlite3_step $VM648  list [sqlite3_column_type $VM 0] [sqlite3_column_type $VM 1] \649               [sqlite3_column_type $VM 2]650} {INTEGER INTEGER INTEGER}651do_test bind-13.4 {652  sqlite3_reset $VM653  sqlite3_clear_bindings $VM654  sqlite3_step $VM655  list [sqlite3_column_type $VM 0] [sqlite3_column_type $VM 1] \656               [sqlite3_column_type $VM 2]657} {NULL NULL NULL}658sqlite3_finalize $VM659 660#--------------------------------------------------------------------661# These tests attempt to reproduce bug #3463.662#663proc param_names {db zSql} {664  set ret [list]665  set VM [sqlite3_prepare db $zSql -1 TAIL]666  for {set ii 1} {$ii <= [sqlite3_bind_parameter_count $VM]} {incr ii} {667    lappend ret [sqlite3_bind_parameter_name $VM $ii]668  }669  sqlite3_finalize $VM670  set ret671}672 673do_test bind-14.1 {674  param_names db { SELECT @a, @b }675} {@a @b}676do_test bind-14.2 {677  param_names db { SELECT NULL FROM (SELECT NULL) WHERE @a = @b }678} {@a @b}679do_test bind-14.3 {680  param_names db { SELECT @a FROM (SELECT NULL) WHERE 1 = @b }681} {@a @b}682do_test bind-14.4 {683  param_names db { SELECT @a, @b FROM (SELECT NULL) }684} {@a @b}685 686#--------------------------------------------------------------------------687# Tests of the OP_Variable opcode where P3>1688#689do_test bind-15.1 {690  db eval {CREATE TABLE t4(a,b,c,d,e,f,g,h);}691  set VM [sqlite3_prepare db {692       INSERT INTO t4(a,b,c,d,f,g,h,e) VALUES(?,?,?,?,?,?,?,?)693  } -1 TAIL]694  sqlite3_bind_int $VM 1 1695  sqlite3_bind_int $VM 2 2696  sqlite3_bind_int $VM 3 3697  sqlite3_bind_int $VM 4 4698  sqlite3_bind_int $VM 5 5699  sqlite3_bind_int $VM 6 6700  sqlite3_bind_int $VM 7 7701  sqlite3_bind_int $VM 8 8702  sqlite3_step $VM703  sqlite3_finalize $VM704  db eval {SELECT * FROM t4}705} {1 2 3 4 8 5 6 7}706do_test bind-15.2 {707  db eval {DELETE FROM t4}708  set VM [sqlite3_prepare db {709       INSERT INTO t4(a,b,c,d,e,f,g,h) VALUES(?,?,?,?,?,?,?,?)710  } -1 TAIL]711  sqlite3_bind_int $VM 1 1712  sqlite3_bind_int $VM 2 2713  sqlite3_bind_int $VM 3 3714  sqlite3_bind_int $VM 4 4715  sqlite3_bind_int $VM 5 5716  sqlite3_bind_int $VM 6 6717  sqlite3_bind_int $VM 7 7718  sqlite3_bind_int $VM 8 8719  sqlite3_step $VM720  sqlite3_finalize $VM721  db eval {SELECT * FROM t4}722} {1 2 3 4 5 6 7 8}723do_test bind-15.3 {724  db eval {DELETE FROM t4}725  set VM [sqlite3_prepare db {726       INSERT INTO t4(h,g,f,e,d,c,b,a) VALUES(?,?,?,?,?,?,?,?)727  } -1 TAIL]728  sqlite3_bind_int $VM 1 1729  sqlite3_bind_int $VM 2 2730  sqlite3_bind_int $VM 3 3731  sqlite3_bind_int $VM 4 4732  sqlite3_bind_int $VM 5 5733  sqlite3_bind_int $VM 6 6734  sqlite3_bind_int $VM 7 7735  sqlite3_bind_int $VM 8 8736  sqlite3_step $VM737  sqlite3_finalize $VM738  db eval {SELECT * FROM t4}739} {8 7 6 5 4 3 2 1}740do_test bind-15.4 {741  db eval {DELETE FROM t4}742  set VM [sqlite3_prepare db {743       INSERT INTO t4(a,b,c,d,e,f,g,h) VALUES(?,?,?,?4,?,?6,?,?)744  } -1 TAIL]745  sqlite3_bind_int $VM 1 1746  sqlite3_bind_int $VM 2 2747  sqlite3_bind_int $VM 3 3748  sqlite3_bind_int $VM 4 4749  sqlite3_bind_int $VM 5 5750  sqlite3_bind_int $VM 6 6751  sqlite3_bind_int $VM 7 7752  sqlite3_bind_int $VM 8 8753  sqlite3_step $VM754  sqlite3_finalize $VM755  db eval {SELECT * FROM t4}756} {1 2 3 4 5 6 7 8}757 758finish_test759