Re: BUG #15289: Type inference of parameters in prepared statements can sometimes fail or succeed, depending...

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: BUG #15289: Type inference of parameters in prepared statements can sometimes fail or succeed, depending...
Дата
Msg-id 3988.1532186616@sss.pgh.pa.us
обсуждение исходный текст
Ответ на BUG #15289: Type inference of parameters in prepared statements cansometimes fail or succeed, depending...  (PG Bug reporting form <noreply@postgresql.org>)
Список pgsql-bugs
=?utf-8?q?PG_Bug_reporting_form?= <noreply@postgresql.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


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

Предыдущее
От: PG Bug reporting form
Дата:
Сообщение: BUG #15289: Type inference of parameters in prepared statements cansometimes fail or succeed, depending...
Следующее
От: "David G. Johnston"
Дата:
Сообщение: Re: BUG #15289: Type inference of parameters in prepared statementscan sometimes fail or succeed, depending...