The following bug has been logged online:
Bug reference: 1784
Logged by: Giacomo G
Email address: matic999@hotmail.com
PostgreSQL version: 8.0.3
Operating system: linux kernel 2.6.12.2
Description: "adding missing FROM-clause" when not needed
Details:
If I populate the database with this two tables:
CREATE TABLE bar ( c varchar, d varchar);
CREATE TABLE foo ( a varchar, b varchar);
COPY bar (c, d) FROM stdin;
1 ghi
2 jkl
\.
COPY foo (a, b) FROM stdin;
1 abc
2 def
\.
When I run this select I get the output I expect:
test=# select * from foo t0 join bar t1 on ( t0.a = t1.c ) where t0.a = 1;
a | b | c | d
---+-----+---+-----
1 | abc | 1 | ghi
(1 row)
But, when i run the same query with the real name of table in the where
statement I get this:
test=# select * from foo t0 join bar t1 on ( t0.a = t1.c ) where foo.a = 1;
NOTICE: adding missing FROM-clause entry for table "foo"
a | b | c | d
---+-----+---+-----
1 | abc | 1 | ghi
2 | def | 2 | jkl
(2 rows)
while I expect the same result of the first query.