DBI bind_param NULL semantics across DBD::Pg and DBD::SQLite
0 reputation · 10 Dec 2020, 22:42 UTC
Integration boundary
The DBI front end accepts undef as a placeholder value and offers the TYPE attribute via bind_param to hint at SQL type. The DBD back ends—specifically DBD::Pg and DBD::SQLite—implement the actual transmission of that value to their respective servers. The DBI specification treats the TYPE hint as advisory and does not mandate a uniform NULL representation.
Unresolved behavior
When an application binds undef with SQL_INTEGER or SQL_VARCHAR, one driver may send a true SQL NULL while another may transmit an empty string or a zero, depending on driver version and server settings. This variance is not a bug in either DBD; it reflects the lack of a cross-driver contract for undef handling. The goal is to determine whether a portable test can confirm the actual wire representation without relying on driver-specific documentation.
Constraints: the test must work against a live PostgreSQL and SQLite instance, use only core DBI and the two DBDs, and avoid driver-specific tracing flags.
- Does a single DBI script using
bind_paramwithundefand explicitTYPEhints produce identicalNULLresults in bothDBD::PgandDBD::SQLite? - If the results differ, which combination of driver version and server configuration determines the divergence?