pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: rihad <rihad@mail.ru>
To: Daniel Verite <daniel@manitou-mail.org>
Cc: Peter Geoghegan <pg@bowt.ie>
Cc: pgsql-general General <pgsql-general@postgresql.org>
Subject: Re: Upgrading locale issues
Date: Thu, 2 May 2019 21:45:25 +0400
Message-ID: <352ac37a-39e6-5afe-d822-b4e031b9b314@mail.ru> (raw)
In-Reply-To: <f113b2da-eef3-4c55-b5f9-e60032603ee3@manitou-mail.org>
References: <f113b2da-eef3-4c55-b5f9-e60032603ee3@manitou-mail.org>

On 05/02/2019 05:36 PM, Daniel Verite wrote:
> 	rihad wrote:
>
>> Thanks for the reply. Do you know what would a "decent" ICU collation be
>> to bind to a field's schema definition so it would mimic a UTF-8
>> encoding for a multilingual column? Maybe und-x-icu? We aren't as much
>> concerned about their sortability in most cases, we just want indexes to
>> better handle future PG/ICU upgrades. But what does und(efined) even
>> mean with respect to collations?
> "undefined" in this context means unspecified language and
> unspecified country or region. It implies that no language-specific
> nor regional rule will be applied to compare strings.
>
> Using C.UTF-8 as the collation for text fields to index may be the
> best trade-off in your case. It should be immune to libc and ICU
> upgrades.
>
> With C.UTF-8, a string like 'BC' will sort before 'ab', and punctuation
> and accents will also sort differently than with a linguistic-aware
> collation.
Thanks, I'm a bit confused here. AFAIK indexes are used for at least two 
things: for speed and for skipping the ORDER BY step (since btree 
indexes are already sorted). Will such an "upgrade-immune" C.UTF-8 index 
still work correctly for table lookups? And can the existing  
en_US.UTF-8 fields' definition be altered in place, without a 
dump+restore? en_US.UTF-8 is the default encoding+locale+collation, it 
isn't set explicitly for any of our string columns. I assume there's 
some "catch-all" ordering taking place even for the C locale, so there 
won't be any bizarre things like b coming before a, or generally for any 
language, the second letter of its alphabet coming before the first?


> If your applications care about that, it can be fixed by simply
> adding COLLATE "default" to the ORDER BY clause of the queries that
> are meant to present data to users.
> COLLATE "default" means the collation of the database, which
> presumably would be something like "language_REGION.UTF-8" in your
> case. If you never specified it explicitly, it came from initdb which
> itself got it from the environment of the server.
>
>
> Best regards,







view thread (12+ messages)  latest in thread

Message-ID: <352ac37a-39e6-5afe-d822-b4e031b9b314@mail.ru>
Permalink:  ../352ac37a-39e6-5afe-d822-b4e031b9b314@mail.ru/
Also on:    postgresql.org/message-id/352ac37a-39e6-5afe-d822-b4e031b9b314@mail.ru

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: rihad@mail.ru, daniel@manitou-mail.org, pg@bowt.ie
  Subject: Re: Upgrading locale issues
  In-Reply-To: <352ac37a-39e6-5afe-d822-b4e031b9b314@mail.ru>
  References: <f113b2da-eef3-4c55-b5f9-e60032603ee3@manitou-mail.org> <352ac37a-39e6-5afe-d822-b4e031b9b314@mail.ru>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox