union all bug?

From: Joe Conway <mail(at)joeconway(dot)com>
To: "Hackers (PostgreSQL)" <pgsql-hackers(at)postgresql(dot)org>
Subject: union all bug?
Date: 2006-06-18 15:36:30
Message-ID: 449572FE.6000408@joeconway.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I was trying to work around limitations with "partitioning" of tables
using constraint exclusion, when I ran across this little oddity:

-- works
test=# select * from (select time from url_access_2006_06_07 order by 1
limit 2) as ss1;
time
---------------------
2006-06-07 15:07:41
2006-06-07 15:07:41
(2 rows)

-- works
test=# select time from url_access_2006_06_08 order by 1 limit 2;
time
---------------------
2006-06-08 15:07:41
2006-06-08 15:07:41
(2 rows)

-- huh ?!?
test=# select * from (select time from url_access_2006_06_07 order by 1
limit 2) as ss1 union all select time from url_access_2006_06_08 order
by 1 limit 2;
time
---------------------
2006-06-07 15:07:41
2006-06-07 15:07:41
(2 rows)

-- works
test=# select * from (select time from url_access_2006_06_07 order by 1
limit 2) as ss1 union all select * from (select time from
url_access_2006_06_08 order by 1 limit 2) as ss2;
time
---------------------
2006-06-07 15:07:41
2006-06-07 15:07:41
2006-06-08 15:07:41
2006-06-08 15:07:41
(4 rows)

I get an error if I try to eliminate the first FROM clause subselect:

test=# select time from url_access_2006_06_07 order by 1 limit 2 union
all select * from (select time from url_access_2006_06_08 order by 1
limit 2) as ss2;
ERROR: syntax error at or near "all" at character 65
LINE 1: ...om url_access_2006_06_07 order by 1 limit 2 union all select...

So I'm wondering whether the second FROM clause subselect is really
required, but not getting enforced as it should?

Joe

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2006-06-18 16:31:01 Re: union all bug?
Previous Message Tom Lane 2006-06-18 15:35:11 Slightly bogus regression test for contrib/dblink