shared_aggregate_state_fix.patch
application/octet-stream
Filename: shared_aggregate_state_fix.patch
Type: application/octet-stream
Part: 0
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: unified
| File | + | − |
|---|---|---|
| src/backend/executor/nodeAgg.c | 11 | 0 |
diff --git a/src/backend/executor/nodeAgg.c b/src/backend/executor/nodeAgg.c
index 0ae5873..b5d6545 100644
--- a/src/backend/executor/nodeAgg.c
+++ b/src/backend/executor/nodeAgg.c
@@ -3808,6 +3808,17 @@ find_compatible_pertrans(AggState *aggstate, Aggref *newagg,
{
ListCell *lc;
+ /*
+ * Don't attempt to share aggregate states between ordered-set aggregates.
+ * Really this is a bit of a hack since some of the builtin ordered-set
+ * aggregate's final functions are destructive to the transition state.
+ * A proper fix for this would be to devise a method of allowing a final
+ * function to know if it was the first or last final function to be
+ * called on the aggregate state.
+ */
+ if (newagg->aggkind == AGGKIND_HYPOTHETICAL)
+ return -1;
+
foreach(lc, transnos)
{
int transno = lfirst_int(lc);