2 # Copyright (c) 2021, PostgreSQL Global Development Group
4 # src/pl/plperl/plc_perlboot.pl
10 use vars
qw(%_SHARED $_TD);
12 PostgreSQL::InServer::Util::bootstrap();
18 return ref($_[0]) =~ m/^(?:PostgreSQL::InServer::)?ARRAY$/;
21 sub ::encode_array_literal
23 my ($arg, $delim) = @_;
24 return $arg unless (::is_array_ref($arg));
25 $delim = ', ' unless defined $delim;
27 foreach my $elem (@$arg)
29 $res .= $delim if length $res;
32 $res .= ::encode_array_literal($elem, $delim);
36 (my $str = $elem) =~ s/(["\\])/\\$1/g;
47 sub ::encode_array_constructor
50 return ::quote_nullable($arg) unless ::is_array_ref($arg);
52 map { (ref $_) ? ::encode_array_constructor($_) : ::quote_nullable($_) }
58 #<<< protect next line from perltidy so perlcritic annotation works
59 package PostgreSQL::InServer; ## no critic (RequireFilenameMatchesPackage)
66 (my $msg = shift) =~ s/\(eval \d+\) //g;
68 &::elog(&::WARNING, $msg);
71 $SIG{__WARN__} = \&plperl_warn;
75 (my $msg = shift) =~ s/\(eval \d+\) //g;
78 $SIG{__DIE__} = \&plperl_die;
82 my ($name, $imports, $prolog, $src) = @_;
84 my $BEGIN = join "\n", map {
85 my $names = $imports->{$_} || [];
86 "$_->import(qw(@$names));"
87 } sort keys %$imports;
88 $BEGIN &&= "BEGIN { $BEGIN }";
90 return qq[ package main; sub { $BEGIN $prolog $src } ];
95 ## no critic (ProhibitNoStrict, ProhibitStringyEval);
96 no strict; # default to no strict for the eval
97 no warnings; # default to no warnings for the eval
98 my $ret = eval(mkfuncsrc(@_));
99 $@ =~ s/\(eval \d+\) //g if $@;
109 package PostgreSQL::InServer::ARRAY;
120 return ::encode_typed_literal($self->{'array'}, $self->{'typeoid'});
125 return shift->{'array'};