parse error: LIMIT combined with UNION

From: Steve Pothier <STEVEN(dot)POTHIER(at)saic(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: parse error: LIMIT combined with UNION
Date: 2001-09-05 19:45:16
Message-ID: 200109051945.f85JjGr06294@payson.tucson.saic.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs


============================================================================
POSTGRESQL BUG REPORT TEMPLATE
============================================================================

Your name : Steve Pothier
Your email address : pothiers(at)aries(dot)tucson(dot)saic(dot)com

System Configuration
---------------------
Architecture (example: Intel Pentium) : Mac PPC, G4

Operating System (example: Linux 2.0.26 ELF) : Linux payson 2.2.16

PostgreSQL version (example: PostgreSQL-6.5.1): PosegreSQL 7.1

Compiler used (example: gcc 2.8.0) :

Please enter a FULL description of your problem:
------------------------------------------------

This works as expected:

hbase=# SELECT * FROM subject WHERE subject_id LIKE '0009%' UNION (SELECT * FROM subject WHERE subject_id LIKE '0008%' );

But this fails to parse:

hbase=# SELECT * FROM subject WHERE subject_id LIKE '0009%' UNION (SELECT * FROM subject WHERE subject_id LIKE '0008%' LIMIT 5);
ERROR: parser: parse error at or near "limit"

This, despite indications to the contrary in the documentation:
file:/swl/postgresql-7.1/doc/html/sql-select.html#SQL-UNION

The following excerpt from the doc seems to be saying that a limit can
be used if included in the parenthesized select statement:

"where table_query specifies any select expression without an ORDER BY, FOR UPDATE, or
LIMIT clause. (ORDER BY and LIMIT can be attached to a sub-expression if it is enclosed in
parentheses. Without parentheses, these clauses will be taken to apply to the result of the UNION,
not to its right-hand input expression.) "

I tried several moving the parens around to no avail.

-Steve Pothier-
----------------------------------------------------------------------

If you know how this problem might be fixed, list the solution below:
---------------------------------------------------------------------

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Bruce Momjian 2001-09-05 21:15:49 Re: create view bug
Previous Message Barry Lind 2001-09-05 19:11:06 Re: JDBC patch (attempt#2) for util.Serialize and jdbc2.PreparedStatement