Re: UNION with more than 2 branches - Mailing list pgsql-hackers

From Gregory Stark
Subject Re: UNION with more than 2 branches
Date
Msg-id 877is18we3.fsf@oxford.xeocode.com
Whole thread Raw
In response to Re: UNION with more than 2 branches  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
"Tom Lane" <tgl@sss.pgh.pa.us> writes:

> Gregory Stark <stark@enterprisedb.com> writes:
>
>> Does it even matter except in the case of nulls? I mean, if the inner pair
>> uses integer and then the outer pair uses bigint it'll still work correctly,
>> no?
>
> Oh, it absolutely matters: you can get different answers.  Consider
>
>     (select '1' union select ' 1') union all select 1;

Ah.

>> What would happen if the inner pair defaulted null to "unknown" instead of
>> text?
>
> You're missing the point, which is that the inner UNION needs to decide
> what its uniqueness semantics are, independently of what might happen to
> its result later.  Or that's how I read the spec anyway.

Ah of course. We wouldn't be able to unionize "unknown" all. hmph.

--  Gregory Stark EnterpriseDB          http://www.enterprisedb.com



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: [PATCHES] Full page writes improvement, code update
Next
From: Peter Eisentraut
Date:
Subject: Re: UNION with more than 2 branches