Disallow specifying ICU rules unless locale provider is ICU
authorPeter Eisentraut <peter@eisentraut.org>
Thu, 9 Mar 2023 07:09:40 +0000 (08:09 +0100)
committerPeter Eisentraut <peter@eisentraut.org>
Thu, 9 Mar 2023 07:09:40 +0000 (08:09 +0100)
Follow-up for 30a53b7929; this was not checked in all cases.

Reported-by: Jeff Davis <pgsql@j-davis.com>
src/backend/commands/collationcmds.c
src/backend/commands/dbcommands.c

index c51e3afdb4c82cd0e82ceb1e129aa3cc23085087..8949684afe1ef7161d5840a756083774b0c0152c 100644 (file)
@@ -271,6 +271,11 @@ DefineCollation(ParseState *pstate, List *names, List *parameters, bool if_not_e
                                        (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                                         errmsg("nondeterministic collations not supported with this provider")));
 
+               if (collicurules && collprovider != COLLPROVIDER_ICU)
+                       ereport(ERROR,
+                                       (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
+                                        errmsg("ICU rules cannot be specified unless locale provider is ICU")));
+
                if (collprovider == COLLPROVIDER_ICU)
                {
 #ifdef USE_ICU
index 7063a5a7ed501755f49c686d2b2421fda0df01e7..4d5d5d686667d1f1ffdfd308996d889eaddaefc9 100644 (file)
@@ -1066,6 +1066,11 @@ createdb(ParseState *pstate, const CreatedbStmt *stmt)
                        ereport(ERROR,
                                        (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
                                         errmsg("ICU locale cannot be specified unless locale provider is ICU")));
+
+               if (dbicurules)
+                       ereport(ERROR,
+                                       (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
+                                        errmsg("ICU rules cannot be specified unless locale provider is ICU")));
        }
 
        /*