Hi,
The 'locale' or 'lc_collate/lc_ctype' argument of an ICU collation may
have a complicated syntax, especially with non-deterministic
collations, and input mistakes in these names will not necessarily be
detected as such by ICU.
The "display name" of a locale is a simple way to get human-readable
feedback about the characteristics of that locale.
pg_import_system_collations() already push these as comments when
creating locales en masse.
I think it would be nice to have CREATE COLLATION report this
information as feedback in the form of a NOTICE message.
PFA a simple patch implementing that.
Best regards,
--
Daniel Vérité
PostgreSQL-powered mailer: http://www.manitou-mail.org
Twitter: @DanielVerite
diff --git a/src/backend/commands/collationcmds.c
b/src/backend/commands/collationcmds.c
index 919e092483..ad011d149c 100644
--- a/src/backend/commands/collationcmds.c
+++ b/src/backend/commands/collationcmds.c
@@ -36,6 +36,10 @@
#include "utils/syscache.h"
+#ifdef USE_ICU
+static char *get_icu_locale_comment(const char *localename);
+#endif
+
typedef struct
{
char *localename; /* name of locale, as per "locale -a" */
@@ -232,6 +236,16 @@ DefineCollation(ParseState *pstate, List *names, List
*parameters, bool if_not_e
if (!OidIsValid(newoid))
return InvalidObjectAddress;
+#ifdef USE_ICU
+ if (collprovider == COLLPROVIDER_ICU)
+ {
+ char *display_name = get_icu_locale_comment(collcollate);
+ if (display_name != NULL)
+ ereport(NOTICE,
+ (errmsg("ICU locale: \"%s\"",
display_name)));
+ }
+#endif
+
/*
* Check that the locales can be loaded. NB:
pg_newlocale_from_collation
* is only supposed to be called on non-C-equivalent locales.