Re: Range Types - symmetric

Поиск
Список
Период
Сортировка
От Christopher Browne
Тема Re: Range Types - symmetric
Дата
Msg-id CAFNqd5XPgd0oHg3gtk2wPYZYFSR76jx382EKqwmc_OgVySD_Fw@mail.gmail.com
обсуждение исходный текст
Ответ на Range Types - symmetric  ("Erik Rijkers" <er@xs4all.nl>)
Ответы Re: Range Types - symmetric
Список pgsql-hackers
On Tue, Sep 13, 2011 at 12:08 PM, Erik Rijkers <er@xs4all.nl> wrote:
> Just a thought:
>
> select int4range(5,2);
> ERROR:  range lower bound must be less than or equal to range upper bound
>
> Of course, I won't argue this is a bug, but I was wondering if it wouldn't be handy to allow a
> 'symmetric' mode in range construction, where, if the first of the pair is higher than the second,
> they are automatically swapped, similar to SYMMETRIC in the BETWEEN clause.
>
> Admittedly, I don't have a specific 'use case' -- it might just often prevent 'manual' swapping
> before range construction calls.

I'll buy that this is a plausible feature, but suggest an opposite
perspective, namely that this "DWIM" means that you can't notice
'getting things backwards' in your application as a bug anymore.

If you have a computation that gets a "backwards" range, then it is
more than possible that what you've got isn't an error of getting the
range backwards, but rather the error that your data is
overconstraining, and that you don't actually have a legitimate range.

So, if I decide that I want a range that expresses:- Dates before 2012-01-01 and- Dates after 2012-02-01

Which smells like (2012-02-01,2012-01-01).

It is NOT proper to turn that into the range (2012-01-01,2012-02-01) -
that's definitely not consistent with the facts I started with.

If you want to create your own range constructor function where you'll
take 2 values and reorder as needed to get a feasible range, that's
fine.

I think I rather oppose doing the swap automagically, by default,
because, in the case described above, it gives a WRONG range.
--
When confronted by a difficult problem, solve it by reducing it to the
question, "How would the Lone Ranger handle this?"


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

Предыдущее
От: Simon Riggs
Дата:
Сообщение: Re: unite recovery.conf and postgresql.conf
Следующее
От: Hannu Krosing
Дата:
Сообщение: Re: What Would You Like To Do?