|
39 | 39 | <para>
|
40 | 40 | Users of source packages must specially enable the build of
|
41 | 41 | PL/Perl during the installation process. (Refer to <xref
|
42 |
| - linkend="install-short"> for more information.) Users of |
| 42 | + linkend="installation"> for more information.) Users of |
43 | 43 | binary packages might find PL/Perl in a separate subpackage.
|
44 | 44 | </para>
|
45 | 45 | </note>
|
@@ -81,7 +81,7 @@ $$ LANGUAGE plperl;
|
81 | 81 | most convenient to use dollar quoting (see <xref
|
82 | 82 | linkend="sql-syntax-dollar-quoting">) for the string constant.
|
83 | 83 | If you choose to use escape string syntax <literal>E''</>,
|
84 |
| - you must double the single quote marks (<literal>'</>) and backslashes |
| 84 | + you must double any single quote marks (<literal>'</>) and backslashes |
85 | 85 | (<literal>\</>) used in the body of the function
|
86 | 86 | (see <xref linkend="sql-syntax-strings">).
|
87 | 87 | </para>
|
@@ -606,6 +606,23 @@ $$ LANGUAGE plperl;
|
606 | 606 | <literal>return $_SHARED{myquote}->($_[0]);</literal>
|
607 | 607 | at the expense of readability.)
|
608 | 608 | </para>
|
| 609 | + |
| 610 | + <para> |
| 611 | + For security reasons, PL/Perl executes functions called by any one SQL role |
| 612 | + in a separate Perl interpreter for that role. This prevents accidental or |
| 613 | + malicious interference by one user with the behavior of another user's |
| 614 | + PL/Perl functions. Each such interpreter has its own value of the |
| 615 | + <varname>%_SHARED</varname> variable and other global state. Thus, two |
| 616 | + PL/Perl functions will share the same value of <varname>%_SHARED</varname> |
| 617 | + if and only if they are executed by the same SQL role. In an application |
| 618 | + wherein a single session executes code under multiple SQL roles (via |
| 619 | + <literal>SECURITY DEFINER</> functions, use of <command>SET ROLE</>, etc) |
| 620 | + you may need to take explicit steps to ensure that PL/Perl functions can |
| 621 | + share data via <varname>%_SHARED</varname>. To do that, make sure that |
| 622 | + functions that should communicate are owned by the same user, and mark |
| 623 | + them <literal>SECURITY DEFINER</>. You must of course take care that |
| 624 | + such functions can't be used to do anything unintended. |
| 625 | + </para> |
609 | 626 | </sect1>
|
610 | 627 |
|
611 | 628 | <sect1 id="plperl-trusted">
|
@@ -673,21 +690,31 @@ $$ LANGUAGE plperl;
|
673 | 690 | </para>
|
674 | 691 |
|
675 | 692 | <note>
|
676 |
| - <para> |
677 |
| - For security reasons, to stop a leak of privileged operations from |
678 |
| - <application>PL/PerlU</> to <application>PL/Perl</>, these two languages |
679 |
| - have to run in separate instances of the Perl interpreter. If your |
680 |
| - Perl installation has been appropriately compiled, this is not a problem. |
681 |
| - However, not all installations are compiled with the requisite flags. |
682 |
| - If <productname>PostgreSQL</> detects that this is the case then it will |
683 |
| - not start a second interpreter, but instead create an error. In |
684 |
| - consequence, in such an installation, you cannot use both |
685 |
| - <application>PL/PerlU</> and <application>PL/Perl</> in the same backend |
686 |
| - process. The remedy for this is to obtain a Perl installation created |
687 |
| - with the appropriate flags, namely either <literal>usemultiplicity</> or |
688 |
| - both <literal>usethreads</> and <literal>useithreads</>. |
689 |
| - For more details,see the <literal>perlembed</> manual page. |
690 |
| - </para> |
| 693 | + <para> |
| 694 | + While <application>PL/Perl</> functions run in a separate Perl |
| 695 | + interpreter for each SQL role, all <application>PL/PerlU</> functions |
| 696 | + executed in a given session run in a single Perl interpreter (which is |
| 697 | + not any of the ones used for <application>PL/Perl</> functions). |
| 698 | + This allows <application>PL/PerlU</> functions to share data freely, |
| 699 | + but no communication can occur between <application>PL/Perl</> and |
| 700 | + <application>PL/PerlU</> functions. |
| 701 | + </para> |
| 702 | + </note> |
| 703 | + |
| 704 | + <note> |
| 705 | + <para> |
| 706 | + Perl cannot support multiple interpreters within one process unless |
| 707 | + it was built with the appropriate flags, namely either |
| 708 | + <literal>usemultiplicity</> or <literal>useithreads</>. |
| 709 | + (<literal>usemultiplicity</> is preferred unless you actually need |
| 710 | + to use threads. For more details, see the |
| 711 | + <citerefentry><refentrytitle>perlembed</></citerefentry> man page.) |
| 712 | + If <application>PL/Perl</> is used with a copy of Perl that was not built |
| 713 | + this way, then it is only possible to have one Perl interpreter per |
| 714 | + session, and so any one session can only execute either |
| 715 | + <application>PL/PerlU</> functions, or <application>PL/Perl</> functions |
| 716 | + that are all called by the same SQL role. |
| 717 | + </para> |
691 | 718 | </note>
|
692 | 719 |
|
693 | 720 | </sect1>
|
|
0 commit comments