plperlu

PL/PerlU untrusted procedural language

Overview

PackageVersionCategoryLicenseLanguage
plperlu1.0LANGPostgreSQLC
IDExtensionBinLibLoadCreateTrustRelocSchema
3270plperluNoYesNoYesNoNo-
3271bool_plperluNoNoNoYesNoNo-
3272jsonb_plperluNoNoNoYesNoNo-
3273hstore_plperluNoNoNoYesNoNo-
Relatedplperlu plperl plluau pltclu bool_plperl hstore_plperl jsonb_plperl plpgsql plv8
Depended Bybool_plperlu hstore_plperlu jsonb_plperlu plperlu pg_utl_smtp sparql

Version

PG18PG17PG16PG15PG14
1.01.01.01.01.0

Install

Note: This is a built-in contrib extension of PostgreSQL

CREATE EXTENSION plperlu;

Usage

plperlu: PL/Perl untrusted procedural language

PL/Perl Untrusted provides full Perl capabilities including external module loading, filesystem access, and network operations. Only superusers can create functions in this language.

CREATE EXTENSION plperlu;

-- Use external CPAN modules
CREATE FUNCTION fetch_url(text) RETURNS text
LANGUAGE plperlu AS $$
  use LWP::Simple;
  my ($url) = @_;
  return get($url);
$$;

-- Read a file from the server filesystem
CREATE FUNCTION read_server_file(text) RETURNS text
LANGUAGE plperlu AS $$
  my ($path) = @_;
  open my $fh, '<', $path or die "Cannot open $path: $!";
  local $/;
  my $content = <$fh>;
  close $fh;
  return $content;
$$;

-- JSON processing with external module
CREATE FUNCTION parse_json_key(text, text) RETURNS text
LANGUAGE plperlu AS $$
  use JSON;
  my ($json_str, $key) = @_;
  my $data = decode_json($json_str);
  return $data->{$key};
$$;

-- Send email using Net::SMTP
CREATE FUNCTION send_email(text, text, text) RETURNS boolean
LANGUAGE plperlu AS $$
  use Net::SMTP;
  my ($to, $subject, $body) = @_;
  my $smtp = Net::SMTP->new('localhost');
  $smtp->mail('postgres@localhost');
  $smtp->to($to);
  $smtp->data();
  $smtp->datasend("Subject: $subject\n\n$body");
  $smtp->dataend();
  $smtp->quit();
  return 1;
$$;

Last Modified 2026-03-12: add pg extension catalog (95749bf)