Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

can you use libraries in PL/Perl

I'm just curious if when writing PL/Perl functions if I can have a use My::Lib; statement, or enable pragma's and features (e.g. 'use strict; use feature 'switch';).

like image 935
xenoterracide Avatar asked Aug 20 '10 02:08

xenoterracide


2 Answers

Not when using PL/Perl. It restricts the use of require and use, so you cannot import modules. However, you can install PL/Perlu (for unrestricted mode) which allows you to load modules.

plperlu can be considered a security risk, however, as it also allows filesystem commands such as open.

like image 120
CanSpice Avatar answered Sep 30 '22 05:09

CanSpice


For security purposes you cannot run a use/require statement within a function under plperl, but you can under plperlu.

IF you want to use modules in a secure way, you can add plperl.on_init = 'require "myperlinit.pl";' to the postgresql.conf file, then create a perl script called myperlinit.pl in the data directory which contains your uses. This will require a restart of the database server and these modules are available to all of your functions.

If you want strict mode turned on, you can plperl.use_strict = true will add it.

Note: this script is executed once per connection when the first perl function is called, and not when the connection is created.

like image 38
Rahly Avatar answered Sep 30 '22 03:09

Rahly