aboutsummaryrefslogtreecommitdiff
path: root/src/include/nodes/execnodes.h
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2017-10-12 15:20:04 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2017-10-12 15:20:16 -0400
commit305cf1fd7239e0ffa9ae4ff54a7c66f36432c741 (patch)
tree7fc6d2976a3c8d2efbcb4e829da86b423dad9900 /src/include/nodes/execnodes.h
parentad4a7ed0996ee044ee7291559deddf9842d8bbf7 (diff)
downloadpostgresql-305cf1fd7239e0ffa9ae4ff54a7c66f36432c741.tar.gz
postgresql-305cf1fd7239e0ffa9ae4ff54a7c66f36432c741.zip
Fix AggGetAggref() so it won't lie to aggregate final functions.
If we merge the transition calculations for two different aggregates, it's reasonable to assume that the transition function should not care which of those Aggref structs it gets from AggGetAggref(). It is not reasonable to make the same assumption about an aggregate final function, however. Commit 804163bc2 broke this, as it will pass whichever Aggref was first associated with the transition state in both cases. This doesn't create an observable bug so far as the core system is concerned, because the only existing uses of AggGetAggref() are in ordered-set aggregates that happen to not pay attention to anything but the input properties of the Aggref; and besides that, we disabled sharing of transition calculations for OSAs yesterday. Nonetheless, if some third-party code were using AggGetAggref() in a normal aggregate, they would be entitled to call this a bug. Hence, back-patch the fix to 9.6 where the problem was introduced. In passing, improve some of the comments about transition state sharing. Discussion: https://postgr.es/m/CAB4ELO5RZhOamuT9Xsf72ozbenDLLXZKSk07FiSVsuJNZB861A@mail.gmail.com
Diffstat (limited to 'src/include/nodes/execnodes.h')
-rw-r--r--src/include/nodes/execnodes.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index c46113444fa..d4ce8d8f494 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -1808,7 +1808,8 @@ typedef struct AggState
ExprContext **aggcontexts; /* econtexts for long-lived data (per GS) */
ExprContext *tmpcontext; /* econtext for input expressions */
ExprContext *curaggcontext; /* currently active aggcontext */
- AggStatePerTrans curpertrans; /* currently active trans state */
+ AggStatePerAgg curperagg; /* currently active aggregate, if any */
+ AggStatePerTrans curpertrans; /* currently active trans state, if any */
bool input_done; /* indicates end of input */
bool agg_done; /* indicates completion of Agg scan */
int projected_set; /* The last projected grouping set */