pgsql: Disallow pushing volatile qual expressions down into DISTINCT su

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Disallow pushing volatile qual expressions down into DISTINCT su
Дата
Msg-id E1X0aaA-0007OC-16@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Disallow pushing volatile qual expressions down into DISTINCT subqueries.

A WHERE clause applied to the output of a subquery with DISTINCT should
theoretically be applied only once per distinct row; but if we push it
into the subquery then it will be evaluated at each row before duplicate
elimination occurs.  If the qual is volatile this can give rise to
observably wrong results, so don't do that.

While at it, refactor a little bit to allow subquery_is_pushdown_safe
to report more than one kind of restrictive condition without indefinitely
expanding its argument list.

Although this is a bug fix, it seems unwise to back-patch it into released
branches, since it might de-optimize plans for queries that aren't giving
any trouble in practice.  So apply to 9.4 but not further back.

Branch
------
REL9_4_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/6327f25dddba0c359f8be8395e1b2d99dfe0d30c

Modified Files
--------------
src/backend/optimizer/path/allpaths.c   |  160 ++++++++++++++++++++-----------
src/test/regress/expected/subselect.out |   29 ++++++
src/test/regress/sql/subselect.sql      |   13 +++
3 files changed, 148 insertions(+), 54 deletions(-)


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: pgsql: Get rid of bogus separate pg_proc entries for json_extract_path
Следующее
От: Tom Lane
Дата:
Сообщение: pgsql: Disallow pushing volatile qual expressions down into DISTINCT su