Postgres – Check ICU Libraries Availability for Postgres 10+

international-components-unicodepostgresqlpostgresql-10

I wonder if my installation of Postgres 10 Beta 2 has been built to include the new International Components for Unicode (ICU) collations. For background info, see More robust collations with ICU support in PostgreSQL 10 by Peter Eisentraut.

I used the pg_config utility to detect the build info. When running pg_config --configure I get output where the last line is 'ICU_LIBS=-L/opt/local/Current/lib -licuuc -licudata -licui18n'.

➠ Does this mean I have the ICU libraries installed, or not?

/Library/PostgreSQL/10Beta2/bin/pg_config –configure

'–with-icu' '–prefix=/mnt/hgfs/pginstaller.pune/server/staging_cache/osx' '–with-ldap' '–with-openssl' '–with-perl' '–with-python' '–with-tcl' '–with-bonjour' '–with-pam' '–enable-thread-safety' '–with-libxml' '–with-uuid=e2fs' '–with-includes=/opt/local/Current/include/libxml2:/opt/local/Current/include:/opt/local/Current/include/security' '–docdir=/mnt/hgfs/pginstaller.pune/server/staging_cache/osx/doc/postgresql' '–with-libxslt' '–with-libedit-preferred' '–with-gssapi' 'CFLAGS=-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk -mmacosx-version-min=10.8 -arch i386 -arch x86_64 -O2' 'LDFLAGS=-L/opt/local/Current/lib' 'ICU_CFLAGS=-I/opt/local/Current/include' 'ICU_LIBS=-L/opt/local/Current/lib -licuuc -licudata -licui18n'

➠ Is there another way to detect if my Postgres has the ICU collations available? Some way via SQL?

When I execute SELECT * FROM pg_collation ;, of the 845 locale names listed, 575 end in -x-icu. Does that happen only if the ICU libraries are in place?

Best Answer

Does this mean I have the ICU libraries installed, or not?

The configure option that really brings in the library is --with-icu. Currently, checking for this one seems the more reliable way to tell whether ICU has been included in the build.

ICU_CFLAGS and ICU_LIBS are paths that are required only if the library is installed where the compiler does not search by default.

Does that happen only if the ICU libraries are in place?

It does, but pg_collation also has a new collprovider field indicating that a collation is from ICU (i) or the libc (c)