From f9e4f611a18f64fd9106a72ec9af9e2220075780 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sun, 12 May 2002 20:10:05 +0000 Subject: First pass at set-returning-functions in FROM, by Joe Conway with some kibitzing from Tom Lane. Not everything works yet, and there's no documentation or regression test, but let's commit this so Joe doesn't need to cope with tracking changes in so many files ... --- src/backend/parser/parse_func.c | 43 +++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 19 deletions(-) (limited to 'src/backend/parser/parse_func.c') diff --git a/src/backend/parser/parse_func.c b/src/backend/parser/parse_func.c index f74f5be2f7b..339577f39ca 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.127 2002/05/03 20:15:02 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.128 2002/05/12 20:10:04 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -181,27 +181,32 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs, * sizeof(Pointer) to signal that the runtime representation * will be a pointer not an Oid. */ - if (rte->rtekind != RTE_RELATION) + switch (rte->rtekind) { - /* - * RTE is a join or subselect; must fail for lack of a - * named tuple type - */ - if (is_column) - elog(ERROR, "No such attribute %s.%s", - refname, strVal(lfirst(funcname))); - else - { - elog(ERROR, "Cannot pass result of sub-select or join %s to a function", - refname); - } + case RTE_RELATION: + toid = get_rel_type_id(rte->relid); + if (!OidIsValid(toid)) + elog(ERROR, "Cannot find type OID for relation %u", + rte->relid); + break; + case RTE_FUNCTION: + toid = exprType(rte->funcexpr); + break; + default: + /* + * RTE is a join or subselect; must fail for lack of a + * named tuple type + */ + if (is_column) + elog(ERROR, "No such attribute %s.%s", + refname, strVal(lfirst(funcname))); + else + elog(ERROR, "Cannot pass result of sub-select or join %s to a function", + refname); + toid = InvalidOid; /* keep compiler quiet */ + break; } - toid = get_rel_type_id(rte->relid); - 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, -- cgit v1.2.3