Skip site navigation (1) Skip section navigation (2)

Re: BUG #2483: Wrong error report about missing entry in from clause

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Klaus Guntermann" <guntermann(dot)kl(at)pvw(dot)tu-darmstadt(dot)de>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #2483: Wrong error report about missing entry in from clause
Date: 2006-06-17 03:54:30
Message-ID: 10807.1150516470@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-bugs
"Klaus Guntermann" <guntermann(dot)kl(at)pvw(dot)tu-darmstadt(dot)de> writes:
> with the following simplified example I get a false error message in the
> second select statement, which is almost like the first one.

> select dummy.myfield from dummy where dummy.myfield=1 union
> select dummy.myfield from dummy where dummy.myfield=2 order by
> dummy.myfield;

It's complaining about the invalid qualification of the ORDER BY item.
An ORDER BY attached to a UNION can only use unqualified column names of
the UNION result (ie, it should just be "ORDER BY myfield" or "ORDER BY
1").  I agree that "missing FROM-clause entry" isn't the best possible
error message for that, but it doesn't look simple to improve it.

FWIW, CVS tip (8.2 to be) gives an error cursor pointing at the ORDER BY
item:

regression=# select dummy.myfield from dummy where dummy.myfield=1 union
regression-# select dummy.myfield from dummy where dummy.myfield=2 order by
regression-# dummy.myfield;
ERROR:  missing FROM-clause entry for table "dummy"
LINE 3: dummy.myfield;
        ^
regression=# 

which should help at least a little.

			regards, tom lane

In response to

pgsql-bugs by date

Next:From: Yu-Lung ShaoDate: 2006-06-17 04:47:02
Subject: BUG #2484: pg_dump not support < redirect
Previous:From: Bruce MomjianDate: 2006-06-16 21:21:21
Subject: Re: [Win32] Problem with rename()

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group