loading libraries on Postmaster startup - Mailing list pgsql-hackers

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
wellfor    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
meritin    a GUC variable to allow libraries such as this to be loaded    and initialized at postmaster start? I'll
generalizethis and    send in a patch if there is interest.
 

Joe




pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: log_duration
Next
From: Greg Stark
Date:
Subject: Re: loading libraries on Postmaster startup