pgsql: Don't presort ORDER BY/DISTINCT Aggrefs with volatile functions

Поиск
Список
Период
Сортировка
От David Rowley
Тема pgsql: Don't presort ORDER BY/DISTINCT Aggrefs with volatile functions
Дата
Msg-id E1pHcmx-00448R-Fb@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Don't presort ORDER BY/DISTINCT Aggrefs with volatile functions

In 1349d2790, we gave the planner the ability to provide ORDER BY/DISTINCT
Aggrefs with presorted input so that nodeAgg would not have to perform
sorts during execution.  That commit failed to properly consider the
implications of if the Aggref had a volatile function in its ORDER
BY/DISTINCT clause.  As it happened, this resulted in an ERROR about the
volatile function being missing from the targetlist.

Here, instead of adding the volatile function to the targetlist, we just
never consider an Aggref with a volatile function in its ORDER BY/DISTINCT
clause when choosing which Aggrefs we should sort by.  We do this as if we
were to choose a plan which provided these aggregates with presorted
input, then if there were many such aggregates which could all share the
same sort order, then it may be surprising if they all shared the same
sort sometimes and didn't at other times when some other set of aggregates
were given presorted results.  We can avoid this inconsistency by just
never providing these volatile function aggregates with presorted input.

Reported-by: Dean Rasheed
Discussion: https://postgr.es/m/CAEZATCWETioXs5kY8vT6BVguY41_wD962VDk=u_Nvd7S1UXzuQ@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/da5800d5fa636c6e10c9c98402d872c76aa1c8d0

Modified Files
--------------
src/backend/optimizer/plan/planner.c     | 55 ++++++++++++++++++++++++++++----
src/test/regress/expected/aggregates.out | 19 +++++++++++
src/test/regress/sql/aggregates.sql      | 11 +++++++
3 files changed, 79 insertions(+), 6 deletions(-)


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: pgsql: Create common infrastructure for cross-version upgrade testing.
Следующее
От: Michael Paquier
Дата:
Сообщение: pgsql: Track behavior of \1 in pg_ident.conf when quoted