UNION bug in 7.1.3?

From: Keary Suska <hierophant(at)pcisys(dot)net>
To: Postgres General <pgsql-general(at)postgresql(dot)org>
Subject: UNION bug in 7.1.3?
Date: 2001-10-23 04:35:14
Message-ID: B7FA4FA2.5182%hierophant@pcisys.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

The following syntax, which works fine in 7.0.3, fails in 7.1.3:

SELECT t1.col1, t2.col2 FROM table1 t1, table2 t2
WHERE t1.col3 = t2.col4
UNION
SELECT t1.col1, NULL FROM table1 t1
WHERE t1.col3 NOT IN (SELECT t2.col2 FROM table2 t2)
ORDER BY t1.col1

Fails with "ERROR: Relation 't1' does not exist".

It seems to be in the "order by" clause. So, if I do:

SELECT t1.col1, t2.col2 FROM table1 t1, table2 t2
WHERE t1.col3 = t2.col4
UNION
SELECT t1.col1, NULL FROM table1 t1
WHERE t1.col3 NOT IN (SELECT t2.col2 FROM table2 t2)
ORDER BY table1.col1

The above error goes away, but is replaced by "ERROR: ORDER BY on a
UNION/INTERSECT/EXCEPT result must be on one of the result columns". Is this
a bug? It doesn't even work when using full table names instead of aliases.

Of course, I can do an outer join without any problem, but I have other
cases where I am doing unions, the above just seems to be the most
explicative example.

Keary Suska
Esoteritech, Inc.
"Leveraging Open Source for a better Internet"

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David Ford 2001-10-23 05:07:23 Re: [GENERAL] To Postgres Devs : Wouldn't changing the selectlimit
Previous Message Bruce Momjian 2001-10-23 04:24:24 Re: [GENERAL] To Postgres Devs : Wouldn't changing the selectlimit