⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bind.test

📁 最新的sqlite3.6.2源代码
💻 TEST
📖 第 1 页 / 共 2 页
字号:
  } {text text text}  do_test bind-7.3 {    db eval {DELETE FROM t1}    sqlite3_bind_text16 $VM 1 [encoding convertto unicode hi\000yall\000] 16    sqlite3_bind_text16 $VM 2 [encoding convertto unicode hi\000yall\000] 14    sqlite3_bind_text16 $VM 3 [encoding convertto unicode hi\000yall\000] -1    sqlite_step $VM N VALUES COLNAMES    sqlite3_reset $VM    execsql {SELECT * FROM t1}  } {hi hi hi}  if {$enc=="UTF-8"} {    do_test bind-7.4 {      execsql {SELECT hex(a), hex(b), hex(c) FROM t1}    } {68690079616C6C00 68690079616C6C 6869}  } elseif {$enc=="UTF-16le"} {    do_test bind-7.4 {      execsql {SELECT hex(a), hex(b), hex(c) FROM t1}    } {680069000000790061006C006C000000 680069000000790061006C006C00 68006900}  } elseif {$enc=="UTF-16be"} {    do_test bind-7.4 {      execsql {SELECT hex(a), hex(b), hex(c) FROM t1}    } {00680069000000790061006C006C0000 00680069000000790061006C006C 00680069}  }  do_test bind-7.5 {    execsql {SELECT typeof(a), typeof(b), typeof(c) FROM t1}  } {text text text}}do_test bind-7.99 {  execsql {DELETE FROM t1;}} {}# Test that the 'out of range' error works.do_test bind-8.1 {  catch { sqlite3_bind_null $VM 0 }} {1}do_test bind-8.2 {  sqlite3_errmsg $DB} {bind or column index out of range}ifcapable {utf16} {  do_test bind-8.3 {    encoding convertfrom unicode [sqlite3_errmsg16 $DB]  } {bind or column index out of range}}do_test bind-8.4 {  sqlite3_bind_null $VM 1   sqlite3_errmsg $DB} {not an error}do_test bind-8.5 {  catch { sqlite3_bind_null $VM 4 }} {1}do_test bind-8.6 {  sqlite3_errmsg $DB} {bind or column index out of range}ifcapable {utf16} {  do_test bind-8.7 {    encoding convertfrom unicode [sqlite3_errmsg16 $DB]  } {bind or column index out of range}}do_test bind-8.8 {  catch { sqlite3_bind_blob $VM 0 "abc" 3 }} {1}do_test bind-8.9 {  catch { sqlite3_bind_blob $VM 4 "abc" 3 }} {1}do_test bind-8.10 {  catch { sqlite3_bind_text $VM 0 "abc" 3 }} {1}ifcapable {utf16} {  do_test bind-8.11 {    catch { sqlite3_bind_text16 $VM 4 "abc" 2 }  } {1}}do_test bind-8.12 {  catch { sqlite3_bind_int $VM 0 5 }} {1}do_test bind-8.13 {  catch { sqlite3_bind_int $VM 4 5 }} {1}do_test bind-8.14 {  catch { sqlite3_bind_double $VM 0 5.0 }} {1}do_test bind-8.15 {  catch { sqlite3_bind_double $VM 4 6.0 }} {1}do_test bind-8.99 {  sqlite3_finalize $VM} SQLITE_OKdo_test bind-9.1 {  execsql {    CREATE TABLE t2(a,b,c,d,e,f);  }  set rc [catch {    sqlite3_prepare $DB {      INSERT INTO t2(a) VALUES(?0)    } -1 TAIL  } msg]  lappend rc $msg} {1 {(1) variable number must be between ?1 and ?999}}do_test bind-9.2 {  set rc [catch {    sqlite3_prepare $DB {      INSERT INTO t2(a) VALUES(?1000)    } -1 TAIL  } msg]  lappend rc $msg} {1 {(1) variable number must be between ?1 and ?999}}do_test bind-9.3.1 {  set VM [    sqlite3_prepare $DB {      INSERT INTO t2(a,b) VALUES(?1,?999)    } -1 TAIL  ]  sqlite3_bind_parameter_count $VM} {999}catch {sqlite3_finalize $VM}do_test bind-9.3.2 {  set VM [    sqlite3_prepare $DB {      INSERT INTO t2(a,b) VALUES(?2,?998)    } -1 TAIL  ]  sqlite3_bind_parameter_count $VM} {998}catch {sqlite3_finalize $VM}do_test bind-9.4 {  set VM [    sqlite3_prepare $DB {      INSERT INTO t2(a,b,c,d) VALUES(?1,?997,?,?)    } -1 TAIL  ]  sqlite3_bind_parameter_count $VM} {999}do_test bind-9.5 {  sqlite3_bind_int $VM 1 1  sqlite3_bind_int $VM 997 999  sqlite3_bind_int $VM 998 1000  sqlite3_bind_int $VM 999 1001  sqlite3_step $VM} SQLITE_DONEdo_test bind-9.6 {  sqlite3_finalize $VM} SQLITE_OKdo_test bind-9.7 {  execsql {SELECT * FROM t2}} {1 999 1000 1001 {} {}}ifcapable {tclvar} {  do_test bind-10.1 {    set VM [      sqlite3_prepare $DB {        INSERT INTO t2(a,b,c,d,e,f) VALUES(:abc,$abc,:abc,$ab,$abc,:abc)      } -1 TAIL    ]    sqlite3_bind_parameter_count $VM  } 3  set v1 {$abc}  set v2 {$ab}}ifcapable {!tclvar} {  do_test bind-10.1 {    set VM [      sqlite3_prepare $DB {        INSERT INTO t2(a,b,c,d,e,f) VALUES(:abc,:xyz,:abc,:xy,:xyz,:abc)      } -1 TAIL    ]    sqlite3_bind_parameter_count $VM  } 3  set v1 {:xyz}  set v2 {:xy}}do_test bind-10.2 {  sqlite3_bind_parameter_index $VM :abc} 1do_test bind-10.3 {  sqlite3_bind_parameter_index $VM $v1} 2do_test bind-10.4 {  sqlite3_bind_parameter_index $VM $v2} 3do_test bind-10.5 {  sqlite3_bind_parameter_name $VM 1} :abcdo_test bind-10.6 {  sqlite3_bind_parameter_name $VM 2} $v1do_test bind-10.7 {  sqlite3_bind_parameter_name $VM 3} $v2do_test bind-10.7.1 {  sqlite3_bind_parameter_name 0 1   ;# Ignore if VM is NULL} {}do_test bind-10.7.2 {  sqlite3_bind_parameter_name $VM 0 ;# Ignore if index too small} {}do_test bind-10.7.3 {  sqlite3_bind_parameter_name $VM 4 ;# Ignore if index is too big} {}do_test bind-10.8 {  sqlite3_bind_int $VM 1 1  sqlite3_bind_int $VM 2 2  sqlite3_bind_int $VM 3 3  sqlite3_step $VM} SQLITE_DONEdo_test bind-10.8.1 {  # Binding attempts after program start should fail  set rc [catch {    sqlite3_bind_int $VM 1 1  } msg]  lappend rc $msg} {1 {}}do_test bind-10.9 {  sqlite3_finalize $VM} SQLITE_OKdo_test bind-10.10 {  execsql {SELECT * FROM t2}} {1 999 1000 1001 {} {} 1 2 1 3 2 1}# Ticket #918#do_test bind-10.11 {  # catch {sqlite3_finalize $VM}  set VM [    sqlite3_prepare $DB {      INSERT INTO t2(a,b,c,d,e,f) VALUES(:abc,?,?4,:pqr,:abc,?4)    } -1 TAIL  ]  sqlite3_bind_parameter_count $VM} 5do_test bind-10.11.1 {  sqlite3_bind_parameter_index 0 :xyz  ;# ignore NULL VM arguments} 0do_test bind-10.12 {  sqlite3_bind_parameter_index $VM :xyz} 0do_test bind-10.13 {  sqlite3_bind_parameter_index $VM {}} 0do_test bind-10.14 {  sqlite3_bind_parameter_index $VM :pqr} 5do_test bind-10.15 {  sqlite3_bind_parameter_index $VM ?4} 4do_test bind-10.16 {  sqlite3_bind_parameter_name $VM 1} :abcdo_test bind-10.17 {  sqlite3_bind_parameter_name $VM 2} {}do_test bind-10.18 {  sqlite3_bind_parameter_name $VM 3} {}do_test bind-10.19 {  sqlite3_bind_parameter_name $VM 4} {?4}do_test bind-10.20 {  sqlite3_bind_parameter_name $VM 5} :pqrcatch {sqlite3_finalize $VM}# Make sure we catch an unterminated "(" in a Tcl-style variable name#ifcapable tclvar {  do_test bind-11.1 {    catchsql {SELECT * FROM sqlite_master WHERE name=$abc(123 and sql NOT NULL;}  } {1 {unrecognized token: "$abc(123"}}}if {[execsql {pragma encoding}]=="UTF-8"} {  # Test the ability to bind text that contains embedded '\000' characters.  # Make sure we can recover the entire input string.  #  do_test bind-12.1 {    execsql {      CREATE TABLE t3(x BLOB);    }    set VM [sqlite3_prepare $DB {INSERT INTO t3 VALUES(?)} -1 TAIL]    sqlite_bind  $VM 1 not-used blob10    sqlite3_step $VM    sqlite3_finalize $VM    execsql {      SELECT typeof(x), length(x), quote(x),             length(cast(x AS BLOB)), quote(cast(x AS BLOB)) FROM t3    }  } {text 3 'abc' 10 X'6162630078797A007071'}  do_test bind-12.2 {    sqlite3_create_function $DB    execsql {      SELECT quote(cast(x_coalesce(x) AS blob)) FROM t3    }  } {X'6162630078797A007071'}}# Test the operation of sqlite3_clear_bindings#do_test bind-13.1 {  set VM [sqlite3_prepare $DB {SELECT ?,?,?} -1 TAIL]  sqlite3_step $VM  list [sqlite3_column_type $VM 0] [sqlite3_column_type $VM 1] \               [sqlite3_column_type $VM 2]} {NULL NULL NULL}do_test bind-13.2 {  sqlite3_reset $VM  sqlite3_bind_int $VM 1 1  sqlite3_bind_int $VM 2 2  sqlite3_bind_int $VM 3 3  sqlite3_step $VM  list [sqlite3_column_type $VM 0] [sqlite3_column_type $VM 1] \               [sqlite3_column_type $VM 2]} {INTEGER INTEGER INTEGER}do_test bind-13.3 {  sqlite3_reset $VM  sqlite3_step $VM  list [sqlite3_column_type $VM 0] [sqlite3_column_type $VM 1] \               [sqlite3_column_type $VM 2]} {INTEGER INTEGER INTEGER}do_test bind-13.4 {  sqlite3_reset $VM  sqlite3_clear_bindings $VM  sqlite3_step $VM  list [sqlite3_column_type $VM 0] [sqlite3_column_type $VM 1] \               [sqlite3_column_type $VM 2]} {NULL NULL NULL}sqlite3_finalize $VMfinish_test

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -