postgresql/src
Tom Lane 8bf66dedd8 Fix confusion about havingQual vs hasHavingQual in planner.
Preprocessing of the HAVING clause will reduce havingQual to NIL
if the clause is constant-TRUE.  This is one case where that
convention is rather unfortunate, because "HAVING TRUE" is not at all
the same as not having any HAVING clause at all.  (Per the SQL spec,
it still forces the query to be grouped.)  The planner deals with this
by having a boolean hasHavingQual that records whether havingQual was
originally nonempty; places that just want to check whether HAVING
was specified are supposed to consult that.

I found three places that got that wrong.  Fortunately, these could
only affect cost estimates not correctness.  It'd be hard even
to demonstrate the errors; for example, the one in allpaths.c would
only matter in a query that has HAVING TRUE but no GROUP BY and no
aggregates, which would require a completely variable-free SELECT
list, making the case probably of only academic interest.  Hence,
while these are worth fixing before someone copies the incorrect
coding somewhere more critical, they don't seem worth back-patching.
I didn't bother trying to devise regression tests, either.

Discussion: https://postgr.es/m/2503888.1666042643@sss.pgh.pa.us
2022-10-18 10:44:34 -04:00
..
backend Fix confusion about havingQual vs hasHavingQual in planner. 2022-10-18 10:44:34 -04:00
bin meson: Add support for building with precompiled headers 2022-10-06 17:19:30 -07:00
common meson: Add support for building with precompiled headers 2022-10-06 17:19:30 -07:00
fe_utils meson: Add support for building with precompiled headers 2022-10-06 17:19:30 -07:00
include Remove compatibility declarations for InitMaterializedSRF() 2022-10-18 10:44:02 +09:00
interfaces libpq: Reset singlerow flag correctly in pipeline mode 2022-10-14 19:06:26 +02:00
makefiles autoconf: Rely on ar supporting index creation 2022-10-07 11:53:39 -07:00
pl Store GUC data in a memory context, instead of using malloc(). 2022-10-14 12:10:48 -04:00
port Use libc's snprintf, not sprintf, for special cases in snprintf.c. 2022-10-16 11:47:44 -04:00
template Move darwin sysroot determination into separate file 2022-09-01 16:54:19 -07:00
test Remove no-longer-needed compatibility hack 2022-10-18 11:51:50 +02:00
timezone meson: Add windows resource files 2022-10-05 09:56:05 -07:00
tools Record dependencies of a cast on other casts that it requires. 2022-10-17 14:02:05 -04:00
tutorial Update copyright for 2022 2022-01-07 19:04:57 -05:00
.gitignore
DEVELOPERS
Makefile
Makefile.global.in autoconf: Rely on ar supporting index creation 2022-10-07 11:53:39 -07:00
Makefile.shlib autoconf: Rely on ar supporting index creation 2022-10-07 11:53:39 -07:00
meson.build meson: Add initial version of meson based build system 2022-09-21 22:37:17 -07:00
nls-global.mk Fix for make unportability 2022-07-13 09:15:01 +02:00