Re: Why is a union of two null-results automatically casted to type text ? - Mailing list pgsql-general

From Tom Lane
Subject Re: Why is a union of two null-results automatically casted to type text ?
Date
Msg-id 3328.1087323609@sss.pgh.pa.us
Whole thread Raw
In response to Re: Why is a union of two null-results automatically casted to type text ?  (Frank van Vugt <ftm.van.vugt@foxi.nl>)
Responses Re: Why is a union of two null-results automatically casted to type text ?  (Frank van Vugt <ftm.van.vugt@foxi.nl>)
List pgsql-general
Frank van Vugt <ftm.van.vugt@foxi.nl> writes:
>> 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 :-(

> But in a UNION ALL the distinctiveness isn't an issue, is it?

True.  We do not currently distinguish UNION from UNION ALL as far as
datatype assignment rules go (INTERSECT/EXCEPT also act just the same).
In theory we could allow an output column of UNION ALL to remain
"unknown".  I'm not sure if it'd be a good idea to do so or not.  It'd
make this particular example work the way you want, but otherwise it
seems like making UNION ALL a special case would be a bit of a wart on
the type system.

            regards, tom lane

pgsql-general by date:

Previous
From: "Scot L. Harris"
Date:
Subject: Re: Installing 7.4.2
Next
From: elein
Date:
Subject: postgresql.conf for pg_stat_activity