Re: Since '2001-09-09 01:46:40'::timestamp microseconds are lost when extracting epoch

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Since '2001-09-09 01:46:40'::timestamp microseconds are lost when extracting epoch
Дата
Msg-id 1128312.1600108433@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Since '2001-09-09 01:46:40'::timestamp microseconds are lost when extracting epoch  (Ranier Vilela <ranier.vf@gmail.com>)
Ответы Re: Since '2001-09-09 01:46:40'::timestamp microseconds are lost when extracting epoch
Список pgsql-hackers
Ranier Vilela <ranier.vf@gmail.com> writes:
> msvc 2019 (64 bits), is worried about it:
>   C:\dll\postgres\src\backend\utils\adt\dbsize.c(630,20): warning C4334:
> '<<': resultado de 32-bit shift convertido implicitamente para 64 bits
> (64-bit shift era pretendid
> o?) [C:\dll\postgres\postgres.vcxproj]

Yeah, most/all of the MSVC buildfarm members are showing this warning too.
The previous coding was

    Int64GetDatum((int64) (1 << count))

which apparently is enough to silence MSVC, though it makes no difference
as to the actual overflow risk involved.

I'm a bit inclined to make the new code be

    NumericGetDatum(int64_to_numeric(INT64CONST(1) << count));

ie do the shift in 64 bits.  That's either free or next door to free, and
it allows larger count values to be accepted.  The existing callers don't
care of course, but someday somebody might try to expose this function
more widely.

            regards, tom lane



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

Предыдущее
От: Ranier Vilela
Дата:
Сообщение: Re: Since '2001-09-09 01:46:40'::timestamp microseconds are lost when extracting epoch
Следующее
От: Andres Freund
Дата:
Сообщение: Re: Allow ERROR from heap_prepare_freeze_tuple to be downgraded to WARNING