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. '开发者_如何学Cuse strict; use feature 'switch';).
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.
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.
加载中,请稍侯......
精彩评论