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

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Bruce Momjian <bruce(at)momjian(dot)us>, Daniele Varrazzo <daniele(dot)varrazzo(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [BUGS] extract(epoch from infinity) is not 0
Date: 2011-07-13 20:58:30
Message-ID: 1310590466-sup-3055@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

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 <bruce(at)momjian(dot)us> 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 <alvherre(at)commandprompt(dot)com>
The PostgreSQL Company - Command Prompt, Inc.
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Brendan Jurd 2011-07-13 21:21:22 Re: [BUGS] extract(epoch from infinity) is not 0
Previous Message Aleksey Tsalolikhin 2011-07-13 20:53:48 BUG #6117: psql -c does not work as expected. a documentation bug? a program bug?

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2011-07-13 21:16:05 Re: Tweaking the planner's heuristics for small/empty tables
Previous Message Robert Haas 2011-07-13 20:13:12 Re: [BUGS] extract(epoch from infinity) is not 0