Home Explore Blog CI



postgresql

18th chunk of `doc/src/sgml/plperl.sgml`
5f6aa544434f3c9d9c44cffa97d0be5587bf5d5273180a5600000001000009c0
 for the first Perl
        interpreter used by a database session — either PL/PerlU, or
        PL/Perl for the first SQL role that calls a PL/Perl function.  Any
        additional Perl interpreters created in a database session will have
        to execute <literal>plperl.on_init</literal> afresh.  Also, on Windows there
        will be no savings whatsoever from preloading, since the Perl
        interpreter created in the postmaster process does not propagate to
        child processes.
       </para>
       <para>
       This parameter can only be set in the <filename>postgresql.conf</filename> file or on the server command line.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry id="guc-plperl-on-plperl-init" xreflabel="plperl.on_plperl_init">
      <term>
       <varname>plperl.on_plperl_init</varname> (<type>string</type>)
       <indexterm>
        <primary><varname>plperl.on_plperl_init</varname> configuration parameter</primary>
       </indexterm>
      </term>
      <term>
       <varname>plperl.on_plperlu_init</varname> (<type>string</type>)
       <indexterm>
        <primary><varname>plperl.on_plperlu_init</varname> configuration parameter</primary>
       </indexterm>
      </term>
      <listitem>
       <para>
        These parameters specify Perl code to be executed when a Perl
        interpreter is specialized for <literal>plperl</literal> or
        <literal>plperlu</literal> respectively.  This will happen when a PL/Perl or
        PL/PerlU function is first executed in a database session, or when
        an additional interpreter has to be created because the other language
        is called or a PL/Perl function is called by a new SQL role.  This
        follows any initialization done by <literal>plperl.on_init</literal>.
        The SPI functions are not available when this code is executed.
        The Perl code in <literal>plperl.on_plperl_init</literal> is executed after
        <quote>locking down</quote> the interpreter, and thus it can only perform
        trusted operations.
       </para>
       <para>
        If the code fails with an error it will abort the initialization and
        propagate out to the calling query, causing the current transaction or
        subtransaction to be aborted.  Any actions already done within Perl
        won't be undone; however, that interpreter won't be used again.
        If the language is used again the initialization will be attempted
        again

Title: PL/Perl Interpreter Initialization and Windows Limitations
Summary
This section discusses the behavior of PL/Perl interpreter initialization in PostgreSQL database sessions. It explains that the plperl.on_init code is executed only for the first Perl interpreter in a session, which could be either PL/PerlU or PL/Perl for the first SQL role calling a PL/Perl function. Any additional interpreters created in the same session must re-execute plperl.on_init. The text also highlights a limitation on Windows systems, where preloading offers no performance benefits because the Perl interpreter created in the postmaster process doesn't propagate to child processes. The section concludes by noting that the plperl.on_init parameter can only be configured in the postgresql.conf file or via server command line options.