[PATCH] Supporting +-Infinity values by to_timestamp(float8) - Mailing list pgsql-hackers

From Vitaly Burovoy
Subject [PATCH] Supporting +-Infinity values by to_timestamp(float8)
Date
Msg-id CAKOSWN=qbbnF_oRue4rfsMmWb+7wkBN6fq5XNHgt5vR0TiAA5g@mail.gmail.com
Whole thread Raw
Responses Re: [PATCH] Supporting +-Infinity values by to_timestamp(float8)
Re: [PATCH] Supporting +-Infinity values by to_timestamp(float8)
Re: [PATCH] Supporting +-Infinity values by to_timestamp(float8)
List pgsql-hackers
Hello, Hackers!

I worked on a patch[1] allows "EXTRACT(epoch FROM
+-Inf::timestamp[tz])" to return "+-Inf::float8".
There is an opposite function "to_timestamp(float8)" which now defined as:
SELECT ('epoch'::timestamptz + $1 * '1 second'::interval)

Since intervals do not support infinity values, it is impossible to do
something like:
SELECT to_timestamp('infinity'::float8);

... which is not good.

Supporting of such converting is in the TODO list[2] (by "converting
between infinity timestamp and float8").

Proposed patch implements it.

There is an other patch in the CF[3] 2016-03 implements checking of
timestamp[tz] for being in allowed range. Since it is wise to set
(fix) the upper boundary of timestamp[tz]s, I've included the file
"src/include/datatype/timestamp.h" from there to check that an input
value and a result are in the allowed range.

There is no changes in a documentation because allowed range is the
same as officially supported[4] (i.e. until 294277 AD).


[1]http://git.postgresql.org/pg/commitdiff/647d87c56ab6da70adb753c08d7cdf7ee905ea8a
[2]https://wiki.postgresql.org/wiki/Todo#Dates_and_Times
[3]https://commitfest.postgresql.org/9/540/
[4]http://www.postgresql.org/docs/devel/static/datatype-datetime.html

--
Best regards,
Vitaly Burovoy

Attachment

pgsql-hackers by date:

Previous
From: Kartyshov Ivan
Date:
Subject: Re: proposal: get oldest LSN - function
Next
From: Vitaly Burovoy
Date:
Subject: Re: [PATCH] Supporting +-Infinity values by to_timestamp(float8)