Gregory Stark <stark@enterprisedb.com> writes:
> Doesn't really strike at the core reason that this is so klugy though. Surely
> the "right" thing is to push the concept of open versus closed end-points
> through deeper into the estimation logic?
No, the right thing is to take the folk who defined "dictionary sort
order" out behind the barn and shoot 'em ;-). This has got nothing to
do with open/closed endpoints and everything to do with the bizarre
sorting rules used by some locales. In particular the reason I want to
append a letter is that some locales discriminate against non-letter
characters in the first pass of sorting.
I did do some experimentation and found that among the ASCII characters
(ie, codes 32-126), nearly all the non-C locales on my Fedora machine
sort Z last and z next-to-last or vice versa. Most of the remainder
sort digits last and z or Z as the last non-digit character. Since Z is
not that close to the end of the sort order in C locale, however, z
seems the best bet.
regards, tom lane