Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 541e601

Browse files
committed
Add support for locale and encoding, fix #406
1 parent 83c71ac commit 541e601

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

‎src/root/usr/share/container-scripts/postgresql/README.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,13 @@ initialization by passing `-e VAR=VALUE` to the Docker run command.
7474
**`POSTGRESQL_ADMIN_PASSWORD`**
7575
Password for the `postgres` admin account (optional)
7676

77+
The following environment variables are optional, and only used when the database is initialzed
78+
79+
**`POSTGRESQL_ENCODING`**
80+
Database encoding. Default to utf8
81+
82+
**`POSTGRESQL_LOCALE`**
83+
Database locale. Default to en_US
7784

7885
Alternatively, the following options are related to migration scenario:
7986

‎src/root/usr/share/container-scripts/postgresql/common.sh‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,9 @@ initdb_wrapper ()
190190
# Initialize the database cluster with utf8 support enabled by default.
191191
# This might affect performance, see:
192192
# http://www.postgresql.org/docs/{{ spec.version }}/static/locale.html
193-
LANG=${LANG:-en_US.utf8} "$@"
193+
ENCODING=${POSTGRESQL_ENCODING:-utf8}
194+
LOCALE=${POSTGRESQL_LOCALE:-en_US}
195+
LANG=${LANG:-$LOCALE.$ENCODING} "$@"
194196
}
195197

196198
function initialize_database() {

‎test/run_test‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ run_s2i_enable_ssl_test
2929
run_upgrade_test
3030
run_migration_test
3131
run_pgaudit_test
32+
run_locales_test
3233
"
3334

3435
test $# -eq 1 -a "${1-}" == --list && echo "$TEST_LIST" && exit 0
@@ -898,6 +899,22 @@ EOSQL"
898899
grep -E 'AUDIT: SESSION,.*,.*,READ,SELECT,,,SELECT' "${data_dir}"/userdata/log/postgresql-*.log
899900
}
900901

902+
function run_locales_test() {
903+
local name=pg-test-locales
904+
DOCKER_ARGS="-e POSTGRESQL_ENCODING=ISO_8859_6 -e POSTGRESQL_LOCALE=C" create_container $name
905+
wait_ready "$name"
906+
907+
docker exec -i $(get_cid "$name") bash -c "psql <<EOSQL
908+
SHOW SERVER_ENCODING;
909+
EOSQL" | grep ISO_8859_6
910+
911+
docker exec -i $(get_cid "$name") bash -c "psql <<EOSQL
912+
SHOW SHOW LC_COLLATE;
913+
EOSQL" | grep -vi LC_COLLA | grep C
914+
915+
docker stop "$(get_cid "$name")"
916+
}
917+
901918
function run_all_tests() {
902919
for test_case in $TEST_LIST; do
903920
: "Running test $test_case"

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /