From: Robert Haas <robertmhaas@gmail.com>
To: Brendan Jurd <direvus@gmail.com>
Cc: Alvaro Herrera <alvherre@commandprompt.com>
Cc: Bruce Momjian <bruce@momjian.us>
Cc: 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 17:16:56 -0500
Message-ID: <73A5666E-2D40-457E-9DFF-248895DB7FAF@gmail.com> (raw)
In-Reply-To: <CADxJZo0BXaetTCygQV+U-PCgtLv-ksBKTGiZbMzAJ5TzgUCsBg@mail.gmail.com>
References: <201107131843.p6DIh8923252@momjian.us>
<F5B7B9C4-66FD-4E47-9FBC-02EAB14B491E@gmail.com>
<1310590466-sup-3055@alvh.no-ip.org>
<CADxJZo0BXaetTCygQV+U-PCgtLv-ksBKTGiZbMzAJ5TzgUCsBg@mail.gmail.com>
On Jul 13, 2011, at 4:21 PM, Brendan Jurd <direvus@gmail.com> wrote:
> On 14 July 2011 06:58, Alvaro Herrera <alvherre@commandprompt.com> wrote:
>> 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?)
>>
>
> Well, for example, how do you go about answering the question "what is
> the day-of-month of the infinite timestamp?" The question is
> nonsense; it doesn't have a defined day of month, so I think we should
> be returning NULL or throwing an error. Returning zero is definitely
> wrong. I think throwing an error is the better way to go, as the user
> probably didn't intend to ask an incoherent question.
>
> It makes sense to special-case 'epoch' because it effectively converts
> the operation into interval math; if we ask "how many seconds from
> 1970-01-01 00:00 UTC until the infinite timestamp?" the answer is
> genuinely "infinite seconds". So +1 for the proposed change for
> epoch, and let's throw an error for the other date fields instead of
> returning zero.
I'd rather we avoid throwing an error, because that sometimes forces people who want to handle that case to use a subtransaction to catch it, which is quite slow. If we don't like 0, perhaps NULL or NaN would be better.
...Robert
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: robertmhaas@gmail.com, direvus@gmail.com, alvherre@commandprompt.com, bruce@momjian.us, daniele.varrazzo@gmail.com, pgsql-hackers@postgresql.org
Subject: Re: [BUGS] extract(epoch from infinity) is not 0
In-Reply-To: <73A5666E-2D40-457E-9DFF-248895DB7FAF@gmail.com>
References: <201107131843.p6DIh8923252@momjian.us> <F5B7B9C4-66FD-4E47-9FBC-02EAB14B491E@gmail.com> <1310590466-sup-3055@alvh.no-ip.org> <CADxJZo0BXaetTCygQV+U-PCgtLv-ksBKTGiZbMzAJ5TzgUCsBg@mail.gmail.com> <73A5666E-2D40-457E-9DFF-248895DB7FAF@gmail.com>
* 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