diff --git a/src/backend/distributed/planner/recursive_planning.c b/src/backend/distributed/planner/recursive_planning.c index 389f5a68b..553ed922f 100644 --- a/src/backend/distributed/planner/recursive_planning.c +++ b/src/backend/distributed/planner/recursive_planning.c @@ -67,6 +67,7 @@ #include "distributed/query_colocation_checker.h" #include "distributed/recursive_planning.h" #include "distributed/relation_restriction_equivalence.h" +#include "distributed/version_compat.h" #include "lib/stringinfo.h" #include "optimizer/planner.h" #include "optimizer/prep.h" diff --git a/src/include/distributed/version_compat.h b/src/include/distributed/version_compat.h index cb2ab66ed..44c50d1c0 100644 --- a/src/include/distributed/version_compat.h +++ b/src/include/distributed/version_compat.h @@ -23,6 +23,7 @@ #include "optimizer/prep.h" #include "postmaster/bgworker.h" #include "utils/memutils.h" +#include "funcapi.h" /* PostgreSQL 11 splits hash procs into "standard" and "extended" */ #define HASHSTANDARD_PROC HASHPROC @@ -134,6 +135,33 @@ canonicalize_qual_compat(Expr *qual, bool is_check) } +/* + * A convenient wrapper around get_expr_result_type() that is added on PG11 + * + * Note that this function ignores the second parameter and behaves + * slightly differently. + * + * 1. The original function throws errors if noError flag is not set, we ignore + * this flag here and return NULL in that case + * 2. TYPEFUNC_COMPOSITE_DOMAIN is introduced in PG11, and references to this + * macro is removed + * */ +static inline TupleDesc +get_expr_result_tupdesc(Node *expr, bool noError) +{ + TupleDesc tupleDesc; + TypeFuncClass functypclass; + + functypclass = get_expr_result_type(expr, NULL, &tupleDesc); + + if (functypclass == TYPEFUNC_COMPOSITE) + { + return tupleDesc; + } + return NULL; +} + + #endif #if (PG_VERSION_NUM >= 110000)