Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oXyZ3-0003bw-6E for pgsql-hackers@arkaria.postgresql.org; Tue, 13 Sep 2022 05:34:29 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oXyZ1-0007y8-7y for pgsql-hackers@arkaria.postgresql.org; Tue, 13 Sep 2022 05:34:27 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oXyZ0-0007xz-OH for pgsql-hackers@lists.postgresql.org; Tue, 13 Sep 2022 05:34:26 +0000 Received: from mail.postgrespro.ru ([93.174.131.139]) by makus.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oXyYv-0008TD-4Q for pgsql-hackers@postgresql.org; Tue, 13 Sep 2022 05:34:25 +0000 Received: from mail.postgrespro.ru (cyclops.postgrespro.ru [93.174.131.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mail.postgrespro.ru (Postfix) with ESMTPSA id E088021C2BD1; Tue, 13 Sep 2022 08:34:16 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1663047257; bh=4sYSQcAp3i+dEKdA5IDcNKMdwivzPdOXLWWQa5RL98g=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=Sw7ZswzP+dbT8zwccfpZ0Z5dPygJJxwKRnCXhBktLm/Mbdjwyb5/tVK6l6420A0pP dAnpui/lItd6LEROXwK1je/Ovz9O9aUswsA1r0E3Cof7XDKwLNi7PH8rliQopNYotV Z89VofVJvJQ91vDAI+iWqDrUwo9CfPDZh5ZgpTMg= MIME-Version: 1.0 Date: Tue, 13 Sep 2022 08:34:16 +0300 From: Marina Polyakova To: Justin Pryzby Cc: pgsql-hackers@postgresql.org, Peter Eisentraut , Julien Rouhaud , Daniel Verite , AndrewBille@gmail.com, michael@paquier.xyz Subject: Re: ICU for global collation In-Reply-To: <20220909164625.GN31833@telsasoft.com> References: <20220628013205.GH19662@telsasoft.com> <7d74b2d7-7fc6-f55b-3f77-c0e05569b64e@enterprisedb.com> <7ad26354e75259f59c4a6c6997b8ee32@postgrespro.ru> <20220824085923.jro5ao2m5b4mdll5@jrouhaud> <13468bee-a5b4-65aa-932c-c12584f4458d@enterprisedb.com> <7c99c132dc9c0ac630e0127f032ac480@postgrespro.ru> <20220909164625.GN31833@telsasoft.com> User-Agent: Roundcube Webmail/1.4.11 Message-ID: <60facfef2a8d54b227500260e86d823e@postgrespro.ru> X-Sender: m.polyakova@postgrespro.ru Organization: Postgres Professional Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2022-09-09 19:46, Justin Pryzby wrote: > In pg14: > |postgres=# create database a LC_COLLATE C LC_CTYPE C LOCALE C; > |ERROR: conflicting or redundant options > |DETAIL: LOCALE cannot be specified together with LC_COLLATE or > LC_CTYPE. > > In pg15: > |postgres=# create database a LC_COLLATE "en_US.UTF-8" LC_CTYPE > "en_US.UTF-8" LOCALE "en_US.UTF-8" ; > |CREATE DATABASE > > f2553d430 actually relaxed the restriction by removing this check: > > - if (dlocale && (dcollate || dctype)) > - ereport(ERROR, > - (errcode(ERRCODE_SYNTAX_ERROR), > - errmsg("conflicting or redundant > options"), > - errdetail("LOCALE cannot be specified > together with LC_COLLATE or LC_CTYPE."))); > > But isn't the right fix to do the corresponding thing in createdb > (relaxing the frontend restriction rather than reverting its relaxation > in the backend). > > diff --git a/src/bin/scripts/createdb.c b/src/bin/scripts/createdb.c > index e523e58b218..5b80e56dfd9 100644 > --- a/src/bin/scripts/createdb.c > +++ b/src/bin/scripts/createdb.c > @@ -159,15 +159,10 @@ main(int argc, char *argv[]) > exit(1); > } > > - if (locale) > - { > - if (lc_ctype) > - pg_fatal("only one of --locale and --lc-ctype can be specified"); > - if (lc_collate) > - pg_fatal("only one of --locale and --lc-collate can be specified"); > + if (locale && !lc_ctype) > lc_ctype = locale; > + if (locale && !lc_collate) > lc_collate = locale; > - } > > if (encoding) > { I agree with you that it is more comfortable and more similar to what has already been done in initdb. IMO it would be easier to do it like this: diff --git a/src/bin/scripts/createdb.c b/src/bin/scripts/createdb.c index e523e58b2189275dc603a06324a2f28b0f49d8b7..a1482df3d981a680dd3322052e7c03ddacc8dc26 100644 --- a/src/bin/scripts/createdb.c +++ b/src/bin/scripts/createdb.c @@ -161,12 +161,10 @@ main(int argc, char *argv[]) if (locale) { - if (lc_ctype) - pg_fatal("only one of --locale and --lc-ctype can be specified"); - if (lc_collate) - pg_fatal("only one of --locale and --lc-collate can be specified"); - lc_ctype = locale; - lc_collate = locale; + if (!lc_ctype) + lc_ctype = locale; + if (!lc_collate) + lc_collate = locale; } if (encoding) Should we change the behaviour of createdb and CREATE DATABASE in previous major versions?.. > BTW it's somewhat crummy that it uses a string comparison, so if you > write "UTF8" without a dash, it says this; it took me a few minutes to > see the difference... > > postgres=# create database a LC_COLLATE "en_US.UTF8" LC_CTYPE > "en_US.UTF8" LOCALE "en_US.UTF8"; > ERROR: new collation (en_US.UTF8) is incompatible with the collation > of the template database (en_US.UTF-8) Perhaps we could check the locale itself with the function normalize_libc_locale_name (collationcmds.c). But ISTM that the current check is a safety net in case the function pg_get_encoding_from_locale (chklocale.c) returns -1 or PG_SQL_ASCII... -- Marina Polyakova Postgres Professional: http://www.postgrespro.com The Russian Postgres Company