postgresql/src
Tom Lane 42b746d4c9 Remove uses of MemoryContextContains in nodeAgg.c and nodeWindowAgg.c.
MemoryContextContains is no longer reliable in the wake of c6e0fe1f2,
so we need to get rid of these uses.

It appears that there's no really good reason to force the result of
an aggregate's finalfn or serialfn to be allocated in the per-tuple
context.  The only other plausible case is that the result points to
or into the aggregate's transition value, and that's fine because it
will last as long as we need it to.  (This conclusion depends on the
assumption that finalfns are not allowed to scribble on the transition
value, but we've long required that.)  So we can just drop the
MemoryContextContains plus datumCopy business, although we do need
to take care to not return a read-write pointer when the transition
value is an expanded datum.

Likewise, we don't really need to force the result of a window
function to be in the output context.  In this case, the plausible
alternative is that it's pointing into the temporary tuple slot used
by WinGetFuncArgInPartition or WinGetFuncArgInFrame (since those
functions could return such a pointer, which might become the window
function's result).  That will hold still for long enough, unless
there is another window function using the same WindowObject.
I'm content to always perform a datumCopy when there's more than one
such function.

On net, these changes should provide small speed improvements as well
as removing problematic code.

Tom Lane and David Rowley

Discussion: https://postgr.es/m/1913788.1664898906@sss.pgh.pa.us
2022-10-06 13:27:34 -04:00
..
backend Remove uses of MemoryContextContains in nodeAgg.c and nodeWindowAgg.c. 2022-10-06 13:27:34 -04:00
bin Fix final compiler warning produced by -Wshadow=compatible-local 2022-10-06 10:19:36 +13:00
common Change some errdetail() to errdetail_internal() 2022-09-28 17:14:53 +02:00
fe_utils Revert 56-bit relfilenode change and follow-up commits. 2022-09-28 09:55:28 -04:00
include Introduce t_isalnum() to replace t_isalpha() || t_isdigit() tests. 2022-10-06 11:08:56 -04:00
interfaces meson: Add windows resource files 2022-10-05 09:56:05 -07:00
makefiles windows: remove date from version number in win32ver.rc 2022-09-26 11:38:02 -07:00
pl tests: Rename conflicting role names 2022-10-05 10:43:13 -07:00
port windows: Set UMDF_USING_NTSTATUS globally, include ntstatus.h 2022-09-28 21:59:15 -07:00
template Move darwin sysroot determination into separate file 2022-09-01 16:54:19 -07:00
test Remove uses of MemoryContextContains in nodeAgg.c and nodeWindowAgg.c. 2022-10-06 13:27:34 -04:00
timezone meson: Add windows resource files 2022-10-05 09:56:05 -07:00
tools meson: Add windows resource files 2022-10-05 09:56:05 -07:00
tutorial Update copyright for 2022 2022-01-07 19:04:57 -05:00
.gitignore
DEVELOPERS
Makefile Remove the option to build thread_test.c outside configure. 2020-10-21 12:08:48 -04:00
Makefile.global.in Split TESTDIR into TESTLOGDIR and TESTDATADIR 2022-09-19 18:03:17 -07:00
Makefile.shlib aix: No need to use mkldexport when we want to export all symbols 2022-09-09 19:11:49 -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