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 within a fresh Perl interpreter.
</para>
<para>
Only superusers can change these settings. Although these settings
can be changed within a session, such changes will not affect Perl
interpreters that have already been used to execute functions.
</para>
</listitem>
</varlistentry>
<varlistentry id="guc-plperl-use-strict" xreflabel="plperl.use_strict">
<term>
<varname>plperl.use_strict</varname> (<type>boolean</type>)
<indexterm>
<primary><varname>plperl.use_strict</varname> configuration parameter</primary>
</indexterm>
</term>
<listitem>
<para>
When set true subsequent compilations of PL/Perl functions will have
the <literal>strict</literal> pragma enabled. This parameter does not affect
functions already compiled in the current session.
</para>
</listitem>
</varlistentry>
</variablelist>
</sect2>
<sect2 id="plperl-missing">
<title>Limitations and Missing Features</title>
<para>
The following features are currently missing from PL/Perl, but they
would make welcome contributions.
<itemizedlist>
<listitem>
<para>
PL/Perl functions cannot call each other directly.
</para>
</listitem>
<listitem>
<para>
SPI is not yet fully implemented.
</para>
</listitem>
<listitem>
<para>
If you are fetching very large data sets using
<literal>spi_exec_query</literal>, you should be aware that
these will all go into memory. You can avoid this by using
<literal>spi_query</literal>/<literal>spi_fetchrow</literal> as
illustrated earlier.
</para>
<para>
A similar problem occurs if a set-returning function passes a
large set of rows back to PostgreSQL via <literal>return</literal>. You
can avoid this problem too by instead using
<literal>return_next</literal> for each row returned, as shown
previously.
</para>
</listitem>
<listitem>
<para>
When a session ends normally, not due to a fatal error, any
<literal>END</literal> blocks that have been defined are executed.
Currently no other actions are performed. Specifically,
file handles are not automatically flushed and objects are
not automatically destroyed.
</para>
</listitem>
</itemizedlist>
</para>
</sect2>
</sect1>
</chapter>