plperlu
PL/PerlU untrusted procedural language
Overview
| Package | Version | Category | License | Language |
|---|---|---|---|---|
plperlu | 1.0 | LANG | PostgreSQL | C |
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 3270 | plperlu | No | Yes | No | Yes | No | No | - |
| 3271 | bool_plperlu | No | No | No | Yes | No | No | - |
| 3272 | jsonb_plperlu | No | No | No | Yes | No | No | - |
| 3273 | hstore_plperlu | No | No | No | Yes | No | No | - |
| Related | plperlu plperl plluau pltclu bool_plperl hstore_plperl jsonb_plperl plpgsql plv8 |
|---|---|
| Depended By | bool_plperlu hstore_plperlu jsonb_plperlu plperlu pg_utl_smtp sparql |
Version
| PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|
| 1.0 | 1.0 | 1.0 | 1.0 | 1.0 |
Install
Note: This is a built-in contrib extension of PostgreSQL
CREATE EXTENSION plperlu;
Usage
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;
$$;
Feedback
Was this page helpful?
Thanks for the feedback! Please let us know how we can improve.
Sorry to hear that. Please let us know how we can improve.