BUG: Unable to bind a null value typed as a UUID in a PreparedStatement

From: Rémi Aubel <remi(dot)aubel(at)gmail(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG: Unable to bind a null value typed as a UUID in a PreparedStatement
Date: 2018-03-28 13:26:48
Message-ID: CAG2M1fdAFD3N8vZxp4TYLEYz4Rwu5f94ghafEErvHv387oWf8g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.
--

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message David G. Johnston 2018-03-28 13:59:26 Re: BUG: Unable to bind a null value typed as a UUID in a PreparedStatement
Previous Message Michael Paquier 2018-03-28 12:12:52 Re: BUG #15132: Build fails in src/backend/utils/adt/encode.c