Re: Bug Report: Error caused due to wrong ordering of filters

Поиск
Список
Период
Сортировка
От Andrew Gierth
Тема Re: Bug Report: Error caused due to wrong ordering of filters
Дата
Msg-id 87in7y75zy.fsf@news-spur.riddles.org.uk
обсуждение исходный текст
Ответ на Bug Report: Error caused due to wrong ordering of filters  (Ekta Khanna <ekhanna@pivotal.io>)
Список pgsql-hackers
>>>>> "Ekta" == Ekta Khanna <ekhanna@pivotal.io> writes:

 Ekta> Hello PGSQL Hackers,
 
 Ekta> We have come across the following issue on Postgres
 Ekta> REL_10_STABLE. Below is the repro:
 [...]
 Ekta> In the plan, we see that planner merges the quals from FROM
 Ekta> clause and the WHERE clause in the same RESTRICTINFO. Is this the
 Ekta> expected behavior?

Yes, it's entirely expected. You CANNOT make assumptions about the order
of evaluation of quals; the planner will rearrange them freely, even
across subquery boundaries (where the semantics allow).

You can do this:

  WHERE CASE WHEN length(b) = 8
             THEN to_date(b, 'YYYYMMDD') > '2018-05-04'
             ELSE false END

since one of the few guarantees about execution order is that a CASE
will evaluate its condition tests before any non-constant subexpressions
in the corresponding THEN clause.

(Another method is to put an OFFSET 0 in the subquery, but that's more
of a hack)

-- 
Andrew (irc:RhodiumToad)


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

Предыдущее
От: Justin Pryzby
Дата:
Сообщение: Re: doc fixes: vacuum_cleanup_index_scale_factor
Следующее
От: Konstantin Knizhnik
Дата:
Сообщение: Re: Built-in connection pooling