On Fri, 2011-06-10 at 00:26 +0200, Florian Pflug wrote: > Maybe that check should just be removed? If one views the range > '[L, U)' as a concise way of expressing "L <= x AND x < U" for some > x, then allowing the case L > U seems quite natural. There won't > be any such x of course, but the range is still valid, just empty.
[ Please excuse the late reply, I was on vacation. ] That's an interesting perspective, but I don't think it's a good idea. Up to this point, I've considered a range value to be a set of contiguous values, and the endpoints just happen to be a way to represent that set. If changing the collation changes a set of positive cardinality into an empty set, clearly it's a different value. We don't want the COLLATE clause to change the value, because things that do change the value (like a typecast) should offer the opportunity to call a function so that you can verify that it's valid or change it to some canonical form. So, I believe that you are proposing to change the concept of a range value from "a contiguous set of values" to "a pair of bounds". There are numerous implications, one of which is that I don't think that we can maintain the equality of all empty ranges. Consider these expressions, where x is a non-empty range with collation "A", but is empty in collation "B" (and "*" means "range intersection"): (x COLLATE "B") COLLATE "A" ((x COLLATE "B") * '(-Inf, Inf)') COLLATE "A" ('-'::textrange * '(-Inf, Inf)') COLLATE "A" All of those expressions should be equal (according to global substitutibility, as Darren mentioned). But they can't be, because the last expression is always an empty range, whereas the first one is not (because merely changing the collation back and forth offers no opportunity to even notice that you have an empty range at one point). So, I believe that we'd be stuck with non-equal empty ranges, as well as many other possibly non-intuitive implications. So, I lean strongly toward the interpretation that a range is a contiguous set of values, and changing the collation should not change the value. Things that do change the value (like a typecast) should offer the opportunity to handle cases like this with a function call, but changing collation does not. This leaves making the collation a part of the range type itself (as Robert suggested). Comments? Regards, Jeff Davis -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers