Re: strcmp() tie-breaker for identical ICU-collated strings

From: Thomas Munro <thomas(dot)munro(at)enterprisedb(dot)com>
To: Peter Geoghegan <pg(at)bowt(dot)ie>
Cc: Amit Khandekar <amitdkhan(dot)pg(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: strcmp() tie-breaker for identical ICU-collated strings
Date: 2017-06-01 21:48:31
Message-ID: CAEepm=3BasPHs2T-np=OZJmJCraQh5_HbcGMdkqW8oha-51ThA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Jun 2, 2017 at 9:27 AM, Peter Geoghegan <pg(at)bowt(dot)ie> wrote:
> On Thu, Jun 1, 2017 at 2:24 PM, Thomas Munro
> <thomas(dot)munro(at)enterprisedb(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2017-06-01 22:05:18 Re: logical replication and PANIC during shutdown checkpoint in publisher
Previous Message Tom Lane 2017-06-01 21:48:17 Re: strcmp() tie-breaker for identical ICU-collated strings