Re: array UNNESTed to rows stable with respect to order? - Mailing list pgsql-general

From Paul Jungwirth
Subject Re: array UNNESTed to rows stable with respect to order?
Date
Msg-id f7d33a67-6c1a-e101-0391-aeaa6b3c04a6@illuminatedcomputing.com
Whole thread Raw
In response to array UNNESTed to rows stable with respect to order?  (Thiemo Kellner <thiemo@gelassene-pferde.biz>)
Responses Re: array UNNESTed to rows stable with respect to order?
List 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@illuminatedcomputing.com


pgsql-general by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: array UNNESTed to rows stable with respect to order?
Next
From: Adrian Klaver
Date:
Subject: Re: rehashing catalog cache id 14 for pg_opclass; 17 tups, 8 buckets