Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 2CB25B5DC11 for ; Wed, 13 Jul 2011 15:43:15 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 72095-08 for ; Wed, 13 Jul 2011 18:43:09 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from momjian.us (momjian.us [70.90.9.53]) by mail.postgresql.org (Postfix) with ESMTP id B989EB5DC19 for ; Wed, 13 Jul 2011 15:43:08 -0300 (ADT) Received: (from bruce@localhost) by momjian.us (8.11.6/8.11.6) id p6DIh8923252; Wed, 13 Jul 2011 14:43:08 -0400 (EDT) From: Bruce Momjian Message-Id: <201107131843.p6DIh8923252@momjian.us> Subject: Re: [BUGS] extract(epoch from infinity) is not 0 In-Reply-To: To: Daniele Varrazzo Date: Wed, 13 Jul 2011 14:43:08 -0400 (EDT) CC: PostgreSQL-development X-Mailer: ELM [version 2.4ME+ PL124 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="US-ASCII" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-5 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201107/678 X-Sequence-Number: 191777 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 http://momjian.us EnterpriseDB http://enterprisedb.com + It's impossible for everything to be true. +