Re: Bug in 7.1.3 and 7.2?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: hs(at)cybertec(dot)at
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: Bug in 7.1.3 and 7.2?
Date: 2001-11-09 04:26:28
Message-ID: 19174.1005279988@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

=?iso-8859-1?Q?Hans=2DJ=FCrgen=20Sch=F6nig?= <hs(at)cybertec(dot)at> writes:
> test=# select a.*, d.* from a as c, b as d where a.id=b.id;
> NOTICE: Adding missing FROM-clause entry for table "a"
> NOTICE: Adding missing FROM-clause entry for table "b"

> Althoug c and d are aliases for a and b, the two tables are added to the
> list in the from clause. Is this the desired behaviour or is it a bug?

This is not a bug. If the system treated different aliases for a table
as interchangeable, then there'd be no possibility of doing a self-join.
"a.*" is not a legal reference to a FROM entry "a as c": the AS alias
*totally* hides the underlying table name as far as this query is
concerned.

What you have above is interpreted as

from a as c, b as d, a as a, b as b

The NOTICEs are intended to warn you that this is going on.

If we took a hardline approach to enforcing the letter of the SQL92
standard, we'd reject this query as illegal: SQL92 doesn't allow
implicit FROM entries. (And no, it doesn't think "a.*" refers to
"a as something-else", either.)

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message pgsql-bugs 2001-11-09 07:42:00 Bug #512: outer join bug
Previous Message Stephan Szabo 2001-11-09 03:57:19 Re: Bug in 7.1.3 and 7.2?