Re: [HACKERS] strcmp() tie-breaker for identical ICU-collated strings - Mailing list pgsql-hackers

From Thomas Munro
Subject Re: [HACKERS] strcmp() tie-breaker for identical ICU-collated strings
Date
Msg-id CAEepm=3BasPHs2T-np=OZJmJCraQh5_HbcGMdkqW8oha-51ThA@mail.gmail.com
Whole thread Raw
In response to Re: [HACKERS] strcmp() tie-breaker for identical ICU-collated strings  (Peter Geoghegan <pg@bowt.ie>)
Responses Re: [HACKERS] strcmp() tie-breaker for identical ICU-collated strings  (Amit Khandekar <amitdkhan.pg@gmail.com>)
List pgsql-hackers
On Fri, Jun 2, 2017 at 9:27 AM, Peter Geoghegan <pg@bowt.ie> wrote:
> On Thu, Jun 1, 2017 at 2:24 PM, Thomas Munro
> <thomas.munro@enterprisedb.com> wrote:
>> Why should ICU be any different than the system provider in this
>> respect?  In both cases, we have a two-level comparison: first we use
>> the collation-aware comparison, and then as a tie breaker, we use a
>> binary comparison.  If we didn't do a binary comparison as a
>> tie-breaker, wouldn't the result be logically incompatible with the =
>> operator, which does a binary comparison?
>
> I agree with that assessment.

I think you *could* make a logically consistent set of operations with
no binary tie-breaker.  = could be defined in terms of strcoll and
hash could hash the output of strxfrm, but it it'd be impractical and
slow.  In order to take advantage of simple and fast = and hash, we go
the other way and teach < and > about binary order.

-- 
Thomas Munro
http://www.enterprisedb.com



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: [HACKERS] strcmp() tie-breaker for identical ICU-collated strings
Next
From: Andres Freund
Date:
Subject: Re: [HACKERS] logical replication and PANIC during shutdowncheckpoint in publisher