From: | Alban Hertroys <dalroi(at)solfertje(dot)student(dot)utwente(dot)nl> |
---|---|
To: | Jon Smark <jon(dot)smark(at)yahoo(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Record with a field consisting of table rows |
Date: | 2011-01-16 00:19:16 |
Message-ID: | 685C2671-5DA2-497C-B507-656D705F9509@solfertje.student.utwente.nl |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 15 Jan 2011, at 21:57, Jon Smark wrote:
>> No, of course not. A function cannot return different
>> amounts of different return-values in any language I know
>> of.
>
> Come on, you make it sound like it's something inconceivable or exotic,
> even though pretty much any strongly-typed language with a post-1970s
> type-system will allow a function to return tuples of arbitrary values.
> Have you never come across Ocaml, Haskell, Scala, and so forth?
A tuple wouldn't be unusual, but you're not asking for a simple tuple here. What you're asking for is a value and a set of tuples. That would sort of look like this:
total | users
---------------------------------------------------------
3 | foo
| bar
| baz
And what's worse, after the first returned tuple you only seem to want the users value, without the total value. I don't know of any language that can do that and I'm pretty sure the languages you mentioned can't do that either. It makes parsing the return values unnecessary difficult, I bet that's a compelling enough reason that nobody seems to have implemented it.
What most languages, including pgsql, _can_ do is this:
total | users
---------------------------------------------------------
3 | foo
3 | bar
3 | baz
Or this:
total | users
---------------------------------------------------------
3 | [foo, bar, baz]
Alban Hertroys
--
Screwing up is an excellent way to attach something to the ceiling.
!DSPAM:737,4d32398a11872893390349!
From | Date | Subject | |
---|---|---|---|
Next Message | Alban Hertroys | 2011-01-16 00:26:03 | Re: Trigger Performance |
Previous Message | Вячеслав Блинников | 2011-01-16 00:07:13 | libpq: multiple commands within single query |