Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0fe931a

Browse files
committed
Code review for anonymous-functions patch --- clean up some confusion
in checkretval about which paths are for base or complex return type.
1 parent44582cd commit0fe931a

File tree

1 file changed

+25
-24
lines changed

1 file changed

+25
-24
lines changed

‎src/backend/catalog/pg_proc.c

Lines changed: 25 additions & 24 deletions
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.85 2002/08/04 23:49:59 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_proc.c,v 1.86 2002/08/05 00:21:27 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -372,25 +372,27 @@ checkretval(Oid rettype, char fn_typtype, List *queryTreeList)
372372

373373
if (fn_typtype=='b')
374374
{
375+
/* Shouldn't have a typerelid */
376+
Assert(typerelid==InvalidOid);
377+
375378
/*
376379
* For base-type returns, the target list should have exactly one
377380
* entry, and its type should agree with what the user declared. (As
378381
* of Postgres 7.2, we accept binary-compatible types too.)
379382
*/
383+
if (tlistlen!=1)
384+
elog(ERROR,"function declared to return %s returns multiple columns in final SELECT",
385+
format_type_be(rettype));
380386

381-
if (typerelid==InvalidOid)
382-
{
383-
if (tlistlen!=1)
384-
elog(ERROR,"function declared to return %s returns multiple columns in final SELECT",
385-
format_type_be(rettype));
386-
387-
restype= ((TargetEntry*)lfirst(tlist))->resdom->restype;
388-
if (!IsBinaryCompatible(restype,rettype))
389-
elog(ERROR,"return type mismatch in function: declared to return %s, returns %s",
390-
format_type_be(rettype),format_type_be(restype));
391-
392-
return;
393-
}
387+
restype= ((TargetEntry*)lfirst(tlist))->resdom->restype;
388+
if (!IsBinaryCompatible(restype,rettype))
389+
elog(ERROR,"return type mismatch in function: declared to return %s, returns %s",
390+
format_type_be(rettype),format_type_be(restype));
391+
}
392+
elseif (fn_typtype=='c')
393+
{
394+
/* Must have a typerelid */
395+
Assert(typerelid!=InvalidOid);
394396

395397
/*
396398
* 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)
405407
if (IsBinaryCompatible(restype,rettype))
406408
return;
407409
}
408-
}
409-
elseif (fn_typtype=='c')
410-
{
410+
411411
/*
412-
* By here, the procedure returns a tuple or set of tuples. This part
413-
* of the typechecking is a hack. We look up the relation that is the
414-
* declared return type, and scan the non-deleted attributes to ensure
415-
* that they match the datatypes of the non-resjunk columns.
412+
* Otherwise verify that the targetlist matches the return tuple type.
413+
* This part of the typechecking is a hack. We look up the relation
414+
* that is the declared return type, and scan the non-deleted
415+
* attributes to ensure that they match the datatypes of the
416+
* non-resjunk columns.
416417
*/
417418
reln=heap_open(typerelid,AccessShareLock);
418419
relnatts=reln->rd_rel->relnatts;
@@ -462,16 +463,16 @@ checkretval(Oid rettype, char fn_typtype, List *queryTreeList)
462463
format_type_be(rettype),rellogcols);
463464

464465
heap_close(reln,AccessShareLock);
465-
466-
return;
467466
}
468467
elseif (fn_typtype=='p'&&rettype==RECORDOID)
469468
{
469+
/* Shouldn't have a typerelid */
470+
Assert(typerelid==InvalidOid);
471+
470472
/*
471473
* For RECORD return type, defer this check until we get the
472474
* first tuple.
473475
*/
474-
return;
475476
}
476477
else
477478
elog(ERROR,"Unknown kind of return type specified for function");

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp