mirror of
https://github.com/postgres/postgres.git
synced 2025-08-19 23:22:23 +03:00
Ensure result of an aggregate's finalfunc is made read-only.
The finalfunc might return a read-write expanded object. If we
de-duplicate multiple call sites for the aggregate, any function(s)
receiving the aggregate result earlier could alter or destroy the
value that reaches the ones called later. This is a brown-paper-bag
bug in commit 42b746d4c
, because we actually considered the need
for read-only-ness but failed to realize that it applied to the case
with a finalfunc as well as the case without.
Per report from Justin Pryzby. New error in HEAD,
no need for back-patch.
Discussion: https://postgr.es/m/ZDm5TuKsh3tzoEjz@telsasoft.com
This commit is contained in:
@@ -623,10 +623,15 @@ finalize_windowaggregate(WindowAggState *winstate,
|
||||
}
|
||||
else
|
||||
{
|
||||
Datum res;
|
||||
|
||||
winstate->curaggcontext = peraggstate->aggcontext;
|
||||
*result = FunctionCallInvoke(fcinfo);
|
||||
res = FunctionCallInvoke(fcinfo);
|
||||
winstate->curaggcontext = NULL;
|
||||
*isnull = fcinfo->isnull;
|
||||
*result = MakeExpandedObjectReadOnly(res,
|
||||
fcinfo->isnull,
|
||||
peraggstate->resulttypeLen);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
Reference in New Issue
Block a user