diff options
Diffstat (limited to 'src/backend/executor')
-rw-r--r-- | src/backend/executor/execExprInterp.c | 6 | ||||
-rw-r--r-- | src/backend/executor/execSRF.c | 5 | ||||
-rw-r--r-- | src/backend/executor/functions.c | 15 | ||||
-rw-r--r-- | src/backend/executor/nodeFunctionscan.c | 3 |
4 files changed, 23 insertions, 6 deletions
diff --git a/src/backend/executor/execExprInterp.c b/src/backend/executor/execExprInterp.c index c5e97ef9e2d..a0f537b706b 100644 --- a/src/backend/executor/execExprInterp.c +++ b/src/backend/executor/execExprInterp.c @@ -3469,8 +3469,12 @@ ExecEvalWholeRowVar(ExprState *state, ExprEvalStep *op, ExprContext *econtext) * generates an INT4 NULL regardless of the dropped column type). * If we find a dropped column and cannot verify that case (1) * holds, we have to use the slow path to check (2) for each row. + * + * If vartype is a domain over composite, just look through that + * to the base composite type. */ - var_tupdesc = lookup_rowtype_tupdesc(variable->vartype, -1); + var_tupdesc = lookup_rowtype_tupdesc_domain(variable->vartype, + -1, false); slot_tupdesc = slot->tts_tupleDescriptor; diff --git a/src/backend/executor/execSRF.c b/src/backend/executor/execSRF.c index cce771d4bea..c24d8b9eade 100644 --- a/src/backend/executor/execSRF.c +++ b/src/backend/executor/execSRF.c @@ -502,7 +502,7 @@ restart: { TupleTableSlot *slot = fcache->funcResultSlot; MemoryContext oldContext; - bool foundTup; + bool foundTup; /* * Have to make sure tuple in slot lives long enough, otherwise @@ -734,7 +734,8 @@ init_sexpr(Oid foid, Oid input_collation, Expr *node, /* Must save tupdesc in sexpr's context */ oldcontext = MemoryContextSwitchTo(sexprCxt); - if (functypclass == TYPEFUNC_COMPOSITE) + if (functypclass == TYPEFUNC_COMPOSITE || + functypclass == TYPEFUNC_COMPOSITE_DOMAIN) { /* Composite data type, e.g. a table's row type */ Assert(tupdesc); diff --git a/src/backend/executor/functions.c b/src/backend/executor/functions.c index 42a4ca94e97..98eb777421b 100644 --- a/src/backend/executor/functions.c +++ b/src/backend/executor/functions.c @@ -1665,7 +1665,15 @@ check_sql_fn_retval(Oid func_id, Oid rettype, List *queryTreeList, } else if (fn_typtype == TYPTYPE_COMPOSITE || rettype == RECORDOID) { - /* Returns a rowtype */ + /* + * Returns a rowtype. + * + * Note that we will not consider a domain over composite to be a + * "rowtype" return type; it goes through the scalar case above. This + * is because SQL functions don't provide any implicit casting to the + * result type, so there is no way to produce a domain-over-composite + * result except by computing it as an explicit single-column result. + */ TupleDesc tupdesc; int tupnatts; /* physical number of columns in tuple */ int tuplogcols; /* # of nondeleted columns in tuple */ @@ -1711,7 +1719,10 @@ check_sql_fn_retval(Oid func_id, Oid rettype, List *queryTreeList, } } - /* Is the rowtype fixed, or determined only at runtime? */ + /* + * Is the rowtype fixed, or determined only at runtime? (Note we + * cannot see TYPEFUNC_COMPOSITE_DOMAIN here.) + */ if (get_func_result_type(func_id, NULL, &tupdesc) != TYPEFUNC_COMPOSITE) { /* diff --git a/src/backend/executor/nodeFunctionscan.c b/src/backend/executor/nodeFunctionscan.c index 9f87a7e5cdd..de476ac75c4 100644 --- a/src/backend/executor/nodeFunctionscan.c +++ b/src/backend/executor/nodeFunctionscan.c @@ -383,7 +383,8 @@ ExecInitFunctionScan(FunctionScan *node, EState *estate, int eflags) &funcrettype, &tupdesc); - if (functypclass == TYPEFUNC_COMPOSITE) + if (functypclass == TYPEFUNC_COMPOSITE || + functypclass == TYPEFUNC_COMPOSITE_DOMAIN) { /* Composite data type, e.g. a table's row type */ Assert(tupdesc); |