Iam having problem creating postgresql function in plperl
CREATE OR REPLACE FUNCTION zm_json (TEXT, TEXT) RETURNS TEXT AS $$
use JSON::XS;
# do something
return $json_out;
$$ LANGUAGE plperl;
When i want to create function above iam getting
ERROR: creation of Perl function "zm_json" failed: Unable to load JSON/XS.pm into plperl at line 2.
BEGIN failed--compilation aborted at line 2.
JSON::XS is under /usr/lib/perl5 and perl inside my postgres shows this directory in libs
CREATE OR REPLACE FUNCTION zm_perl_directories() RETURNS TEXT AS $$
return join(':', @INC);
$$ LANGUAGE plperl;
select zm_perl_directories();
-[ RECORD 1 ]-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------
zm_perl_directories | /etc/perl:/usr/local/lib/perl/5.10.1:/usr/local/share/perl/5.10.1:/usr/lib/perl5:/usr/share/perl5:/usr/lib/perl/5.10:/usr/share/perl/5.10:/usr/local/lib/site_perl:.
Any ideas why?
I think plperl is using a safer subset of Perl capabilities.
As such, some language builtins are restricted.
useorrequireis one of those, otherwise it’d allow for arbitrary code execution.If you don’t care about that, feel free to use
PL/Perlu, which is the unrestricted Perl.