views:

171

answers:

2

If I wrote something in plperlu, and it used a Perl module (e.g. MyModule::Foo), when would that module be reloaded? Does it keep track of them like mod_perl's Apache2::Reload, so that a touch will cause a reinterpretation?

+1  A: 

Didn't you ask this question yesterday?

http://stackoverflow.com/questions/558519/does-postgresql-keep-its-pl-interpreters-loaded-persistently

jrockway
I kind of asked two questions, and since the one was answered and possibly is not related to the other, I thought I should accept the answer and rephrase. The difference is between whether Perl code is kept around and whether the Perl interpreter stays loaded.
Kev
It is the same question. The interpreter keeps the module loaded, so if the interpreter stays loaded, so do the modules.
Leon Timmermans
So when do they get reloaded, if they change?
Kev
Does it keep track of them like mod_perl's Apache2::Reload, so that a touch will cause a reinterpretation?
Kev
Leon, you should've submitted that as an answer, it was new information to me, I would've modded you up.
Kev
A: 

After some testing based on what Leon commented, apparently MyModule::Foo stays in memory from the first time it gets used successfully, but only within the current process (i.e., database handle.)

If there were errors in either compiling it (it would complain when you defined a function that use'd it) or using it (when you select from your function, for example), it'll reload it. However, I can't see a way to force it to reload within a process once it successfully runs, even by calling a different sub in the module that does error out.

Also, if you're accessing PostgreSQL via Apache::DBI, this means your cached handles won't pick up module changes unless you disconnect all the cached handles.

So I guess there's no way to force a check within a process, a la Apache2::Reload...

Kev