pgsql: Don't split up SRFs when choosing to postpone SELECT output expr

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Don't split up SRFs when choosing to postpone SELECT output expr
Date: 2016-03-25 15:19:58
Message-ID: E1ajTWo-0004zu-Ni@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Don't split up SRFs when choosing to postpone SELECT output expressions.

In commit 9118d03a8cca3d97 we taught the planner to postpone evaluation of
set-returning functions in a SELECT's targetlist until after any sort done
to satisfy ORDER BY. However, if we postpone some SRFs this way while
others do not get postponed (because they're sort or group key columns)
we will break the traditional behavior by which all SRFs in the tlist run
in-step during ExecTargetList(), so that you get the least common multiple
of their periods not the product. Fix make_sort_input_target() so it will
not split up SRF evaluation in such cases.

There is still a hazard of similar odd behavior if there's a SRF in a
grouping column and another one that isn't, but that was true before
and we're just trying to preserve bug-compatibility with the traditional
behavior. This whole area is overdue to be rethought and reimplemented,
but we'll try to avoid changing behavior until then.

Per report from Regina Obe.

Branch
------
master

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

Modified Files
--------------
src/backend/optimizer/plan/planner.c | 48 ++++++++++++++++++++++++++----------
src/test/regress/expected/limit.out | 38 ++++++++++++++++++++++++++++
src/test/regress/sql/limit.sql | 13 ++++++++++
3 files changed, 86 insertions(+), 13 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2016-03-25 16:33:27 pgsql: Fix DROP OPERATOR to reset oprcom/oprnegate links to the dropped
Previous Message Robert Haas 2016-03-25 15:19:01 Re: [COMMITTERS] pgsql: Move each SLRU's lwlocks to a separate tranche.