Re: BUG #16615: Cannot determine type of Date for "is null" expression

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: BUG #16615: Cannot determine type of Date for "is null" expression
Дата
Msg-id 749016.1600008172@sss.pgh.pa.us
обсуждение исходный текст
Ответ на BUG #16615: Cannot determine type of Date for "is null" expression  (PG Bug reporting form <noreply@postgresql.org>)
Ответы Re: BUG #16615: Cannot determine type of Date for "is null" expression  (yuanhang <yuanhang.zheng@qq.com>)
Список pgsql-bugs
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



В списке pgsql-bugs по дате отправления:

Предыдущее
От: Alexander Lakhin
Дата:
Сообщение: Re: BUG #16272: Index expression can refer to wrong attributes if index is created via CREATE TABLE LIKE
Следующее
От: Tom Lane
Дата:
Сообщение: Re: BUG #16272: Index expression can refer to wrong attributes if index is created via CREATE TABLE LIKE