While using PL/R in a web based application, I noticed that the library
load and initialization time is significant enough to be annoying. So I
wrote a quick hack to load and initialize the library on postmaster
startup. This way, the backends get a fully initialized copy of the
interpreter when they are forked. The hack was to postmaster.c just
after the SSL initialization code at about line 650 (just remembered
this is 7.3.2 though):

if (true) /* later use startup GUC var */
{
char *fullname = "$libdir/plr.so";
char *funcname = "start_interp";
func_ptr initfunc;

initfunc = (func_ptr)
load_external_function(fullname, funcname, true, NULL);
(*initfunc)();
}

(I also had to add a #define for func_ptr)

This brings me to a couple questions:

1. Is there anything inherently dangerous with this approach?
My light testing seems to show that it works quite well for
my purpose.

2. It seems to me that other libraries such as those for PL/Tcl,
PL/Perl, etc may have the same issue. Is there any merit in
a GUC variable to allow libraries such as this to be loaded
and initialized at postmaster start? I'll generalize this and
send in a patch if there is interest.

Joe

Search Discussions

Discussion Posts

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 6 | next ›
Discussion Overview
grouppgsql-hackers @
categoriespostgresql
postedFeb 13, '03 at 4:17a
activeMay 28, '03 at 5:12p
posts6
users5
websitepostgresql.org...
irc#postgresql

People

Translate

site design / logo © 2022 Grokbase