Ensure result of an aggregate's finalfunc is made read-only.
Tom Lane <tgl@sss.pgh.pa.us>
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
Files
| Path | Change | +/− |
|---|---|---|
| src/backend/executor/nodeAgg.c | modified | +14 −4 |
| src/backend/executor/nodeWindowAgg.c | modified | +6 −1 |
| src/test/regress/expected/aggregates.out | modified | +37 −0 |
| src/test/regress/sql/aggregates.sql | modified | +39 −0 |
Discussion
- v16dev: invalid memory alloc request size 8488348128 10 messages · 2023-04-14 → 2023-04-16