Re: UNION with more than 2 branches

Поиск
Список
Период
Сортировка
От Gregory Stark
Тема Re: UNION with more than 2 branches
Дата
Msg-id 87bqhd8yn7.fsf@oxford.xeocode.com
обсуждение исходный текст
Ответ на Re: UNION with more than 2 branches  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: UNION with more than 2 branches  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
"Tom Lane" <tgl@sss.pgh.pa.us> writes:

> Maybe we should just ignore those qualms and do it anyway --- I must
> admit that I'm hard-pressed to come up with a situation where anyone
> would really want different datatypes used in the inner union than
> the outer.

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?

What would happen if the inner pair defaulted null to "unknown" instead of
text? Then the next level would have a chance to union between unknown and
integer successfully.

It's a bit odd that that's basically what happens currently *except* for in
unions:

postgres=# create table foo as select null;
WARNING:  column "?column?" has type "unknown"
DETAIL:  Proceeding with relation creation anyway.
SELECT
postgres=# create table bar as select null union all select null;
SELECT
postgres=# \d foo       Table "public.foo" Column  |   Type    | Modifiers 
----------+-----------+-----------?column? | "unknown" | 

postgres=# \d bar    Table "public.bar" Column  | Type | Modifiers 
----------+------+-----------?column? | text | 



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



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: UNION with more than 2 branches
Следующее
От: Tom Lane
Дата:
Сообщение: Re: UNION with more than 2 branches