From: | Merlin Moncure <mmoncure(at)gmail(dot)com> |
---|---|
To: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
Cc: | PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Proposal: casts row to array and array to row |
Date: | 2011-10-11 13:07:22 |
Message-ID: | CAHyXU0z0KB9LXpt7kr-MPj9mkzbo-ufx6uBe=WpGXagrLJzdUg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Tue, Oct 11, 2011 at 3:40 AM, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> wrote:
> Hello
>
> A current limits of dynamic work with row types in PL/pgSQL can be
> decreased with a possible casts between rows and arrays. Now we have a
> lot of tools for arrays, and these tools should be used for rows too.
>
> postgres=# \d mypoint
> Composite type "public.mypoint"
> Column │ Type │ Modifiers
> ────────┼─────────┼───────────
> a │ integer │
> b │ integer │
>
> postgres=# select cast(rmypoint '(10,20) as int[]);
> array
> ────────────
> {10,20}
> (1 row)
>
> postgres=# select cast(ARRAY[10,20] AS mypoint);
> mypoint
> ─────────
> (10,20)
> (1 row)
>
> What do you think about this idea?
Not sure what it buys you over the syntax we already have:
select row(foo[1], bar[2]);
select array[(bar).a, (bar).b];
Also, in my coding of composite types, homogeneously typed rows don't
really come up that often...
merlin
From | Date | Subject | |
---|---|---|---|
Next Message | Pavel Stehule | 2011-10-11 13:18:33 | Re: Proposal: casts row to array and array to row |
Previous Message | Pavel Stehule | 2011-10-11 13:06:07 | Re: Proposal: casts row to array and array to row |