mirror of
https://github.com/postgres/postgres.git
synced 2025-07-26 01:22:12 +03:00
Various small improvements and cleanups for PL/Perl.
- Allow (ineffective) use of 'require' in plperl If the required module is not already loaded then it dies. So "use strict;" now works in plperl. - Pre-load the feature module if perl >= 5.10. So "use feature :5.10;" now works in plperl. - Stored procedure subs are now given names. The names are not visible in ordinary use, but they make tools like Devel::NYTProf and Devel::Cover much more useful. - Simplified and generalized the subroutine creation code. Now one code path for generating sub source code, not four. Can generate multiple 'use' statements with specific imports (which handles plperl.use_strict currently and can easily be extended to handle a plperl.use_feature=':5.12' in future). - Disallows use of Safe version 2.20 which is broken for PL/Perl. http://rt.perl.org/rt3/Ticket/Display.html?id=72068 - Assorted minor optimizations by pre-growing data structures. Patch from Tim Bunce, reviewed by Alex Hunsaker.
This commit is contained in:
@ -368,5 +368,13 @@ DO $$
|
||||
$$ LANGUAGE plperl;
|
||||
|
||||
-- check that restricted operations are rejected in a plperl DO block
|
||||
DO $$ use Config; $$ LANGUAGE plperl;
|
||||
DO $$ eval "1+1"; $$ LANGUAGE plperl;
|
||||
|
||||
-- check that we can't "use" a module that's not been loaded already
|
||||
-- compile-time error: "Unable to load blib.pm into plperl"
|
||||
DO $$ use blib; $$ LANGUAGE plperl;
|
||||
|
||||
-- check that we can "use" a module that has already been loaded
|
||||
-- runtime error: "Can't use string ("foo") as a SCALAR ref while "strict refs" in use
|
||||
DO $do$ use strict; my $name = "foo"; my $ref = $$name; $do$ LANGUAGE plperl;
|
||||
|
||||
|
Reference in New Issue
Block a user