PL/Perl allows you to write functions in the Perl programming language that may be used in SQL queries as if they were built into PostgreSQL.
The PL/Perl interpreter (when installed as trusted interpreter with default name plperl) interpreter is a full Perl interpreter. However, certain operations have been disabled in order to maintain the security of the system. In general, the operations that are restricted are those that interact with the environment. This includes file handle operations, require, and use (for external modules). It should be noted that this security is not absolute. Indeed, several Denial-of-Service attacks are still possible - memory exhaustion and endless loops are two examples.
When PL/Perl is installed as "untrusted" interpreter (with name plperlu), everything is permitted, and any Perl code can be loaded (by superuser only).
In order to build and install PL/Perl if you are installing PostgreSQL from source then the --with-perl must be supplied to the configure script. PL/Perl requires that, when Perl was installed, the libperl library was build as a shared object. At the time of this writing, this is almost never the case in the Perl packages that are distributed with the operating systems. A message like this will appear during the build to point out this fact:
***** * Cannot build PL/Perl because libperl is not a shared library. * Skipped. *****
Therefore it is likely that you will have to re-build and install Perl manually to be able to build PL/Perl.
When you want to retry to build PL/Perl after having reinstalled Perl, then change to the directory src/pl/plperl in the PostgreSQL source tree and issue the commands
gmake clean gmake all gmake install
The createlang command is used to install the language into a database.
$ createlang plperl template1
Alternatively, to create untrusted interpreter (where functions can only be created by superuser, but the functions are not restricted), use:
$ createlang plperlu template1
If it is installed into template1, all future databases will have the language installed automatically.