Re: [HACKERS] It would be nice if this could be fixed... - Mailing list pgsql-hackers

From Chris Bitmead
Subject Re: [HACKERS] It would be nice if this could be fixed...
Date
Msg-id 37258C6D.23891317@bigfoot.com
Whole thread Raw
In response to Re: [HACKERS] It would be nice if this could be fixed...  (The Hermit Hacker <scrappy@hub.org>)
List pgsql-hackers
The Hermit Hacker wrote:

> As D'Arcy did ask...which oid would you want used?  The one from table a,
> or from Table b?  

Just like any situation where column names conflict, the answer is
"whichever one I say".

If I have a join then I would say
CREATE view productv as SELECT product.oid, product.name, mfr.name from
product, mfr where product.mfr = mfr.oid;

This is no different from any other case where you join two tables with
same column names. Only difference is that it doesn't work :-(.


>They are two distinctly different numbers...the VIEW
> itself doesn't have an OID assigned to its rows,

Exactly, so why prevent the user having a column called "oid"?
only the physical tables
> themselves...
> 
>  > > "D'Arcy J.M. Cain" wrote:
> > >
> > > Thus spake Chris Bitmead
> > > > It would be much better if you could have an oid column in a view if you
> > > > want. Like
> > > > CREATE VIEW productv AS SELECT oid, * FROM product;
> > > >
> > > > But that's not allowed. Any reason why?
> > >
> > > Because the oid is not included in the view.  Consider the following.
> > >
> > > CREATE VIEW c AS SELECT a1, a2, b1, b2 FROM a, b WHERE a_key = b_key;
> > >
> > > So which oid do you want, the one from table a or the one from table b?
> > > You can, however, do this.
> > >
> > > CREATE VIEW c AS SELECT a.oid AS a_oid, b.oid AS b_oid, a1, a2, b1, b2
> > >     FROM a, b WHERE a_key = b_key;
> > >
> > > --
> > > D'Arcy J.M. Cain <darcy@{druid|vex}.net>   |  Democracy is three wolves
> > > http://www.druid.net/darcy/                |  and a sheep voting on
> > > +1 416 424 2871     (DoD#0082)    (eNTP)   |  what's for dinner.
> >
> > --
> > Chris Bitmead
> > http://www.bigfoot.com/~chris.bitmead
> > mailto:chris.bitmead@bigfoot.com
> >
> 
> Marc G. Fournier                   ICQ#7615664               IRC Nick: Scrappy
> Systems Administrator @ hub.org
> primary: scrappy@hub.org           secondary: scrappy@{freebsd|postgresql}.org

-- 
Chris Bitmead
http://www.bigfoot.com/~chris.bitmead
mailto:chris.bitmead@bigfoot.com


pgsql-hackers by date:

Previous
From: Tatsuo Ishii
Date:
Subject: fix for _copyUnique()
Next
From: Chris Bitmead
Date:
Subject: Re: [HACKERS] It would be nice if this could be fixed...