From 33dfca7cad44e48a8d003e9103af4814c9a86d37 Mon Sep 17 00:00:00 2001 From: Andy Pfister Date: Fri, 27 Sep 2024 13:28:44 +0200 Subject: [PATCH] Remove `lc_collate` and `lc_type` --- docker-entrypoint.sh | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 75fccc5..01aa5a8 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -504,10 +504,20 @@ _main() { local COLLATE=unset local CTYPE=unset local ENCODING=unset - COLLATE=$(echo 'SHOW LC_COLLATE' | "${OLDPATH}/bin/postgres" --single -D "${OLD}" "${POSTGRES_DB}" | grep 'lc_collate = "' | cut -d '"' -f 2) - CTYPE=$(echo 'SHOW LC_CTYPE' | "${OLDPATH}/bin/postgres" --single -D "${OLD}" "${POSTGRES_DB}" | grep 'lc_ctype = "' | cut -d '"' -f 2) + ENCODING=$(echo 'SHOW SERVER_ENCODING' | "${OLDPATH}/bin/postgres" --single -D "${OLD}" "${POSTGRES_DB}" | grep 'server_encoding = "' | cut -d '"' -f 2) - POSTGRES_INITDB_ARGS="--locale=${COLLATE} --lc-collate=${COLLATE} --lc-ctype=${CTYPE} --encoding=${ENCODING}" + + # LC_COLLATE and LC_TYPE have been removed with PG v16 + # https://www.postgresql.org/docs/release/16.0/ + if [ "${PGVER}" -lt 16 ]; then + COLLATE=$(echo 'SHOW LC_COLLATE' | "${OLDPATH}/bin/postgres" --single -D "${OLD}" "${POSTGRES_DB}" | grep 'lc_collate = "' | cut -d '"' -f 2) + CTYPE=$(echo 'SHOW LC_CTYPE' | "${OLDPATH}/bin/postgres" --single -D "${OLD}" "${POSTGRES_DB}" | grep 'lc_ctype = "' | cut -d '"' -f 2) + + POSTGRES_INITDB_ARGS="--locale=${COLLATE} --lc-collate=${COLLATE} --lc-ctype=${CTYPE} --encoding=${ENCODING}" + else + POSTGRES_INITDB_ARGS="--encoding=${ENCODING}" + fi + echo "---------------------------------------------------------------" echo "The initdb arguments we determined are: ${POSTGRES_INITDB_ARGS}" echo "---------------------------------------------------------------"