Re: wierd AND condition evaluation for plpgsql

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: wierd AND condition evaluation for plpgsql
Дата
Msg-id 1415.1022775249@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: wierd AND condition evaluation for plpgsql  ("Joel Burton" <joel@joelburton.com>)
Список pgsql-hackers
"Joel Burton" <joel@joelburton.com> writes:
> Is there any generalizable help would could offer to people who write
> functions that have side effects? Don't use them in WHERE (or ON or HAVING)
> clauses? Evaluate the function in a earlier db call, then plug the resolved
> results into the SQL WHERE statement?

Certainly putting side-effects into WHERE clauses is a recipe for
trouble, and it'd not be a bad idea to point that out in the docs.
(I don't think it is mentioned at the moment.)

When you really need to control order of evaluation, you can do it
using CASE or by pushing the whole expression into a function.  But
these defeat optimization so should be avoided if possible.
        regards, tom lane


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

Предыдущее
От: "Joel Burton"
Дата:
Сообщение: Re: wierd AND condition evaluation for plpgsql
Следующее
От: Tom Lane
Дата:
Сообщение: Re: self-tuning histograms