Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 39293B5DC4A for ; Wed, 13 Jul 2011 17:58:43 -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 86104-07 for ; Wed, 13 Jul 2011 20:58:37 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from spinlock.commandprompt.com (host-215.commandprompt.net [207.173.203.215]) by mail.postgresql.org (Postfix) with ESMTP id E9D74B5DC49 for ; Wed, 13 Jul 2011 17:58:36 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by spinlock.commandprompt.com (Postfix) with ESMTP id 3624F348048; Wed, 13 Jul 2011 13:58:36 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at commandprompt.com Received: from spinlock.commandprompt.com ([127.0.0.1]) by localhost (spinlock.commandprompt.com.commandprompt.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id q1vgaMdTGji3; Wed, 13 Jul 2011 13:58:34 -0700 (PDT) Received: from perhan.alvh.no-ip.org (unknown [190.95.21.209]) by spinlock.commandprompt.com (Postfix) with ESMTPSA id E9055348046; Wed, 13 Jul 2011 13:58:33 -0700 (PDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 35CEE6E60F; Wed, 13 Jul 2011 16:58:30 -0400 (CLT) Content-Type: text/plain; charset=UTF-8 Cc: Bruce Momjian , Daniele Varrazzo , PostgreSQL-development Subject: Re: [BUGS] extract(epoch from infinity) is not 0 From: Alvaro Herrera To: Robert Haas In-reply-to: References: <201107131843.p6DIh8923252@momjian.us> Date: Wed, 13 Jul 2011 16:58:30 -0400 Message-Id: <1310590466-sup-3055@alvh.no-ip.org> User-Agent: Sup/git Content-Transfer-Encoding: 8bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-5 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201107/693 X-Sequence-Number: 191792 Excerpts from Robert Haas's message of mié jul 13 16:13:12 -0400 2011: > On Jul 13, 2011, at 1:43 PM, Bruce Momjian wrote: > > Daniele Varrazzo wrote: > >> =# select extract(epoch from 'infinity'::timestamp); > >> date_part > >> ----------- > >> 0 > >> > >> A better value would be 'infinity'::float8. Ditto for -infinity. > > 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. > It's sort of non-obvious that either behavior is better than the > other. We might just be replacing one surprising behavior with > another. I don't find the proposed behavior all that suprising, which the original behavior surely is. I guess the bigger question is whether the values that timestamptz_part() returns for other cases (than epoch) should also be different from 0 when an 'infinity' timestamp is passed. (In other words, why should 0 be the assumed return value here?) -- Álvaro Herrera The PostgreSQL Company - Command Prompt, Inc. PostgreSQL Replication, Consulting, Custom Development, 24x7 support