pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedUse of perl modules in plperl ?
3+ messages / 2 participants
[nested] [flat]
* Use of perl modules in plperl ?
@ 2020-03-04 11:03 stan <stanb@panix.com>
0 siblings, 2 replies; 3+ messages in thread
From: stan @ 2020-03-04 11:03 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
I am trying to examine the values of $_TD->{new}. I thought the easiest way
to see what this structure looked like was to use the Dumper functionality.
To do so I need to include the appropriate Perl module, which I would think
would be done like this:
use Data::Dumper qw(Dumper);
But inserting that into the script to create the function, like this:
CREATE OR REPLACE FUNCTION valid_id() RETURNS trigger AS $$
use Data::Dumper qw(Dumper);
if (($_TD->{new}{i} >= 100) || ($_TD->{new}{i} <= 0)) {
......
Returned this error message:
ERROR: Unable to load Data/Dumper.pm into plperl at line 2.
BEGIN failed--compilation aborted at line 2.
CONTEXT: compilation of PL/Perl function "valid_id"
What do I have to do to use Perl modules in plperl function/
BTW this works outside plperl
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper qw(Dumper);
..................
Thanks for the help.
--
"They that would give up essential liberty for temporary safety deserve
neither liberty nor safety."
-- Benjamin Franklin
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Use of perl modules in plperl ?
@ 2020-03-04 11:15 stan <stanb@panix.com>
parent: stan <stanb@panix.com>
1 sibling, 0 replies; 3+ messages in thread
From: stan @ 2020-03-04 11:15 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
On Wed, Mar 04, 2020 at 06:03:22AM -0500, stan wrote:
> I am trying to examine the values of $_TD->{new}. I thought the easiest way
> to see what this structure looked like was to use the Dumper functionality.
> To do so I need to include the appropriate Perl module, which I would think
> would be done like this:
>
> use Data::Dumper qw(Dumper);
>
> But inserting that into the script to create the function, like this:
>
> CREATE OR REPLACE FUNCTION valid_id() RETURNS trigger AS $$
> use Data::Dumper qw(Dumper);
> if (($_TD->{new}{i} >= 100) || ($_TD->{new}{i} <= 0)) {
> ......
>
> Returned this error message:
>
> ERROR: Unable to load Data/Dumper.pm into plperl at line 2.
> BEGIN failed--compilation aborted at line 2.
> CONTEXT: compilation of PL/Perl function "valid_id"
>
> What do I have to do to use Perl modules in plperl function/
>
> BTW this works outside plperl
>
> #!/usr/bin/perl
> use strict;
> use warnings;
> use Data::Dumper qw(Dumper);
>
> ..................
>
> Thanks for the help.
>
Found plperlu in the docs.
But some syntax help on referencing all the values returned by $_TD->{new}
would be helpful.
--
"They that would give up essential liberty for temporary safety deserve
neither liberty nor safety."
-- Benjamin Franklin
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Use of perl modules in plperl ?
@ 2020-03-04 11:15 hubert depesz lubaczewski <depesz@depesz.com>
parent: stan <stanb@panix.com>
1 sibling, 0 replies; 3+ messages in thread
From: hubert depesz lubaczewski @ 2020-03-04 11:15 UTC (permalink / raw)
To: stan <stanb@panix.com>; +Cc: pgsql-general@lists.postgresql.org
On Wed, Mar 04, 2020 at 06:03:22AM -0500, stan wrote:
> I am trying to examine the values of $_TD->{new}. I thought the easiest way
> to see what this structure looked like was to use the Dumper functionality.
> To do so I need to include the appropriate Perl module, which I would think
> would be done like this:
> use Data::Dumper qw(Dumper);
plperl is trusted, and you can't use "use" in it.
More on this:
https://www.postgresql.org/docs/current/plperl-trusted.html
You have two options:
1. Switch to pl/PerlU
2. set plperl.on_init to whatever "use" you need, examples:
https://www.postgresql.org/docs/current/plperl-under-the-hood.html#PLPERL-CONFIG
Best regards,
depesz
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2020-03-04 11:15 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-03-04 11:03 Use of perl modules in plperl ? stan <stanb@panix.com>
2020-03-04 11:15 ` stan <stanb@panix.com>
2020-03-04 11:15 ` hubert depesz lubaczewski <depesz@depesz.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox