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 13:33:34
Message-ID: 441.1087306414@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:
> # 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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message D. Stimits 2004-06-15 14:20:21 how does license work for non-profit companies?
Previous Message Jim Seymour 2004-06-15 11:40:45 Re: [HACKERS] Release 7.4.3 branded