Comment puis-je changer la valeur par défaut client_encoding dans Postgres?

Je suis en train de modifier la valeur par défaut pour le client_encoding variable de configuration pour une base de données PostgreSQL, je suis en cours d'exécution. Je veux qu'il soit UTF8, mais actuellement c'est à LATIN1.

La base de données est déjà configuré pour utiliser l'encodage UTF8:

application_database=# \l
                                                 List of databases
           Name       |  Owner   | Encoding |   Collate   |    Ctype    |          Access privileges
----------------------+----------+----------+-------------+-------------+--------------------------------------
 postgres             | postgres | LATIN1   | en_US       | en_US       |
 application_database | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | postgres=CTc/postgres           +
                      |          |          |             |             | application_database=Tc/postgres
 template0            | postgres | LATIN1   | en_US       | en_US       | =c/postgres                     +
                      |          |          |             |             | postgres=CTc/postgres
 template1            | postgres | LATIN1   | en_US       | en_US       | =c/postgres                     +
                      |          |          |             |             | postgres=CTc/postgres
(4 rows)

Qui selon les docs devrait déjà amener le client à utiliser UTF8 par défaut client_encoding (l'emphase est mienne):

client_encoding (string)

Définit le côté client de l'encodage (jeu de caractères). La valeur par défaut est d'utiliser la base de données de codage.

Mais il n'a pas d':

$ sudo psql --dbname=application_database
psql (9.1.19)
Type "help" for help.

application_database=# SHOW client_encoding;
 client_encoding
-----------------
 LATIN1
(1 row)

J'ai même essayé d'utiliser ALTER USER <user> SET ... pour modifier la configuration par défaut pour l'utilisateur que je suis connecter en tant que:

application_database=# ALTER USER root SET client_encoding='UTF8';
ALTER ROLE
application_database=# SELECT usename, useconfig FROM pg_shadow;
         usename      |       useconfig
----------------------+------------------------
 postgres             |
 root                 | {client_encoding=UTF8}
 application_database |
(3 rows)

Mais qui a également eu aucun effet:

$ sudo psql --dbname=application_database
psql (9.1.19)
Type "help" for help.

application_database=# SELECT current_user;
 current_user
--------------
 root
(1 row)

application_database=# SHOW client_encoding;
 client_encoding
-----------------
 LATIN1
(1 row)

Il n'y a rien dans le PSQL les fichiers sur mon système:

vagrant@app-database:~$ cat ~/.psqlrc
cat: /home/vagrant/.psqlrc: No such file or directory
vagrant@app-database:~$ cat /etc/psqlrc
cat: /etc/psqlrc: No such file or directory
vagrant@app-database:~$ sudo su
root@app-database:/home/vagrant# cat ~/.psqlrc
cat: /root/.psqlrc: No such file or directory

Je suis en cours d'exécution PosgreSQL 9.1:

application_database=# SELECT version();
                                                   version
-------------------------------------------------------------------------------------------------------------
 PostgreSQL 9.1.19 on x86_64-unknown-linux-gnu, compiled by gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3, 64-bit
(1 row)

OriginalL'auteur Ajedi32 | 2016-04-28