aboutsummaryrefslogtreecommitdiff
path: root/src/backend/optimizer/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/optimizer/util')
-rw-r--r--src/backend/optimizer/util/clauses.c8
-rw-r--r--src/backend/optimizer/util/tlist.c37
2 files changed, 16 insertions, 29 deletions
diff --git a/src/backend/optimizer/util/clauses.c b/src/backend/optimizer/util/clauses.c
index 0e738c1ccc0..7138cad31d8 100644
--- a/src/backend/optimizer/util/clauses.c
+++ b/src/backend/optimizer/util/clauses.c
@@ -465,13 +465,11 @@ aggregates_allow_partial_walker(Node *node, partial_agg_context *context)
/*
* If we find any aggs with an internal transtype then we must check
- * that these have a serialization type, serialization func and
- * deserialization func; otherwise, we set the maximum allowed type to
- * PAT_INTERNAL_ONLY.
+ * whether these have serialization/deserialization functions;
+ * otherwise, we set the maximum allowed type to PAT_INTERNAL_ONLY.
*/
if (aggform->aggtranstype == INTERNALOID &&
- (!OidIsValid(aggform->aggserialtype) ||
- !OidIsValid(aggform->aggserialfn) ||
+ (!OidIsValid(aggform->aggserialfn) ||
!OidIsValid(aggform->aggdeserialfn)))
context->allowedtype = PAT_INTERNAL_ONLY;
diff --git a/src/backend/optimizer/util/tlist.c b/src/backend/optimizer/util/tlist.c
index de0a8c7b57f..5fa80ac51be 100644
--- a/src/backend/optimizer/util/tlist.c
+++ b/src/backend/optimizer/util/tlist.c
@@ -15,7 +15,7 @@
#include "postgres.h"
#include "access/htup_details.h"
-#include "catalog/pg_aggregate.h"
+#include "catalog/pg_type.h"
#include "nodes/makefuncs.h"
#include "nodes/nodeFuncs.h"
#include "optimizer/tlist.h"
@@ -766,8 +766,8 @@ apply_pathtarget_labeling_to_tlist(List *tlist, PathTarget *target)
/*
* apply_partialaggref_adjustment
* Convert PathTarget to be suitable for a partial aggregate node. We simply
- * adjust any Aggref nodes found in the target and set the aggoutputtype to
- * the aggtranstype or aggserialtype. This allows exprType() to return the
+ * adjust any Aggref nodes found in the target and set the aggoutputtype
+ * appropriately. This allows exprType() to return the
* actual type that will be produced.
*
* Note: We expect 'target' to be a flat target list and not have Aggrefs buried
@@ -784,40 +784,29 @@ apply_partialaggref_adjustment(PathTarget *target)
if (IsA(aggref, Aggref))
{
- HeapTuple aggTuple;
- Form_pg_aggregate aggform;
Aggref *newaggref;
- aggTuple = SearchSysCache1(AGGFNOID,
- ObjectIdGetDatum(aggref->aggfnoid));
- if (!HeapTupleIsValid(aggTuple))
- elog(ERROR, "cache lookup failed for aggregate %u",
- aggref->aggfnoid);
- aggform = (Form_pg_aggregate) GETSTRUCT(aggTuple);
-
newaggref = (Aggref *) copyObject(aggref);
/*
- * Use the serialization type, if one exists. Note that we don't
- * support it being a polymorphic type. (XXX really we ought to
- * hardwire this as INTERNAL -> BYTEA, and avoid a catalog lookup
- * here altogether?)
+ * Normally, a partial aggregate returns the aggregate's
+ * transition type, but if that's INTERNAL, it returns BYTEA
+ * instead. (XXX this assumes we're doing parallel aggregate with
+ * serialization; later we might need an argument to tell this
+ * function whether we're doing parallel or just local partial
+ * aggregation.)
*/
- if (OidIsValid(aggform->aggserialtype))
- newaggref->aggoutputtype = aggform->aggserialtype;
+ Assert(OidIsValid(newaggref->aggtranstype));
+
+ if (newaggref->aggtranstype == INTERNALOID)
+ newaggref->aggoutputtype = BYTEAOID;
else
- {
- /* Otherwise, we return the aggregate's transition type */
- Assert(OidIsValid(newaggref->aggtranstype));
newaggref->aggoutputtype = newaggref->aggtranstype;
- }
/* flag it as partial */
newaggref->aggpartial = true;
lfirst(lc) = newaggref;
-
- ReleaseSysCache(aggTuple);
}
}
}