Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f8XXW-00073B-2U for pgsql-general@arkaria.postgresql.org; Tue, 17 Apr 2018 20:49:22 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1f8XXU-0001Ik-9D for pgsql-general@arkaria.postgresql.org; Tue, 17 Apr 2018 20:49:20 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f8XXT-0001IU-RP for pgsql-general@lists.postgresql.org; Tue, 17 Apr 2018 20:49:20 +0000 Received: from mail-pf0-x234.google.com ([2607:f8b0:400e:c00::234]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1f8XXQ-0003lu-4b for pgsql-general@lists.postgresql.org; Tue, 17 Apr 2018 20:49:18 +0000 Received: by mail-pf0-x234.google.com with SMTP id y66so12710196pfi.7 for ; Tue, 17 Apr 2018 13:49:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=illuminatedcomputing-com.20150623.gappssmtp.com; s=20150623; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=J6A1rM/EZL/JpkhSOHLP3/4/fdOstFgRThK+uWCdkOY=; b=FL+ioPoH8XUBiPWhsElB2W8bki/ZXKF/Iwr4trzD3ANKm20ivPAt6Nr0gTwae6keZ7 hrvr93fbZ+9CNZJvo4wbyBfn1OtqBrdJ6nVXX9flybqo5PLq4seTbW8fV0LC3phayMRh W6DWfxhRYW7sMp4C8pZQ3RVlheonAEhR6X/YMUXssWCcPGdvV5oqM8nMPhzWGPus2lZ+ eI/eq18eVdhX154Tkn7MECMi97SWB3hk785Qy3rM3MTTlO7xPCZ/YQKI5V/vC1c5ZY1e yo8jEXxBrfBBjPxkgize8Vv3EpuhVC0vXOmtXUlEdlfz4Nyfdmw9iLkxT02l/9BnI3K7 E+fA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=J6A1rM/EZL/JpkhSOHLP3/4/fdOstFgRThK+uWCdkOY=; b=biL2uopAjqzNDY78DDL6rHZ9N1YC94qQIbiThQjCaoYUcZZATvnp1nz8Owf286nhZ5 5zNZTLdsYcRcEaFyTZyeJYyLFdvqM/sN1qC0QDv5TI7YMBcIuHsaH47gzIj5wQO1wjfe CYNFsaCzbWMlDZ7kFk90wAYM5O6td3s4F65daixhB0Oh1RmPtdJgrdFY/1mpYESERXdm 1kzXzljUbqmF97FW9e6syMPGJcVM0w9098/YvD502GxgvKQYiGd9mxP/aI1JPQkwIvjY hdI0x+os1UE7zIZFUXylURV/dDaU/cHQD85Dt3jn9XKpxfUtN7tNI5t5HmzpbdYdjj2k DqIQ== X-Gm-Message-State: ALQs6tB5odyMRTFNmq5BUMl/ZrsliRpcHJnsfuHjRaPT3AJ9GhKe/bPh S+2GeZ/fUqjrtovFNAMSEt+imm3Q X-Google-Smtp-Source: AIpwx49gxrZpInK7w2b4lr0Cze07SrRgtgm7SifnkvUHObL9YRPtPuyY592Gb2w8ysh6rO/Z3K21Hg== X-Received: by 10.99.39.135 with SMTP id n129mr2990401pgn.167.1523998154580; Tue, 17 Apr 2018 13:49:14 -0700 (PDT) Received: from [192.168.2.201] (static-50-53-109-254.bvtn.or.frontiernet.net. [50.53.109.254]) by smtp.googlemail.com with ESMTPSA id w12sm40059251pfi.180.2018.04.17.13.49.13 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Apr 2018 13:49:13 -0700 (PDT) Subject: Re: array UNNESTed to rows stable with respect to order? To: pgsql-general@lists.postgresql.org References: <4cbc9fe5-5907-9f2f-ffd3-d67a43ace38b@gelassene-pferde.biz> From: Paul Jungwirth Message-ID: Date: Tue, 17 Apr 2018 13:49:13 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <4cbc9fe5-5907-9f2f-ffd3-d67a43ace38b@gelassene-pferde.biz> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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