Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id CD7DCB5DCBB for ; Fri, 3 Jun 2011 15:21:35 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 59866-01 for ; Fri, 3 Jun 2011 18:21:27 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id 1E8DFB633D3 for ; Fri, 3 Jun 2011 15:21:26 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id p53ILPXD002769; Fri, 3 Jun 2011 14:21:25 -0400 (EDT) To: Robert Haas cc: Daniel Cristian Cruz , pgsql-bugs@postgresql.org Subject: Re: BUG #6050: Dump and restore of view after a schema change: can't restore the view In-reply-to: References: <201106031238.p53CcA8P075374@wwwmaster.postgresql.org> <27042.1307113140@sss.pgh.pa.us> <1357.1307121567@sss.pgh.pa.us> Comments: In-reply-to Robert Haas message dated "Fri, 03 Jun 2011 13:53:50 -0400" Date: Fri, 03 Jun 2011 14:21:25 -0400 Message-ID: <2768.1307125285@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-5 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201106/42 X-Sequence-Number: 30421 Robert Haas writes: > On Fri, Jun 3, 2011 at 1:19 PM, Tom Lane wrote: >> Now, if the query doesn't involve any explicit reference to "joinalias.*", >> we could probably fake it with some ugly thing involving >> COALESCE(leftcol, rightcol) ... but I don't think people will want to >> read that, and anyway the idea falls apart as soon as you do have a >> whole-row reference. > Well, it gets internally translated to COALESCE(leftcol, rightcol) We do that during planning; it's not the form that gets stored in views or dumped by pg_dump. I don't really want pg_dump dumping this kind of thing, because that locks us down to supporting it that way forever. > I'm not seeing the problem with whole-row references; can you elaborate on that? SELECT somefunc(j.*) FROM (tab1 JOIN tab2 USING (id)) j; The shape of the record passed to somefunc() depends on removal of the second id column. Now you might claim that we could expand the j.* to a ROW() construct with an explicit list of columns, which indeed is what happens internally. But again, that happens at plan time, it's not what gets stored in rules. And that matters, because locking down the column expansion too early would break the response to ADD/DROP COLUMN on one of the input tables. regards, tom lane