Re: array UNNESTed to rows stable with respect to order?

From: Paul Jungwirth <pj(at)illuminatedcomputing(dot)com>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: array UNNESTed to rows stable with respect to order?
Date: 2018-04-17 20:49:13
Message-ID: f7d33a67-6c1a-e101-0391-aeaa6b3c04a6@illuminatedcomputing.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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(at)illuminatedcomputing(dot)com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2018-04-17 20:55:53 Re: rehashing catalog cache id 14 for pg_opclass; 17 tups, 8 buckets
Previous Message David G. Johnston 2018-04-17 20:40:57 Re: array UNNESTed to rows stable with respect to order?