Re: Add on_perl_init and proper destruction to plperl [PATCH] - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Add on_perl_init and proper destruction to plperl [PATCH]
Date
Msg-id 8392.1264611359@sss.pgh.pa.us
Whole thread Raw
In response to Re: Add on_perl_init and proper destruction to plperl [PATCH]  (Andrew Dunstan <andrew@dunslane.net>)
List pgsql-hackers
Andrew Dunstan <andrew@dunslane.net> writes:
> I see I asked the wrong question. Start again.
> What more should be done to make all or some of it acceptable?

I think a "must" is to get rid of the use of atexit().  Possibly an
on_proc_exit callback could be used instead, although I'm not sure how
you'd handle the case of code loaded in the postmaster that would like
corresponding exit-time code to happen in child processes.  (OTOH, it
seems likely that it's impossible to make that work correctly anyway.
It certainly isn't going to work the same on EXEC_BACKEND platforms
as anywhere else, and I don't particularly want to see us documenting
that the feature works differently on Windows than elsewhere.)

Dropping the ability to make the postmaster run any such code would go a
very long way towards fixing the above, as well as assuaging other
fears.

The other thing that I find entirely unconvincing is Tim's idea that
shutting off SPI isolates perl from the rest of the backend.  I have
no confidence in that, but no real idea of how to do better either :-(.
If you think that shutting off SPI is sufficient, you can find
counterexamples in the CVS history, for instance where we had to take
special measures to prevent Perl from screwing up the locale settings.
I'm afraid that on_perl_init is going to vastly expand the opportunities
for that kind of unwanted side-effect; and the earlier that it runs, the
more likely it's going to be that we can't recover easily.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Andrew Dunstan
Date:
Subject: Re: Add on_perl_init and proper destruction to plperl [PATCH]
Next
From: Tom Lane
Date:
Subject: Re: Add on_perl_init and proper destruction to plperl [PATCH]