Package: dbconfig-pgsql Severity: normal Tags: patch Dear Maintainer,
PostgreSQL "CREATE DATABASE" support parameter. While setting the ENCODING is already implemented with dbconfig, setting LC_COLLATE and LC_CTYPE is not. Unfortenatly, these parameter have to be specified on creation. They can't be changed afterwards. The Bareos project (https://github.com/bareos/bareos) uses dbconfig, and their databases should use LC_COLLATE=C and LC_CTYPE=C. -- System Information: Debian Release: bullseye/sid APT prefers focal-updates APT policy: (500, 'focal-updates'), (500, 'focal-security'), (500, 'focal'), (100, 'focal-backports') Architecture: amd64 (x86_64) Foreign Architectures: i386 Kernel: Linux 5.4.0-90-generic (SMP w/8 CPU cores) Kernel taint flags: TAINT_CRAP, TAINT_OOT_MODULE, TAINT_UNSIGNED_MODULE Locale: LANG=de_DE.UTF-8, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8), LANGUAGE=de_DE.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Init: systemd (via /run/systemd/system) LSM: AppArmor: enabled Versions of packages dbconfig-pgsql depends on: pn dbconfig-common <none> ii postgresql-client-12 [postgresql-client] 12.9-0ubuntu0.20.04.1 dbconfig-pgsql recommends no packages. Versions of packages dbconfig-pgsql suggests: ii postgresql 12+214ubuntu0.1
>From 7662ce565795b33b710988fe4907b76afab13e48 Mon Sep 17 00:00:00 2001 From: Joerg Steffens <joerg.steff...@dass-it.de> Date: Thu, 16 Dec 2021 19:13:18 +0100 Subject: [PATCH] pgsql: add support for LC_COLLATE and LC_CTYPE CREATE DATABASE offers the parameter ENCODING, LC_COLLATE and LC_CTYPE. While ENCODING can already be specified with dbc_pgsql_createdb_encoding this patch adds the option to set LC_COLLATE by dbc_pgsql_createdb_collate and/or LC_CTYPE by dbc_pgsql_createdb_ctype --- examples/db-test-pgsql-2.2/debian/postinst | 5 ++++- internal/pgsql | 14 +++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/examples/db-test-pgsql-2.2/debian/postinst b/examples/db-test-pgsql-2.2/debian/postinst index e372167..6b19283 100644 --- a/examples/db-test-pgsql-2.2/debian/postinst +++ b/examples/db-test-pgsql-2.2/debian/postinst @@ -6,8 +6,11 @@ set -e . /usr/share/debconf/confmodule . /usr/share/dbconfig-common/dpkg/postinst.pgsql -# you can set the default database encoding to something else +# you can overwrite the default database encoding, LC_COLLATE and LC_CTYPE dbc_pgsql_createdb_encoding="UTF8" +dbc_pgsql_createdb_collate="C" +dbc_pgsql_createdb_ctype="C" + dbc_sql_substitutions="yes" dbc_go db-test-pgsql "$@" diff --git a/internal/pgsql b/internal/pgsql index d4b2d4a..c695191 100644 --- a/internal/pgsql +++ b/internal/pgsql @@ -114,9 +114,17 @@ _dbc_createdb(){ retval=0 if [ "${dbc_ssl:-}" ]; then PGSSLMODE="require"; fi extra=$(_dbc_psql_cmd_args) - if [ "${dbc_pgsql_createdb_encoding:-}" ]; then - extrasql=" WITH TEMPLATE = \"template0\""; - extrasql="$extrasql ENCODING = '$dbc_pgsql_createdb_encoding'"; + if [ "${dbc_pgsql_createdb_encoding:-}" -o "${dbc_pgsql_createdb_collate:-}" -o "${dbc_pgsql_createdb_ctype:-}" ]; then + extrasql=" WITH TEMPLATE = \"template0\"" + if [ "${dbc_pgsql_createdb_encoding:-}" ]; then + extrasql="$extrasql ENCODING = '$dbc_pgsql_createdb_encoding'" + fi + if [ "${dbc_pgsql_createdb_collate:-}" ]; then + extrasql="$extrasql LC_COLLATE = '$dbc_pgsql_createdb_collate'" + fi + if [ "${dbc_pgsql_createdb_ctype:-}" ]; then + extrasql="$extrasql LC_CTYPE = '$dbc_pgsql_createdb_ctype'" + fi fi _dbc_nodb="yes" _dbc_pgsql_exec_command "CREATE DATABASE \"$dbc_dbname\"${extrasql:-}" -- 2.25.1