Thread

  1. Add on_perl_init and proper destruction to plperl UPDATED [PATCH]

    Tim Bunce <tim.bunce@pobox.com> — 2010-01-28T15:46:12Z

    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.
    
  2. Re: Add on_perl_init and proper destruction to plperl UPDATED [PATCH]

    Andrew Dunstan <andrew@dunslane.net> — 2010-01-29T04:02:23Z

    
    Tim Bunce wrote:
    > 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.
    >   
    
    This patch is giving me a build error on Windows:
    
    dlltool --export-all  --output-def libplperldll.def plperl.o SPI.o Util.o
    dllwrap  -o plperl.dll --dllname plperl.dll  --def libplperldll.def 
    plperl.o SPI.o Util.o -L../../../src/backend -lpostgres 
    -LC:/Perl/lib/CORE -L../../../src/port -L/c/tcl/lib -lperl58
    plperl.o(.text+0x33b): In function `plperl_destroy_interp':
    C:/msys/1.0/home/pgrunner/bf/root/HEAD/pgsql.plperlnew/src/pl/plperl/plperl.c:639: 
    undefined reference to `Perl_sv_clean_objs'
    collect2: ld returned 1 exit status
    c:\mingw\bin\dllwrap.exe: c:\mingw\bin\gcc exited with status 1
    
    cheers
    
    andrew
    
    
    
    
    
  3. Re: Add on_perl_init and proper destruction to plperl UPDATED [PATCH]

    Tim Bunce <tim.bunce@pobox.com> — 2010-01-29T11:33:43Z

    On Thu, Jan 28, 2010 at 11:02:23PM -0500, Andrew Dunstan wrote:
    > 
    > 
    > Tim Bunce wrote:
    > >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.
    > 
    > This patch is giving me a build error on Windows:
    > 
    > undefined reference to `Perl_sv_clean_objs'
    
    Ah, phooey. That's technically a private function so isn't exported on
    platforms that support selective exporting.
    
    The options are either to go back to calling perl_destruct(), which
    would then require careful auditing of what perl_destruct actually does,
    or do simply not bother destroying objects.
    
    I'm going to go for the latter. Time is short and calling END blocks is
    still a major step forward. (Anyone who needs objects destroyed can
    probably arrange that themselves via an END block.)
    
    Updated patch to follow...
    
    Tim.
    
    
  4. Add on_perl_init and proper destruction to plperl UPDATE v3 [PATCH]

    Tim Bunce <tim.bunce@pobox.com> — 2010-01-29T13:33:18Z

    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.
       SPI functions will die if called at this time.
    
    This updated version no longer tries to call object destructors.
    I've added a note in the Limitations section of the PL/Perl docs.
    It also adds a PERL_SET_CONTEXT() that's needed but was missing.
    
    Tim.
    
  5. Re: Add on_perl_init and proper destruction to plperl UPDATE v3 [PATCH]

    Andrew Dunstan <andrew@dunslane.net> — 2010-01-30T02:10:48Z

    
    Tim Bunce wrote:
    > 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.
    >    SPI functions will die if called at this time.
    >
    > This updated version no longer tries to call object destructors.
    > I've added a note in the Limitations section of the PL/Perl docs.
    > It also adds a PERL_SET_CONTEXT() that's needed but was missing.
    >
    >   
    
    I have committed this. The final thing that persuaded me that no great 
    damage would be done by on_perl_init was the realization that we already 
    have the ability to do more or less the same thing anyway via standard 
    Perl mechanisms, and I'd be very surprised if enterprising Perl users 
    hadn't made use of it.
    
    My impression is that the on_trusted_init and on_untrusted_init settings 
    that are in the next patch are a bit less controversial.
    
    Tim, can you rebase the last two patches against current CVS HEAD?
    
    cheers
    
    andrew
    
    
  6. Re: Add on_perl_init and proper destruction to plperl UPDATE v3 [PATCH]

    Tim Bunce <tim.bunce@pobox.com> — 2010-01-30T14:25:55Z

    On Fri, Jan 29, 2010 at 09:10:48PM -0500, Andrew Dunstan wrote:
    > 
    > Tim Bunce wrote:
    > >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.
    > >   SPI functions will die if called at this time.
    > >
    > >This updated version no longer tries to call object destructors.
    > >I've added a note in the Limitations section of the PL/Perl docs.
    > >It also adds a PERL_SET_CONTEXT() that's needed but was missing.
    > 
    > I have committed this.
    
    Many thanks.
    
    > Tim, can you rebase the last two patches against current CVS HEAD?
    
    ASAP...
    
    Tim.