Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 68FC4B5F586 for ; Tue, 7 Jun 2011 12:43:46 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 55097-03 for ; Tue, 7 Jun 2011 15:43:39 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-bw0-f46.google.com (mail-bw0-f46.google.com [209.85.214.46]) by mail.postgresql.org (Postfix) with ESMTP id 7BDD4B5F3E2 for ; Tue, 7 Jun 2011 12:43:38 -0300 (ADT) Received: by bwz15 with SMTP id 15so4287600bwz.19 for ; Tue, 07 Jun 2011 08:43:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=KJ36upSf5A5TRiL9oXOxX9v3qUAwf+6gnLng+/pqIoc=; b=sFPZHXjvXxbmNFYYRXAQ6vghRTnMtIi4yU/VScpxvzanCzyMR3TPEGaCiSXKiK00oY 4bo/rQPlGj4GF4nSjUry44Gm8XUNwPtNxAeH/84xUdFS2fcxGEHig58/23QiIpVmWZtK 86305HyUkMYWknVfBWCPV2403mkxAWQyCJKG8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=AR7syqNkkpTyNKmXJhx+7KPvGUDDKktoe5jIsO5cEQUCxpIxzVpzcIjXtFmCpECYU2 giFTuOQvZ+jWLMInhPOr98F22KbgAGOkYGK2+pSMeKbXPzwj5U/SgxPIWBeKLoOuUy7B vOBq99Kr8UdkRrUk0IfCRO34VvC8A04IKpRY0= MIME-Version: 1.0 Received: by 10.204.26.132 with SMTP id e4mr3929993bkc.142.1307461417514; Tue, 07 Jun 2011 08:43:37 -0700 (PDT) Received: by 10.204.38.141 with HTTP; Tue, 7 Jun 2011 08:43:37 -0700 (PDT) In-Reply-To: References: <201106031238.p53CcA8P075374@wwwmaster.postgresql.org> <27042.1307113140@sss.pgh.pa.us> <1357.1307121567@sss.pgh.pa.us> <2768.1307125285@sss.pgh.pa.us> Date: Tue, 7 Jun 2011 12:43:37 -0300 Message-ID: Subject: Re: BUG #6050: Dump and restore of view after a schema change: can't restore the view From: Daniel Cristian Cruz To: Robert Haas Cc: Tom Lane , pgsql-bugs@postgresql.org Content-Type: multipart/alternative; boundary=00032555ae7a5937fd04a52115c2 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.897 tagged_above=-5 required=5 tests=BAYES_00=-1.9, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RFC_ABUSE_POST=0.001 X-Spam-Level: X-Archive-Number: 201106/68 X-Sequence-Number: 30447 --00032555ae7a5937fd04a52115c2 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable But as a PostgreSQL user, I would like to had a warning when creating a vie= w with USING. It solves my problem. Maybe many others too. 2011/6/7 Robert Haas > On Fri, Jun 3, 2011 at 2:21 PM, Tom Lane wrote: > > 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. > > Hmm. > > >> I'm not seeing the problem with whole-row references; can you elaborat= e > 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. > > Ah, yes. > > > 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. > > Fair enough, but the current implementation with respect to ADD > COLUMN. And RENAME COLUMN. > > If your point here is that you don't want to spend time hacking on > this because it's a fairly marginal feature and therefore not terribly > high on your priority list, I can understand that. But if you're > actually defending the current implementation, I'm going to have to > respectfully disagree. It's broken, and it sucks, and this is not the > first complaint we've had about it. > > -- > Robert Haas > EnterpriseDB: http://www.enterprisedb.com > The Enterprise PostgreSQL Company > --=20 Daniel Cristian Cruz =E3=82=AF=E3=83=AB=E3=82=BA =E3=82=AF=E3=83=AA=E3=82=B9=E3=83=81=E3=82=A2= =E3=83=B3 =E3=83=80=E3=83=8B=E3=82=A8=E3=83=AB --00032555ae7a5937fd04a52115c2 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable But as a PostgreSQL user, I would like to had a warning when creating a vie= w with USING. It solves my problem. Maybe many others too.

2011/6/7 Robert Haas <robertmhaas@gmail.com>
On Fri, Jun 3, 2011 at 2:21 PM, Tom Lane &l= t;tgl@sss.pgh.pa.us> wrote:
> Robert Haas <robertmhaas@g= mail.com> writes:
>> On Fri, Jun 3, 2011 at 1:19 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>>> Now, if the query doesn't involve any explicit reference t= o "joinalias.*",
>>> we could probably fake it with some ugly thing involving
>>> COALESCE(leftcol, rightcol) ... but I don't think people w= ill want to
>>> read that, and anyway the idea falls apart as soon as you do h= ave 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. =C2=A0I don't really want pg_dump dumping th= is kind of
> thing, because that locks us down to supporting it that way forever.
Hmm.

>> 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.

Ah, yes.

> Now you might claim that we could expand the j.* to a ROW() construct<= br> > with an explicit list of columns, which indeed is what happens
> internally. =C2=A0But again, that happens at plan time, it's not w= hat gets
> stored in rules. =C2=A0And that matters, because locking down the colu= mn
> expansion too early would break the response to ADD/DROP COLUMN on
> one of the input tables.

Fair enough, but the current implementation with respect to ADD
COLUMN. =C2=A0And RENAME COLUMN.

If your point here is that you don't want to spend time hacking on
this because it's a fairly marginal feature and therefore not terribly<= br> high on your priority list, I can understand that. =C2=A0But if you're<= br> actually defending the current implementation, I'm going to have to
respectfully disagree. =C2=A0It's broken, and it sucks, and this is not= the
first complaint we've had about it.

--
Robert Haas
EnterpriseDB: htt= p://www.enterprisedb.com
The Enterprise PostgreSQL Company



--
Daniel Cristian = Cruz
=E3=82=AF=E3=83=AB=E3=82=BA =E3=82=AF=E3=83=AA=E3=82=B9=E3=83=81=E3= =82=A2=E3=83=B3 =E3=83=80=E3=83=8B=E3=82=A8=E3=83=AB
--00032555ae7a5937fd04a52115c2--