Re: UNION with more than 2 branches

From: Gregory Stark <stark(at)enterprisedb(dot)com>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Peter Eisentraut" <peter_e(at)gmx(dot)net>, <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: UNION with more than 2 branches
Date: 2007-04-24 18:23:00
Message-ID: 877is18we3.fsf@oxford.xeocode.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

"Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us> writes:

> Gregory Stark <stark(at)enterprisedb(dot)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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2007-04-24 18:23:12 Re: UNION with more than 2 branches
Previous Message Tom Lane 2007-04-24 18:19:30 Re: [HACKERS] Full page writes improvement, code update