NAME
DBIO::Storage::DBI::NoBindVars - Some DBDs have poor to no support for bind variables
VERSION
version 0.900004
DESCRIPTION
This class allows queries to work when the DBD or underlying library does not support the usual ? placeholders, or at least doesn't support them very well, as is the case with DBD::Sybase
METHODS
connect_info
We can't cache very effectively without bind variables, so force the disable_sth_caching setting to be turned on when the connect info is set.
_prep_for_execute
Manually subs in the values for the usual ? placeholders.
_prep_rendered_for_execute
The same substitution for a statement core rendered itself rather than generated through sql_maker -- the EXISTS statement "results_exist" in DBIO::ResultSet runs (ADR 0037). It does not pass through "_prep_for_execute", so without this it would reach an engine with no usable placeholders with its ? intact.
_interpolate_bind_values
Stringify the bind args, quote them via $dbh, and manually insert them in place of the ? placeholders. Returns the new SQL and an empty bind list; the list is an object of DBIO::Storage::DBI::NoBindVars::Interpolated that keeps the statement in placeholder form and the values apart, for the text of an error.
The placeholders are the free ? found by "split_at_placeholders"; a ? inside a quoted identifier or a string literal is part of the name or the text. The number of placeholders has to equal the number of binds, otherwise the statement is refused with placeholder count N does not match bind count M.
_error_form_of_bind
The statement of an error text is the statement in placeholder form with the number of values written into it (VALUES (?, ?) with 2 bind values), and the values go to "_mask_error_values" in DBIO::Storage::DBI: the statement that reaches the engine carries them, the text of an error does not.
split_at_placeholders
my @part = DBIO::Storage::DBI::NoBindVars::split_at_placeholders($sql);
A function, not a method of the storage. Walks the rendered statement and returns the text between its placeholders, so the result has one element more than the statement has placeholders (empty elements at either end are kept). A placeholder is a ? outside any quoted identifier ("...", `...`, [...], the closing quote doubled inside), outside any string literal ('...', with '' for a quote inside) and outside any SQL comment (-- to the end of the line, /* ... */). A ? in one of those stays in the text, and so does a -- or /* inside a literal or a quoted identifier. A comment left open at the end of the statement is text up to the end. A driver with an interpolation path of its own uses this function to find its placeholders instead of searching the text for ?, and compares their number with the number of binds.
placeholder_offsets
my @offset = DBIO::Storage::DBI::NoBindVars::placeholder_offsets($sql);
A function, not a method of the storage. Returns the character offset of every free placeholder in the statement, in order. It applies the rule of "split_at_placeholders" (the two share one scanner), so substr($sql, $offset, 1) is ? for each offset and their number is the number of placeholders.
interpolate_unquoted
This method is called by "_interpolate_bind_values" (and so by both "_prep_for_execute" and "_prep_rendered_for_execute") for every bind value that carries a data type, in order to determine if its value should be quoted or not. The arguments are the current column data type and the actual bind value. The return value is interpreted as: true - do not quote, false - do quote. You should override this in your Storage::DBI::<database> subclass, if your RDBMS does not like quotes around certain datatypes (e.g. Sybase and integer columns). The default method returns false, except for integer datatypes paired with values containing nothing but digits.
WARNING!!!
Always validate that the bind-value is valid for the current datatype.
Otherwise you may very well open the door to SQL injection attacks.
_prep_interpolated_value
Given a datatype and the value to be inserted directly into a SQL query, returns the necessary string to represent that value (by e.g. adding a '$' sign)
AUTHOR
DBIO & DBIx::Class Authors
COPYRIGHT AND LICENSE
Copyright (C) 2026 DBIO Authors Portions Copyright (C) 2005-2025 DBIx::Class Authors Based on DBIx::Class, heavily modified.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.