pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG: Unable to bind a null value typed as a UUID in a PreparedStatement
12+ messages / 4 participants
[nested] [flat]

* BUG: Unable to bind a null value typed as a UUID in a PreparedStatement
@ 2018-03-28 13:26 Rémi Aubel <remi.aubel@gmail.com>
  2018-03-28 13:59 ` Re: BUG: Unable to bind a null value typed as a UUID in a PreparedStatement David G. Johnston <david.g.johnston@gmail.com>
  2018-03-28 14:30 ` Re: BUG: Unable to bind a null value typed as a UUID in a PreparedStatement Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 2 replies; 12+ messages in thread

From: Rémi Aubel @ 2018-03-28 13:26 UTC (permalink / raw)
  To: 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.
--

^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* Re: BUG: Unable to bind a null value typed as a UUID in a PreparedStatement
  2018-03-28 13:26 BUG: Unable to bind a null value typed as a UUID in a PreparedStatement Rémi Aubel <remi.aubel@gmail.com>
@ 2018-03-28 13:59 ` David G. Johnston <david.g.johnston@gmail.com>
  2018-03-28 14:11   ` Re: BUG: Unable to bind a null value typed as a UUID in a PreparedStatement Dave Cramer <davecramer@gmail.com>
  1 sibling, 1 reply; 12+ messages in thread

From: David G. Johnston @ 2018-03-28 13:59 UTC (permalink / raw)
  To: Rémi Aubel <remi.aubel@gmail.com>; +Cc: pgsql-bugs

On Wed, Mar 28, 2018 at 6:26 AM, Rémi Aubel <remi.aubel@gmail.com> wrote:

> 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".
> ​[...]​
> 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.
>

​JDBC Driver bugs are off-topic for this list.  They should be reported on
the project's GitHub site's Issues List.

David J.

^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* Re: BUG: Unable to bind a null value typed as a UUID in a PreparedStatement
  2018-03-28 13:26 BUG: Unable to bind a null value typed as a UUID in a PreparedStatement Rémi Aubel <remi.aubel@gmail.com>
  2018-03-28 13:59 ` Re: BUG: Unable to bind a null value typed as a UUID in a PreparedStatement David G. Johnston <david.g.johnston@gmail.com>
@ 2018-03-28 14:11   ` Dave Cramer <davecramer@gmail.com>
  2018-03-28 14:25     ` Re: BUG: Unable to bind a null value typed as a UUID in a PreparedStatement Rémi Aubel <remi.aubel@gmail.com>
  0 siblings, 1 reply; 12+ messages in thread

From: Dave Cramer @ 2018-03-28 14:11 UTC (permalink / raw)
  To: David G. Johnston <david.g.johnston@gmail.com>; +Cc: Rémi Aubel <remi.aubel@gmail.com>; pgsql-bugs

Remi,

See https://github.com/pgjdbc/pgjdbc/pull/1160

Dave Cramer

On 28 March 2018 at 09:59, David G. Johnston <david.g.johnston@gmail.com>
wrote:

> On Wed, Mar 28, 2018 at 6:26 AM, Rémi Aubel <remi.aubel@gmail.com> wrote:
>
>> 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".
>> ​[...]​
>> 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.
>>
>
> ​JDBC Driver bugs are off-topic for this list.  They should be reported on
> the project's GitHub site's Issues List.
>
> David J.
>
>
>

^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* Re: BUG: Unable to bind a null value typed as a UUID in a PreparedStatement
  2018-03-28 13:26 BUG: Unable to bind a null value typed as a UUID in a PreparedStatement Rémi Aubel <remi.aubel@gmail.com>
  2018-03-28 13:59 ` Re: BUG: Unable to bind a null value typed as a UUID in a PreparedStatement David G. Johnston <david.g.johnston@gmail.com>
  2018-03-28 14:11   ` Re: BUG: Unable to bind a null value typed as a UUID in a PreparedStatement Dave Cramer <davecramer@gmail.com>
@ 2018-03-28 14:25     ` Rémi Aubel <remi.aubel@gmail.com>
  2018-03-28 14:27       ` Re: BUG: Unable to bind a null value typed as a UUID in a PreparedStatement Dave Cramer <davecramer@gmail.com>
  0 siblings, 1 reply; 12+ messages in thread

From: Rémi Aubel @ 2018-03-28 14:25 UTC (permalink / raw)
  To: Dave Cramer <davecramer@gmail.com>; +Cc: David G. Johnston <david.g.johnston@gmail.com>; pgsql-bugs

Oh Thanks, Dave!
I had created the issue on GitHub (
https://github.com/pgjdbc/pgjdbc/issues/1161) and saw you marked it as
duplicate.

Le mer. 28 mars 2018 à 16:12, Dave Cramer <davecramer@gmail.com> a écrit :

> Remi,
>
> See https://github.com/pgjdbc/pgjdbc/pull/1160
>
> Dave Cramer
>
> On 28 March 2018 at 09:59, David G. Johnston <david.g.johnston@gmail.com>
> wrote:
>
>> On Wed, Mar 28, 2018 at 6:26 AM, Rémi Aubel <remi.aubel@gmail.com> wrote:
>>
>>> 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".
>>> ​[...]​
>>> 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.
>>>
>>
>> ​JDBC Driver bugs are off-topic for this list.  They should be reported
>> on the project's GitHub site's Issues List.
>>
>> David J.
>>
>>
>>
> --

^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* Re: BUG: Unable to bind a null value typed as a UUID in a PreparedStatement
  2018-03-28 13:26 BUG: Unable to bind a null value typed as a UUID in a PreparedStatement Rémi Aubel <remi.aubel@gmail.com>
  2018-03-28 13:59 ` Re: BUG: Unable to bind a null value typed as a UUID in a PreparedStatement David G. Johnston <david.g.johnston@gmail.com>
  2018-03-28 14:11   ` Re: BUG: Unable to bind a null value typed as a UUID in a PreparedStatement Dave Cramer <davecramer@gmail.com>
  2018-03-28 14:25     ` Re: BUG: Unable to bind a null value typed as a UUID in a PreparedStatement Rémi Aubel <remi.aubel@gmail.com>
@ 2018-03-28 14:27       ` Dave Cramer <davecramer@gmail.com>
  0 siblings, 0 replies; 12+ messages in thread

From: Dave Cramer @ 2018-03-28 14:27 UTC (permalink / raw)
  To: Rémi Aubel <remi.aubel@gmail.com>; +Cc: David G. Johnston <david.g.johnston@gmail.com>; pgsql-bugs

@Remi,

You are welcome. It would be wonderful it you could test the fix ?



Dave Cramer

On 28 March 2018 at 10:25, Rémi Aubel <remi.aubel@gmail.com> wrote:

> Oh Thanks, Dave!
> I had created the issue on GitHub (https://github.com/pgjdbc/
> pgjdbc/issues/1161) and saw you marked it as duplicate.
>
> Le mer. 28 mars 2018 à 16:12, Dave Cramer <davecramer@gmail.com> a écrit :
>
>> Remi,
>>
>> See https://github.com/pgjdbc/pgjdbc/pull/1160
>>
>> Dave Cramer
>>
>> On 28 March 2018 at 09:59, David G. Johnston <david.g.johnston@gmail.com>
>> wrote:
>>
>>> On Wed, Mar 28, 2018 at 6:26 AM, Rémi Aubel <remi.aubel@gmail.com>
>>> wrote:
>>>
>>>> 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".
>>>> ​[...]​
>>>> 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.
>>>>
>>>
>>> ​JDBC Driver bugs are off-topic for this list.  They should be reported
>>> on the project's GitHub site's Issues List.
>>>
>>> David J.
>>>
>>>
>>>
>> --
>
>
>

^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* Re: BUG: Unable to bind a null value typed as a UUID in a PreparedStatement
  2018-03-28 13:26 BUG: Unable to bind a null value typed as a UUID in a PreparedStatement Rémi Aubel <remi.aubel@gmail.com>
@ 2018-03-28 14:30 ` Tom Lane <tgl@sss.pgh.pa.us>
  2018-03-28 14:38   ` Re: BUG: Unable to bind a null value typed as a UUID in a PreparedStatement Dave Cramer <davecramer@gmail.com>
  1 sibling, 1 reply; 12+ messages in thread

From: Tom Lane @ 2018-03-28 14:30 UTC (permalink / raw)
  To: Rémi Aubel <remi.aubel@gmail.com>; +Cc: pgsql-bugs

=?UTF-8?Q?R=C3=A9mi_Aubel?= <remi.aubel@gmail.com> writes:
> 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".

Some experimentation suggests that it'd probably work if you wrote the
clauses in the other order:

regression=# create table test_table (c_uuid uuid);
CREATE TABLE
regression=# prepare foo as select * from test_table where $1 is null or $1 = c_uuid;
ERROR:  could not determine data type of parameter $1
LINE 1: prepare foo as select * from test_table where $1 is null or ...
                                                      ^
regression=# prepare foo as select * from test_table where $1 = c_uuid or $1 is null;
PREPARE

In an ideal world, perhaps the order of the parameter references would not
matter, but AFAICS making that work would be mighty hard.  For now, PG's
parser wants to resolve the type of an otherwise-unlabeled parameter
symbol the first time it sees it --- and the context "IS NULL" offers
no clue what type it should be.

Alternatively, you could force the issue with an explicit cast in the
text of the query:

regression=# prepare foo2 as select * from test_table where $1::uuid is null or $1 = c_uuid;
PREPARE

			regards, tom lane




^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* Re: BUG: Unable to bind a null value typed as a UUID in a PreparedStatement
  2018-03-28 13:26 BUG: Unable to bind a null value typed as a UUID in a PreparedStatement Rémi Aubel <remi.aubel@gmail.com>
  2018-03-28 14:30 ` Re: BUG: Unable to bind a null value typed as a UUID in a PreparedStatement Tom Lane <tgl@sss.pgh.pa.us>
@ 2018-03-28 14:38   ` Dave Cramer <davecramer@gmail.com>
  2018-03-28 15:08     ` Re: BUG: Unable to bind a null value typed as a UUID in a PreparedStatement Rémi Aubel <remi.aubel@gmail.com>
  0 siblings, 1 reply; 12+ messages in thread

From: Dave Cramer @ 2018-03-28 14:38 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Rémi Aubel <remi.aubel@gmail.com>; pgsql-bugs

On 28 March 2018 at 10:30, Tom Lane <tgl@sss.pgh.pa.us> wrote:

> =?UTF-8?Q?R=C3=A9mi_Aubel?= <remi.aubel@gmail.com> writes:
> > 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".
>
> Some experimentation suggests that it'd probably work if you wrote the
> clauses in the other order:
>
> regression=# create table test_table (c_uuid uuid);
> CREATE TABLE
> regression=# prepare foo as select * from test_table where $1 is null or
> $1 = c_uuid;
> ERROR:  could not determine data type of parameter $1
> LINE 1: prepare foo as select * from test_table where $1 is null or ...
>                                                       ^
> regression=# prepare foo as select * from test_table where $1 = c_uuid or
> $1 is null;
> PREPARE
>
> In an ideal world, perhaps the order of the parameter references would not
> matter, but AFAICS making that work would be mighty hard.  For now, PG's
> parser wants to resolve the type of an otherwise-unlabeled parameter
> symbol the first time it sees it --- and the context "IS NULL" offers
> no clue what type it should be.
>
> Alternatively, you could force the issue with an explicit cast in the
> text of the query:
>
> regression=# prepare foo2 as select * from test_table where $1::uuid is
> null or $1 = c_uuid;
> PREPARE
>

Tom,

This is just a simple example of a bigger problem. One for which there is a
solution in the driver which was not implemented.

I have implemented it now.

Thanks,

Dave

^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* Re: BUG: Unable to bind a null value typed as a UUID in a PreparedStatement
  2018-03-28 13:26 BUG: Unable to bind a null value typed as a UUID in a PreparedStatement Rémi Aubel <remi.aubel@gmail.com>
  2018-03-28 14:30 ` Re: BUG: Unable to bind a null value typed as a UUID in a PreparedStatement Tom Lane <tgl@sss.pgh.pa.us>
  2018-03-28 14:38   ` Re: BUG: Unable to bind a null value typed as a UUID in a PreparedStatement Dave Cramer <davecramer@gmail.com>
@ 2018-03-28 15:08     ` Rémi Aubel <remi.aubel@gmail.com>
  2018-04-03 10:29       ` Re: BUG: Unable to bind a null value typed as a UUID in a PreparedStatement Rémi Aubel <remi.aubel@gmail.com>
  0 siblings, 1 reply; 12+ messages in thread

From: Rémi Aubel @ 2018-03-28 15:08 UTC (permalink / raw)
  To: Dave Cramer <davecramer@gmail.com>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; pgsql-bugs

@Dave,

I have just tested it. It works fine with setNull(_, 1111, "uuid").
Thanks again :-)

Rémi

Le mer. 28 mars 2018 à 16:38, Dave Cramer <davecramer@gmail.com> a écrit :

> On 28 March 2018 at 10:30, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>
>> =?UTF-8?Q?R=C3=A9mi_Aubel?= <remi.aubel@gmail.com> writes:
>> > 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".
>>
>> Some experimentation suggests that it'd probably work if you wrote the
>> clauses in the other order:
>>
>> regression=# create table test_table (c_uuid uuid);
>> CREATE TABLE
>> regression=# prepare foo as select * from test_table where $1 is null or
>> $1 = c_uuid;
>> ERROR:  could not determine data type of parameter $1
>> LINE 1: prepare foo as select * from test_table where $1 is null or ...
>>                                                       ^
>> regression=# prepare foo as select * from test_table where $1 = c_uuid or
>> $1 is null;
>> PREPARE
>>
>> In an ideal world, perhaps the order of the parameter references would not
>> matter, but AFAICS making that work would be mighty hard.  For now, PG's
>> parser wants to resolve the type of an otherwise-unlabeled parameter
>> symbol the first time it sees it --- and the context "IS NULL" offers
>> no clue what type it should be.
>>
>> Alternatively, you could force the issue with an explicit cast in the
>> text of the query:
>>
>> regression=# prepare foo2 as select * from test_table where $1::uuid is
>> null or $1 = c_uuid;
>> PREPARE
>>
>
> Tom,
>
> This is just a simple example of a bigger problem. One for which there is
> a solution in the driver which was not implemented.
>
> I have implemented it now.
>
> Thanks,
>
> Dave
>
--

^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* Re: BUG: Unable to bind a null value typed as a UUID in a PreparedStatement
  2018-03-28 13:26 BUG: Unable to bind a null value typed as a UUID in a PreparedStatement Rémi Aubel <remi.aubel@gmail.com>
  2018-03-28 14:30 ` Re: BUG: Unable to bind a null value typed as a UUID in a PreparedStatement Tom Lane <tgl@sss.pgh.pa.us>
  2018-03-28 14:38   ` Re: BUG: Unable to bind a null value typed as a UUID in a PreparedStatement Dave Cramer <davecramer@gmail.com>
  2018-03-28 15:08     ` Re: BUG: Unable to bind a null value typed as a UUID in a PreparedStatement Rémi Aubel <remi.aubel@gmail.com>
@ 2018-04-03 10:29       ` Rémi Aubel <remi.aubel@gmail.com>
  2018-04-03 10:42         ` Re: BUG: Unable to bind a null value typed as a UUID in a PreparedStatement Dave Cramer <davecramer@gmail.com>
  0 siblings, 1 reply; 12+ messages in thread

From: Rémi Aubel @ 2018-04-03 10:29 UTC (permalink / raw)
  To: Dave Cramer <davecramer@gmail.com>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; pgsql-bugs

Hello,

Do you know when the next driver release (including fix
https://github.com/pgjdbc/pgjdbc/pull/1160) is expected?

Rémi

Le mer. 28 mars 2018 à 17:08, Rémi Aubel <remi.aubel@gmail.com> a écrit :

> @Dave,
>
> I have just tested it. It works fine with setNull(_, 1111, "uuid").
> Thanks again :-)
>
> Rémi
>
> Le mer. 28 mars 2018 à 16:38, Dave Cramer <davecramer@gmail.com> a écrit :
>
>> On 28 March 2018 at 10:30, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>>
>>> =?UTF-8?Q?R=C3=A9mi_Aubel?= <remi.aubel@gmail.com> writes:
>>> > 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".
>>>
>>> Some experimentation suggests that it'd probably work if you wrote the
>>> clauses in the other order:
>>>
>>> regression=# create table test_table (c_uuid uuid);
>>> CREATE TABLE
>>> regression=# prepare foo as select * from test_table where $1 is null or
>>> $1 = c_uuid;
>>> ERROR:  could not determine data type of parameter $1
>>> LINE 1: prepare foo as select * from test_table where $1 is null or ...
>>>                                                       ^
>>> regression=# prepare foo as select * from test_table where $1 = c_uuid
>>> or $1 is null;
>>> PREPARE
>>>
>>> In an ideal world, perhaps the order of the parameter references would
>>> not
>>> matter, but AFAICS making that work would be mighty hard.  For now, PG's
>>> parser wants to resolve the type of an otherwise-unlabeled parameter
>>> symbol the first time it sees it --- and the context "IS NULL" offers
>>> no clue what type it should be.
>>>
>>> Alternatively, you could force the issue with an explicit cast in the
>>> text of the query:
>>>
>>> regression=# prepare foo2 as select * from test_table where $1::uuid is
>>> null or $1 = c_uuid;
>>> PREPARE
>>>
>>
>> Tom,
>>
>> This is just a simple example of a bigger problem. One for which there is
>> a solution in the driver which was not implemented.
>>
>> I have implemented it now.
>>
>> Thanks,
>>
>> Dave
>>
> --
>
>
> --

^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* Re: BUG: Unable to bind a null value typed as a UUID in a PreparedStatement
  2018-03-28 13:26 BUG: Unable to bind a null value typed as a UUID in a PreparedStatement Rémi Aubel <remi.aubel@gmail.com>
  2018-03-28 14:30 ` Re: BUG: Unable to bind a null value typed as a UUID in a PreparedStatement Tom Lane <tgl@sss.pgh.pa.us>
  2018-03-28 14:38   ` Re: BUG: Unable to bind a null value typed as a UUID in a PreparedStatement Dave Cramer <davecramer@gmail.com>
  2018-03-28 15:08     ` Re: BUG: Unable to bind a null value typed as a UUID in a PreparedStatement Rémi Aubel <remi.aubel@gmail.com>
  2018-04-03 10:29       ` Re: BUG: Unable to bind a null value typed as a UUID in a PreparedStatement Rémi Aubel <remi.aubel@gmail.com>
@ 2018-04-03 10:42         ` Dave Cramer <davecramer@gmail.com>
  2018-04-03 11:19           ` Re: BUG: Unable to bind a null value typed as a UUID in a PreparedStatement Rémi Aubel <remi.aubel@gmail.com>
  0 siblings, 1 reply; 12+ messages in thread

From: Dave Cramer @ 2018-04-03 10:42 UTC (permalink / raw)
  To: Rémi Aubel <remi.aubel@gmail.com>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; pgsql-bugs

Hi Remi,

https://github.com/pgjdbc/pgjdbc/milestones approximately.

Dave Cramer

On 3 April 2018 at 06:29, Rémi Aubel <remi.aubel@gmail.com> wrote:

> Hello,
>
> Do you know when the next driver release (including fix
> https://github.com/pgjdbc/pgjdbc/pull/1160) is expected?
>
> Rémi
>
> Le mer. 28 mars 2018 à 17:08, Rémi Aubel <remi.aubel@gmail.com> a écrit :
>
>> @Dave,
>>
>> I have just tested it. It works fine with setNull(_, 1111, "uuid").
>> Thanks again :-)
>>
>> Rémi
>>
>> Le mer. 28 mars 2018 à 16:38, Dave Cramer <davecramer@gmail.com> a
>> écrit :
>>
>>> On 28 March 2018 at 10:30, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>>>
>>>> =?UTF-8?Q?R=C3=A9mi_Aubel?= <remi.aubel@gmail.com> writes:
>>>> > 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".
>>>>
>>>> Some experimentation suggests that it'd probably work if you wrote the
>>>> clauses in the other order:
>>>>
>>>> regression=# create table test_table (c_uuid uuid);
>>>> CREATE TABLE
>>>> regression=# prepare foo as select * from test_table where $1 is null
>>>> or $1 = c_uuid;
>>>> ERROR:  could not determine data type of parameter $1
>>>> LINE 1: prepare foo as select * from test_table where $1 is null or ...
>>>>                                                       ^
>>>> regression=# prepare foo as select * from test_table where $1 = c_uuid
>>>> or $1 is null;
>>>> PREPARE
>>>>
>>>> In an ideal world, perhaps the order of the parameter references would
>>>> not
>>>> matter, but AFAICS making that work would be mighty hard.  For now, PG's
>>>> parser wants to resolve the type of an otherwise-unlabeled parameter
>>>> symbol the first time it sees it --- and the context "IS NULL" offers
>>>> no clue what type it should be.
>>>>
>>>> Alternatively, you could force the issue with an explicit cast in the
>>>> text of the query:
>>>>
>>>> regression=# prepare foo2 as select * from test_table where $1::uuid is
>>>> null or $1 = c_uuid;
>>>> PREPARE
>>>>
>>>
>>> Tom,
>>>
>>> This is just a simple example of a bigger problem. One for which there
>>> is a solution in the driver which was not implemented.
>>>
>>> I have implemented it now.
>>>
>>> Thanks,
>>>
>>> Dave
>>>
>> --
>>
>>
>> --
>
>
>

^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* Re: BUG: Unable to bind a null value typed as a UUID in a PreparedStatement
  2018-03-28 13:26 BUG: Unable to bind a null value typed as a UUID in a PreparedStatement Rémi Aubel <remi.aubel@gmail.com>
  2018-03-28 14:30 ` Re: BUG: Unable to bind a null value typed as a UUID in a PreparedStatement Tom Lane <tgl@sss.pgh.pa.us>
  2018-03-28 14:38   ` Re: BUG: Unable to bind a null value typed as a UUID in a PreparedStatement Dave Cramer <davecramer@gmail.com>
  2018-03-28 15:08     ` Re: BUG: Unable to bind a null value typed as a UUID in a PreparedStatement Rémi Aubel <remi.aubel@gmail.com>
  2018-04-03 10:29       ` Re: BUG: Unable to bind a null value typed as a UUID in a PreparedStatement Rémi Aubel <remi.aubel@gmail.com>
  2018-04-03 10:42         ` Re: BUG: Unable to bind a null value typed as a UUID in a PreparedStatement Dave Cramer <davecramer@gmail.com>
@ 2018-04-03 11:19           ` Rémi Aubel <remi.aubel@gmail.com>
  2018-04-25 14:15             ` Re: BUG: Unable to bind a null value typed as a UUID in a PreparedStatement Rémi Aubel <remi.aubel@gmail.com>
  0 siblings, 1 reply; 12+ messages in thread

From: Rémi Aubel @ 2018-04-03 11:19 UTC (permalink / raw)
  To: Dave Cramer <davecramer@gmail.com>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; pgsql-bugs

Thanks

Le mar. 3 avr. 2018 à 12:43, Dave Cramer <davecramer@gmail.com> a écrit :

> Hi Remi,
>
> https://github.com/pgjdbc/pgjdbc/milestones approximately.
>
> Dave Cramer
>
> On 3 April 2018 at 06:29, Rémi Aubel <remi.aubel@gmail.com> wrote:
>
>> Hello,
>>
>> Do you know when the next driver release (including fix
>> https://github.com/pgjdbc/pgjdbc/pull/1160) is expected?
>>
>> Rémi
>>
>> Le mer. 28 mars 2018 à 17:08, Rémi Aubel <remi.aubel@gmail.com> a écrit :
>>
>>> @Dave,
>>>
>>> I have just tested it. It works fine with setNull(_, 1111, "uuid").
>>> Thanks again :-)
>>>
>>> Rémi
>>>
>>> Le mer. 28 mars 2018 à 16:38, Dave Cramer <davecramer@gmail.com> a
>>> écrit :
>>>
>>>> On 28 March 2018 at 10:30, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>>>>
>>>>> =?UTF-8?Q?R=C3=A9mi_Aubel?= <remi.aubel@gmail.com> writes:
>>>>> > 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".
>>>>>
>>>>> Some experimentation suggests that it'd probably work if you wrote the
>>>>> clauses in the other order:
>>>>>
>>>>> regression=# create table test_table (c_uuid uuid);
>>>>> CREATE TABLE
>>>>> regression=# prepare foo as select * from test_table where $1 is null
>>>>> or $1 = c_uuid;
>>>>> ERROR:  could not determine data type of parameter $1
>>>>> LINE 1: prepare foo as select * from test_table where $1 is null or ...
>>>>>                                                       ^
>>>>> regression=# prepare foo as select * from test_table where $1 = c_uuid
>>>>> or $1 is null;
>>>>> PREPARE
>>>>>
>>>>> In an ideal world, perhaps the order of the parameter references would
>>>>> not
>>>>> matter, but AFAICS making that work would be mighty hard.  For now,
>>>>> PG's
>>>>> parser wants to resolve the type of an otherwise-unlabeled parameter
>>>>> symbol the first time it sees it --- and the context "IS NULL" offers
>>>>> no clue what type it should be.
>>>>>
>>>>> Alternatively, you could force the issue with an explicit cast in the
>>>>> text of the query:
>>>>>
>>>>> regression=# prepare foo2 as select * from test_table where $1::uuid
>>>>> is null or $1 = c_uuid;
>>>>> PREPARE
>>>>>
>>>>
>>>> Tom,
>>>>
>>>> This is just a simple example of a bigger problem. One for which there
>>>> is a solution in the driver which was not implemented.
>>>>
>>>> I have implemented it now.
>>>>
>>>> Thanks,
>>>>
>>>> Dave
>>>>
>>> --
>>>
>>>
>>> --
>>
>>
>>
> --

^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* Re: BUG: Unable to bind a null value typed as a UUID in a PreparedStatement
  2018-03-28 13:26 BUG: Unable to bind a null value typed as a UUID in a PreparedStatement Rémi Aubel <remi.aubel@gmail.com>
  2018-03-28 14:30 ` Re: BUG: Unable to bind a null value typed as a UUID in a PreparedStatement Tom Lane <tgl@sss.pgh.pa.us>
  2018-03-28 14:38   ` Re: BUG: Unable to bind a null value typed as a UUID in a PreparedStatement Dave Cramer <davecramer@gmail.com>
  2018-03-28 15:08     ` Re: BUG: Unable to bind a null value typed as a UUID in a PreparedStatement Rémi Aubel <remi.aubel@gmail.com>
  2018-04-03 10:29       ` Re: BUG: Unable to bind a null value typed as a UUID in a PreparedStatement Rémi Aubel <remi.aubel@gmail.com>
  2018-04-03 10:42         ` Re: BUG: Unable to bind a null value typed as a UUID in a PreparedStatement Dave Cramer <davecramer@gmail.com>
  2018-04-03 11:19           ` Re: BUG: Unable to bind a null value typed as a UUID in a PreparedStatement Rémi Aubel <remi.aubel@gmail.com>
@ 2018-04-25 14:15             ` Rémi Aubel <remi.aubel@gmail.com>
  0 siblings, 0 replies; 12+ messages in thread

From: Rémi Aubel @ 2018-04-25 14:15 UTC (permalink / raw)
  To: Dave Cramer <davecramer@gmail.com>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; pgsql-bugs

Hi all,

Do you have any update about the release date for driver 42.2.3?

Rémi

Le mar. 3 avr. 2018 à 13:19, Rémi Aubel <remi.aubel@gmail.com> a écrit :

> Thanks
>
> Le mar. 3 avr. 2018 à 12:43, Dave Cramer <davecramer@gmail.com> a écrit :
>
>> Hi Remi,
>>
>> https://github.com/pgjdbc/pgjdbc/milestones approximately.
>>
>> Dave Cramer
>>
>> On 3 April 2018 at 06:29, Rémi Aubel <remi.aubel@gmail.com> wrote:
>>
>>> Hello,
>>>
>>> Do you know when the next driver release (including fix
>>> https://github.com/pgjdbc/pgjdbc/pull/1160) is expected?
>>>
>>> Rémi
>>>
>>> Le mer. 28 mars 2018 à 17:08, Rémi Aubel <remi.aubel@gmail.com> a
>>> écrit :
>>>
>>>> @Dave,
>>>>
>>>> I have just tested it. It works fine with setNull(_, 1111, "uuid").
>>>> Thanks again :-)
>>>>
>>>> Rémi
>>>>
>>>> Le mer. 28 mars 2018 à 16:38, Dave Cramer <davecramer@gmail.com> a
>>>> écrit :
>>>>
>>>>> On 28 March 2018 at 10:30, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>>>>>
>>>>>> =?UTF-8?Q?R=C3=A9mi_Aubel?= <remi.aubel@gmail.com> writes:
>>>>>> > 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".
>>>>>>
>>>>>> Some experimentation suggests that it'd probably work if you wrote the
>>>>>> clauses in the other order:
>>>>>>
>>>>>> regression=# create table test_table (c_uuid uuid);
>>>>>> CREATE TABLE
>>>>>> regression=# prepare foo as select * from test_table where $1 is null
>>>>>> or $1 = c_uuid;
>>>>>> ERROR:  could not determine data type of parameter $1
>>>>>> LINE 1: prepare foo as select * from test_table where $1 is null or
>>>>>> ...
>>>>>>                                                       ^
>>>>>> regression=# prepare foo as select * from test_table where $1 =
>>>>>> c_uuid or $1 is null;
>>>>>> PREPARE
>>>>>>
>>>>>> In an ideal world, perhaps the order of the parameter references
>>>>>> would not
>>>>>> matter, but AFAICS making that work would be mighty hard.  For now,
>>>>>> PG's
>>>>>> parser wants to resolve the type of an otherwise-unlabeled parameter
>>>>>> symbol the first time it sees it --- and the context "IS NULL" offers
>>>>>> no clue what type it should be.
>>>>>>
>>>>>> Alternatively, you could force the issue with an explicit cast in the
>>>>>> text of the query:
>>>>>>
>>>>>> regression=# prepare foo2 as select * from test_table where $1::uuid
>>>>>> is null or $1 = c_uuid;
>>>>>> PREPARE
>>>>>>
>>>>>
>>>>> Tom,
>>>>>
>>>>> This is just a simple example of a bigger problem. One for which there
>>>>> is a solution in the driver which was not implemented.
>>>>>
>>>>> I have implemented it now.
>>>>>
>>>>> Thanks,
>>>>>
>>>>> Dave
>>>>>
>>>> --
>>>>
>>>>
>>>> --
>>>
>>>
>>>
>> --
>
>
> --

^ permalink  raw  reply  [nested|flat] 12+ messages in thread


end of thread, other threads:[~2018-04-25 14:15 UTC | newest]

Thread overview: 12+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-03-28 13:26 BUG: Unable to bind a null value typed as a UUID in a PreparedStatement Rémi Aubel <remi.aubel@gmail.com>
2018-03-28 13:59 ` David G. Johnston <david.g.johnston@gmail.com>
2018-03-28 14:11   ` Dave Cramer <davecramer@gmail.com>
2018-03-28 14:25     ` Rémi Aubel <remi.aubel@gmail.com>
2018-03-28 14:27       ` Dave Cramer <davecramer@gmail.com>
2018-03-28 14:30 ` Tom Lane <tgl@sss.pgh.pa.us>
2018-03-28 14:38   ` Dave Cramer <davecramer@gmail.com>
2018-03-28 15:08     ` Rémi Aubel <remi.aubel@gmail.com>
2018-04-03 10:29       ` Rémi Aubel <remi.aubel@gmail.com>
2018-04-03 10:42         ` Dave Cramer <davecramer@gmail.com>
2018-04-03 11:19           ` Rémi Aubel <remi.aubel@gmail.com>
2018-04-25 14:15             ` Rémi Aubel <remi.aubel@gmail.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox