Feature or bug: getting "Inf"::timestamp[tz] by "regular" value

Started by Vitaly Burovoyabout 10 years ago2 messages
#1Vitaly Burovoy
vitaly.burovoy@gmail.com

Hackers!

I'm writing another patch for timestamps and while I tried to cover
corner-cases I found out there is an ability to get
"Infinity"::timestamptz via defining it by a specific (but not
"Infinity") value:

postgres=# SELECT '294277-01-09 04:00:54.775806+00'::timestamptz; -- OK
timestamptz
---------------------------------
294277-01-09 04:00:54.775806+00
(1 row)

postgres=# SELECT '294277-01-09 04:00:54.775807+00'::timestamptz; -- Inf???
timestamptz
-------------
infinity
(1 row)

postgres=# SELECT '294277-01-09 04:00:54.775808+00'::timestamptz; --
Higher values give an error
ERROR: timestamp out of range: "294277-01-09 04:00:54.775808+00"
LINE 1: SELECT '294277-01-09 04:00:54.775808+00'::timestamptz;
^
I could not find a way to get "-Infinity" by similar way.
Is it feature or a bug? Does it worth to insert a check for that
special case to raise an exception "timestamp out of range"?
--
Best regards,
Vitaly Burovoy

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Vitaly Burovoy (#1)
Re: Feature or bug: getting "Inf"::timestamp[tz] by "regular" value

Vitaly Burovoy <vitaly.burovoy@gmail.com> writes:

I'm writing another patch for timestamps and while I tried to cover
corner-cases I found out there is an ability to get
"Infinity"::timestamptz via defining it by a specific (but not
"Infinity") value:
postgres=# SELECT '294277-01-09 04:00:54.775807+00'::timestamptz; -- Inf???
timestamptz
-------------
infinity
(1 row)

I could not find a way to get "-Infinity" by similar way.
Is it feature or a bug?

It's a bug. Probably related to the fact that "Infinity" is represented
as INT_MAX in the case of integer timestamps.

regards, tom lane

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers