pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Phil Sorber <phil@omniti.com>
Cc: pgsql-bugs@postgresql.org
Subject: Re: converting between infinity timestamp and float8 (epoch)
Date: Tue, 27 Dec 2011 13:00:42 -0500
Message-ID: <11910.1325008842@sss.pgh.pa.us> (raw)
In-Reply-To: <CADAkt-jRYHGFjLb1NdU9CbNJvVPUbb2JQ+mTuxO+KegLDO3K+g@mail.gmail.com>
References: <CADAkt-icuESH16uLOCXbR-dKpcvwtUJE4JWXnkdAjAAwP6j12g@mail.gmail.com>
	<CADAkt-jRYHGFjLb1NdU9CbNJvVPUbb2JQ+mTuxO+KegLDO3K+g@mail.gmail.com>

Phil Sorber <phil@omniti.com> writes:
> My search foo failed me. Someone just pointed me to a similar
> conversation from some months ago:
> http://archives.postgresql.org/pgsql-hackers/2011-07/msg00677.php

> I would propose that since we can't know the hour or minute of
> infinity that we should return null for those. I think NaN would be
> wrong because it is a real number, it's just unknown. If we can just
> pass infinity through the function, I think we should.

The last thread ended with a request for somebody to think through
the behavior for *all* extract field types and make a coherent proposal.
I don't think you've really advanced the discussion yet.

I think I agree with the position that we shouldn't return 0 unless
the correct value actually is 0, but it's not clear to me whether
to use NULL or NaN to represent "indeterminate".  Traditionally we
consider NULL to mean "unknown", but it seems like "what's the hour
of an infinite timestamp" is a subtly different sort of situation:
it's not unknown, we know perfectly well that it's indeterminate.
OTOH, choosing NaN would put a pretty significant dependence on
IEEE-float arithmetic into the external specification of timestamps,
and I find that a bit worrisome, even though IEEE float arithmetic
is nigh universal these days.  So maybe splitting hairs like that
would be ill-advised.  It probably depends also on what you expect
people to do with the result of extract() --- NULL would presumably
propagate through any additional calculation steps as-is, whereas
NaN might have less predictable behavior.

There was also some support for throwing an error in the previous
thread, though I can't say I like that answer myself.

			regards, tom lane



view thread (6+ messages)  latest in thread

Message-ID: <11910.1325008842@sss.pgh.pa.us>
Permalink:  ../11910.1325008842@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/11910.1325008842@sss.pgh.pa.us

 · 

reply

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: tgl@sss.pgh.pa.us, phil@omniti.com
  Subject: Re: converting between infinity timestamp and float8 (epoch)
  In-Reply-To: <11910.1325008842@sss.pgh.pa.us>
  References: <CADAkt-icuESH16uLOCXbR-dKpcvwtUJE4JWXnkdAjAAwP6j12g@mail.gmail.com> <CADAkt-jRYHGFjLb1NdU9CbNJvVPUbb2JQ+mTuxO+KegLDO3K+g@mail.gmail.com> <11910.1325008842@sss.pgh.pa.us>

* 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