#!../jet-2.0 End-to-end tests for / - see docs/design-sql-bound-parameters.md. Run by tests/runbindtests.sh against a real MySQL server; only TEMPORARY tables are used, so nothing outlives the connection. Compared byte-for-byte with tests/testbind.expected. Generated - contains raw 0xBF and NUL bytes. create temporary table bindtest (id int auto_increment primary key, s varbinary(255), n int, dec_v decimal(10,2), d date, dt datetime, b tinyint, t varchar(100) character set utf8mb4) Injection strings and odd bytes come back byte-for-byte. insert into bindtest (s) values (?) select hex(s) as h from bindtest where id=last_insert_id() default plain: $[.h] insert into bindtest (s) values (?) select hex(s) as h from bindtest where id=last_insert_id() default or-injection: $[.h] insert into bindtest (s) values (?) select hex(s) as h from bindtest where id=last_insert_id() default backslash-quote: $[.h] select concat('a', char(92)) as v insert into bindtest (s) values (?) select hex(s) as h from bindtest where id=last_insert_id() default trailing-backslash: $[.h] insert into bindtest (s) values (?) select hex(s) as h from bindtest where id=last_insert_id() default dashdash: $[.h] insert into bindtest (s) values (?) select hex(s) as h from bindtest where id=last_insert_id() default semicolon: $[.h] insert into bindtest (s) values (?) select hex(s) as h from bindtest where id=last_insert_id() default gbk-bf27: $[.h] insert into bindtest (s) values (?) select hex(s) as h from bindtest where id=last_insert_id() default double-quote: $[.h] insert into bindtest (s) values (?) select hex(s) as h from bindtest where id=last_insert_id() default question: $[.h] insert into bindtest (s) values (?) select hex(s) as h from bindtest where id=last_insert_id() default nul: $[.h] insert into bindtest (s) values (?) select hex(s) as h from bindtest where id=last_insert_id() default utf8: $[.h] set session sql_mode = concat(@@sql_mode, ',NO_BACKSLASH_ESCAPES') insert into bindtest (s) values (?) select hex(s) as h from bindtest where id=last_insert_id() nbe plain: $[.h] insert into bindtest (s) values (?) select hex(s) as h from bindtest where id=last_insert_id() nbe or-injection: $[.h] insert into bindtest (s) values (?) select hex(s) as h from bindtest where id=last_insert_id() nbe backslash-quote: $[.h] select concat('a', char(92)) as v insert into bindtest (s) values (?) select hex(s) as h from bindtest where id=last_insert_id() nbe trailing-backslash: $[.h] insert into bindtest (s) values (?) select hex(s) as h from bindtest where id=last_insert_id() nbe dashdash: $[.h] insert into bindtest (s) values (?) select hex(s) as h from bindtest where id=last_insert_id() nbe semicolon: $[.h] insert into bindtest (s) values (?) select hex(s) as h from bindtest where id=last_insert_id() nbe gbk-bf27: $[.h] insert into bindtest (s) values (?) select hex(s) as h from bindtest where id=last_insert_id() nbe double-quote: $[.h] insert into bindtest (s) values (?) select hex(s) as h from bindtest where id=last_insert_id() nbe question: $[.h] insert into bindtest (s) values (?) select hex(s) as h from bindtest where id=last_insert_id() nbe nul: $[.h] insert into bindtest (s) values (?) select hex(s) as h from bindtest where id=last_insert_id() nbe utf8: $[.h] set session sql_mode = replace(@@sql_mode, 'NO_BACKSLASH_ESCAPES', '') Every type. insert into bindtest (n, dec_v, d, dt, b, t) values (?, ?, ?, ?, ?, ?) select n, dec_v, d, dt, b, t is null as tnull from bindtest where id=last_insert_id() types: $[.n] $[.dec_v] $[.d] $[.dt] $[.b] $[.tnull] ? inside literals, identifiers and comments is left alone. select '?' as a, "?" as `b?`, ? as c /* ? */ -- ? literals: $[.a] $[.b?] $[.c] A query with no bind runs unchanged, even with a literal ?. select concat('what', '?') as q nobind: $[.q] bind inside if inside sql. select ? as x nested: $[.x] ident with allow, order by. insert into bindtest (n) values (5), (3), (9) select n from bindtest where n in (?, ?, ?) order by ? ? ident: $[.n] Result access on a bound query: whilerow, column names and counts. select n, s from bindtest where n > ? order by n rows: $[.#] columns: $[.?#] first column: $[.?1] second column: $[.?2] Errors - all catchable, none echo the value. select ?, ?, ?mismatch: $[err] select ?badint: $[err] select ?baddate: $[err] select ? from bindtestbadident: $[err] outside: $[err] select 1novalue: $[err] select ?badtype: $[err] SET NAMES latin1setnames: $[err] set character_set_client = gbksetcharset: $[err] select @@character_set_client as cs charset: $[.cs]