Re: to_hex() for negative inputs

Поиск
Список
Период
Сортировка
От Dean Rasheed
Тема Re: to_hex() for negative inputs
Дата
Msg-id CAEZATCUE04jLA_+-i80arv4D7H03nKTnEm-H_L7wOXHxTWTNmQ@mail.gmail.com
обсуждение исходный текст
Ответ на Re: to_hex() for negative inputs  (Aleksander Alekseev <aleksander@timescale.com>)
Ответы Re: to_hex() for negative inputs  (Aleksander Alekseev <aleksander@timescale.com>)
Список pgsql-hackers
On Tue, 24 Jan 2023 at 13:43, Aleksander Alekseev
<aleksander@timescale.com> wrote:
>
> Adding extra arguments for something the user can implement
> (him/her)self doesn't seem to be a great idea. With this approach we
> may end up with hundreds of arguments one day.
>

I don't see how a couple of extra arguments will expand to hundreds.

> =# select case when sign(x) > 0 then '' else '-' end || to_hex(abs(x))
> from ( values (123), (-123) ) as s(x);
>

Which is broken for INT_MIN:

select case when sign(x) > 0 then '' else '-' end || to_hex(abs(x))
from ( values (-2147483648) ) as s(x);

ERROR:  integer out of range

Part of the reason for implementing this in core would be to save
users from such easy-to-overlook bugs.

Regards,
Dean



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

Предыдущее
От: Vladimir Sitnikov
Дата:
Сообщение: Re: run pgindent on a regular basis / scripted manner
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Improve GetConfigOptionValues function