Re: BUG #14268: NULL parameter conversion

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: coladict(at)gmail(dot)com
Cc: "pgsql-bugs(at)postgresql(dot)org" <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: BUG #14268: NULL parameter conversion
Date: 2016-07-28 13:56:34
Message-ID: CAKFQuwYAQw9u1=-Z9AWjcU28hpF02=tWdS0nU=gr6HdiBY-YFQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Thu, Jul 28, 2016 at 9:30 AM, <coladict(at)gmail(dot)com> wrote:

> The following bug has been logged on the website:
>
> Bug reference: 14268
> Logged by: Jordan Gigov
> Email address: coladict(at)gmail(dot)com
> PostgreSQL version: 9.3.13
> Operating system: Ubuntu 14.04
> Description:

​[...]​

>
>
When the value is NULL, the type
> shouldn't matter.
>

​According to what authority?

​[...]
>
INSERT INTO my_array_table(somedata) VALUES (NULL::bytea);
>

​If you are saying the above should work I'd say that is arguable at best.​
All values, even NULL, are typed in PostgreSQL.

> I recognize that the JDBC driver explicitly sends the parameter type in a
> prepared statement, but I think it should be ignored when the value is
> NULL.
>

​As your first example shows if the NULL remains unknown it will be
auto-cast according to the context in which it is used. Its not
PostgreSQL's place to discard type information.

​The JDBC API defines "setNull(int parameterIndex, int​ sqlType); which
makes me inclined to say your complaint should be directed at JPA and not
either PostgreSQL itself or JDBC.

Now, as I am lacking knowledge about the specific problem, JPA, and how
other databases function, I am unable to meaningfully comment further. But
I can say this isn't a bug. PostgreSQL is operating as expected given how
it handles NULL.

David J.

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message joel.traf 2016-07-28 15:11:54 bug error message constraint "con_item_id_costelement" for table "costs" does not exist SQL state: 42704
Previous Message coladict 2016-07-28 13:30:07 BUG #14268: NULL parameter conversion