pgsql: Make contain_volatile_functions/contain_mutable_functions look i

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Make contain_volatile_functions/contain_mutable_functions look i
Дата
Msg-id E1Vep43-0004lk-IS@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Make contain_volatile_functions/contain_mutable_functions look into SubLinks.

This change prevents us from doing inappropriate subquery flattening in
cases such as dangerous functions hidden inside a sub-SELECT in the
targetlist of another sub-SELECT.  That could result in unexpected behavior
due to multiple evaluations of a volatile function, as in a recent
complaint from Etienne Dube.  It's been questionable from the very
beginning whether these functions should look into subqueries (as noted in
their comments), and this case seems to provide proof that they should.

Because the new code only descends into SubLinks, not SubPlans or
InitPlans, the change only affects the planner's behavior during
prepjointree processing and not later on --- for example, you can still get
it to use a volatile function in an indexqual if you wrap the function in
(SELECT ...).  That's a historical behavior, for sure, but it's reasonable
given that the executor's evaluation rules for subplans don't depend on
whether there are volatile functions inside them.  In any case, we need to
constrain the behavioral change as narrowly as we can to make this
reasonable to back-patch.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/b97ee66cc1f9319f7b457e7d8a78aab711da2dda

Modified Files
--------------
src/backend/optimizer/util/clauses.c    |   33 +++++++++++++---
src/test/regress/expected/subselect.out |   64 +++++++++++++++++++++++++++++++
src/test/regress/sql/subselect.sql      |   16 ++++++++
3 files changed, 107 insertions(+), 6 deletions(-)


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: pgsql: Make contain_volatile_functions/contain_mutable_functions look i
Следующее
От: Tom Lane
Дата:
Сообщение: pgsql: Make contain_volatile_functions/contain_mutable_functions look i