Re: money type overflow checks

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: money type overflow checks
Дата
Msg-id 30735.1470417264@sss.pgh.pa.us
обсуждение исходный текст
Ответ на money type overflow checks  (Peter Eisentraut <peter.eisentraut@2ndquadrant.com>)
Ответы Re: money type overflow checks  (Peter Eisentraut <peter.eisentraut@2ndquadrant.com>)
Список pgsql-hackers
Peter Eisentraut <peter.eisentraut@2ndquadrant.com> writes:
> The input function of the money type has no overflow checks:

Ugh.

> (Is checking for < 0 a valid overflow check?

No, I don't think it's sufficient after a multiplication by 10.  That
would be enough to shift some bits clear out of the word, but there's
no certainty that the new sign bit would be 1.

The scheme used in scanint8 is safe.  But I think it was written that way
mainly to avoid hard-wired assumptions about how wide int64 is, a
consideration that's a mite obsolete now.  You could possibly avoid the
cost of a division by relying on comparisons to PG_INT64_MAX/10.
        regards, tom lane



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

Предыдущее
От: Simon Riggs
Дата:
Сообщение: Re: Logical Replication WIP
Следующее
От: Pavan Deolasee
Дата:
Сообщение: Re: Heap WARM Tuples - Design Draft