pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jeff Davis <pgsql@j-davis.com>
To: Kyle Spearrin <kspearrin@bitwarden.com>
To: pgsql-bugs@lists.postgresql.org
Cc: Justin Baur <jbaur@bitwarden.com>
Cc: Vince Grassia <vgrassia@bitwarden.com>
Cc: Peter Eisentraut <peter@eisentraut.org>
Subject: Re: CREATE COLLATION without LOCALE throws error in v15
Date: Tue, 06 Dec 2022 15:57:19 -0800
Message-ID: <7b99b4a7fc5284008bae32b77a776d25b4a400bc.camel@j-davis.com> (raw)
In-Reply-To: <CALDQics_oBEYfOnu_zH6yw9WR1waPCmcrqxQ8+39hK3Op=z2UQ@mail.gmail.com>
References: <CALDQics_oBEYfOnu_zH6yw9WR1waPCmcrqxQ8+39hK3Op=z2UQ@mail.gmail.com>

On Fri, 2022-12-02 at 14:14 -0500, Kyle Spearrin wrote:
> However, in Postgres 15 we see the following error:
> 
> ERROR:  parameter "locale" must be specified

I agree that this is some kind of bug. The docs seem pretty clear[1]:

  "locale

    This is a shortcut for setting LC_COLLATE and LC_CTYPE
    at once. If you specify this, you cannot specify either
    of those parameters."

The error appears to come from commit f2553d4306 ("Add option to use
ICU as global locale provider"). My guess is that it was seen as
clearer to write LOCALE, and that the error wasn't expected to cause
anyone a problem. But, given that it's causing a problem for ORMs, we
should fix it.

Simple patch attached. I intend to commit and backpatch to 15 in the
next day or so.

Looking at the docs for CREATE COLLATION[1] and CREATE DATABASE[2], we
could probably do more to make this area consistent. But that's for
another discussion.

[1] https://www.postgresql.org/docs/devel/sql-createcollation.html
[2] https://www.postgresql.org/docs/devel/sql-createdatabase.html


-- 
Jeff Davis
PostgreSQL Contributor Team - AWS

Attachments:

v1-0001-Re-allow-creating-ICU-collation-if-LC_COLLATE-mat.patch (text/x-patch, 1.2K) download From db8851a4b6f38d3223a7229abc4d7a08737258b7 Mon Sep 17 00:00:00 2001 From: Jeff Davis <jeff@j-davis.com> Date: Tue, 6 Dec 2022 15:36:54 -0800 Subject: [PATCH v1] Re-allow creating ICU collation if LC_COLLATE matches LC_CTYPE. Commit f2553d4306 disallowed creating an ICU collation if LOCALE was not specified. Previously, this was allowed as long as LC_COLLATE and LC_CTYPE matched. Discussion: https://postgr.es/m/CALDQics_oBEYfOnu_zH6yw9WR1waPCmcrqxQ8+39hK3Op=z2UQ@mail.gmail.com Reported-by: Kyle Spearrin <kspearrin@bitwarden.com> Backpatch-through: 15 --- src/backend/commands/collationcmds.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/backend/commands/collationcmds.c b/src/backend/commands/collationcmds.c index 81e54e0ce6..4b2f1d2c15 100644 --- a/src/backend/commands/collationcmds.c +++ b/src/backend/commands/collationcmds.c @@ -240,6 +240,10 @@ DefineCollation(ParseState *pstate, List *names, List *parameters, bool if_not_e } else if (collprovider == COLLPROVIDER_ICU) { + if (!colliculocale && collcollate && collctype && + strcmp(collcollate, collctype) == 0) + colliculocale = collcollate; + if (!colliculocale) ereport(ERROR, (errcode(ERRCODE_INVALID_OBJECT_DEFINITION), -- 2.34.1

view thread (8+ messages)  latest in thread

Message-ID: <7b99b4a7fc5284008bae32b77a776d25b4a400bc.camel@j-davis.com>
Permalink:  ../7b99b4a7fc5284008bae32b77a776d25b4a400bc.camel@j-davis.com/
Also on:    postgresql.org/message-id/7b99b4a7fc5284008bae32b77a776d25b4a400bc.camel@j-davis.com

 ·  · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: pgsql@j-davis.com, kspearrin@bitwarden.com, pgsql-bugs@lists.postgresql.org, jbaur@bitwarden.com, vgrassia@bitwarden.com, peter@eisentraut.org
  Subject: Re: CREATE COLLATION without LOCALE throws error in v15
  In-Reply-To: <7b99b4a7fc5284008bae32b77a776d25b4a400bc.camel@j-davis.com>

* 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