Re: NAB : insert into select distinct => when used on null, distinct causes loss of type knowledge
Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: NAB : insert into select distinct => when used on null, distinct causes loss of type knowledge
Дата
Msg-id 12269.1093383056@sss.pgh.pa.us
обсуждение исходный текст
Ответ на NAB : insert into select distinct => when used on null, distinct causes loss of type knowledge  (Frank van Vugt <ftm.van.vugt@foxi.nl>)
Ответы Re: NAB : insert into select distinct => when used on null, distinct causes loss of type knowledge  (Frank van Vugt <ftm.van.vugt@foxi.nl>)
Список pgsql-general
Frank van Vugt <ftm.van.vugt@foxi.nl> writes:
> So it seems distinct applied to the second column causes it to lose knowledge
> on its type.

No, because it never had any: NULL is typeless (type UNKNOWN, to the
parser).  In the straight INSERT this doesn't matter because we don't
have to resolve the type until we get up to the INSERT, and then we know
we want to insert into the value column.  But to do a DISTINCT, the
parser has to assign datatypes to all the columns (to determine the
comparison rules).  The default assumption for an UNKNOWN constant is
type TEXT.  This is chosen based on the assumption that when someone
writes
    select distinct 'foo';
they are probably expecting the system to treat 'foo' as a TEXT literal.

            regards, tom lane

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

Предыдущее
От: Stephan Szabo
Дата:
Сообщение: Re: How is this possible? (more on deadlocks)
Следующее
От: "Christine Desmuke"
Дата:
Сообщение: Gentoo for production DB server?