Home Explore Blog CI



postgresql

3rd chunk of `doc/src/sgml/charset.sgml`
f799ac3074d757a7e34d6e8f1137aa859f6fad248b6d45a00000000100000fa3
 setting the server configuration parameters
    that have the same name as the locale categories (see <xref
    linkend="runtime-config-client-format"/> for details).  The values
    that are chosen by <command>initdb</command> are actually only written
    into the configuration file <filename>postgresql.conf</filename> to
    serve as defaults when the server is started.  If you remove these
    assignments from <filename>postgresql.conf</filename> then the
    server will inherit the settings from its execution environment.
   </para>

   <para>
    Note that the locale behavior of the server is determined by the
    environment variables seen by the server, not by the environment
    of any client.  Therefore, be careful to configure the correct locale settings
    before starting the server.  A consequence of this is that if
    client and server are set up in different locales, messages might
    appear in different languages depending on where they originated.
   </para>

   <note>
    <para>
     When we speak of inheriting the locale from the execution
     environment, this means the following on most operating systems:
     For a given locale category, say the collation, the following
     environment variables are consulted in this order until one is
     found to be set: <envar>LC_ALL</envar>, <envar>LC_COLLATE</envar>
     (or the variable corresponding to the respective category),
     <envar>LANG</envar>.  If none of these environment variables are
     set then the locale defaults to <literal>C</literal>.
    </para>

    <para>
     Some message localization libraries also look at the environment
     variable <envar>LANGUAGE</envar> which overrides all other locale
     settings for the purpose of setting the language of messages.  If
     in doubt, please refer to the documentation of your operating
     system, in particular the documentation about
     <application>gettext</application>.
    </para>
   </note>

   <para>
    To enable messages to be translated to the user's preferred language,
    <acronym>NLS</acronym> must have been selected at build time
    (<literal>configure --enable-nls</literal>).  All other locale support is
    built in automatically.
   </para>
  </sect2>

  <sect2 id="locale-behavior">
   <title>Behavior</title>

   <para>
    The locale settings influence the following SQL features:

    <itemizedlist>
     <listitem>
      <para>
       Sort order in queries using <literal>ORDER BY</literal> or the standard
       comparison operators on textual data
       <indexterm><primary>ORDER BY</primary><secondary>and locales</secondary></indexterm>
      </para>
     </listitem>

     <listitem>
      <para>
       The <function>upper</function>, <function>lower</function>, and <function>initcap</function>
       functions
       <indexterm><primary>upper</primary><secondary>and locales</secondary></indexterm>
       <indexterm><primary>lower</primary><secondary>and locales</secondary></indexterm>
      </para>
     </listitem>

     <listitem>
      <para>
       Pattern matching operators (<literal>LIKE</literal>, <literal>SIMILAR TO</literal>,
       and POSIX-style regular expressions); locales affect both case
       insensitive matching and the classification of characters by
       character-class regular expressions
       <indexterm><primary>LIKE</primary><secondary>and locales</secondary></indexterm>
       <indexterm><primary>regular expressions</primary><secondary>and locales</secondary></indexterm>
      </para>
     </listitem>

     <listitem>
      <para>
       The <function>to_char</function> family of functions
       <indexterm><primary>to_char</primary><secondary>and locales</secondary></indexterm>
      </para>
     </listitem>

     <listitem>
      <para>
       The ability to use indexes with <literal>LIKE</literal> clauses
      </para>
     </listitem>
    </itemizedlist>
   </para>

   <para>
    The drawback of using locales other than <literal>C</literal>

Title: Locale Settings and Their Impact on PostgreSQL Behavior
Summary
This section discusses how locale settings affect various SQL features in PostgreSQL, such as sort order, character classification, and pattern matching, and how to configure locale settings to enable message translation and inheritance from the execution environment.