Supported Versions: Current (17) / 16 / 15 / 14 / 13
Development Versions: devel
Unsupported versions: 12 / 11 / 10 / 9.6 / 9.5 / 9.4 / 9.3 / 9.2 / 9.1 / 9.0 / 8.4 / 8.3 / 8.2 / 8.1 / 8.0 / 7.4 / 7.3 / 7.2 / 7.1
This documentation is for an unsupported version of PostgreSQL.
You may want to view the same page for the current version, or one of the other supported versions listed above instead.

Chapter 26. PL/Perl - Perl Procedural Language

Table of Contents
26.1. Building and Installing
26.2. Using PL/Perl

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 Postgres.

The PL/Perl intepreter 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 filehandle 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.

26.1. Building and Installing

In order to build and install PL/Perl if you are installing Postgres 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 Postgres 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
If it is installed into template1, all future databases will have the language installed automatically.