From: | David Rowley <dgrowleyml(at)gmail(dot)com> |
---|---|
To: | PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Andres Freund <andres(at)anarazel(dot)de>, Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com> |
Subject: | Small clean up in nodeAgg.c |
Date: | 2021-06-12 11:03:43 |
Message-ID: | CAApHDvptMQ9FmF0D67zC_w88yVnoNVR2+kkOQGUrCmdxWxLULQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Much of nodeAgg.c does not really know the difference between the
aggregate's combine function and the aggregate's transition function.
This was done on purpose so that we can keep as much code the same as
possible between partial aggregate and finalize aggregate.
We can take this a bit further with the attached patch which managed a
net reduction of about 3 dozen lines of code.
3 files changed, 118 insertions(+), 155 deletions(-)
I also did some renaming to try and make it more clear about when
we're talking about aggtransfn and when we're just talking about the
transition function that's being used, which in the finalize aggregate
case will be the combine function.
I proposed this a few years ago in [1], but at the time we went with a
more minimal patch to fix the bug being reported there with plans to
come back and do a bit more once we branched.
I've rebased this and I'd like to propose this small cleanup for pg15.
The patch is basically making build_pertrans_for_aggref() oblivious to
if it's working with the aggtransfn or the aggcombinefn and all the
code that needs to treat them differently is moved up into
ExecInitAgg(). This allows us to just completely get rid of
build_aggregate_combinefn_expr() and just use
build_aggregate_transfn_expr() instead.
I feel this is worth doing as nodeAgg.c has grown quite a bit over the
years. Shrinking it down a bit and maybe making it a bit more readable
seems like a worthy goal. Heikki took a big step forward towards that
goal in 0a2bc5d61e. This, arguably, helps a little more.
I've included Andres and Horiguchi-san because they were part of the
discussion on the original thread.
David
Attachment | Content-Type | Size |
---|---|---|
v2-0001-Cleanup-some-aggregate-code-in-the-executor.patch | application/octet-stream | 15.8 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Andrew Dunstan | 2021-06-12 11:31:59 | Re: Race condition in recovery? |
Previous Message | Amit Kapila | 2021-06-12 10:47:54 | Re: Question about StartLogicalReplication() error path |