diff options
| author | Peter Eisentraut | 2022-03-20 09:21:45 +0000 |
|---|---|---|
| committer | Peter Eisentraut | 2022-03-20 09:21:45 +0000 |
| commit | 3a671e1f7cb8b29ad77b08f891b8f22621f490a3 (patch) | |
| tree | cbf5c62be3c78836a8d50c81994ab3a740fb0d45 /src/bin | |
| parent | 3c0c5cc5e65906bad6abe6bb8c2d9f6669870f33 (diff) | |
Fix global ICU collations for ICU < 54
createdb() didn't check for collation attributes validity, which has
to be done explicitly on ICU < 54. It also forgot to close the ICU collator
opened during the check which leaks some memory.
To fix both, add a new check_icu_locale() that does all the appropriate
verification and close the ICU collator.
initdb also had some partial check for ICU < 54. To have consistent error
reporting across major ICU versions, and get rid of the need to include ucol.h,
remove the partial check there. The backend will report an error if needed
during the post-boostrap iniitialization phase.
Author: Julien Rouhaud <[email protected]>
Discussion: https://www.postgresql.org/message-id/20220319041459.qqqiqh335sga5ezj@jrouhaud
Diffstat (limited to 'src/bin')
| -rw-r--r-- | src/bin/initdb/Makefile | 2 | ||||
| -rw-r--r-- | src/bin/initdb/initdb.c | 22 | ||||
| -rw-r--r-- | src/bin/initdb/t/001_initdb.pl | 2 |
3 files changed, 5 insertions, 21 deletions
diff --git a/src/bin/initdb/Makefile b/src/bin/initdb/Makefile index 8dd25e7afc6..b0dd13dfbdf 100644 --- a/src/bin/initdb/Makefile +++ b/src/bin/initdb/Makefile @@ -40,7 +40,7 @@ OBJS = \ all: initdb initdb: $(OBJS) | submake-libpq submake-libpgport submake-libpgfeutils - $(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) $(ICU_LIBS) -o $@$(X) + $(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X) # We must pull in localtime.c from src/timezones localtime.c: % : $(top_srcdir)/src/timezone/% diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c index cbcd55288f2..5e36943ef3b 100644 --- a/src/bin/initdb/initdb.c +++ b/src/bin/initdb/initdb.c @@ -55,10 +55,6 @@ #include <signal.h> #include <time.h> -#ifdef USE_ICU -#include <unicode/ucol.h> -#endif - #ifdef HAVE_SHM_OPEN #include "sys/mman.h" #endif @@ -2205,22 +2201,10 @@ setlocales(void) } /* - * Check ICU locale ID + * In supported builds, the ICU locale ID will be checked by the + * backend when performing the post-boostrap initialization. */ -#ifdef USE_ICU - { - UErrorCode status; - - status = U_ZERO_ERROR; - ucol_open(icu_locale, &status); - if (U_FAILURE(status)) - { - pg_log_error("could not open collator for locale \"%s\": %s", - icu_locale, u_errorName(status)); - exit(1); - } - } -#else +#ifndef USE_ICU pg_log_error("ICU is not supported in this build"); fprintf(stderr, _("You need to rebuild PostgreSQL using %s.\n"), "--with-icu"); exit(1); diff --git a/src/bin/initdb/t/001_initdb.pl b/src/bin/initdb/t/001_initdb.pl index c636bf3ab2c..a3397777cf2 100644 --- a/src/bin/initdb/t/001_initdb.pl +++ b/src/bin/initdb/t/001_initdb.pl @@ -105,7 +105,7 @@ if ($ENV{with_icu} eq 'yes') 'option --icu-locale'); command_fails_like(['initdb', '--no-sync', '--locale-provider=icu', '--icu-locale=@colNumeric=lower', "$tempdir/dataX"], - qr/initdb: error: could not open collator for locale/, + qr/FATAL: could not open collator for locale/, 'fails for invalid ICU locale'); } else |
