pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bruce Momjian <bruce@momjian.us>
To: Daniele Varrazzo <daniele.varrazzo@gmail.com>
Cc: PostgreSQL-development <pgsql-hackers@postgreSQL.org>
Subject: Re: [BUGS] extract(epoch from infinity) is not 0
Date: Wed, 13 Jul 2011 14:43:08 -0400 (EDT)
Message-ID: <201107131843.p6DIh8923252@momjian.us> (raw)
In-Reply-To: <CA+mi_8bda-Fnev9iXeUbnqhVaCWzbYhHkWoxPQfBca9eDPpRMw@mail.gmail.com>

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@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

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



view thread (9+ messages)  latest in thread

Message-ID: <201107131843.p6DIh8923252@momjian.us>
Permalink:  ../201107131843.p6DIh8923252@momjian.us/
Also on:    postgresql.org/message-id/201107131843.p6DIh8923252@momjian.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: bruce@momjian.us, daniele.varrazzo@gmail.com, pgsql-hackers@postgreSQL.org
  Subject: Re: [BUGS] extract(epoch from infinity) is not 0
  In-Reply-To: <201107131843.p6DIh8923252@momjian.us>
  References: <CA+mi_8bda-Fnev9iXeUbnqhVaCWzbYhHkWoxPQfBca9eDPpRMw@mail.gmail.com> <201107131843.p6DIh8923252@momjian.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox