aboutsummaryrefslogtreecommitdiff
path: root/src/backend/executor/nodeWindowAgg.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/executor/nodeWindowAgg.c')
-rw-r--r--src/backend/executor/nodeWindowAgg.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/backend/executor/nodeWindowAgg.c b/src/backend/executor/nodeWindowAgg.c
index 81ba024bbaf..4f4aeb2883e 100644
--- a/src/backend/executor/nodeWindowAgg.c
+++ b/src/backend/executor/nodeWindowAgg.c
@@ -2300,7 +2300,27 @@ ExecWindowAgg(PlanState *pstate)
continue;
}
else
+ {
winstate->status = WINDOWAGG_PASSTHROUGH;
+
+ /*
+ * If we're not the top-window, we'd better NULLify
+ * the aggregate results. In pass-through mode we no
+ * longer update these and this avoids the old stale
+ * results lingering. Some of these might be byref
+ * types so we can't have them pointing to free'd
+ * memory. The planner insisted that quals used in
+ * the runcondition are strict, so the top-level
+ * WindowAgg will filter these NULLs out in the filter
+ * clause.
+ */
+ numfuncs = winstate->numfuncs;
+ for (i = 0; i < numfuncs; i++)
+ {
+ econtext->ecxt_aggvalues[i] = (Datum) 0;
+ econtext->ecxt_aggnulls[i] = true;
+ }
+ }
}
else
{