plperlu
plperlu
plperlu : PL/PerlU untrusted procedural language
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 3270 | plperlu
|
plperlu
|
1.0 |
LANG
|
PostgreSQL
|
C
|
| Attribute | Has Binary | Has Library | Need Load | Has DDL | Relocatable | Trusted |
|---|---|---|---|---|---|---|
--s-d--
|
No
|
Yes
|
No
|
Yes
|
no
|
no
|
| Relationships | |
|---|---|
| Schemas | pg_catalog |
| Requires | plperlu
|
| Need By | bool_plperlu
hstore_plperlu
jsonb_plperlu
plperlu
pg_utl_smtp
sparql
|
| See Also | plperl
plluau
pltclu
bool_plperl
hstore_plperl
jsonb_plperl
plpgsql
plv8
|
| Siblings | bool_plperlu
jsonb_plperlu
hstore_plperlu
|
Packages
| PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|
1.0
|
1.0
|
1.0
|
1.0
|
1.0
|
This is a built-in contrib extension ship with the PostgreSQL kernel
Install
Create this extension with:
CREATE EXTENSION plperlu CASCADE; -- requires plperluUsage
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 updated on