Simplify planner's final setup of Aggrefs for partial aggregation.
Tom Lane <tgl@sss.pgh.pa.us>
Simplify planner's final setup of Aggrefs for partial aggregation. Commit e06a38965's original coding for constructing the execution-time expression tree for a combining aggregate was rather messy, involving duplicating quite a lot of code in setrefs.c so that it could inject a nonstandard matching rule for Aggrefs. Get rid of that in favor of explicitly constructing a combining Aggref with a partial Aggref as input, then allowing setref's normal matching logic to match the partial Aggref to the output of the lower plan node and hence replace it with a Var. In passing, rename and redocument make_partialgroup_input_target to have some connection to what it actually does.
Files
| Path | Change | +/− |
|---|---|---|
| src/backend/optimizer/plan/planner.c | modified | +89 −37 |
| src/backend/optimizer/plan/setrefs.c | modified | +80 −245 |
| src/backend/optimizer/util/tlist.c | modified | +0 −51 |
| src/include/optimizer/planner.h | modified | +2 −0 |
| src/include/optimizer/tlist.h | modified | +0 −1 |