libraries might provide their own mechanisms,
via the shell or otherwise, that allow the user to alter session
settings without direct use of SQL commands.
</para>
</listitem>
</itemizedlist>
</sect2>
<sect2 id="config-includes">
<title>Managing Configuration File Contents</title>
<para>
<productname>PostgreSQL</productname> provides several features for breaking
down complex <filename>postgresql.conf</filename> files into sub-files.
These features are especially useful when managing multiple servers
with related, but not identical, configurations.
</para>
<para>
<indexterm>
<primary><literal>include</literal></primary>
<secondary>in configuration file</secondary>
</indexterm>
In addition to individual parameter settings,
the <filename>postgresql.conf</filename> file can contain <firstterm>include
directives</firstterm>, which specify another file to read and process as if
it were inserted into the configuration file at this point. This
feature allows a configuration file to be divided into physically
separate parts. Include directives simply look like:
<programlisting>
include 'filename'
</programlisting>
If the file name is not an absolute path, it is taken as relative to
the directory containing the referencing configuration file.
Inclusions can be nested.
</para>
<para>
<indexterm>
<primary><literal>include_if_exists</literal></primary>
<secondary>in configuration file</secondary>
</indexterm>
There is also an <literal>include_if_exists</literal> directive, which acts
the same as the <literal>include</literal> directive, except
when the referenced file does not exist or cannot be read. A regular
<literal>include</literal> will consider this an error condition, but
<literal>include_if_exists</literal> merely logs a message and continues
processing the referencing configuration file.
</para>
<para>
<indexterm>
<primary><literal>include_dir</literal></primary>
<secondary>in configuration file</secondary>
</indexterm>
The <filename>postgresql.conf</filename> file can also contain
<literal>include_dir</literal> directives, which specify an entire
directory of configuration files to include. These look like
<programlisting>
include_dir 'directory'
</programlisting>
Non-absolute directory names are taken as relative to the directory
containing the referencing configuration file. Within the specified
directory, only non-directory files whose names end with the
suffix <literal>.conf</literal> will be included. File names that
start with the <literal>.</literal> character are also ignored, to
prevent mistakes since such files are hidden on some platforms. Multiple
files within an include directory are processed in file name order
(according to C locale rules, i.e., numbers before letters, and
uppercase letters before lowercase ones).
</para>
<para>
Include files or directories can be used to logically separate portions
of the database configuration, rather than having a single large
<filename>postgresql.conf</filename> file. Consider a company that has two
database servers, each with a different amount of memory. There are
likely elements of the configuration both will share, for things such
as logging. But memory-related parameters on the server will vary
between the two. And there might be server specific customizations,
too. One way to manage this situation is to break the custom
configuration changes for your site into three files. You could add
this to the end of your <filename>postgresql.conf</filename> file to include
them:
<programlisting>
include 'shared.conf'
include 'memory.conf'
include 'server.conf'