Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 0A383B5DCE3 for ; Wed, 13 Jul 2011 17:12:44 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 03031-02 for ; Wed, 13 Jul 2011 20:12:38 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-gy0-f174.google.com (mail-gy0-f174.google.com [209.85.160.174]) by mail.postgresql.org (Postfix) with ESMTP id DF86CB5DCD8 for ; Wed, 13 Jul 2011 17:12:37 -0300 (ADT) Received: by gyh3 with SMTP id 3so2570742gyh.19 for ; Wed, 13 Jul 2011 13:12:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=references:in-reply-to:mime-version:content-transfer-encoding :content-type:message-id:cc:x-mailer:from:subject:date:to; bh=dOSIFc8NZ+CdJFRG9b7yGx6WhUw/G4j5JWStTl5ZhxA=; b=ZH4R8TvqY/7YCfHwh4f1wTcj626uR5PcfnmS4XauWb6ql8NDwoaEwPSpWJXebKw61O fvL91lyyyFCYotowc1GQPuoZ/4m4JH7ckCegseXVubb8wv8gfuklfwUArLlsKDGWH+t/ WW5BIGv7+u22kN0k0oUJRFW7Pqxucu5rdaiAw= Received: by 10.236.200.133 with SMTP id z5mr2196853yhn.272.1310587957342; Wed, 13 Jul 2011 13:12:37 -0700 (PDT) Received: from [10.13.216.130] (mobile-198-228-227-187.mycingular.net [198.228.227.187]) by mx.google.com with ESMTPS id k8sm1202804yhm.45.2011.07.13.13.12.35 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 13 Jul 2011 13:12:36 -0700 (PDT) References: <201107131843.p6DIh8923252@momjian.us> In-Reply-To: <201107131843.p6DIh8923252@momjian.us> Mime-Version: 1.0 (iPhone Mail 8A293) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Message-Id: Cc: Daniele Varrazzo , PostgreSQL-development X-Mailer: iPhone Mail (8A293) From: Robert Haas Subject: Re: [BUGS] extract(epoch from infinity) is not 0 Date: Wed, 13 Jul 2011 15:13:12 -0500 To: Bruce Momjian X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.898 tagged_above=-5 required=5 tests=BAYES_00=-1.9, FREEMAIL_FROM=0.001, MIME_QP_LONG_LINE=0.001 X-Spam-Level: X-Archive-Number: 201107/692 X-Sequence-Number: 191791 On Jul 13, 2011, at 1:43 PM, Bruce Momjian wrote: > Daniele Varrazzo wrote: >> Hello, >>=20 >> =3D# select extract(epoch from 'infinity'::timestamp); >> date_part >> ----------- >> 0 >>=20 >> A better value would be 'infinity'::float8. Ditto for -infinity. >>=20 >> 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). >=20 > Looking at: >=20 > timestamptz_part(PG_FUNCTION_ARGS) >=20 > I see: >=20 > if (TIMESTAMP_NOT_FINITE(timestamp)) > { > result =3D 0; > PG_RETURN_FLOAT8(result); > } >=20 > 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. >=20 > Does anyone object to changing this? It's sort of non-obvious that either behavior is better than the other. We m= ight just be replacing one surprising behavior with another. ...Robert=