From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | "Gene Sokolov" <hook(at)aktrad(dot)ru> |
Cc: | pgsql-hackers(at)postgreSQL(dot)org |
Subject: | Re: [HACKERS] Curiously confused query parser. |
Date: | 1999-11-19 15:36:02 |
Message-ID: | 2550.943025762@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
"Gene Sokolov" <hook(at)aktrad(dot)ru> writes:
> This query is fine:
> test=> select o1.id from ord as o1, ord as o2 where o1.pos>2 and o2.pos<2
test-> and o1.tp=o2.tp;
> id
> --
> 5
> 3
> (2 rows)
> And this one is invalid:
> test=> select o1.id from ord as o1, ord as o2 where o1.pos>2 and o2.pos<2
test-> and o1.tp=o2.tp and ord.id>3;
> id
> --
> 5
> 5
> 3
> 3
> (4 rows)
It's not invalid, at least not according to Postgres' view of the world;
your reference to ord.id adds an implicit "FROM ord AS ord" to the FROM
clause, turning the query into a 3-way join. The output is correct for
that interpretation.
Implicit FROM clauses are a POSTQUEL leftover that is not to be found
in the SQL92 spec. There's been some talk of emitting a warning message
when one is added, because we do regularly see questions from confused
users. But if we took the feature out entirely, we'd doubtless break
some existing applications :-(
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Thomas Lockhart | 1999-11-19 15:40:30 | Mandrake Postgres RPMs |
Previous Message | Thomas Lockhart | 1999-11-19 15:32:54 | Re: [HACKERS] Primary key requires SERIAL |