Re: havingQual vs hasHavingQual buglets

Richard Guo <guofenglinux@gmail.com>

From: Richard Guo <guofenglinux@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-hackers@lists.postgresql.org
Date: 2022-10-18T00:47:35Z
Lists: pgsql-hackers
On Tue, Oct 18, 2022 at 5:37 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:

> I came across a couple of places in the planner that are checking
> for nonempty havingQual; but since these bits run after
> const-simplification of the HAVING clause, that produces the wrong
> answer for a constant-true HAVING clause (which'll be folded to
> empty).  Correct code is to check root->hasHavingQual instead.


+1. root->hasHavingQual is set before we do any expression
preprocessing. It should be the right one to check with.

Thanks
Richard

Commits

  1. Fix confusion about havingQual vs hasHavingQual in planner.