Re: plperl & sort
От | Alex Hunsaker |
---|---|
Тема | Re: plperl & sort |
Дата | |
Msg-id | 34d269d40811041249r46b45702j22ee4fab28716286@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: plperl & sort ("Alex Hunsaker" <badalex@gmail.com>) |
Ответы |
Re: plperl & sort
|
Список | pgsql-bugs |
On Tue, Nov 4, 2008 at 12:43, Alex Hunsaker <badalex@gmail.com> wrote: > It has something to do with anon subs not sure what... It has to do with us returning the anonymous sub inside of the safe and then calling the function outside of the safe (or at least in a different namespace) we do something eqvilient to this: my $func_ptr = $safe->reval('sub { ... }'); $func_ptr->(); because safe makes its own namespace from perldoc Safe The "root" of the namespace (i.e. "main::") is changed to a different package and code evaluated in the compartment cannot refer to variables outside this namespace, even with run-time glob lookups and other tricks. I only see one way to "fix" this which is to do something groddy like share a global variable between the safe and the real interpreter. Something like: my $_pl_sub; sub call_pl_sub { retrun $_pl_sub; } $safe->share(qw(call_pl_sub); my $sub = $safe->reval('sub { ...}'); $_pl_sub = $sub; $safe->reval('call_pl_sub();'); Note I tried just sharing $_pl_sub and doing $safe->reval('$_pl_sub->()'); but I just get 'Undefined subroutine &main::' Should I work up a patch? Assuming someone confirm this?
В списке pgsql-bugs по дате отправления: