Chapter 25. PL/Perl - Perl Procedural Language

Table of Contents
25.1. Overview
25.2. Building and Installing PL/Perl
25.3. Description
25.3.1. PL/Perl Functions and Arguments
25.3.2. Data Values in PL/Perl
25.3.3. Database Access from PL/Perl
25.3.4. Missing Features

PL/Perl is a loadable procedural language that enables the Perl programming language to be used to write PostgreSQL functions.

25.1. Overview

Normally, PL/Perl is installed as a "trusted" programming language named plperl. In this setup, certain Perl operations are disabled to preserve security. 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). There is no way to access internals of the database backend or to gain OS-level access under the permissions of the PostgreSQL user ID, as a C function can do. Thus, any unprivileged database user may be permitted to use this language.

Sometimes it is desirable to write Perl functions that are not restricted --- for example, one might want a Perl function that sends mail. To handle these cases, PL/Perl can also be installed as an "untrusted" language (usually named plperlu). In this case the full Perl language is available. The writer of a PL/PerlU function must take care that the function cannot be used to do anything unwanted, since it will be able to do anything that could be done by a user logged in as the database administrator. Note that the database system allows only database superusers to create functions in untrusted languages.