Skip to content

Commit

Permalink
Remove lc_collate and lc_type
Browse files Browse the repository at this point in the history
  • Loading branch information
andyundso committed Sep 27, 2024
1 parent adf293f commit 33dfca7
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 "---------------------------------------------------------------"
Expand Down

0 comments on commit 33dfca7

Please sign in to comment.