Re: [BUGS] extract(epoch from infinity) is not 0

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Daniele Varrazzo <daniele(dot)varrazzo(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgreSQL(dot)org>
Subject: Re: [BUGS] extract(epoch from infinity) is not 0
Date: 2011-07-13 18:43:08
Message-ID: 201107131843.p6DIh8923252@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

Daniele Varrazzo wrote:
> Hello,
>
> =# select extract(epoch from 'infinity'::timestamp);
> date_part
> -----------
> 0
>
> A better value would be 'infinity'::float8. Ditto for -infinity.
>
> I'm trying to use a box-based index to represent the intervals in a
> table containing a pair of fields date_from, date_to (timestamps),
> where semi-open intervals are represented with +/- infinity. Building
> the boxes using extract(epoch from ...) creates wrong entries as
> semi-open intervals are converted into a box with a corner in (0,0).

Looking at:

timestamptz_part(PG_FUNCTION_ARGS)

I see:

if (TIMESTAMP_NOT_FINITE(timestamp))
{
result = 0;
PG_RETURN_FLOAT8(result);
}

The assumption is that extracting _anything_ from an infinite timestamp
should be zero, but I can see your point that epoch perhaps should be
special-cased to return +/- inifinity.

Does anyone object to changing this?

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Robert Haas 2011-07-13 20:13:12 Re: [BUGS] extract(epoch from infinity) is not 0
Previous Message tushar 2011-07-13 12:57:18 BUG #6116: Not able to drop user if S/he has permission on tablespace

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2011-07-13 18:45:51 Re: Need help understanding pg_locks
Previous Message Heikki Linnakangas 2011-07-13 18:35:44 Re: Small patch for GiST: move childoffnum to child