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

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: '1 year' = '360 days' ????
Дата
Msg-id 5047.1098588965@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: '1 year' = '360 days' ????  (Bruno Wolff III <bruno@wolff.to>)
Ответы Re: '1 year' = '360 days' ????  (Bruno Wolff III <bruno@wolff.to>)
Список pgsql-general
Bruno Wolff III <bruno@wolff.to> writes:
>   Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> 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.

No, you can't, at least not if you want to have btree indexes on
interval columns.  The comparison operators can never return NULL
for nonnull inputs.

> 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.

We don't have to have this particular sorting decision, we just have
to have *some* unique sorting order.  In particular, if we want to say
that two interval values are not equal, we have to be able to say which
one is less.  For instance, "compare the months first and only if equal
compare the seconds" would work fine from the point of view of btree.
It's just that that leads to a sort order that users will probably not
like very much.

            regards, tom lane

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

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