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

From Vincenzo Romano
Subject Re: [GENERAL] RETURNS SETOF RECORD with 1 column
Date
Msg-id CAHjZ2x4eBAaAS0Dy-fYwA8Afwe9TieWfXNicZFN+nwdRZKgXkQ@mail.gmail.com
Whole thread Raw
In response to Re: [GENERAL] RETURNS SETOF RECORD with 1 column  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general

Il 28 lug 2017 16:18, "Tom Lane" <tgl@sss.pgh.pa.us> ha scritto:
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 ...

Here the "setof record" would help against typos. The table() wouldn't.

This is indubitably a typo.

Case B:

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

Here the table() would help. The setof record wouldn't.

I don't see any clear advantage beyond code style.

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.

Moreover, there is another number of typos for which the syntax won't help.

There is a slight difference in the win cases because of an asymmetry introduced to "avoid typos". 

You can create more asymmetries in the syntax to make a construct more general than others. The reasons would be, to me, quite disputable.


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.

I was infact asking for the reasons.
I am still looking for an answer, if any.

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.

I don't think people chooses PgSQL because of its adherence to the standard, but rather because of its smart deviances and enhancements. 



                        regards, tom lane

Enzo.

pgsql-general by date:

Previous
From: Gabriel Furstenheim Milerud
Date:
Subject: Re: [GENERAL] Executing regex in C code
Next
From: marcelo
Date:
Subject: Re: [GENERAL] Schemas and serials