union all bug? - Mailing list pgsql-hackers

From Joe Conway
Subject union all bug?
Date
Msg-id 449572FE.6000408@joeconway.com
Whole thread Raw
Responses Re: union all bug?
List 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


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Slightly bogus regression test for contrib/dblink
Next
From: Tom Lane
Date:
Subject: Re: union all bug?