From: Paul Jungwirth <pj@illuminatedcomputing.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: array UNNESTed to rows stable with respect to order?
Date: Tue, 17 Apr 2018 13:49:13 -0700
Message-ID: <f7d33a67-6c1a-e101-0391-aeaa6b3c04a6@illuminatedcomputing.com> (raw)
In-Reply-To: <4cbc9fe5-5907-9f2f-ffd3-d67a43ace38b@gelassene-pferde.biz>
References: <4cbc9fe5-5907-9f2f-ffd3-d67a43ace38b@gelassene-pferde.biz>
On 04/17/2018 01:20 PM, Thiemo Kellner wrote:
> I use UNNEST to get rows from array. This works fine but I am
> not sure whether the ordering remains in the later use.
I think you are looking for `WITH ORDINALITY` (in pg 9.4+). For instance
you could rewrite your first CTE like so:
SELECT oid as PROOID,
PRONAME,
t as PROARGTYPE,
i,
PRONAMESPACE,
PROOWNER
FROM PG_CATALOG.PG_PROC,
UNNEST(PROARGTYPES) WITH ORDINALITY AS proargtypes(t, i)
;
Yours,
--
Paul ~{:-)
pj@illuminatedcomputing.com
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: pj@illuminatedcomputing.com
Subject: Re: array UNNESTed to rows stable with respect to order?
In-Reply-To: <f7d33a67-6c1a-e101-0391-aeaa6b3c04a6@illuminatedcomputing.com>
References: <4cbc9fe5-5907-9f2f-ffd3-d67a43ace38b@gelassene-pferde.biz> <f7d33a67-6c1a-e101-0391-aeaa6b3c04a6@illuminatedcomputing.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox