Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit cbc5f4f

Browse files
committed
checkretval() failed to cope with an empty SQL function body.
1 parent 821f467 commit cbc5f4f

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/backend/catalog/pg_proc.c

+10-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_proc.c,v 1.51 2000/11/20 20:36:47 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_proc.c,v 1.52 2000/12/07 19:40:56 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -339,6 +339,15 @@ checkretval(Oid rettype, List *queryTreeList)
339339
int relnatts;
340340
int i;
341341

342+
/* guard against empty function body; OK only if no return type */
343+
if (queryTreeList == NIL)
344+
{
345+
if (rettype != InvalidOid)
346+
elog(ERROR, "function declared to return %s, but no SELECT provided",
347+
typeidTypeName(rettype));
348+
return;
349+
}
350+
342351
/* find the final query */
343352
parse = (Query *) nth(length(queryTreeList) - 1, queryTreeList);
344353

0 commit comments

Comments
 (0)