Chapter 42. PL/Perl - Perl Procedural Language
DO ’elog(WARNING, join ", ", sort keys %INC)’ LANGUAGE plperl;
Initialization will happen in the postmaster if the plperl library is included in
shared_preload_libraries, 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
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 ﬁrst Perl interpreter used by a database session
— either PL/PerlU, or PL/Perl for the ﬁrst SQL role that calls a PL/Perl function. Any
additional Perl interpreters createdin a database session will have to execute
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.
This parameter can only be set in the
ﬁle or on the server command line.
These parameters specify Perl code to be executed when a Perl interpreter is specialized for
respectively. This will happen when a PL/Perl or PL/PerlU function is ﬁrst
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
.The SPI functions are not available when this code
is executed. The Perl code in
is executed after “locking down” the
interpreter, and thus it can only perform trusted operations.
If the code fails with anerror itwill abort the initialization andpropagate out tothecallingquery,
causing the current transaction or subtransaction to be aborted. Any actions already done within
Perlwon’t be undone;however, that interpreter won’tbeusedagain. If the language is usedagain
the initialization will be attempted again within a fresh Perl interpreter.
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
When set true subsequent compilations of PL/Perl functions will have the
abled. This parameter does not affect functions already compiled in the current session.
42.8.2. Limitations and Missing Features
The following features are currently missing from PL/Perl, but they would make welcome contribu-
PL/Perl functions cannot call each other directly.
SPI is not yet fully implemented.
If you are fetching very large data sets using
,you should be aware that these
will all go into memory. You can avoid this by using
Asimilar problem occurs if a set-returning function passes a large set of rows backto PostgreSQL
.You can avoid this problem toobyinstead using
for eachrow returned,
as shown previously.