Re: [GENERAL] RETURNS SETOF RECORD with 1 column - Mailing list pgsql-general

From Tom Lane
Subject Re: [GENERAL] RETURNS SETOF RECORD with 1 column
Date
Msg-id 26650.1501251534@sss.pgh.pa.us
Whole thread Raw
In response to Re: [GENERAL] RETURNS SETOF RECORD with 1 column  (Vincenzo Romano <vincenzo.romano@notorand.it>)
Responses Re: [GENERAL] RETURNS SETOF RECORD with 1 column  (Vincenzo Romano <vincenzo.romano@notorand.it>)
List pgsql-general
Vincenzo Romano <vincenzo.romano@notorand.it> writes:
> I would like to understand the typo protection mentioned by Tom earlier:
> I need to understand the reason for creating that special case.

Well, case A:

create function foo(out x int4) returns setof int8 ...

This is indubitably a typo.

Case B:

create function foo(out x record) returns setof record ...

Now what?  Is the user expecting us to wrap x in an additional
layer of composite, or not?  Our current assumption is "not",
but it would be pretty inconsistent to do that if x did get
wrapped as long as it were any other type.

Yes, we could have resolved that ambiguity in one direction or the
other and then said that "returns record" or "returns setof record"
is OK regardless of the number of OUT parameters, but we didn't.
Considering that the SQL-standard syntax for this is TABLE(), and that
hasn't got these issues in the first place, I don't feel any need to
revisit the question.

            regards, tom lane


pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: [GENERAL] tzdata version
Next
From: Timokhin Maxim
Date:
Subject: Re: [GENERAL] duplicate key value violates unique constraint and duplicated records