Sophie

Sophie

distrib > Mageia > 7 > x86_64 > by-pkgid > 9b6cc37ce608401d44f6535a0c7cb777 > files > 580

postgresql11-docs-11.5-1.mga7.noarch.rpm

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>45.8. PL/Perl Under the Hood</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="plperl-event-triggers.html" title="45.7. PL/Perl Event Triggers" /><link rel="next" href="plpython.html" title="Chapter 46. PL/Python - Python Procedural Language" /></head><body><div xmlns="http://www.w3.org/TR/xhtml1/transitional" class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">45.8. PL/Perl Under the Hood</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="plperl-event-triggers.html" title="45.7. PL/Perl Event Triggers">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="plperl.html" title="Chapter 45. PL/Perl - Perl Procedural Language">Up</a></td><th width="60%" align="center">Chapter 45. PL/Perl - Perl Procedural Language</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 11.5 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="plpython.html" title="Chapter 46. PL/Python - Python Procedural Language">Next</a></td></tr></table><hr></hr></div><div class="sect1" id="PLPERL-UNDER-THE-HOOD"><div class="titlepage"><div><div><h2 class="title" style="clear: both">45.8. PL/Perl Under the Hood</h2></div></div></div><div class="toc"><dl class="toc"><dt><span class="sect2"><a href="plperl-under-the-hood.html#PLPERL-CONFIG">45.8.1. Configuration</a></span></dt><dt><span class="sect2"><a href="plperl-under-the-hood.html#PLPERL-MISSING">45.8.2. Limitations and Missing Features</a></span></dt></dl></div><div class="sect2" id="PLPERL-CONFIG"><div class="titlepage"><div><div><h3 class="title">45.8.1. Configuration</h3></div></div></div><p>
  This section lists configuration parameters that affect <span class="application">PL/Perl</span>.
  </p><div class="variablelist"><dl class="variablelist"><dt id="GUC-PLPERL-ON-INIT"><span class="term">
       <code class="varname">plperl.on_init</code> (<code class="type">string</code>)
      <a id="id-1.8.10.16.2.3.1.1.3" class="indexterm"></a>
      </span></dt><dd><p>
        Specifies Perl code to be executed when a Perl interpreter is first
        initialized, before it is specialized for use by <code class="literal">plperl</code> or
        <code class="literal">plperlu</code>.
        The SPI functions are not available when this code is executed.
        If the code fails with an error it will abort the initialization of
        the interpreter and propagate out to the calling query, causing the
        current transaction or subtransaction to be aborted.
       </p><p>
       The Perl code is limited to a single string. Longer code can be placed
       into a module and loaded by the <code class="literal">on_init</code> string.
       Examples:
</p><pre class="programlisting">
plperl.on_init = 'require "plperlinit.pl"'
plperl.on_init = 'use lib "/my/app"; use MyApp::PgInit;'
</pre><p>
       </p><p>
       Any modules loaded by <code class="literal">plperl.on_init</code>, either directly or
       indirectly, will be available for use by <code class="literal">plperl</code>.  This may
       create a security risk. To see what modules have been loaded you can use:
</p><pre class="programlisting">
DO 'elog(WARNING, join ", ", sort keys %INC)' LANGUAGE plperl;
</pre><p>
       </p><p>
        Initialization will happen in the postmaster if the <code class="literal">plperl</code> library is
        included in <a class="xref" href="runtime-config-client.html#GUC-SHARED-PRELOAD-LIBRARIES">shared_preload_libraries</a>, in which
        case extra consideration should be given to the risk of destabilizing
        the postmaster.  The principal reason for making use of this feature
        is that Perl modules loaded by <code class="literal">plperl.on_init</code> need be
        loaded only at postmaster start, and will be instantly available
        without loading overhead in individual database sessions.  However,
        keep in mind that the overhead is avoided only 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 <code class="literal">plperl.on_init</code> 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.
       </p><p>
       This parameter can only be set in the <code class="filename">postgresql.conf</code> file or on the server command line.
       </p></dd><dt id="GUC-PLPERL-ON-PLPERL-INIT"><span class="term">
       <code class="varname">plperl.on_plperl_init</code> (<code class="type">string</code>)
       <a id="id-1.8.10.16.2.3.2.1.3" class="indexterm"></a>
      <br /></span><span class="term">
       <code class="varname">plperl.on_plperlu_init</code> (<code class="type">string</code>)
       <a id="id-1.8.10.16.2.3.2.2.3" class="indexterm"></a>
      </span></dt><dd><p>
        These parameters specify Perl code to be executed when a Perl
        interpreter is specialized for <code class="literal">plperl</code> or
        <code class="literal">plperlu</code> 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 <code class="literal">plperl.on_init</code>.
        The SPI functions are not available when this code is executed.
        The Perl code in <code class="literal">plperl.on_plperl_init</code> is executed after
        <span class="quote">“<span class="quote">locking down</span>”</span> the interpreter, and thus it can only perform
        trusted operations.
       </p><p>
        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.
       </p><p>
        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.
       </p></dd><dt id="GUC-PLPERL-USE-STRICT"><span class="term">
       <code class="varname">plperl.use_strict</code> (<code class="type">boolean</code>)
       <a id="id-1.8.10.16.2.3.3.1.3" class="indexterm"></a>
      </span></dt><dd><p>
        When set true subsequent compilations of PL/Perl functions will have
        the <code class="literal">strict</code> pragma enabled.  This parameter does not affect
        functions already compiled in the current session.
       </p></dd></dl></div></div><div class="sect2" id="PLPERL-MISSING"><div class="titlepage"><div><div><h3 class="title">45.8.2. Limitations and Missing Features</h3></div></div></div><p>
   The following features are currently missing from PL/Perl, but they
   would make welcome contributions.

   </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>
      PL/Perl functions cannot call each other directly.
     </p></li><li class="listitem"><p>
      SPI is not yet fully implemented.
     </p></li><li class="listitem"><p>
      If you are fetching very large data sets using
      <code class="literal">spi_exec_query</code>, you should be aware that
      these will all go into memory.  You can avoid this by using
      <code class="literal">spi_query</code>/<code class="literal">spi_fetchrow</code> as
      illustrated earlier.
     </p><p>
        A similar problem occurs if a set-returning function passes a
        large set of rows back to PostgreSQL via <code class="literal">return</code>. You
        can avoid this problem too by instead using
        <code class="literal">return_next</code> for each row returned, as shown
        previously.
     </p></li><li class="listitem"><p>
        When a session ends normally, not due to a fatal error, any
        <code class="literal">END</code> 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.
      </p></li></ul></div><p>
  </p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="plperl-event-triggers.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="plperl.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="plpython.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">45.7. PL/Perl Event Triggers </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Chapter 46. PL/Python - Python Procedural Language</td></tr></table></div></body></html>