Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iADDr-0004fd-N7 for pgsql-hackers@arkaria.postgresql.org; Tue, 17 Sep 2019 13:08:47 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iADDq-00053V-Bi for pgsql-hackers@arkaria.postgresql.org; Tue, 17 Sep 2019 13:08:46 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iADDp-00053M-W8 for pgsql-hackers@lists.postgresql.org; Tue, 17 Sep 2019 13:08:46 +0000 Received: from mail.verite.pro ([185.16.44.216]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1iADDm-0005sN-EW for pgsql-hackers@postgresql.org; Tue, 17 Sep 2019 13:08:44 +0000 Received: from genius-map.net (verite.pro [195.154.189.246]) by mail.verite.pro (Postfix) with ESMTP id B22E38C0021; Tue, 17 Sep 2019 15:02:05 +0200 (CEST) Received: by genius-map.net (Postfix, from userid 1001) id 2D8F038A178F; Tue, 17 Sep 2019 15:08:38 +0200 (CEST) Content-Type: text/plain; charset="iso-8859-15" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: ICU for global collation From: "Daniel Verite" To: "Peter Eisentraut" Cc: "pgsql-hackers" In-Reply-To: <5e756dd6-0e91-d778-96fd-b1bcb06c161a@2ndquadrant.com> Date: Tue, 17 Sep 2019 15:08:36 +0200 Message-Id: <5d807706-60a2-4e56-bc59-eef9e7deb138@manitou-mail.org> X-Mailer: Manitou v1.7.3 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi, When trying databases defined with ICU locales, I see that backends that serve such databases seem to have their LC_CTYPE inherited from the environment (as opposed to a per-database fixed value). That's a problem for the backend code that depends on libc functions that themselves depend on LC_CTYPE, such as the full text search parser and dictionaries. For instance, if you start the instance with a C locale (LC_ALL=3DC pg_ctl...) , and tries to use FTS in an ICU UTF-8 database, it doesn't work: template1=3D# create database "fr-utf8"=20 template 'template0' encoding UTF8 locale 'fr' collation_provider 'icu'; template1=3D# \c fr-utf8 You are now connected to database "fr-utf8" as user "daniel". fr-utf8=3D# show lc_ctype; lc_ctype=20 ---------- fr (1 row) fr-utf8=3D# select to_tsvector('=E9t=E9'); ERROR: invalid multibyte character for locale HINT: The server's LC_CTYPE locale is probably incompatible with the database encoding. If I peek into the "real" LC_CTYPE when connected to this database, I can see it's "C": fr-utf8=3D# create extension plperl; CREATE EXTENSION fr-utf8=3D# create function lc_ctype() returns text as '$ENV{LC_CTYPE};' language plperl; CREATE FUNCTION fr-utf8=3D# select lc_ctype(); lc_ctype=20 ---------- C Best regards, --=20 Daniel V=E9rit=E9 PostgreSQL-powered mailer: http://www.manitou-mail.org Twitter: @DanielVerite