]
Work on TEIID-5615 started by Steven Hawkins.
---------------------------------------------
Error when binding NULL to nullable parameter in a prepared statement
with PDO PostgreSQL ODBC client
-----------------------------------------------------------------------------------------------------
Key: TEIID-5615
URL:
https://issues.jboss.org/browse/TEIID-5615
Project: Teiid
Issue Type: Bug
Components: ODBC
Affects Versions: 11.0, 11.2
Environment: All infrastructure is Dockerized on Windows 64bit (see below)
WildFly Full 11.0.0.Final (WildFly Core 3.0.8.Final)
Teiid Engine 11.2.0
DatabaseProductVersion=11.1 (Debian 11.1-1.pgdg90+1)
PostgreSQL JDBC Driver=42.2.5
PDO Driver for PostgreSQL (from phpinfo())
PostgreSQL(libpq) Version: 9.6.10
Module version: 7.1.26
Reporter: George Ushakov
Assignee: Steven Hawkins
Priority: Major
On Teiid 11.0 (and probably later versions, as well) running in a WildFly there is a
problem when binding to a NULLABLE parameter in a prepared statement with NULL value when
running against a PostgreSQL source from a PDO (PHP) ODBC client.
PDO calls causing the error are related to
[
PDOStatement::bindValue|https://secure.php.net/manual/en/pdostatement.bin...]
and
[
PDOStatement::bindParam|https://secure.php.net/manual/en/pdostatement.bin...].
It occurs exclusively when the client is trying to bind a NULL value (corresponding to a
NULLABLE column in a table) to the prepared statement using PDO::PARAM_NULL type.
Example PHP code
{code:php}
$dbh = new
PDO('pgsql:host=<teiid_host>;port=35432;dbname=<vdb_name>;user=<teiid_user>;password=<teiid_password>');
$stmt = $dbh->prepare("INSERT INTO foobar (id, optional) VALUES(?, ?)");
$stmt->bindValue(1, 1);
$stmt->bindValue(2, null, PDO::PARAM_NULL);
$stmt->execute();
{code}
Exception thrown is
Caused by: java.lang.NegativeArraySizeException
at
org.teiid.transport.PgFrontendProtocol.createByteArray(PgFrontendProtocol.java:328)
at org.teiid.transport.PgFrontendProtocol.buildBind(PgFrontendProtocol.java:266)
at
org.teiid.transport.PgFrontendProtocol.createRequestMessage(PgFrontendProtocol.java:153)
at org.teiid.transport.PgFrontendProtocol.decode(PgFrontendProtocol.java:133)
at
io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:411)
... 15 more