ReleaseSysCache in logical_optimizer

fix_120_custom_aggregates_distribute_multiarg
Philip Dubé 2019-06-17 03:34:34 -07:00
parent a82fa8831c
commit 186f632f88
1 changed files with 10 additions and 10 deletions

View File

@ -1510,9 +1510,9 @@ MasterAggregateExpression(Aggref *originalAggregate,
AggClauseCosts aggregateCosts; AggClauseCosts aggregateCosts;
HeapTuple aggTuple; HeapTuple aggTuple;
Form_pg_aggregate aggform; Form_pg_aggregate aggform;
Oid combinefn; Oid combine;
Oid serialfn = InvalidOid; Oid serial = InvalidOid;
Oid deserialfn = InvalidOid; Oid deserial = InvalidOid;
aggTuple = SearchSysCache1(AGGFNOID, aggTuple = SearchSysCache1(AGGFNOID,
ObjectIdGetDatum(originalAggregate->aggfnoid)); ObjectIdGetDatum(originalAggregate->aggfnoid));
@ -1520,15 +1520,15 @@ MasterAggregateExpression(Aggref *originalAggregate,
elog(ERROR, "cache lookup failed for aggregate %u", elog(ERROR, "cache lookup failed for aggregate %u",
originalAggregate->aggfnoid); originalAggregate->aggfnoid);
aggform = (Form_pg_aggregate) GETSTRUCT(aggTuple); aggform = (Form_pg_aggregate) GETSTRUCT(aggTuple);
combine = aggform->aggcombinefn;
/* planner recorded transition state type in the Aggref itself */ if (IsValidOid(combine) && originalAggregate->aggtranstype == INTERNALOID) {
combinefn = aggform->aggcombinefn; serial = aggform->aggserialfn;
deserial = aggform->aggdeserialfn;
if (combinefn != InvalidOid) {
if (originalAggregate->aggtranstype == INTERNALOID) {
serialfn = aggform->aggserialfn;
deserialfn = aggform->aggdeserialfn;
} }
ReleaseSysCache(aggTuple);
if (IsValidOid(combine)) {
} else if (aggregateType == AGGREGATE_COUNT && originalAggregate->aggdistinct && } else if (aggregateType == AGGREGATE_COUNT && originalAggregate->aggdistinct &&
CountDistinctErrorRate == DISABLE_DISTINCT_APPROXIMATION && CountDistinctErrorRate == DISABLE_DISTINCT_APPROXIMATION &&
walkerContext->pullDistinctColumns) walkerContext->pullDistinctColumns)