Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bhISr-0004qg-3a for pgsql-hackers@arkaria.postgresql.org; Tue, 06 Sep 2016 15:39:09 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bhISq-0007l1-HD for pgsql-hackers@arkaria.postgresql.org; Tue, 06 Sep 2016 15:39:08 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bhIRT-0006AQ-5y for pgsql-hackers@postgresql.org; Tue, 06 Sep 2016 15:37:43 +0000 Received: from out4-smtp.messagingengine.com ([66.111.4.28]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bhIRP-0001WX-Jn for pgsql-hackers@postgresql.org; Tue, 06 Sep 2016 15:37:42 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id 3868B2076A; Tue, 6 Sep 2016 11:37:38 -0400 (EDT) Received: from frontend1 ([10.202.2.160]) by compute2.internal (MEProxy); Tue, 06 Sep 2016 11:37:38 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=czSQl+PK/R/Kb6X k3lnN/j/nCNI=; b=XDBNZFfct0sm4PcfBV1bpXnDWE0QQ72Xy4qvoLf8xg2ghIv ZNwOhFwMFJ7JTDNKZKJabyHgCPFIQGDSThbwq++ZFdJxohbxc72XCM5q1rSszhQ8 5EEY9ff7aqOpAzKZ1dYv/ttJjFVTHSngd0mIfdT9AhlSj78I8TREfPgyL8Sg= X-Sasl-enc: WoTF5QGQkj2yJlL+N1Z66Yz+LQquSzSW6X3IjMDkFQL0 1473176257 Received: from april.local (c-73-13-66-39.hsd1.pa.comcast.net [73.13.66.39]) by mail.messagingengine.com (Postfix) with ESMTPA id C4360F29D9; Tue, 6 Sep 2016 11:37:37 -0400 (EDT) Subject: Re: ICU integration To: Doug Doole References: <85364fde-091f-bbc0-fec2-e3ede39840a6@2ndquadrant.com> <51759C7D-BE9E-4173-B5F9-EFD7B9594C2B@salesforce.com> Cc: Craig Ringer , pgsql-hackers From: Peter Eisentraut Organization: 2ndQuadrant Message-ID: Date: Tue, 6 Sep 2016 11:37:37 -0400 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 In-Reply-To: <51759C7D-BE9E-4173-B5F9-EFD7B9594C2B@salesforce.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org On 8/31/16 4:24 PM, Doug Doole wrote: > ICU explicitly does not provide stability in their locales and collations. We pushed them hard to provide this, but between changes to the CLDR data and changes to the ICU code it just wasn’t feasible for them to provide version to version stability. > > What they do offer is a compile option when building ICU to version all their APIs. So instead of calling icu_foo() you’d call icu_foo46(). (Or something like this - it’s been a few years since I actually worked with the ICU code.) This ultimately allows you to load multiple versions of the ICU library into a single program and provide stability by calling the appropriate version of the library. (Unfortunately, the OS - at least my Linux box - only provides the generic version of ICU and not the version annotated APIs, which means a separate compile of ICU is needed.) > > The catch with this is that it means you likely want to expose the version information. In another note it was suggested to use something like fr_FR%icu. If you want to pin it to a specific version of ICU, you’ll likely need something like fr_FR%icu46. (There’s nothing wrong with supporting fr_FR%icu to give users an easy way of saying “give me the latest and greatest”, but you’d probably want to harden it to a specific ICU version internally.) There are multiple things going on. Collations in ICU are versioned. You can find out the version of the collation you are currently using using an API call. A collation version does not change during the life of a single version of ICU. But it might well change in the next version of ICU, as bugs are fixed and things are refined. There is no way in the API to call for a collation of a specific version, since there is only one version of a collation in a specific installation of ICU. So my implementation is that we store the version of the collation in the catalog when we create the collation, and if we later on find at run time that the collation is of a different version, we warn about it. The ICU ABI (not API) is also versioned. The way that this is done is that all functions are actually macros to a versioned symbol. So ucol_open() is actually a macro that expands to, say, ucol_open_57() in ICU version 57. (They also got rid of a dot in their versions a while ago.) It's basically hand-crafted symbol versioning. That way, you can link with multiple versions of ICU at the same time. However, the purpose of that, as I understand it, is so that plugins can have a different version of ICU loaded than the main process or another plugin. In terms of postgres using the right version of ICU, it doesn't buy anything beyond what the soname mechanism does. >> + if (numversion != collform->collversion) >> + ereport(WARNING, >> + (errmsg("ICU collator version mismatch"), >> + errdetail("The database was created using >> version 0x%08X, the library provides version 0x%08X.", >> + (uint32) collform->collversion, >> (uint32) numversion), >> + errhint("Rebuild affected indexes, or build >> PostgreSQL with the right version of ICU."))); >> >> So you still need to manage this carefully, but at least you have a >> chance to learn about it. > > Indexes are the obvious place where collation comes into play, and are relatively easy to address. But consider all the places where string comparisons can be done. For example, check constraints and referential constraints can depend on string comparisons. If the collation rules change because of a new version of ICU, the database can become inconsistent and will need a lot more work than an index rebuild. We can refine the guidance. But indexes are the most important issue, I think, because changing the sorting rules in the background makes data silently disappear. -- Peter Eisentraut http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers