Re: '1 year' = '360 days' ????

Поиск
Список
Период
Сортировка
От Bruno Wolff III
Тема Re: '1 year' = '360 days' ????
Дата
Msg-id 20041024022908.GA14348@wolff.to
обсуждение исходный текст
Ответ на Re: '1 year' = '360 days' ????  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: '1 year' = '360 days' ????
Список pgsql-general
On Sat, Oct 23, 2004 at 21:38:15 -0400,
  Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Doug McNaught <doug@mcnaught.org> writes:
> > template1=# select '1 year'::interval = '360 days'::interval;
> >  ?column?
> > ----------
> >  t
> > (1 row)
>
> Yeah, if you look at interval_cmp_internal() it's fairly obvious why.
> I think that this definition is probably bogus, and that only intervals
> that match exactly (equal months parts *and* equal seconds parts) should
> be considered "equal".  However the most obvious way to redefine it
> (compare the months, and only if equal compare the seconds) would lead
> to rather nonintuitive behaviors such as "'1 year' > '1000 days'".
> Anybody have any thoughts about a better way to map the multicomponent
> reality into a one-dimensional sorting order?

You could return NULL for cases where the number of months in the
first interval is less than the second, but the number of seconds in
the second interval is greater than the first.
You could even tighten things down more by using that months have to
be at least 28 days, but not more than 31 days (neglecting daylight
savings time).
If you want to be able to use a btree index, you need a total ordering, so
in that case I think you have to have things work pretty much the way they do
now, including the way the equality operator works.

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: '1 year' = '360 days' ????
Следующее
От: Tom Lane
Дата:
Сообщение: Re: '1 year' = '360 days' ????