summaryrefslogtreecommitdiff
path: root/doc/src
diff options
context:
space:
mode:
authorPeter Eisentraut <peter_e@gmx.net>2011-02-19 08:54:58 +0200
committerPeter Eisentraut <peter_e@gmx.net>2011-02-19 08:54:58 +0200
commit02e14562a806a96f38120c96421d39dfa7394192 (patch)
treec2bdedb7a4646fe07b3b6ac49ccf50591075a920 /doc/src
parent327e0250716f12fe94b62669d25e572b40a8fba5 (diff)
Set psql client encoding from locale by default
Add a new libpq connection option client_encoding (which includes the existing PGCLIENTENCODING environment variable), which besides an encoding name accepts a special value "auto" that tries to determine the encoding from the locale in the client's environment, using the mechanisms that have been in use in initdb. psql sets this new connection option to "auto" when running from a terminal and not overridden by setting PGCLIENTENCODING. original code by Heikki Linnakangas, with subsequent contributions by Jaime Casanova, Peter Eisentraut, Stephen Frost, Ibrar Ahmed
Diffstat (limited to 'doc/src')
-rw-r--r--doc/src/sgml/libpq.sgml36
-rw-r--r--doc/src/sgml/ref/psql-ref.sgml11
2 files changed, 36 insertions, 11 deletions
diff --git a/doc/src/sgml/libpq.sgml b/doc/src/sgml/libpq.sgml
index 2d15e78fd08..49edc51dbac 100644
--- a/doc/src/sgml/libpq.sgml
+++ b/doc/src/sgml/libpq.sgml
@@ -259,6 +259,21 @@ PGconn *PQconnectdbParams(const char **keywords, const char **values, int expand
</listitem>
</varlistentry>
+ <varlistentry id="libpq-connect-client-encoding" xreflabel="client_encoding">
+ <term><literal>client_encoding</literal></term>
+ <listitem>
+ <para>
+ This sets the <varname>client_encoding</varname>
+ configuration parameter for this connection. In addition to
+ the values accepted by the corresponding server option, you
+ can use <literal>auto</literal> to determine the right
+ encoding from the current locale in the client
+ (<envar>LC_CTYPE</envar> environment variable on Unix
+ systems).
+ </para>
+ </listitem>
+ </varlistentry>
+
<varlistentry id="libpq-connect-options" xreflabel="options">
<term><literal>options</literal></term>
<listitem>
@@ -6345,6 +6360,16 @@ myEventProc(PGEventId evtId, void *evtInfo, void *passThrough)
linkend="libpq-connect-connect-timeout"> connection parameter.
</para>
</listitem>
+
+ <listitem>
+ <para>
+ <indexterm>
+ <primary><envar>PGCLIENTENCODING</envar></primary>
+ </indexterm>
+ <envar>PGCLIENTENCODING</envar> behaves the same as the <xref
+ linkend="libpq-connect-client-encoding"> connection parameter.
+ </para>
+ </listitem>
</itemizedlist>
</para>
@@ -6381,17 +6406,6 @@ myEventProc(PGEventId evtId, void *evtInfo, void *passThrough)
<listitem>
<para>
<indexterm>
- <primary><envar>PGCLIENTENCODING</envar></primary>
- </indexterm>
- <envar>PGCLIENTENCODING</envar> sets the default client character
- set encoding. (Equivalent to <literal>SET client_encoding TO
- ...</literal>.)
- </para>
- </listitem>
-
- <listitem>
- <para>
- <indexterm>
<primary><envar>PGGEQO</envar></primary>
</indexterm>
<envar>PGGEQO</envar> sets the default mode for the genetic query
diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml
index ff60a72059e..baefb578826 100644
--- a/doc/src/sgml/ref/psql-ref.sgml
+++ b/doc/src/sgml/ref/psql-ref.sgml
@@ -593,6 +593,17 @@ $ <userinput>psql "service=myservice sslmode=require"</userinput>
privileges, server is not running on the targeted host, etc.),
<application>psql</application> will return an error and terminate.
</para>
+
+ <para>
+ If at least one of standard input or standard output are a
+ terminal, then <application>psql</application> sets the client
+ encoding to <quote>auto</quote>, which will detect the
+ appropriate client encoding from the locale settings
+ (<envar>LC_CTYPE</envar> environment variable on Unix systems).
+ If this doesn't work out as expected, the client encoding can be
+ overridden using the environment
+ variable <envar>PGCLIENTENCODING</envar>.
+ </para>
</refsect2>
<refsect2 id="R2-APP-PSQL-4">