PostgreSQL Bugs

Collected from the PG bugs email list.

Bug ID16357
PG Version9.6.17
OSLinux 5.0.0, Ubuntu 18.04.1
Opened2020-04-11 06:01:49+00
Reported byIvan Beloborodov
StatusNew

Body of first available message related to this bug follows.

The following bug has been logged on the website:

Bug reference:      16357
Logged by:          Ivan Beloborodov
Email address:      (redacted)
PostgreSQL version: 9.6.17
Operating system:   Linux 5.0.0, Ubuntu 18.04.1
Description:        

to_timestamp() returns incorrect results for some negative arguments: 

set extra_float_digits to 1;
SET
select extract(epoch from timestamp '1920-10-24 12:11:13.975227');
     date_part      
--------------------
 -1552218526.024773
(1 row)
select to_timestamp(-1552218526.024773) at time zone 'UTC';
          timezone          
----------------------------
 1920-10-24 12:11:13.975228
(1 row)

Whereas for positive arguments of the same magnitude everything's ok:

select extract(epoch from timestamp '2019-03-10 11:48:46.024773');
     date_part     
-------------------
 1552218526.024773
(1 row)
select to_timestamp(1552218526.024773) at time zone 'UTC';
          timezone          
----------------------------
 2019-03-10 11:48:46.024773
(1 row)

The problem is not with extra_float_digits:

set extra_float_digits to 0;
SET
select to_timestamp(-1552218526.024773) at time zone 'UTC' = timestamp
'1920-10-24 12:11:13.975227';
 ?column? 
----------
 f
(1 row)

And, as far as I understand, not with insufficient precision of float8, here
is an example with the same behaviour with 15 significant digits:

select extract(epoch from timestamp '1853-08-15 10:04:15.35064');
     date_part     
-------------------
 -3672568544.64936
(1 row)
select to_timestamp(-3672568544.64936) at time zone 'UTC';
          timezone          
----------------------------
 1853-08-15 10:04:15.350639
(1 row)
select extract(epoch from timestamp '2086-05-18 13:55:44.64936');
    date_part     
------------------
 3672568544.64936
(1 row)
select to_timestamp(3672568544.64936) at time zone 'UTC';
         timezone          
---------------------------
 2086-05-18 13:55:44.64936
(1 row)

Tested this behaviour on PostgreSQL 9.6.17, Linux 5.0.0, Ubuntu 18.04.1 and
PostgreSQL 10.1, Linux 4.4.0, Ubuntu 14.04.1

Messages

DateAuthorSubject
2020-04-11 06:01:49+00PG Bug reporting formBUG #16357: Incorrect rounding for negative arguments in to_timestamp()