diff options
Diffstat (limited to 'src/backend/optimizer')
| -rw-r--r-- | src/backend/optimizer/prep/prepjointree.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/backend/optimizer/prep/prepjointree.c b/src/backend/optimizer/prep/prepjointree.c index d13cb582272..f489f140e37 100644 --- a/src/backend/optimizer/prep/prepjointree.c +++ b/src/backend/optimizer/prep/prepjointree.c @@ -26,6 +26,7 @@ #include "postgres.h" #include "catalog/pg_type.h" +#include "funcapi.h" #include "nodes/makefuncs.h" #include "nodes/nodeFuncs.h" #include "optimizer/clauses.h" @@ -1683,6 +1684,9 @@ pull_up_constant_function(PlannerInfo *root, Node *jtnode, { Query *parse = root->parse; RangeTblFunction *rtf; + TypeFuncClass functypclass; + Oid funcrettype; + TupleDesc tupdesc; pullup_replace_vars_context rvcontext; /* Fail if the RTE has ORDINALITY - we don't implement that here. */ @@ -1696,6 +1700,20 @@ pull_up_constant_function(PlannerInfo *root, Node *jtnode, if (!IsA(rtf->funcexpr, Const)) return jtnode; + /* + * If the function's result is not a scalar, we punt. In principle we + * could break the composite constant value apart into per-column + * constants, but for now it seems not worth the work. + */ + if (rtf->funccolcount != 1) + return jtnode; /* definitely composite */ + + functypclass = get_expr_result_type(rtf->funcexpr, + &funcrettype, + &tupdesc); + if (functypclass != TYPEFUNC_SCALAR) + return jtnode; /* must be a one-column composite type */ + /* Create context for applying pullup_replace_vars */ rvcontext.root = root; rvcontext.targetlist = list_make1(makeTargetEntry((Expr *) rtf->funcexpr, |
