Re: BUG #18399: Query plan optimization results in runtime error when hoisting cast from inside subquery

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: BUG #18399: Query plan optimization results in runtime error when hoisting cast from inside subquery
Дата
Msg-id 4085750.1710895021@sss.pgh.pa.us
обсуждение исходный текст
Ответ на BUG #18399: Query plan optimization results in runtime error when hoisting cast from inside subquery  (PG Bug reporting form <noreply@postgresql.org>)
Ответы Re: BUG #18399: Query plan optimization results in runtime error when hoisting cast from inside subquery  (Sawyer Knoblich <scknoblich@gmail.com>)
Список pgsql-bugs
Sawyer Knoblich <scknoblich@gmail.com> writes:
> To make sure I'm understanding correctly, are you suggesting that this is
> not a bug? The mention of "the cast to integer is presumed to be
> side-effect-free, which isn't true if you're working with data where it
> could throw errors" to me heavily implies that this is a faulty assumption
> on behalf of the optimizer about what behaviors certain parts of the query
> may have, but I didn't get the impression that this is being considered an
> optimizer bug and is instead something that just needs to be worked around
> or avoided (although if I'm not interpreting it right then definitely
> please correct me).

It is not an optimizer bug: the optimizer is doing what the function
marking entitles it to.  You could argue that it's a marking bug and
no function/operator that can throw an error should be marked stable
or immutable, because throwing an error is a kind of side-effect.
But that would be a pretty useless answer, as it would nearly destroy
our ability to optimize queries at all, since there's not all that
many functions that can be guaranteed not to throw errors.

In short, this state of affairs is an engineering compromise.
It's not perfect, but it's not easy to see how to do better either.

            regards, tom lane



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

Предыдущее
От: Carl Smith
Дата:
Сообщение: Re: BUG #18392: Can't restore database (using pg_restore) after latest Feb 8 update
Следующее
От: Thomas Munro
Дата:
Сообщение: Re: Regression tests fail with musl libc because libpq.so can't be loaded