pgsql: Correctly set up aggregate FILTER expression in partial-aggregat

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Correctly set up aggregate FILTER expression in partial-aggregat
Date: 2016-07-24 00:17:14
Message-ID: E1bR76Y-000319-H1@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Correctly set up aggregate FILTER expression in partial-aggregation plans.

The aggfilter expression should be removed from the parent (combining)
Aggref, since it's not supposed to apply the filter, and indeed cannot
because any Vars used in the filter would not be available after the
lower-level aggregation step. Per report from Jeff Janes.

(This has been broken since the introduction of partial aggregation,
I think. The error became obvious after commit 59a3795c2, when setrefs.c
began processing the parent Aggref's fields normally and thus would detect
such Vars. The special-case coding previously used in setrefs.c skipped
over the parent's aggfilter field without processing it. That was broken
in its own way because no other setrefs.c processing got applied either;
though since the executor would not execute the filter expression, only
initialize it, that oversight might not have had any visible symptoms at
present.)

Report: <CAMkU=1xfuPf2edAe4ZGXTmJpU7jxuKukKyvNtEXwu35B7dvejg(at)mail(dot)gmail(dot)com>

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/6d85bb1ba79c2792214df9fa17bcc8fac229c11c

Modified Files
--------------
src/backend/optimizer/plan/setrefs.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Noah Misch 2016-07-24 00:32:46 pgsql: Make the AIX case of Makefile.shlib safe for parallel make.
Previous Message Tom Lane 2016-07-22 19:41:50 pgsql: Fix regression tests to work in Welsh locale.