postgresql/src
Tom Lane 82ad7ecb42 Fix check_agg_arguments' examination of aggregate FILTER clauses.
Recursion into the FILTER clause was mis-implemented, such that a
relevant Var or Aggref at the very top of the FILTER clause would
be ignored.  (Of course, that'd have to be a plain boolean Var or
boolean-returning aggregate.)  The consequence would be
mis-identification of the correct semantic level of the aggregate,
which could lead to not-per-spec query behavior.  If the FILTER
expression is an aggregate, this could also lead to failure to issue
an expected "aggregate function calls cannot be nested" error, which
would likely result in a core dump later on, since the planner and
executor aren't expecting such cases to appear.

The root cause is that commit b560ec1b0 blindly copied some code
that assumed it's recursing into a List, and thus didn't examine the
top-level node.  To forestall questions about why this call doesn't
look like the others, as well as possible future copy-and-paste
mistakes, let's change all three check_agg_arguments_walker calls in
check_agg_arguments, even though only the one for the filter clause
is really broken.

Per bug #17152 from Zhiyong Wu.  This has been wrong since we
implemented FILTER, so back-patch to all supported versions.
(Testing suggests that pre-v11 branches manage to avoid crashing
in the bad-Aggref case, thanks to "redundant" checks in ExecInitAgg.
But I'm not sure how thorough that protection is, and anyway the
wrong-behavior issue remains, so fix 9.6 and 10 too.)

Discussion: https://postgr.es/m/17152-c7f906cc1a88e61b@postgresql.org
2021-08-18 18:12:51 -04:00
..
backend Fix check_agg_arguments' examination of aggregate FILTER clauses. 2021-08-18 18:12:51 -04:00
bin Translation updates 2021-08-09 12:58:41 +02:00
common Replace use of sys_siglist[] with strsignal(). 2020-07-15 22:05:12 -04:00
fe_utils Fix incautious handling of possibly-miscoded strings in client code. 2021-06-07 14:15:25 -04:00
include Add RISC-V spinlock support in s_lock.h. 2021-08-13 13:59:25 -04:00
interfaces Set type identifier on BIO 2021-08-17 14:30:51 +02:00
makefiles Select CFLAGS_SL at configure time, not in platform-specific Makefiles. 2019-10-21 12:32:36 -04:00
pl Fix corner-case uninitialized-variable issues in plpgsql. 2021-07-20 13:01:48 -04:00
port Stamp 10.18. 2021-08-09 16:54:22 -04:00
template Further tweaking of PG_SYSROOT heuristics for macOS. 2021-01-20 12:07:46 -05:00
test Fix check_agg_arguments' examination of aggregate FILTER clauses. 2021-08-18 18:12:51 -04:00
timezone Update time zone data files to tzdata release 2021a. 2021-01-24 16:29:48 -05:00
tools fix syntax error 2021-05-28 09:35:55 -04:00
tutorial tutorial: land height is "elevation", not "altitude" 2021-03-10 20:25:18 -05:00
.gitignore
DEVELOPERS
Makefile Build src/test/isolation during "make" and "make install". 2017-11-22 20:18:52 -08:00
Makefile.global.in Fix prove_installcheck to use correct paths when used with PGXS 2021-07-01 08:48:24 -04:00
Makefile.shlib makefile: use proper linker flags for C++ compiles 2020-03-31 22:26:11 -04:00
nls-global.mk