Re: Range Types - symmetric

From: Jeff Davis <pgsql(at)j-davis(dot)com>
To: Christopher Browne <cbbrowne(at)gmail(dot)com>
Cc: Erik Rijkers <er(at)xs4all(dot)nl>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Range Types - symmetric
Date: 2011-09-13 16:55:24
Message-ID: 1315932924.7281.112.camel@jdavis
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, 2011-09-13 at 12:34 -0400, Christopher Browne wrote:
> > 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.

...

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

Agreed. On balance, it's just as likely that you miss an error as save a
few keystrokes.

I'll add that it would also cause a little confusion with inclusivity.
What if you do: '[5,2)'::int4range? Is that really '[2,5)' or '(2,5]'?

Regards,
Jeff Davis

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Thom Brown 2011-09-13 16:58:11 Re: What Would You Like To Do?
Previous Message David E. Wheeler 2011-09-13 16:44:36 Re: What Would You Like To Do?