havingQual vs hasHavingQual buglets

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-hackers@lists.postgresql.org
Date: 2022-10-17T21:37:23Z
Lists: pgsql-hackers

Attachments

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.

These mistakes only affect cost estimates, and they're sufficiently
corner cases that it'd be hard even to devise a reliable test case
showing a different plan choice.  So I'm not very excited about this,
and am thinking of committing only to HEAD.

			regards, tom lane

Commits

  1. Fix confusion about havingQual vs hasHavingQual in planner.