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);

(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.


---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]

Reply via email to