Home Explore Blog CI



postgresql

10th chunk of `doc/src/sgml/extend.sgml`
0de9f4913225a304be264b45b758142e9bd2c93917f65ef60000000100000fa0
 <primary>control file</primary>
   </indexterm>

    <para>
     The <command>CREATE EXTENSION</command> command relies on a control
     file for each extension, which must be named the same as the extension
     with a suffix of <literal>.control</literal>, and must be placed in the
     installation's <literal>SHAREDIR/extension</literal> directory.  There
     must also be at least one <acronym>SQL</acronym> script file, which follows the
     naming pattern
     <literal><replaceable>extension</replaceable>--<replaceable>version</replaceable>.sql</literal>
     (for example, <literal>foo--1.0.sql</literal> for version <literal>1.0</literal> of
     extension <literal>foo</literal>).  By default, the script file(s) are also
     placed in the <literal>SHAREDIR/extension</literal> directory; but the
     control file can specify a different directory for the script file(s).
    </para>

    <para>
     Additional locations for extension control files can be configured using
     the parameter <xref linkend="guc-extension-control-path"/>.
    </para>

    <para>
     The file format for an extension control file is the same as for the
     <filename>postgresql.conf</filename> file, namely a list of
     <replaceable>parameter_name</replaceable> <literal>=</literal> <replaceable>value</replaceable>
     assignments, one per line.  Blank lines and comments introduced by
     <literal>#</literal> are allowed.  Be sure to quote any value that is not
     a single word or number.
    </para>

    <para>
     A control file can set the following parameters:
    </para>

    <variablelist>
     <varlistentry id="extend-extensions-files-directory">
      <term><varname>directory</varname> (<type>string</type>)</term>
      <listitem>
       <para>
        The directory containing the extension's <acronym>SQL</acronym> script
        file(s).  Unless an absolute path is given, the name is relative to
        the directory where the control file was found.  By default,
        the script files are looked for in the same directory where the
        control file was found.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry id="extend-extensions-files-default-version">
      <term><varname>default_version</varname> (<type>string</type>)</term>
      <listitem>
       <para>
        The default version of the extension (the one that will be installed
        if no version is specified in <command>CREATE EXTENSION</command>).  Although
        this can be omitted, that will result in <command>CREATE EXTENSION</command>
        failing if no <literal>VERSION</literal> option appears, so you generally
        don't want to do that.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry id="extend-extensions-files-comment">
      <term><varname>comment</varname> (<type>string</type>)</term>
      <listitem>
       <para>
        A comment (any string) about the extension.  The comment is applied
        when initially creating an extension, but not during extension updates
        (since that might override user-added comments).  Alternatively,
        the extension's comment can be set by writing
        a <xref linkend="sql-comment"/> command in the script file.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry id="extend-extensions-files-encoding">
      <term><varname>encoding</varname> (<type>string</type>)</term>
      <listitem>
       <para>
        The character set encoding used by the script file(s).  This should
        be specified if the script files contain any non-ASCII characters.
        Otherwise the files will be assumed to be in the database encoding.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry id="extend-extensions-files-module-pathname">
      <term><varname>module_pathname</varname> (<type>string</type>)</term>
      <listitem>
       <para>
        The value of this parameter will be substituted for each occurrence
       

Title: Extension Control File Structure in PostgreSQL
Summary
This section details the structure and contents of extension control files in PostgreSQL. It explains that the CREATE EXTENSION command relies on a control file for each extension, which must be named with a .control suffix and placed in the SHAREDIR/extension directory. The control file format is similar to postgresql.conf, consisting of parameter-value pairs. The text outlines several key parameters that can be set in the control file, including 'directory' (specifying the location of SQL script files), 'default_version' (the default version of the extension), 'comment' (a description of the extension), 'encoding' (the character set encoding of script files), and 'module_pathname' (used for substitution in script files). It also mentions that additional locations for control files can be configured using the extension-control-path parameter.