From 76d09f4610cbf23ccc36649b35d8691ec5dcd1e1 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sat, 19 Oct 2002 21:23:20 +0000 Subject: [PATCH] Fix case where a function in FROM returns a scalar type, but is referred to with whole-tuple syntax. --- src/backend/parser/parse_func.c | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/src/backend/parser/parse_func.c b/src/backend/parser/parse_func.c index 9a54a900ae..6c194f06c5 100644 --- a/src/backend/parser/parse_func.c +++ b/src/backend/parser/parse_func.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.137 2002/09/18 21:35:22 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.138 2002/10/19 21:23:20 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -191,9 +191,33 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs, if (!OidIsValid(toid)) elog(ERROR, "Cannot find type OID for relation %u", rte->relid); + /* replace RangeVar in the arg list */ + lfirst(i) = makeVar(vnum, + InvalidAttrNumber, + toid, + sizeof(Pointer), + sublevels_up); break; case RTE_FUNCTION: toid = exprType(rte->funcexpr); + if (get_typtype(toid) == 'c') + { + /* func returns composite; same as relation case */ + lfirst(i) = makeVar(vnum, + InvalidAttrNumber, + toid, + sizeof(Pointer), + sublevels_up); + } + else + { + /* func returns scalar; use attno 1 instead */ + lfirst(i) = makeVar(vnum, + 1, + toid, + -1, + sublevels_up); + } break; default: @@ -210,13 +234,6 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs, toid = InvalidOid; /* keep compiler quiet */ break; } - - /* replace RangeVar in the arg list */ - lfirst(i) = makeVar(vnum, - InvalidAttrNumber, - toid, - sizeof(Pointer), - sublevels_up); } else toid = exprType(arg);