Code review for anonymous-functions patch --- clean up some confusion
in checkretval about which paths are for base or complex return type.
This commit is contained in:
parent
44582cd879
commit
0fe931a3e0
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_proc.c,v 1.85 2002/08/04 23:49:59 tgl Exp $
|
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_proc.c,v 1.86 2002/08/05 00:21:27 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -372,14 +372,14 @@ checkretval(Oid rettype, char fn_typtype, List *queryTreeList)
|
|||||||
|
|
||||||
if (fn_typtype == 'b')
|
if (fn_typtype == 'b')
|
||||||
{
|
{
|
||||||
|
/* Shouldn't have a typerelid */
|
||||||
|
Assert(typerelid == InvalidOid);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* For base-type returns, the target list should have exactly one
|
* For base-type returns, the target list should have exactly one
|
||||||
* entry, and its type should agree with what the user declared. (As
|
* entry, and its type should agree with what the user declared. (As
|
||||||
* of Postgres 7.2, we accept binary-compatible types too.)
|
* of Postgres 7.2, we accept binary-compatible types too.)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (typerelid == InvalidOid)
|
|
||||||
{
|
|
||||||
if (tlistlen != 1)
|
if (tlistlen != 1)
|
||||||
elog(ERROR, "function declared to return %s returns multiple columns in final SELECT",
|
elog(ERROR, "function declared to return %s returns multiple columns in final SELECT",
|
||||||
format_type_be(rettype));
|
format_type_be(rettype));
|
||||||
@ -388,9 +388,11 @@ checkretval(Oid rettype, char fn_typtype, List *queryTreeList)
|
|||||||
if (!IsBinaryCompatible(restype, rettype))
|
if (!IsBinaryCompatible(restype, rettype))
|
||||||
elog(ERROR, "return type mismatch in function: declared to return %s, returns %s",
|
elog(ERROR, "return type mismatch in function: declared to return %s, returns %s",
|
||||||
format_type_be(rettype), format_type_be(restype));
|
format_type_be(rettype), format_type_be(restype));
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
else if (fn_typtype == 'c')
|
||||||
|
{
|
||||||
|
/* Must have a typerelid */
|
||||||
|
Assert(typerelid != InvalidOid);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If the target list is of length 1, and the type of the varnode in
|
* If the target list is of length 1, and the type of the varnode in
|
||||||
@ -405,14 +407,13 @@ checkretval(Oid rettype, char fn_typtype, List *queryTreeList)
|
|||||||
if (IsBinaryCompatible(restype, rettype))
|
if (IsBinaryCompatible(restype, rettype))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else if (fn_typtype == 'c')
|
|
||||||
{
|
|
||||||
/*
|
/*
|
||||||
* By here, the procedure returns a tuple or set of tuples. This part
|
* Otherwise verify that the targetlist matches the return tuple type.
|
||||||
* of the typechecking is a hack. We look up the relation that is the
|
* This part of the typechecking is a hack. We look up the relation
|
||||||
* declared return type, and scan the non-deleted attributes to ensure
|
* that is the declared return type, and scan the non-deleted
|
||||||
* that they match the datatypes of the non-resjunk columns.
|
* attributes to ensure that they match the datatypes of the
|
||||||
|
* non-resjunk columns.
|
||||||
*/
|
*/
|
||||||
reln = heap_open(typerelid, AccessShareLock);
|
reln = heap_open(typerelid, AccessShareLock);
|
||||||
relnatts = reln->rd_rel->relnatts;
|
relnatts = reln->rd_rel->relnatts;
|
||||||
@ -462,16 +463,16 @@ checkretval(Oid rettype, char fn_typtype, List *queryTreeList)
|
|||||||
format_type_be(rettype), rellogcols);
|
format_type_be(rettype), rellogcols);
|
||||||
|
|
||||||
heap_close(reln, AccessShareLock);
|
heap_close(reln, AccessShareLock);
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
else if (fn_typtype == 'p' && rettype == RECORDOID)
|
else if (fn_typtype == 'p' && rettype == RECORDOID)
|
||||||
{
|
{
|
||||||
|
/* Shouldn't have a typerelid */
|
||||||
|
Assert(typerelid == InvalidOid);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* For RECORD return type, defer this check until we get the
|
* For RECORD return type, defer this check until we get the
|
||||||
* first tuple.
|
* first tuple.
|
||||||
*/
|
*/
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
elog(ERROR, "Unknown kind of return type specified for function");
|
elog(ERROR, "Unknown kind of return type specified for function");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user