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

