NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Updating default PostgreSQL server encoding from SQL_ASCII to UTF8



Hi, everyone

I noticed that NetBSD 11 initializes postgreSQL cluster with SQL_ASCII as
the default encoding.

I think it would be good to use unicode UTF8 encoding by default.
Although we can always overwrite the encoding when creating a new db,
it's easy to forget and many times the SQL_ASCII encoding will take us
to trouble.

Just to test, I updated two lines in /etc/rc.d/pgsql

Added:
args_init="-o '--encoding=UTF8'"

and updated the line in pgsql_initdb()
from
#/usr/bin/su -m ${pgsql_user} -c "${command} init ${command_args}
to
/usr/bin/su -m ${pgsql_user} -c "${command} init ${command_args} ${args_init}"

BTW, I think the second "-p" in "/bin/mkdir -p -p ${pgsql_home}" of the
pgsql_initdb() is redundant.

What do you think? This is the output from the newly created cluster, defaulting to unicode.


tolstoy# /etc/rc.d/pgsql oneinitdb
Initializing PostgreSQL databases.
initdb: warning: enabling "trust" authentication for local connections
initdb: hint: You can change this by editing pg_hba.conf or using the option -A, or --auth-local and --auth-host, the next time you run initdb.
tolstoy# /etc/rc.d/pgsql onestart
Starting pgsql.
tolstoy# psql -U pgsql -l
                                             List of databases
   Name    | Owner | Encoding | Locale Provider | Collate | Ctype | Locale | ICU Rules | Access privileges 
-----------+-------+----------+-----------------+---------+-------+--------+-----------+-------------------
 postgres  | pgsql | UTF8     | libc            | C       | C     |        |           | 
 template0 | pgsql | UTF8     | libc            | C       | C     |        |           | =c/pgsql         +
           |       |          |                 |         |       |        |           | pgsql=CTc/pgsql
 template1 | pgsql | UTF8     | libc            | C       | C     |        |           | =c/pgsql         +
           |       |          |                 |         |       |        |           | pgsql=CTc/pgsql
(3 rows)



Home | Main Index | Thread Index | Old Index