postgresql/src/tools
David Rowley 7d2c7f08d9 Fix query pullup issue with WindowClause runCondition
94985c210 added code to detect when WindowFuncs were monotonic and
allowed additional quals to be "pushed down" into the subquery to be
used as WindowClause runConditions in order to short-circuit execution
in nodeWindowAgg.c.

The Node representation of runConditions wasn't well selected and
because we do qual pushdown before planning the subquery, the planning
of the subquery could perform subquery pull-up of nested subqueries.
For WindowFuncs with args, the arguments could be changed after pushing
the qual down to the subquery.

This was made more difficult by the fact that the code duplicated the
WindowFunc inside an OpExpr to include in the WindowClauses runCondition
field.  This could result in duplication of subqueries and a pull-up of
such a subquery could result in another initplan parameter being issued
for the 2nd version of the subplan.  This could result in errors such as:

ERROR:  WindowFunc not found in subplan target lists

To fix this, we change the node representation of these run conditions
and instead of storing an OpExpr containing the WindowFunc in a list
inside WindowClause, we now store a new node type named
WindowFuncRunCondition within a new field in the WindowFunc.  These get
transformed into OpExprs later in planning once subquery pull-up has been
performed.

This problem did exist in v15 and v16, but that was fixed by 9d36b883b
and e5d20bbd.

Cat version bump due to new node type and modifying WindowFunc struct.

Bug: #18305
Reported-by: Zuming Jiang
Discussion: https://postgr.es/m/18305-33c49b4c830b37b3%40postgresql.org
2024-05-05 12:54:46 +12:00
..
ci ci: freebsd repartition script didn't copy .git directory 2024-03-24 08:41:14 +01:00
editors Make Emacs perl-mode indent more like perltidy. 2019-01-13 11:32:31 -08:00
ifaddrs Use printf's %m format instead of strerror(errno) in more places 2024-03-12 10:02:54 +09:00
perlcheck Activate perlcritic InputOutput::RequireCheckedSyscalls and fix resulting warnings 2024-03-19 07:09:31 +01:00
pg_bsd_indent Update copyright for 2024 2024-01-03 20:49:05 -05:00
pginclude Update src/tools/pginclude/README to match recent changes to cpluspluscheck 2024-04-18 11:37:01 +02:00
pgindent Fix query pullup issue with WindowClause runCondition 2024-05-05 12:54:46 +12:00
PerfectHash.pm Update copyright for 2024 2024-01-03 20:49:05 -05:00
RELEASE_CHANGES Stop generating plain-text INSTALL instructions. 2023-12-22 13:32:15 -05:00
ccsym tools/ccsym: update for modern versions of gcc 2015-01-20 13:02:58 -05:00
check_bison_recursion.pl Update copyright for 2024 2024-01-03 20:49:05 -05:00
codelines Fix remaining stray references to CVS. 2010-09-22 19:51:39 -04:00
copyright.pl Update copyright for 2024 2024-01-03 20:49:05 -05:00
darwin_sysroot Move darwin sysroot determination into separate file 2022-09-01 16:54:19 -07:00
find_badmacros Remove cvs keywords from all files. 2010-09-20 22:08:53 +02:00
find_meson meson: Add initial version of meson based build system 2022-09-21 22:37:17 -07:00
find_static Fix `trap` in a few shell scripts 2022-09-20 18:50:16 +02:00
find_typedef Refer to OS X as "macOS", except for the port name which is still "darwin". 2016-09-25 15:40:57 -04:00
fix-old-flex-code.pl Update copyright for 2024 2024-01-03 20:49:05 -05:00
gen_export.pl Remove AIX support 2024-02-28 15:17:23 +04:00
gen_keywordlist.pl Update copyright for 2024 2024-01-03 20:49:05 -05:00
git-external-diff Preserve information on use of git-external-diff 2018-05-24 23:45:31 +09:30
git_changelog Update copyright for 2024 2024-01-03 20:49:05 -05:00
install_files meson: make install_test_files more generic, rename to install_files 2023-03-23 21:20:18 -07:00
make_ctags Fix make_etags breakage on certain platforms. 2023-06-14 11:02:50 +09:00
make_etags Fix make_etags failure on Mac. 2023-02-15 09:52:42 +09:00
make_mkid Add another pgdefine path check, and a cvs-git change. 2011-08-26 21:52:35 -04:00
mark_pgdllimport.pl Update copyright for 2024 2024-01-03 20:49:05 -05:00
msvc_gendef.pl Activate perlcritic InputOutput::RequireCheckedSyscalls and fix resulting warnings 2024-03-19 07:09:31 +01:00
pgflex meson: Add initial version of meson based build system 2022-09-21 22:37:17 -07:00
pgtest pgtest: fix spacing 2023-08-14 14:03:29 -04:00
rcgen meson: Add windows resource files 2022-10-05 09:56:05 -07:00
testint128.c Update copyright for 2024 2024-01-03 20:49:05 -05:00
testwrap Explicitly skip TAP tests under Meson if disabled 2023-11-16 08:14:33 +01:00
valgrind.supp Record dependencies of a cast on other casts that it requires. 2022-10-17 14:02:05 -04:00
version_stamp.pl Update copyright for 2024 2024-01-03 20:49:05 -05:00
win32tzlist.pl Update copyright for 2024 2024-01-03 20:49:05 -05:00