Re: Boolean casting in 7.3 -> changed?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Boolean casting in 7.3 -> changed?
Дата
Msg-id 28836.1038439122@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Boolean casting in 7.3 -> changed?  (Peter Eisentraut <peter_e@gmx.net>)
Ответы Re: Boolean casting in 7.3 -> changed?  (Ian Barwick <barwick@gmx.net>)
Список pgsql-hackers
Peter Eisentraut <peter_e@gmx.net> writes:
> Ian Barwick writes:
>> "Casting integers to boolean (for example, 0::bool) is no longer allowed,
>> use '0'::bool instead".

> This advice would probably only cause more confusion, because we are now
> moving into the direction that character strings are no longer acceptable
> as numeric data.

Yes, phrased that way it's just misleading.  We do not and did not have
a general int-to-bool cast (though it may be reasonable to add one, now
that we could mark it explicit-only).  The case that worked in 7.2 and
before was only for numeric-looking *literals* being cast to bool (or
any other type for that matter) --- parser_typecast_constant would
essentially act as though the literal had quotes around it, whether
it actually did or not.  Thus in the old code, the validity of, say,42::bool
would depend on whether bool's input converter would accept the string
'42'.  In the new code, 42 is taken to be an int4 constant and the
validity of the expression depends on whether there is an int4-to-bool
cast.

7.2:

regression=# select 42::bool;
ERROR:  Bad boolean external representation '42'

Current:

regression=# select 42::bool;
ERROR:  Cannot cast type integer to boolean
        regards, tom lane


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

Предыдущее
От: "scott.marlowe"
Дата:
Сообщение: Re: [spam] Re: [mail] Re: Native Win32 sources
Следующее
От: Tom Lane
Дата:
Сообщение: Planning for improved versions of IN/NOT IN