Skip site navigation (1) Skip section navigation (2)

Re: BUG #5066: plperl issues with perl_destruct() and ENDblocks

From: David Fetter <david(at)fetter(dot)org>
To: Tim Bunce <Tim(dot)Bunce(at)pobox(dot)com>
Cc: Alvaro Herrera <alvherre(at)commandprompt(dot)com>,Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Robert Haas <robertmhaas(at)gmail(dot)com>,pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #5066: plperl issues with perl_destruct() and ENDblocks
Date: 2009-09-21 15:51:10
Message-ID: 20090921155110.GI31599@fetter.org (view raw or flat)
Thread:
Lists: pgsql-bugs
On Mon, Sep 21, 2009 at 11:05:43AM +0100, Tim Bunce wrote:
> On Sun, Sep 20, 2009 at 10:00:01PM -0400, Alvaro Herrera wrote:
> > There's a definitional problem here however.  When should we call the
> > destructor?  My impression is that it should happen when the calling
> > query terminates, not when the backend shuts down.  I'm sure this will
> > cause other issues -- for example %_SHARED will be destroyed way too
> > early.
> 
> The perlmod man page says:
> 
>         An "END" code block is executed as late as possible, that is, after
>        perl has finished running the program and just before the interpreter
>        is being exited, even if it is exiting as a result of a die() function.
>        [...]
>        Note that "END" code blocks are not executed at the end of a string
>        "eval()": if any "END" code blocks are created in a string "eval()",
>        they will be executed just as any other "END" code block of that pack‐
>        age in LIFO order just before the interpreter is being exited.
> 
> so executing at the end of query, a transaction, or a session would be
> wrong. They should execute "as late as possible", "just before the
> interpreter being exited".

Taken literally, that would mean, "the last action before the backend
exits," but at least to me, that sounds troubling for the same reasons
that "end of transaction" triggers do.  What happens when there are
two different END blocks in a session?  With connection poolers,
backends can last quite awhile.  Is it OK for the END block to run
hours after the rest of the code?

Cheers,
David.
-- 
David Fetter <david(at)fetter(dot)org> http://fetter.org/
Phone: +1 415 235 3778  AIM: dfetter666  Yahoo!: dfetter
Skype: davidfetter      XMPP: david(dot)fetter(at)gmail(dot)com

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate

In response to

Responses

pgsql-bugs by date

Next:From: Alvaro HerreraDate: 2009-09-21 16:06:30
Subject: Re: BUG #5066: plperl issues with perl_destruct() and END blocks
Previous:From: Tom LaneDate: 2009-09-21 15:42:41
Subject: Re: BUG #5070: Drop <schema> cascade fails on 8.4

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group