Frank van Vugt <ftm.van.vugt@foxi.nl> writes:
> # select 1 union select * from (select null union select null) as foo;
> ERROR: UNION types integer and text cannot be matched
> I'm wondering about the reason this cast to text takes place,
UNION requires assignment of a definite type to the inputs, because
otherwise there's no certainty that we know how to identify distinct
and non-distinct values. The alternative to assigning TEXT is to
reject the inner UNION outright :-(
regards, tom lane