| From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
|---|---|
| To: | farmernick-pg(at)varteg(dot)nz |
| Cc: | pgsql-bugs(at)lists(dot)postgresql(dot)org |
| Subject: | Re: BUG #15289: Type inference of parameters in prepared statements can sometimes fail or succeed, depending... |
| Date: | 2018-07-21 15:23:36 |
| Message-ID: | 3988.1532186616@sss.pgh.pa.us |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs |
=?utf-8?q?PG_Bug_reporting_form?= <noreply(at)postgresql(dot)org> writes:
> Type inference of parameters in prepared statements can sometimes fail even
> though all the information is present and can be obtained if the statement
> is altered in a way that really shouldn't make any functional difference.
This is not a bug. If you don't specify a type for a parameter, the
parser attempts to infer it on first use. If the first use is
"v = $1", it will guess that $1 is meant to be the same type as v
(whose type is already known from having processed the FROM clause).
If the first use is "$1 IS NULL", there's no basis to infer a type.
One could imagine some complicated parse-time processing that tries
to defer resolving the parameter's type in hopes that some other use
will be seen later; but there is no such thing in PG, and I doubt
it will appear soon.
regards, tom lane
| From | Date | Subject | |
|---|---|---|---|
| Next Message | David G. Johnston | 2018-07-21 16:48:52 | Re: BUG #15289: Type inference of parameters in prepared statements can sometimes fail or succeed, depending... |
| Previous Message | PG Bug reporting form | 2018-07-21 11:47:12 | BUG #15289: Type inference of parameters in prepared statements can sometimes fail or succeed, depending... |