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

Поиск
Список
Период
Сортировка
От Frank van Vugt
Тема Why is a union of two null-results automatically casted to type text ?
Дата
Msg-id 200406151329.31604.ftm.van.vugt@foxi.nl
обсуждение исходный текст
Ответы Re: Why is a union of two null-results automatically casted to type text ?  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
Hi all,

Boiling down a problem in one of my queries, I noticed this behaviour.


# select version();
                                version
------------------------------------------------------------------------
 PostgreSQL 7.4.2 on i586-pc-linux-gnu, compiled by GCC gcc (GCC) 3.2.3
(1 row)


# select 1 union all select '2';
 ?column?
----------
        1
        2
(2 rows)

# select 1 union select null;
 ?column?
----------
        1

(2 rows)

# select 1 union select * from (select null union select null) as foo;
ERROR:  UNION types integer and text cannot be matched


I guess the last one fails because the second union of two unknown(?) types
gets casted to text, which in turn cannot be processed by the UNION while the
left part is of type integer.

I'm wondering about the reason this cast to text takes place, is this simply
because SQL specs say so?





--
Best,




Frank.


В списке pgsql-general по дате отправления:

Предыдущее
От: "Neeraj "
Дата:
Сообщение: Interpreting OSDB Results
Следующее
От: jseymour@linxnet.com (Jim Seymour)
Дата:
Сообщение: Re: [HACKERS] Release 7.4.3 branded