gooderp18绿色标准版
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

111 行
9.7KB

  1. <?xml version="1.0" encoding="UTF-8" standalone="no"?>
  2. <!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>44.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 V1.79.1" /><link rel="prev" href="plperl-event-triggers.html" title="44.7. PL/Perl Event Triggers" /><link rel="next" href="plpython.html" title="Chapter 45. 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">44.8. PL/Perl Under the Hood</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="plperl-event-triggers.html" title="44.7. PL/Perl Event Triggers">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="plperl.html" title="Chapter 44. PL/Perl - Perl Procedural Language">Up</a></td><th width="60%" align="center">Chapter 44. PL/Perl - Perl Procedural Language</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 12.4 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="plpython.html" title="Chapter 45. 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">44.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">44.8.1. Configuration</a></span></dt><dt><span class="sect2"><a href="plperl-under-the-hood.html#PLPERL-MISSING">44.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">44.8.1. Configuration</h3></div></div></div><p>
  3. This section lists configuration parameters that affect <span class="application">PL/Perl</span>.
  4. </p><div class="variablelist"><dl class="variablelist"><dt id="GUC-PLPERL-ON-INIT"><span class="term">
  5. <code class="varname">plperl.on_init</code> (<code class="type">string</code>)
  6. <a id="id-1.8.10.16.2.3.1.1.3" class="indexterm"></a>
  7. </span></dt><dd><p>
  8. Specifies Perl code to be executed when a Perl interpreter is first
  9. initialized, before it is specialized for use by <code class="literal">plperl</code> or
  10. <code class="literal">plperlu</code>.
  11. The SPI functions are not available when this code is executed.
  12. If the code fails with an error it will abort the initialization of
  13. the interpreter and propagate out to the calling query, causing the
  14. current transaction or subtransaction to be aborted.
  15. </p><p>
  16. The Perl code is limited to a single string. Longer code can be placed
  17. into a module and loaded by the <code class="literal">on_init</code> string.
  18. Examples:
  19. </p><pre class="programlisting">
  20. plperl.on_init = 'require "plperlinit.pl"'
  21. plperl.on_init = 'use lib "/my/app"; use MyApp::PgInit;'
  22. </pre><p>
  23. </p><p>
  24. Any modules loaded by <code class="literal">plperl.on_init</code>, either directly or
  25. indirectly, will be available for use by <code class="literal">plperl</code>. This may
  26. create a security risk. To see what modules have been loaded you can use:
  27. </p><pre class="programlisting">
  28. DO 'elog(WARNING, join ", ", sort keys %INC)' LANGUAGE plperl;
  29. </pre><p>
  30. </p><p>
  31. Initialization will happen in the postmaster if the <code class="literal">plperl</code> library is
  32. included in <a class="xref" href="runtime-config-client.html#GUC-SHARED-PRELOAD-LIBRARIES">shared_preload_libraries</a>, in which
  33. case extra consideration should be given to the risk of destabilizing
  34. the postmaster. The principal reason for making use of this feature
  35. is that Perl modules loaded by <code class="literal">plperl.on_init</code> need be
  36. loaded only at postmaster start, and will be instantly available
  37. without loading overhead in individual database sessions. However,
  38. keep in mind that the overhead is avoided only for the first Perl
  39. interpreter used by a database session — either PL/PerlU, or
  40. PL/Perl for the first SQL role that calls a PL/Perl function. Any
  41. additional Perl interpreters created in a database session will have
  42. to execute <code class="literal">plperl.on_init</code> afresh. Also, on Windows there
  43. will be no savings whatsoever from preloading, since the Perl
  44. interpreter created in the postmaster process does not propagate to
  45. child processes.
  46. </p><p>
  47. This parameter can only be set in the <code class="filename">postgresql.conf</code> file or on the server command line.
  48. </p></dd><dt id="GUC-PLPERL-ON-PLPERL-INIT"><span class="term">
  49. <code class="varname">plperl.on_plperl_init</code> (<code class="type">string</code>)
  50. <a id="id-1.8.10.16.2.3.2.1.3" class="indexterm"></a>
  51. <br /></span><span class="term">
  52. <code class="varname">plperl.on_plperlu_init</code> (<code class="type">string</code>)
  53. <a id="id-1.8.10.16.2.3.2.2.3" class="indexterm"></a>
  54. </span></dt><dd><p>
  55. These parameters specify Perl code to be executed when a Perl
  56. interpreter is specialized for <code class="literal">plperl</code> or
  57. <code class="literal">plperlu</code> respectively. This will happen when a PL/Perl or
  58. PL/PerlU function is first executed in a database session, or when
  59. an additional interpreter has to be created because the other language
  60. is called or a PL/Perl function is called by a new SQL role. This
  61. follows any initialization done by <code class="literal">plperl.on_init</code>.
  62. The SPI functions are not available when this code is executed.
  63. The Perl code in <code class="literal">plperl.on_plperl_init</code> is executed after
  64. <span class="quote">“<span class="quote">locking down</span>”</span> the interpreter, and thus it can only perform
  65. trusted operations.
  66. </p><p>
  67. If the code fails with an error it will abort the initialization and
  68. propagate out to the calling query, causing the current transaction or
  69. subtransaction to be aborted. Any actions already done within Perl
  70. won't be undone; however, that interpreter won't be used again.
  71. If the language is used again the initialization will be attempted
  72. again within a fresh Perl interpreter.
  73. </p><p>
  74. Only superusers can change these settings. Although these settings
  75. can be changed within a session, such changes will not affect Perl
  76. interpreters that have already been used to execute functions.
  77. </p></dd><dt id="GUC-PLPERL-USE-STRICT"><span class="term">
  78. <code class="varname">plperl.use_strict</code> (<code class="type">boolean</code>)
  79. <a id="id-1.8.10.16.2.3.3.1.3" class="indexterm"></a>
  80. </span></dt><dd><p>
  81. When set true subsequent compilations of PL/Perl functions will have
  82. the <code class="literal">strict</code> pragma enabled. This parameter does not affect
  83. functions already compiled in the current session.
  84. </p></dd></dl></div></div><div class="sect2" id="PLPERL-MISSING"><div class="titlepage"><div><div><h3 class="title">44.8.2. Limitations and Missing Features</h3></div></div></div><p>
  85. The following features are currently missing from PL/Perl, but they
  86. would make welcome contributions.
  87. </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>
  88. PL/Perl functions cannot call each other directly.
  89. </p></li><li class="listitem"><p>
  90. SPI is not yet fully implemented.
  91. </p></li><li class="listitem"><p>
  92. If you are fetching very large data sets using
  93. <code class="literal">spi_exec_query</code>, you should be aware that
  94. these will all go into memory. You can avoid this by using
  95. <code class="literal">spi_query</code>/<code class="literal">spi_fetchrow</code> as
  96. illustrated earlier.
  97. </p><p>
  98. A similar problem occurs if a set-returning function passes a
  99. large set of rows back to PostgreSQL via <code class="literal">return</code>. You
  100. can avoid this problem too by instead using
  101. <code class="literal">return_next</code> for each row returned, as shown
  102. previously.
  103. </p></li><li class="listitem"><p>
  104. When a session ends normally, not due to a fatal error, any
  105. <code class="literal">END</code> blocks that have been defined are executed.
  106. Currently no other actions are performed. Specifically,
  107. file handles are not automatically flushed and objects are
  108. not automatically destroyed.
  109. </p></li></ul></div><p>
  110. </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">44.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 45. PL/Python - Python Procedural Language</td></tr></table></div></body></html>
上海开阖软件有限公司 沪ICP备12045867号-1