Re: client_encoding issue with SQL_ASCII on 8.3 to 10 upgrade

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Keith Fiske <keith(dot)fiske(at)crunchydata(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: client_encoding issue with SQL_ASCII on 8.3 to 10 upgrade
Date: 2018-04-16 18:26:12
Message-ID: 997ca3e4-358f-ec9a-5757-526cc9c33ec5@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 04/16/2018 10:18 AM, Keith Fiske wrote:
>
>
> On Mon, Apr 16, 2018 at 12:21 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us
> <mailto:tgl(at)sss(dot)pgh(dot)pa(dot)us>> wrote:
>

>
> So playing around with the "client_encoding" configuration option in
> postgresql.conf. According to the docs, setting this should set the
> default encoding for any client that connects, right?
>
> https://www.postgresql.org/docs/10/static/runtime-config-client.html#GUC-CLIENT-ENCODING
> <https://www.postgresql.org/docs/10/static/runtime-config-client.html#GUC-CLIENT-ENCODING>
>
> That description also seems misleading in saying that the default client
> encoding is what the database encoding is as well. At least as far as
> psql is concerned, right? I've tried setting that value in
> postgresql.conf but psql keeps setting it to UTF8 when I connect to the
> SQL_ASCII database unless I then specifically run "set client_encoding =
> 'SQL_ASCII';"

Realized that while my previous suggestion of setting PGCLIENTENCODING
to 'SQL_ASCII' would work it would also affect libpq programs beside psql.

For a finer grained approach set \encoding 'SQL_ASCII' in a .psqlrc file.:

https://www.postgresql.org/docs/10/static/app-psql.html

"Files

psqlrc and ~/.psqlrc

Unless it is passed an -X option, psql attempts to read and execute
commands from the system-wide startup file (psqlrc) and then the user's
personal startup file (~/.psqlrc), after connecting to the database but
before accepting normal commands. These files can be used to set up the
client and/or the server to taste, typically with \set and SET commands.

The system-wide startup file is named psqlrc and is sought in the
installation's “system configuration” directory, which is most reliably
identified by running pg_config --sysconfdir. By default this directory
will be ../etc/ relative to the directory containing the PostgreSQL
executables. The name of this directory can be set explicitly via the
PGSYSCONFDIR environment variable.

The user's personal startup file is named .psqlrc and is sought in
the invoking user's home directory. On Windows, which lacks such a
concept, the personal startup file is named
%APPDATA%\postgresql\psqlrc.conf. The location of the user's startup
file can be set explicitly via the PSQLRC environment variable.

Both the system-wide startup file and the user's personal startup
file can be made psql-version-specific by appending a dash and the
PostgreSQL major or minor release number to the file name, for example
~/.psqlrc-9.2 or ~/.psqlrc-9.2.5. The most specific version-matching
file will be read in preference to a non-version-specific file.
"

>
> --
> Keith Fiske
> Senior Database Engineer
> Crunchy Data - http://crunchydata.com

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Bob Jones 2018-04-16 18:30:43 To prefer sorts or filters in postgres, that is the question....
Previous Message Adrian Klaver 2018-04-16 17:57:19 Re: client_encoding issue with SQL_ASCII on 8.3 to 10 upgrade