On Sat, Jun 25, 2011 at 6:29 PM, Jeff Davis <pgsql(at)j-davis(dot)com> wrote:
> Different ranges over the same subtype make sense when using different
> total orders for the subtype. This is most apparent with text collation,
> but makes sense (at least mathematically, if not practically) for any
> For instance:
> [a, Z)
> is a valid range in "en_US", but not in "C", so it makes sense to have
> multiple ranges over the same subtype with different collations.
> But what if you have a function (like a constructor), of the form:
> (anyelement, anyelement) -> anyrange
> ? To work with the type system, you need to be able to figure out the
> return type from the arguments; which means to support functions like
> this we need a mapping from the subtype to the range type.
> Unfortunately, that restricts us to one range type per subtype (this
> isn't a problem for ARRAYs, because there is only one useful array type
> for a given element type).
> This problem first came up a while ago:
> My workaround was to use domains, but that's not a very clean solution
> (you have to add a bunch of casts to make sure the right domain is
> chosen). It became entirely unworkable with collations, because people
> would be using different text collations a lot more frequently than,
> say, a different ordering for timestamptz. Tom mentioned that here:
> I think Florian proposed the most promising line of attack here:
> by suggesting that functions of the form:
> (anyelement, [other non-anyrange arguments]) -> anyrange
> might be expendable. After all, they are only useful for constructors as
> far as we can tell. Other range functions will have an anyrange
> parameter, and we can use the actual type of the argument to know the
> range type (as well as the subtype).
> Although it's very nice to be able to say:
> and get an int4range out of it, it's not the only way, and it's not
> without its problems anyway. For instance, to get an int8range you have
> to do:
> range(1::int8, 10::int8)
> or similar.
> So, we could just make functions like:
> int4range(int4, int4)
> int8range(int8, int8)
> when creating the range type, and it would actually be a usability
Couldn't we also do neither of these things? I mean, presumably
'[1,10]'::int8range had better work.
I'm not saying that's ideal from a usability perspective but I fear
this patch is going to be unmanageably large, and separating out the
things that you need for it to work at all from the things that you
need in order for it to be convenient might have some merit.
The Enterprise PostgreSQL Company
In response to
pgsql-hackers by date
|Next:||From: Noah Misch||Date: 2011-06-27 18:59:37|
|Subject: Re: [v9.2] DROP Reworks Part.0 - 'missing_ok' support ofget_object_address|
|Previous:||From: David E. Wheeler||Date: 2011-06-27 18:38:32|
|Subject: Re: generate_series() Interpretation|