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

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

Ah, thanks Tom.

No, I think I'll go for the current implementation instead ;)

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

So why is this failing as well:
    select 1 union select * from (select null union all select null) as foo;

I strolled through chapters 8 and 10 of the docs ('data types' and 'type
conversion') earlier, is there some additional source of information that
describes the way PostgreSQL handles typing, specifically things like what
you're describing here? Other than the source that is...





--
Best,




Frank.


pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Why is a union of two null-results automatically casted to type text ?
Next
From: "Chris Ochs"
Date:
Subject: Feature idea