From: Vitaly Burovoy <vitaly(dot)burovoy(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject:
Date: 2016-01-31 07:06:10
Message-ID: CAKOSWNked3JOE++PEs49GMDNfR2ieu9A2jFCEZ6EW-+1c5_u9Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hackers,

I've just found a little bug: extracting "epoch" from the last 30
years before Postgres' "+Infinity" leads an integer overflow:

postgres=# SELECT x::timestamptz, extract(epoch FROM x::timestamptz)
postgres-# FROM
postgres-# (VALUES
postgres(# ('294247-01-10 04:00:54.775805'),
postgres(# ('294247-01-10 04:00:55.775806'),
postgres(# ('294277-01-09 04:00:54.775806'), -- the last value before 'Inf'
postgres(# ('294277-01-09 04:00:54.775807') -- we've discussed, it
should be fixed
postgres(# ) as t(x);
x | date_part
---------------------------------+-------------------
294247-01-10 04:00:54.775805+00 | 9223372036854.78
294247-01-10 04:00:55.775806+00 | -9223372036853.78
294277-01-09 04:00:54.775806+00 | -9222425352054.78
infinity | Infinity
(4 rows)

With the attached patch it becomes positive:
x | date_part
---------------------------------+------------------
294247-01-10 04:00:54.775805+00 | 9223372036854.78
294247-01-10 04:00:55.775806+00 | 9223372036855.78
294277-01-09 04:00:54.775806+00 | 9224318721654.78
infinity | Infinity
(4 rows)

--
Best regards,
Vitaly Burovoy

Attachment Content-Type Size
fix_extract_overflow_v1.patch application/octet-stream 2.1 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Konstantin Knizhnik 2016-01-31 07:54:35 Re: Optimizer questions
Previous Message Vitaly Burovoy 2016-01-31 07:04:20 Re: custom function for converting human readable sizes to bytes