Re: DISTINCT with NULLs and INT fields

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: DISTINCT with NULLs and INT fields
Дата
Msg-id 3362.1135825399@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: DISTINCT with NULLs and INT fields  ("George Pavlov" <gpavlov@mynewplace.com>)
Список pgsql-sql
"George Pavlov" <gpavlov@mynewplace.com> writes:
> the interesting thing here is that 4::int gets into a text
> field whereas 4::text does not get into an integer field. seems to me
> like there is an implicit int-to-text cast (without a symmetrical
> text-to-int one)

Yeah, there is.  You can easily see the list of implicit casts for
yourself:
select castsource::regtype, casttarget::regtype from pg_castwhere castcontext = 'i' and castsource != casttarget;

There's 90 of them in current CVS tip, and most of 'em are unsurprising
within-type-category casts, such as implicit promotion of int to bigint.
However we have about a dozen implicit casts to text from the numeric
and datetime type categories.  Personally I would dearly love to get
rid of these, because they are accidents waiting to happen (and they
do regularly bite people, see the mail list archives for evidence).
But it seems people expect to be able to do things likenumber || ' string'
without explicitly casting the number to text.
        regards, tom lane


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

Предыдущее
От: Michael Fuhr
Дата:
Сообщение: Re: Cursors and recursion
Следующее
От: Bruno Wolff III
Дата:
Сообщение: Re: constraint and ordered value