Re: Re: Query 'Bout A Bug. - Mailing list pgsql-hackers

From Philip Warner
Subject Re: Re: Query 'Bout A Bug.
Date
Msg-id 3.0.5.32.20000713130519.02059c10@mail.rhyme.com.au
Whole thread Raw
In response to Re: Query 'Bout A Bug.  (Bruce Momjian <pgman@candle.pha.pa.us>)
List pgsql-hackers
At 22:30 12/07/00 -0400, Bruce Momjian wrote:
>[ Charset ISO-8859-1 unsupported, converting... ]
>> Bruce,
>>  
>> The bug list includes the following:
>>  
>> a.. SELECT foo UNION SELECT foo is incorrectly simplified to SELECT foo 
>> 
>> Wy is this simplification incorrect? I don't get it.
>
>Not sure.  Maybe someone can comment. 
>

As far as I can see, we'd need to know the definition of 'foo'.

eg. 
   select nextval('id') UNION SELECT nextval('id') 

should produce two rows. 

If foo is invariant, then you should be fine because the default behaviour
for union should be to do a set union of the tuples (ie. only *distinct*
rows are added to the result set). 

But, determining invariance is pretty hard for a complex foo (eg. a select
statement that causes rewrite rules to fire).

Finally, select 1 union ALL select 1

should produce two rows.

----------------------------------------------------------------
Philip Warner                    |     __---_____
Albatross Consulting Pty. Ltd.   |----/       -  \
(A.C.N. 008 659 498)             |          /(@)   ______---_
Tel: (+61) 0500 83 82 81         |                 _________  \
Fax: (+61) 0500 83 82 82         |                 ___________ |
Http://www.rhyme.com.au          |                /           \|                                |    --________--
PGP key available upon request,  |  /
and from pgp5.ai.mit.edu:11371   |/


pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: Query 'Bout A Bug.
Next
From: Tim Perdue
Date:
Subject: Re: Some Improvement