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