From: | Rodrigo De León <rdeleonp(at)gmail(dot)com> |
---|---|
To: | "Hans-Peter Oeri" <hp(at)oeri(dot)ch> |
Cc: | ListaPostgre <pgsql-novice(at)postgresql(dot)org> |
Subject: | Re: array indizes in SQL |
Date: | 2007-11-14 21:16:49 |
Message-ID: | a55915760711141316p690a9682ha79bb7e5caaf561b@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
On Nov 12, 2007 12:04 PM, Hans-Peter Oeri <hp(at)oeri(dot)ch> wrote:
> SELECT
> CAST(c.conrelid as regclass) AS "you"
> , am.attname AS "mine"
> , ay.attname AS "yours"
> FROM
> generate_series(1,5) as i
> , pg_catalog.pg_attribute as am
> , pg_catalog.pg_attribute as ay
> , pg_catalog.pg_constraint as c
> WHERE
> c.confrelid = CAST(? AS regclass)
> AND am.attrelid = c.confrelid
> AND ay.attrelid = c.conrelid
> AND c.confkey[i] = am.attnum -- position in the respective array
> AND c.conkey[i] = ay.attnum -- must be identical
> ORDER BY
> i ASC
I see. If correct ordering is a requirement, I see no reason to
classify your original query as "unclean". If it works for you, and
it's fast enough, go for it.
Good luck.
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2007-11-14 23:03:42 | Re: array indizes in SQL |
Previous Message | G. J. Walsh | 2007-11-14 20:09:37 | populating arrays with default values |