strxfrm output stability

Paul Eggert eggert@cs.ucla.edu
Wed Sep 9 16:45:00 GMT 2015


Florian Weimer wrote:
>> >I'll go out on a limb and say that no sane application uses strxfrm,
>> >either on disk or off.
> PostgreSQL uses it to avoid calling strcoll on strings which have
> distinctly ordered prefixes in their strxfrm output.

Good catch, and that is what I get for going out on a limb.

Although after looking at it a bit, it is not a true counterexample, as the 
PostgreSQL code is crazy.  For example, it inspects strxfrm output for 
upper-case ASCII letters?!  Overall PostgreSQL's use of strxfrm has the smell of 
someone applying theory from the 1970s without having measured whether 
performance actually improves in the typical case nowadays. and it might be 
amusing to replace PostgreSQL's use of strxfrm with a function that always 
returns the empty string; the code would still work, and might even run faster.



More information about the Libc-alpha mailing list