"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