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