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?
-
Didn't you ask this question yesterday? http://stackoverflow.com/questions/558519/does-postgresql-keep-its-pl-interpreters-loaded-persistently – jrockway Feb 18 '09 at 20:49
-
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 Feb 18 '09 at 20:51
-
1It is the same question. The interpreter keeps the module loaded, so if the interpreter stays loaded, so do the modules. – Leon Timmermans Feb 18 '09 at 21:06
-
So when do they get reloaded, if they change? – Kev Feb 18 '09 at 21:14
-
Does it keep track of them like mod_perl's Apache2::Reload, so that a touch will cause a reinterpretation? – Kev Feb 18 '09 at 21:17
-
1Leon, you should've submitted that as an answer, it was new information to me, I would've modded you up. – Kev Feb 19 '09 at 13:48
1 Answers
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...

- 15,899
- 15
- 79
- 112