Re: GSets: Fix bug involving GROUPING and HAVING together

From: Andres Freund <andres(at)anarazel(dot)de>
To: Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>
Cc: Jeevan Chalke <jeevan(dot)chalke(at)enterprisedb(dot)com>, Atri Sharma <atri(dot)jiit(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Postgres-Bugs <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: GSets: Fix bug involving GROUPING and HAVING together
Date: 2015-07-26 15:14:56
Message-ID: 20150726151456.GD12755@awork2.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

On 2015-07-24 11:34:22 +0100, Andrew Gierth wrote:
> >>>>> "Andrew" == Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk> writes:
>
> Andrew> The other is that in subquery_planner, the optimization of
> Andrew> converting HAVING clauses to WHERE clauses is suppressed if
> Andrew> parse->groupingSets isn't empty. (It is empty if there's either
> Andrew> no group by clause at all, or if there's exactly one grouping
> Andrew> set, which must not be empty, however derived.) This is costing
> Andrew> us some optimizations, especially in the case of an explicit
> Andrew> GROUP BY () clause; I'll look into this.
>
> I'm inclined to go with the simplest approach here, which copies the
> quals if there are grouping sets. The only way we could safely move a
> qual without copying is if we can show that none of the grouping sets is
> empty, that is (), and at this point the grouping set list has not been
> expanded so it's not trivial to determine that.

I pushed this to both master and 9.5. While this isn't strictly a
bugfix, it seemed better to keep the branches the same at this point.

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Andres Freund 2015-07-26 15:15:56 Re: [HACKERS] GSets: Getting collation related error when GSets has text column
Previous Message Andres Freund 2015-07-26 15:14:11 Re: [HACKERS] GSets: Fix bug involving GROUPING and HAVING together

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2015-07-26 15:15:56 Re: [HACKERS] GSets: Getting collation related error when GSets has text column
Previous Message Andres Freund 2015-07-26 15:14:11 Re: [HACKERS] GSets: Fix bug involving GROUPING and HAVING together