Re: Question about integer out of range in function

Поиск
Список
Период
Сортировка
От Peter J. Holzer
Тема Re: Question about integer out of range in function
Дата
Msg-id 20210521151752.GA23484@hjp.at
обсуждение исходный текст
Ответ на Question about integer out of range in function  ("David G. Johnston" <david.g.johnston@gmail.com>)
Список pgsql-general
On 2021-05-16 11:09:38 -0700, David G. Johnston wrote:
> On Sunday, May 16, 2021, Condor <condor@stz-bg.com> wrote:
>
>
>          new_time = fromtime * 1000; -- here is line 19
>          
>
>
> An integer times an integer results in an integer.  Period.  Neither fromtime
> nor new_time have been assigned to yet, the in-memory result of the computation
> is only allocated integer bits and if you overflow that you get an error.

This is also true in C, btw, except that in C an overflow of a signed
int is undefined behaviour while an unsigned int is required to wrap
around.

        hp

--
   _  | Peter J. Holzer    | Story must make more sense than reality.
|_|_) |                    |
| |   | hjp@hjp.at         |    -- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |       challenge!"

Вложения

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

Предыдущее
От: Ian Lawrence Barwick
Дата:
Сообщение: Re: I have no idea why pg_dump isn't dumping all of my data
Следующее
От: Adrian Klaver
Дата:
Сообщение: Re: The contents of the pg_timezone_names view bring some surprises