Re: UNIONS

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: UNIONS
Дата
Msg-id 6928.965671677@sss.pgh.pa.us
обсуждение исходный текст
Ответ на UNIONS  (Thomas Swan <tswan@olemiss.edu>)
Ответы Re: UNIONS  (Thomas Swan <tswan@olemiss.edu>)
Список pgsql-hackers
Thomas Swan <tswan@olemiss.edu> writes:
> select id, null as text from foo union select id, name from foo_child;
> fails with
> unable to trasform {insert whatever type here} into unknown
>          Each UNION | EXCEPT | INTERSECT clause must have compatible target 
> types

The UNION type-resolution code could use some work; right now I think
the algorithm is to use the types of the first SELECT and force
everything else into that.  A more symmetrical
promote-to-common-supertype approach would be nice.  The UNION code is
such a mess that I haven't wanted to touch it until we do querytree
revisions in 7.2, though.

In the meantime, you should force the NULL to have the datatype you want
with something like "null::text" or "cast (null as text)".  Note that
the way you have it above is only assigning a column label that happens
to be "text"; it's not a type coercion.
        regards, tom lane


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

Предыдущее
От: Stephan Szabo
Дата:
Сообщение: Re: Constraint stuff
Следующее
От: Don Baccus
Дата:
Сообщение: Re: mac.c