From: Tom Lane <tgl@sss.pgh.pa.us>
To: yuanhang.zheng@qq.com
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #16615: Cannot determine type of Date for "is null" expression
Date: Sun, 13 Sep 2020 10:42:52 -0400
Message-ID: <749016.1600008172@sss.pgh.pa.us> (raw)
In-Reply-To: <16615-1f85b569d6a34277@postgresql.org>
References: <16615-1f85b569d6a34277@postgresql.org>
PG Bug reporting form <noreply@postgresql.org> writes:
> 1. Postgres JDBC driver will always use Oid UNSPECIFIED(0) for Date type.
> See PgPreparedStatement.java, in setDate function.
You could ask the JDBC crew why they do that, although I suspect they
have reasons.
> 2. In Postgres server, it won't coerce the type to Date even if we provide
> the type. See parse_expr.c in transformExprRecurse function.
There's nothing to coerce it *to*.
I'd suggest working around this with something like
select * from tb_user where (?::date is null or createdat > ?)
Although TBH that query looks pretty fishy to start with. Do you
really want the entire table when the argument is null? Is it even
possible for the argument to be null --- I doubt Java has such a
thing as a null Date?
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, yuanhang.zheng@qq.com, pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #16615: Cannot determine type of Date for "is null" expression
In-Reply-To: <749016.1600008172@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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