Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1g10Fh-0006ND-Mn for pgsql-general@arkaria.postgresql.org; Sat, 15 Sep 2018 02:24:05 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1g10Fe-0002TH-VD for pgsql-general@arkaria.postgresql.org; Sat, 15 Sep 2018 02:24:02 +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 1g10Fe-0002T7-Hd for pgsql-general@lists.postgresql.org; Sat, 15 Sep 2018 02:24:02 +0000 Received: from [195.159.176.226] (helo=blaine.gmane.org) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1g10FX-000373-VS for pgsql-general@postgresql.org; Sat, 15 Sep 2018 02:24:01 +0000 Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1g10DO-0000FF-6J for pgsql-general@postgresql.org; Sat, 15 Sep 2018 04:21:42 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-general@postgresql.org From: Sebastian P. Luque Subject: Re: column information from view Date: Fri, 14 Sep 2018 21:23:44 -0500 Organization: Church of Emacs Lines: 23 Message-ID: <874lerjy6n.fsf@otaria.sebmel.org> References: <87in373gpd.fsf@gmail.com> <2046.1536961948@sss.pgh.pa.us> <87a7oj3efm.fsf@gmail.com> <3830.1536964167@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain X-Complaints-To: usenet@blaine.gmane.org User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) Cancel-Lock: sha1:WUKJwepbHAIlBXf7VvkRLd6lDNE= X-Host-Lookup-Failed: Reverse DNS lookup failed for 195.159.176.226 (failed) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Fri, 14 Sep 2018 18:29:27 -0400, Tom Lane wrote: > "Sebastian P. Luque" writes: >> Tom Lane wrote: >>> Personally, I'd probably write it something like this: >>> select pa.attnum, pa.attname, col_description(pa.attrelid, >>> pa.attnum) from pg_attribute pa, pg_attribute ta where pa.attrelid = >>> 'persistent_view'::regclass and ta.attrelid = >>> 'temporary_view'::regclass and pa.attname = ta.attname order by >>> pa.attnum; >> Thank you Tom, this does seem more elegant, but I'd have to retrieve >> the actual "attrelid" from the names of the two views somehow. > That's what the regclass converter does for you. Amazing! Thank you all for these insights, -- Seb