BUG: Unable to bind a null value typed as a UUID in a PreparedStatement - Mailing list pgsql-bugs

From Rémi Aubel
Subject BUG: Unable to bind a null value typed as a UUID in a PreparedStatement
Date
Msg-id CAG2M1fdAFD3N8vZxp4TYLEYz4Rwu5f94ghafEErvHv387oWf8g@mail.gmail.com
Whole thread Raw
Responses Re: BUG: Unable to bind a null value typed as a UUID in a PreparedStatement  ("David G. Johnston" <david.g.johnston@gmail.com>)
Re: BUG: Unable to bind a null value typed as a UUID in a PreparedStatement  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
I need to bind a UUID parameter which may be null in a statement like "select * from test table where ? is null or ? = c_uuid".
Whatever approach I use, the driver rejects my request with "ERROR: could not determine data type of parameter $1".

See the code here: https://ideone.com/DKnqa9

When run, it gives the output below: 
JDBC Driver Version: 42.2.1
PostgreSQL version: PostgreSQL 9.5.9 on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609, 64-bit
setNull(varchar) + setObject(null) => works
setNull(other) + setNull(other) => fails (ERROR: could not determine data type of parameter $1)
setNull(other, uuid) + setNull(other, uuid) => fails (ERROR: could not determine data type of parameter $1)

The third case (last line above) uses method PreparedStatement.setNull(pos, type, typeName) and should work.
But in the current implementation of the driver, the PreparedStatement.setNull(int, int, String) delegates to setNull(int, int) so that specifying the type name has no effect.
--


pgsql-bugs by date:

Previous
From: Michael Paquier
Date:
Subject: Re: BUG #15132: Build fails in src/backend/utils/adt/encode.c
Next
From: "David G. Johnston"
Date:
Subject: Re: BUG: Unable to bind a null value typed as a UUID in a PreparedStatement