Re: 'infinity'::Interval should be added

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: 'infinity'::Interval should be added
Дата
Msg-id 26022.1545087636@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: 'infinity'::Interval should be added  (Simon Riggs <simon@2ndquadrant.com>)
Ответы Re: 'infinity'::Interval should be added  (Isaac Morland <isaac.morland@gmail.com>)
Список pgsql-hackers
Simon Riggs <simon@2ndquadrant.com> writes:
> I would like to represent 'infinity' as interval->months = INT_MAX

Per the discussion upthread, what we need when creating an
infinite value is to set
month = INT32_MAX, day = INT32_MAX, time = INT64_MAX (for +Infinity)
month = INT32_MIN, day = INT32_MIN, time = INT64_MIN (for -Infinity)
else we'll need to put special-case logic into comparisons.

However, I think that we only need to restrict ordinary values from
not having month equal to INT32_MIN/MAX, that is the full range
of the other two fields can still be available for normal use.
So when *testing* for an infinity, you would only need to look at the
month field.

> Currently
> postgres=# select 'infinity'::timestamp = 'infinity'::timestamp;
>  ?column?
> ----------
>  t

Correct, we'd need that here too, if only because btree indexes and
sorting require the reflexive axiom to hold.

> so I was thinking that
> postgres=# select 'infinity'::timestamp - 'infinity'::timestamp;
> would be zero rather than an error, for least surprise.

Wrong.  This case needs to be undefined, because "infinity"
isn't a specific value.  That's what makes it okay to define, say,
infinity plus any finite value as infinity.  There are very
well-defined rules about how to calculate with infinity, and
not following them is not the way to proceed here.

tl;dr: we should model it after the behavior of IEEE float infinities,
except we'll want to throw errors where those produce NaNs.

            regards, tom lane


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

Предыдущее
От: Kevin Grittner
Дата:
Сообщение: Re: Referential Integrity Checks with Statement-level Triggers
Следующее
От: Alexander Korotkov
Дата:
Сообщение: Re: gist microvacuum doesn't appear to care about hot standby?