Re: '1 year' = '360 days' ???? - Mailing list pgsql-general

From Tom Lane
Subject Re: '1 year' = '360 days' ????
Date
Msg-id 5047.1098588965@sss.pgh.pa.us
Whole thread Raw
In response to Re: '1 year' = '360 days' ????  (Bruno Wolff III <bruno@wolff.to>)
Responses Re: '1 year' = '360 days' ????  (Bruno Wolff III <bruno@wolff.to>)
List 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 by date:

Previous
From: Bruno Wolff III
Date:
Subject: Re: '1 year' = '360 days' ????
Next
From: Bruno Wolff III
Date:
Subject: Re: '1 year' = '360 days' ????