This is an updated version of the third of the patches to be split out
from the former 'plperl feature patch 1'.
It includes changes following discussions with Tom Lane and others.
Changes in this patch:
- Added plperl.on_perl_init GUC for DBA use (PGC_SIGHUP)
SPI functions are not available when the code is run.
- Added interpreter destruction behaviour
Hooked via on_proc_exit().
Only has any effect for normal shutdown.
END blocks, if any, are run then objects are
destroyed, calling their DESTROY methods, if any.
SPI functions will die if called at this time.
Tim.
diff --git a/doc/src/sgml/plperl.sgml b/doc/src/sgml/plperl.sgml
index 5fa7e3a..06c63df 100644
*** a/doc/src/sgml/plperl.sgml
--- b/doc/src/sgml/plperl.sgml
*** CREATE TRIGGER test_valid_id_trig
*** 1028,1034
/para
/sect1
! sect1 id=plperl-missing
titleLimitations and Missing Features/title
para
--- 1028,1098
/para
/sect1
! sect1 id=plperl-under-the-hood
! titlePL/Perl Under the Hood/title
!
! sect2 id=plperl-config
! titleConfiguration/title
!
! para
! This section lists configuration parameters that affect applicationPL/Perl/.
! To set any of these parameters before applicationPL/Perl/ has been loaded,
! it is necessary to have added quoteliteralplperl// to the
! xref linkend=guc-custom-variable-classes list in
! filenamepostgresql.conf/filename.
! /para
!
! variablelist
!
! varlistentry id=guc-plperl-on-perl-init xreflabel=plperl.on_perl_init
! termvarnameplperl.on_perl_init/varname (typestring/type)/term
! indexterm
!primaryvarnameplperl.on_perl_init/ configuration parameter/primary
! /indexterm
! listitem
!para
!Specifies perl code to be executed when a perl interpreter is first initialized.
!The SPI functions are not available when this code is executed.
!If the code fails with an error it will abort the initialization of the interpreter
!and propagate out to the calling query, causing the current transaction
!or subtransaction to be aborted.
!/para
!para
! The perl code is limited to a single string. Longer code can be placed
! into a module and loaded by the literalon_perl_init/ string.
! Examples:
! programlisting
! plplerl.on_perl_init = '$ENV{NYTPROF}=start=no; require Devel::NYTProf::PgPLPerl'
! plplerl.on_perl_init = 'use lib /my/app; use MyApp::PgInit;'
! /programlisting
!/para
!para
!Initialization will happen in the postmaster if the plperl library is included
!in literalshared_preload_libraries/ (see xref linkend=shared_preload_libraries),
!in which case extra consideration should be given to the risk of destabilizing the postmaster.
!/para
!para
!This parameter can only be set in the postgresql.conf file or on the server command line.
!/para
! /listitem
! /varlistentry
!
! varlistentry id=guc-plperl-use-strict xreflabel=plperl.use_strict
! termvarnameplperl.use_strict/varname (typeboolean/type)/term
! indexterm
!primaryvarnameplperl.use_strict/ configuration parameter/primary
! /indexterm
! listitem
!para
!When set true subsequent compilations of PL/Perl functions have the literalstrict/ pragma enabled.
!This parameter does not affect functions already compiled in the current session.
!/para
! /listitem
! /varlistentry
!
! /variablelist
!
! sect2 id=plperl-missing
titleLimitations and Missing Features/title
para
*** CREATE TRIGGER test_valid_id_trig
*** 1067,1072
--- 1131,1138
/listitem
/itemizedlist
/para
+ /sect2
+
/sect1
/chapter
diff --git a/src/pl/plperl/plc_perlboot.pl b/src/pl/plperl/plc_perlboot.pl
index 24e2487..5d2e962 100644
*** a/src/pl/plperl/plc_perlboot.pl
--- b/src/pl/plperl/plc_perlboot.pl
***
*** 2,8
# $PostgreSQL$
PostgreSQL::InServer::Util::bootstrap();
- PostgreSQL::InServer::SPI::bootstrap();
use strict;
use warnings;
--- 2,7
diff --git a/src/pl/plperl/plperl.c b/src/pl/plperl/plperl.c
index 9277072..2202b0f 100644
*** a/src/pl/plperl/plperl.c
--- b/src/pl/plperl/plperl.c
***
*** 27,32
--- 27,33
#include miscadmin.h
#include nodes/makefuncs.h
#include parser/parse_type.h
+ #include storage/ipc.h
#include utils/builtins.h
#include utils/fmgroids.h
#include utils/guc.h
*** static HTAB *plperl_proc_hash = NULL;
*** 138,143
--- 139,146
static HTAB *plperl_query_hash = NULL;
static bool plperl_use_strict = false;
+ static char *plperl_on_perl_init = NULL;
+ static bool plperl_ending = false;
/* this is saved and restored by plperl_call_handler */
static plperl_call_data *current_call_data = NULL;
*** Datum plperl_validator(PG_FUNCTION_ARGS
*** 151,156