From 30a53b792959b36f07200dae246067b3adbcc0b9 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Wed, 8 Mar 2023 16:35:42 +0100 Subject: Allow tailoring of ICU locales with custom rules This exposes the ICU facility to add custom collation rules to a standard collation. New options are added to CREATE COLLATION, CREATE DATABASE, createdb, and initdb to set the rules. Reviewed-by: Laurenz Albe Reviewed-by: Daniel Verite Discussion: https://www.postgresql.org/message-id/flat/821c71a4-6ef0-d366-9acf-bb8e367f739f@enterprisedb.com --- src/bin/scripts/createdb.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/bin/scripts/createdb.c') diff --git a/src/bin/scripts/createdb.c b/src/bin/scripts/createdb.c index 80859dadc4d..b4205c4fa51 100644 --- a/src/bin/scripts/createdb.c +++ b/src/bin/scripts/createdb.c @@ -41,6 +41,7 @@ main(int argc, char *argv[]) {"maintenance-db", required_argument, NULL, 3}, {"locale-provider", required_argument, NULL, 4}, {"icu-locale", required_argument, NULL, 5}, + {"icu-rules", required_argument, NULL, 6}, {NULL, 0, NULL, 0} }; @@ -67,6 +68,7 @@ main(int argc, char *argv[]) char *locale = NULL; char *locale_provider = NULL; char *icu_locale = NULL; + char *icu_rules = NULL; PQExpBufferData sql; @@ -134,6 +136,9 @@ main(int argc, char *argv[]) case 5: icu_locale = pg_strdup(optarg); break; + case 6: + icu_rules = pg_strdup(optarg); + break; default: /* getopt_long already emitted a complaint */ pg_log_error_hint("Try \"%s --help\" for more information.", progname); @@ -231,6 +236,11 @@ main(int argc, char *argv[]) appendPQExpBufferStr(&sql, " ICU_LOCALE "); appendStringLiteralConn(&sql, icu_locale, conn); } + if (icu_rules) + { + appendPQExpBufferStr(&sql, " ICU_RULES "); + appendStringLiteralConn(&sql, icu_rules, conn); + } appendPQExpBufferChar(&sql, ';'); @@ -288,6 +298,7 @@ help(const char *progname) printf(_(" --lc-collate=LOCALE LC_COLLATE setting for the database\n")); printf(_(" --lc-ctype=LOCALE LC_CTYPE setting for the database\n")); printf(_(" --icu-locale=LOCALE ICU locale setting for the database\n")); + printf(_(" --icu-rules=RULES ICU rules setting for the database\n")); printf(_(" --locale-provider={libc|icu}\n" " locale provider for the database's default collation\n")); printf(_(" -O, --owner=OWNER database user to own the new database\n")); -- cgit v1.2.3