Re: BUG #14268: NULL parameter conversion - Mailing list pgsql-bugs

From David G. Johnston
Subject Re: BUG #14268: NULL parameter conversion
Date
Msg-id CAKFQuwYAQw9u1=-Z9AWjcU28hpF02=tWdS0nU=gr6HdiBY-YFQ@mail.gmail.com
Whole thread Raw
In response to BUG #14268: NULL parameter conversion  (coladict@gmail.com)
Responses Re: BUG #14268: NULL parameter conversion
List pgsql-bugs
On Thu, Jul 28, 2016 at 9:30 AM, <coladict@gmail.com> wrote:

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

=E2=80=8B[...]=E2=80=8B

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

=E2=80=8BAccording to what authority?

=E2=80=8B[...]
>
INSERT INTO my_array_table(somedata) VALUES (NULL::bytea);
>

=E2=80=8BIf you are saying the above should work I'd say that is arguable a=
t best.=E2=80=8B
 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.
>

=E2=80=8BAs 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.

=E2=80=8BThe JDBC API defines "setNull(int parameterIndex, int=E2=80=8B sql=
Type); 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.

pgsql-bugs by date:

Previous
From: coladict@gmail.com
Date:
Subject: BUG #14268: NULL parameter conversion
Next
From: joel.traf@magwerks.com
Date:
Subject: bug error message constraint "con_item_id_costelement" for table "costs" does not exist SQL state: 42704