Re: to_hex() for negative inputs

Поиск
Список
Период
Сортировка
От Aleksander Alekseev
Тема Re: to_hex() for negative inputs
Дата
Msg-id CAJ7c6TOKesxF3ReJ+GoBRdM2tHr5X=TLRxM5SDgvXaNQgtmFkg@mail.gmail.com
обсуждение исходный текст
Ответ на Re: to_hex() for negative inputs  (Dean Rasheed <dean.a.rasheed@gmail.com>)
Ответы Re: to_hex() for negative inputs  (Dean Rasheed <dean.a.rasheed@gmail.com>)
Список pgsql-hackers
Hi Dean,

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

Maybe I was exaggerating, but the point is that adding extra flags for
every possible scenario is a disadvantageous approach in general.
There is no need to increase the code base, the amount of test cases
and the amount of documentation every time someone has an idea "in
rare cases I also may want to do A or B, let's add a flag for this".

> 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

I'm afraid the behavior of something like to_hex(X, with_sign => true)
is going to be exactly the same. There is no safe and consistent way
to calculate abs(INT_MIN).

-- 
Best regards,
Aleksander Alekseev



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

Предыдущее
От: Andres Freund
Дата:
Сообщение: Re: plpython vs _POSIX_C_SOURCE
Следующее
От: David Rowley
Дата:
Сообщение: Re: heapgettup() with NoMovementScanDirection unused in core?