From: Tom Lane <tgl@sss.pgh.pa.us>
To: David G. Johnston <david.g.johnston@gmail.com>
Cc: Arthur McGibbon <arthur.mcgibbon@gmail.com>
Cc: pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>
Subject: Re: BUG #17051: Incorrect params inferred on PREPARE
Date: Tue, 08 Jun 2021 12:35:38 -0400
Message-ID: <1119340.1623170138@sss.pgh.pa.us> (raw)
In-Reply-To: <CAKFQuwbp2upso+eP2j6g0WXqLbtMtvFTmjg1gW3h3oNJSBhnaQ@mail.gmail.com>
References: <17051-c20aad26366e11b4@postgresql.org>
<CAKFQuwZXSkAhp0xvVbFFriYzq00G8D6-YRjpX7NLJuci+rsXRg@mail.gmail.com>
<CAL2LXQW=GK2itoa4hBurd97q7Axsbpe+xRRm4DoM1txBGw86MA@mail.gmail.com>
<CAKFQuwbp2upso+eP2j6g0WXqLbtMtvFTmjg1gW3h3oNJSBhnaQ@mail.gmail.com>
"David G. Johnston" <david.g.johnston@gmail.com> writes:
> On Tuesday, June 8, 2021, Arthur McGibbon <arthur.mcgibbon@gmail.com> wrote:
>> Could you point me to the documentation - I could only find
>> https://www.postgresql.org/docs/current/sql-prepare.html and it doesn't
>> mention how unknown params are handled.
> https://www.postgresql.org/docs/current/typeconv-union-case.html
Yeah, the point here is that the type of the parameter symbol is
guessed in the context of resolving the CASE construct. There's
no mechanism for applying external knowledge about what that CASE
ought to yield. While maybe we could do something in this
specific context, examples that are only slightly more complex
would really be quite impossible. For example,
... SET timestampCol = foo(CASE WHEN timestampCol IS NULL THEN $1 ELSE NULL END);
There's no way to tell which foo() function is meant until we've
identified a result type for the CASE, so the function context is
pretty much a blocker.
Roughly speaking, we only get to use one syntactic level of context
to guess the type of a parameter symbol. Doing better would really
be a research project.
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, david.g.johnston@gmail.com, arthur.mcgibbon@gmail.com, pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #17051: Incorrect params inferred on PREPARE
In-Reply-To: <1119340.1623170138@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