Re: [HACKERS] Re: Join/table alias bug
Bruce Momjian <pgman@candle.pha.pa.us>
From: Bruce Momjian <pgman@candle.pha.pa.us>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Peter Eisentraut <peter_e@gmx.net>, Adriaan Joubert <a.joubert@albourne.com>, pgsql-hackers@postgresql.org, pgsql-bugs@postgresql.org
Date: 2000-09-30T02:45:32Z
Lists: pgsql-bugs, pgsql-hackers
Yes, this is what was eventually done... only emit warnings for tables already in the RTE, as Tom mentioned. > Peter Eisentraut <e99re41@DoCS.UU.SE> writes: > > ... The reason this behaves that way is because queries > > without from lists (SELECT my_tbl.a) are valid in PostgreSQL for > > historical reasons, so we're stuck with it. > > Not only for historical reasons: there are cases where it allows you > to do things you couldn't easily do otherwise. An example is deleting > using a join: > > DELETE FROM target WHERE field1 = source.field2 > > which deletes any record in target whose field1 matches any field2 > value in source. This isn't SQL92 since DELETE doesn't allow you > to specify any tables except the target table in FROM. (Yeah, > I know this example could be written with a subselect --- but with > a more complex WHERE condition it gets harder to do that. Also > slower.) > > > We've pondered many times about emitting warnings but a definite > > consensus was never reached. > > Bruce had actually put in some code to emit warnings, but Thomas > objected to it for reasons I don't recall clearly. I think it was > an implementation issue rather than objecting to the idea of having > warnings. AFAIR we had pretty much agreed that a warning would be > a good idea. > > IIRC, Bruce's code would emit a warning whenever an implicit RTE was > added. I think that might be overly verbose --- I'd be inclined to > warn only in the case that an implicit RTE is added for a table that > has an RTE already (under a different alias). That is the only > situation I've seen user complaints about. > > regards, tom lane > -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 853-3000 + If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania 19026