Re: BUG #15071: Error in PostgreSQL-specific :: type cast

Поиск
Список
Период
Сортировка
От Daniel Gustafsson
Тема Re: BUG #15071: Error in PostgreSQL-specific :: type cast
Дата
Msg-id 315DAB2D-4D2A-4556-8941-036784005F98@yesql.se
обсуждение исходный текст
Ответ на BUG #15071: Error in PostgreSQL-specific :: type cast  (PG Bug reporting form <noreply@postgresql.org>)
Ответы Re: BUG #15071: Error in PostgreSQL-specific :: type cast
Список pgsql-bugs
> On 16 Feb 2018, at 12:57, PG Bug reporting form <noreply@postgresql.org> wrote:
>
> The following bug has been logged on the website:
>
> Bug reference:      15071
> Logged by:          Yuriy Beliy
> Email address:      whiteman.kr@gmail.com
> PostgreSQL version: 10.1
> Operating system:   Windows 10
> Description:
>
> PostgreSQL-specific :: type casts for lowest values of integer types are
> produce "Out of range" errors:
>
> SELECT -32768::smallint
> ^ERROR:  smallint out of range

The parser will represents this as the numeric portion, 32768, and a “-“ in an
expression of type AEXPR_OP.  When passed to i4toi2(), only the numeric part is
passed and the out of range is due to 32768 > SHRT_MAX (same type of issue for
the other types).  Casting from non-numeric, like text for example, to smallint
works since it isn’t parsed into an “-“ expr: '-32768'::smallint;

Applying the “-“ op before passing to the typecast function seems the easy
answer, or passing the “-“ separately (which seems kludgier) This is quite old
code though, so I don’t know how much else that would break?

cheers ./daniel

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

Предыдущее
От: PG Bug reporting form
Дата:
Сообщение: BUG #15071: Error in PostgreSQL-specific :: type cast
Следующее
От: Tom Lane
Дата:
Сообщение: Re: BUG #15071: Error in PostgreSQL-specific :: type cast