Re: 'infinity'::Interval should be added

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: 'infinity'::Interval should be added
Дата
Msg-id 5210.1545018533@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: 'infinity'::Interval should be added  (Robert Haas <robertmhaas@gmail.com>)
Ответы Re: 'infinity'::Interval should be added  (Simon Riggs <simon@2ndquadrant.com>)
Список pgsql-hackers
Robert Haas <robertmhaas@gmail.com> writes:
> Simon's argument for adding this is that we support 'infinity' for
> timestamp, but is that a good argument for making 'interval' do it,
> given that there are many other types like date for which we don't
> support it?

My feeling is that date is to timestamp as integer is to float.
We have infinities in the latter types but not the former, and
that seems just fine: infinity is one of the additional values
that you get to have with the bigger/more expensive type.
So I don't really feel that the lack of infinity in date is an
argument against whether to provide it for interval.

The positive argument for adding infinity to interval is that
we define operations such as timestamp minus timestamp as
yielding interval.  That's why this has to fail right now:

regression=# select timestamp 'infinity' - timestamp 'now';
ERROR:  cannot subtract infinite timestamps

But if we had infinite intervals then that would have a well
defined result, just as this works:

regression=# select extract(epoch from timestamp 'infinity');
 date_part 
-----------
  Infinity
(1 row)

Of course, there are still cases like timestamp 'infinity' -
timestamp 'infinity' that would need to fail, but that has a
semantic basis rather than "the output type can't represent it".
(No, I don't want to invent an interval equivalent of NaN
to make that not fail.)

[ wanders away wondering why type numeric has NaN but not infinity ]

            regards, tom lane


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Robert Haas
Дата:
Сообщение: Re: 'infinity'::Interval should be added
Следующее
От: Isaac Morland
Дата:
Сообщение: Re: 'infinity'::Interval should be added