Re: RETURNS SETOF RECORD with 1 column

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Vincenzo Romano <vincenzo(dot)romano(at)notorand(dot)it>
Cc: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, PostgreSQL General <pgsql-general(at)postgresql(dot)org>
Subject: Re: RETURNS SETOF RECORD with 1 column
Date: 2017-07-28 14:18:54
Message-ID: 26650.1501251534@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Vincenzo Romano <vincenzo(dot)romano(at)notorand(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Timokhin Maxim 2017-07-28 14:34:43 Re: duplicate key value violates unique constraint and duplicated records
Previous Message Tom Lane 2017-07-28 14:06:41 Re: tzdata version