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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Frank van Vugt <ftm(dot)van(dot)vugt(at)foxi(dot)nl>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Why is a union of two null-results automatically casted to type text ?
Date: 2004-06-15 18:20:09
Message-ID: 3328.1087323609@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Frank van Vugt <ftm(dot)van(dot)vugt(at)foxi(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message elein 2004-06-15 19:03:23 postgresql.conf for pg_stat_activity
Previous Message Scot L. Harris 2004-06-15 18:06:09 Re: Installing 7.4.2