Calling PL/Perl SPI from within a module.
You may or may not have noticed that you can't simply call PLPerl SPI subroutines from within your module. What happens is you get an error saying cannot find Package::Name::spi_*. This is because the PL/Perl SPI subroutines are not provided as perl CORE functions but rather local subroutines in the main:: package.
What can be done?
You may be tempted (as I was) to pass in an anonymous sub routine reference to your module like so:
return Package::Name->new()->process( sub { re…
If its worth doing, its worth doing right.