Re: BUG #17051: Incorrect params inferred on PREPARE

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: BUG #17051: Incorrect params inferred on PREPARE
Дата
Msg-id 1119340.1623170138@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: BUG #17051: Incorrect params inferred on PREPARE  ("David G. Johnston" <david.g.johnston@gmail.com>)
Список pgsql-bugs
"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



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

Предыдущее
От: "David G. Johnston"
Дата:
Сообщение: Re: BUG #17051: Incorrect params inferred on PREPARE
Следующее
От: Tom Lane
Дата:
Сообщение: Re: BUG #17052: Incorrect params inferred on PREPARE (part 2)