From: Vallimaharajan <vallimaharajan.gs@zohocorp.com>
Subject: [PATCH] Set aggregate values to NULL when run condition fails in WINDOWAGG_PASSTHROUGH_STRICT mode
Date: Wed, 13 Nov 2024 20:18:36 +0530
---
src/backend/executor/nodeWindowAgg.c | 34 +++++++++++++---------------
1 file changed, 16 insertions(+), 18 deletions(-)
inline patch 1: src/backend/executor/nodeWindowAgg.c (+16/-18 lines) download inline-1.patchdiff --git a/src/backend/executor/nodeWindowAgg.c b/src/backend/executor/nodeWindowAgg.cindex 51a6708a39..839808fd58 100644--- a/src/backend/executor/nodeWindowAgg.c+++ b/src/backend/executor/nodeWindowAgg.c@@ -2353,6 +2353,22 @@ ExecWindowAgg(PlanState *pstate)
*/
if (winstate->use_pass_through)
{
+ /*+ * we'd better NULLify the aggregate results for pass-through+ * mode. In this 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;+ }+
/*
* STRICT pass-through mode is required for the top window
* when there is a PARTITION BY clause. Otherwise we must
@@ -2367,24 +2383,6 @@ ExecWindowAgg(PlanState *pstate)
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
--
2.34.1
------=_Part_6447_1211805977.1731511331918
Content-Type: application/octet-stream; name=malloc_allocator.patch
Content-Transfer-Encoding: 7bit
X-ZM_AttachId: 139508041319290000
Content-Disposition: attachment; filename=malloc_allocator.patch
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: vallimaharajan.gs@zohocorp.com
Subject: Re: [PATCH] Set aggregate values to NULL when run condition fails in WINDOWAGG_PASSTHROUGH_STRICT mode
In-Reply-To: <no-message-id-25440@localhost>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox