Statement parsing problem ?

From: Chris Dunlop <chris(at)onthe(dot)net(dot)au>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Statement parsing problem ?
Date: 2004-09-15 13:43:47
Message-ID: 20040915134347.GA11921@onthe.net.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2004-09-15 13:57:41 Re: Rollback on Error
Previous Message Bruce Momjian 2004-09-15 13:24:54 Re: SELECT FOR UPDATE NOWAIT and PostgreSQL 8.0