Skip site navigation (1) Skip section navigation (2)

preload libraries patch [was: [GENERAL] hexadecimal to decimal]

From: Joe Conway <mail(at)joeconway(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Ron Johnson <ron(dot)l(dot)johnson(at)cox(dot)net>,"Patches (PostgreSQL)" <pgsql-patches(at)postgresql(dot)org>
Subject: preload libraries patch [was: [GENERAL] hexadecimal to decimal]
Date: 2003-07-31 17:56:43
Message-ID: 3F29585B.6060305@joeconway.com (view raw or flat)
Thread:
Lists: pgsql-generalpgsql-patches
Tom Lane wrote:
> It seems entirely sensible to me for the postmaster to choke on invalid
> settings in postgresql.conf.  Better than failing to mention the problem
> at all, anyway.
> 
>>2) do you want a patch that exports plperl_init_all() (and I guess 
>>similar init functions in pltcl and plpython)?
> 
> Yeah, I guess.  Might as well make one in plpgsql too --- even if it
> does nothing today, it might be useful in the future, so the
> documentation ought to recommend "call 'plxxx_init' when preloading plxxx"
> as a general thing.
> 

Attached is a patch that:
1) fixes the behavior of preload_libraries
2) adds an exported xxx_init() function to plperl, pltcl, plpython, and
    plpgsql
3) updates the documentation for the changes

Compiles clean, and passes all regression tests with the following line 
in postgresql.conf (this probably won't wrap nicely):
preload_libraries = 
'$libdir/plperl:plperl_init,$libdir/pltcl:pltcl_init,$libdir/plpython:plpython_init,$libdir/plpgsql:plpgsql_init'

I ran the following both without (one psql session for all four 
statements) and with preloading (also all four in one session). The 
actual function definitions at the bottom of the email:

without preload:
=====================================================================
regression=# explain analyze select echo_plperl('hello');
  Total runtime: 55.29 msec
regression=# explain analyze select echo_pltcl('hello');
  Total runtime: 23.34 msec
regression=# explain analyze select echo_plpythonu('hello');
  Total runtime: 32.40 msec
regression=# explain analyze select echo_plpgsql('hello');
  Total runtime: 3.09 msec

with preload:
=====================================================================
regression=# explain analyze select echo_plperl('hello');
  Total runtime: 5.14 msec
regression=# explain analyze select echo_pltcl('hello');
  Total runtime: 7.64 msec
regression=# explain analyze select echo_plpythonu('hello');
  Total runtime: 1.91 msec
regression=# explain analyze select echo_plpgsql('hello');
  Total runtime: 1.35 msec

Please apply.

Thanks,

Joe


--test functions
CREATE OR REPLACE FUNCTION echo_plperl(text) RETURNS text AS '
   return $_[0];
' LANGUAGE plperl;

CREATE OR REPLACE FUNCTION echo_pltcl(text) RETURNS text AS '
   return $1
' LANGUAGE pltcl;

CREATE OR REPLACE FUNCTION echo_plpythonu(text) RETURNS text AS '
   return args[0]
' LANGUAGE plpythonu;

CREATE OR REPLACE FUNCTION echo_plpgsql(text) RETURNS text AS '
   begin
     return $1;
   end;
' LANGUAGE plpgsql;

explain analyze select echo_plperl('hello');
explain analyze select echo_pltcl('hello');
explain analyze select echo_plpythonu('hello');
explain analyze select echo_plpgsql('hello');

Attachment: preload-fix.01.patch
Description: text/plain (15.2 KB)

In response to

Responses

pgsql-patches by date

Next:From: Tom LaneDate: 2003-07-31 18:33:04
Subject: Re: preload libraries patch [was: [GENERAL] hexadecimal to decimal]
Previous:From: Josh BerkusDate: 2003-07-31 16:43:32
Subject: Re: Proof-of-concept for initdb-time shared_buffers selection

pgsql-general by date

Next:From: Sergio PiliDate: 2003-07-31 18:02:10
Subject: Transactions across multiples databases
Previous:From: Cornelia BoenigkDate: 2003-07-31 17:25:41
Subject: Re: [GENERAL] interesting PHP/MySQL thread

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group