Statement parsing problem ? - Mailing list pgsql-hackers

From Chris Dunlop
Subject Statement parsing problem ?
Date
Msg-id 20040915134347.GA11921@onthe.net.au
Whole thread Raw
Responses Re: Statement parsing problem ?
Re: Statement parsing problem ?
List pgsql-hackers
G'day,

There seems to be a kind of statement parsing problem in 7.4.5
(from debian postgresql-7.4.5-3, i386).

Either that, or I'm missing something...

The following script:

----------------------------------------------------------------------
create table t1 ( foo1 integer, foo2 integer );
create table t2 ( foo3 integer );
create table t3 ( foo4 integer, foo5 integer );
create table t4 ( foo6 integer );

\echo
\echo -----------
\echo this works
\echo -----------

select 1 as "OK"
from t1, t2, t3 join t4 on (t4.foo6 = t3.foo5)
where t2.foo3 = t1.foo1 and t3.foo4 = t1.foo2 ;

\echo
\echo ------------
\echo Error, from simply swapping the order of t2 and t3 ???
\echo ------------

select 1
from t1, t3, t2 join t4 on (t4.foo6 = t3.foo5)
where t2.foo3 = t1.foo1 and t3.foo4 = t1.foo2 ;

\echo
\echo ------------
\echo slightly different error, using a table alias
\echo ------------

select 1
from t1, t3 a, t2 join t4 on (t4.foo6 = a.foo5)
where t2.foo3 = t1.foo1 and a.foo4 = t1.foo2 ;
----------------------------------------------------------------------

produces the output:

----------------------------------------------------------------------
-----------
this works
-----------OK 
----
(0 rows)


------------
Error, from simply swapping the order of t2 and t3 ???
------------
psql:/tmp/test.sql:32: NOTICE:  adding missing FROM-clause entry for table "t3"
psql:/tmp/test.sql:32: ERROR:  JOIN/ON clause refers to "t3", which is not part of JOIN

------------
slightly different error, using a table alias
------------
psql:/tmp/test.sql:46: ERROR:  relation "a" does not exist

----------------------------------------------------------------------


So is it me, or is this just a bit borken ?


Cheers,

Chris.


pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: SELECT FOR UPDATE NOWAIT and PostgreSQL 8.0
Next
From: James Robinson
Date:
Subject: Re: Statement parsing problem ?