From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Keith Fiske <keith.fiske@crunchydata.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: client_encoding issue with SQL_ASCII on 8.3 to 10 upgrade
Date: Mon, 16 Apr 2018 11:26:12 -0700
Message-ID: <997ca3e4-358f-ec9a-5757-526cc9c33ec5@aklaver.com> (raw)
In-Reply-To: <CAODZiv65fgA9jcOk0BcZDQXgrRmpKWb2AHnpq7LAvz9jGksB5A@mail.gmail.com>
References: <CAODZiv7K+AaJSPk=uqmNa7UQ2va7z_1d_KgVeZzEeqDNvgBn9g@mail.gmail.com>
<10581.1523894949@sss.pgh.pa.us>
<CAODZiv75hfwLbfH0BWKFdq6c5M5NjyhB+oexLWPDvpJuwBLmeg@mail.gmail.com>
<11209.1523895708@sss.pgh.pa.us>
<CAODZiv65fgA9jcOk0BcZDQXgrRmpKWb2AHnpq7LAvz9jGksB5A@mail.gmail.com>
On 04/16/2018 10:18 AM, Keith Fiske wrote:
>
>
> On Mon, Apr 16, 2018 at 12:21 PM, Tom Lane <tgl@sss.pgh.pa.us
> <mailto:tgl@sss.pgh.pa.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.klaver@aklaver.com
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: adrian.klaver@aklaver.com, keith.fiske@crunchydata.com, tgl@sss.pgh.pa.us
Subject: Re: client_encoding issue with SQL_ASCII on 8.3 to 10 upgrade
In-Reply-To: <997ca3e4-358f-ec9a-5757-526cc9c33ec5@aklaver.com>
References: <CAODZiv7K+AaJSPk=uqmNa7UQ2va7z_1d_KgVeZzEeqDNvgBn9g@mail.gmail.com> <10581.1523894949@sss.pgh.pa.us> <CAODZiv75hfwLbfH0BWKFdq6c5M5NjyhB+oexLWPDvpJuwBLmeg@mail.gmail.com> <11209.1523895708@sss.pgh.pa.us> <CAODZiv65fgA9jcOk0BcZDQXgrRmpKWb2AHnpq7LAvz9jGksB5A@mail.gmail.com> <997ca3e4-358f-ec9a-5757-526cc9c33ec5@aklaver.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox