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');
Index: doc/src/sgml/runtime.sgml
===
RCS file: /opt/src/cvs/pgsql-server/doc/src/sgml/runtime.sgml,v
retrieving revision 1.197
diff -c -r1.197 runtime.sgml
*** doc/src/sgml/runtime.sgml 29 Jul 2003 00:03:17 - 1.197
--- doc/src/sgml/runtime.sgml 31 Jul 2003 18:09:00 -
***
*** 1008,1032
can also be optionally specified by adding a colon followed by
the name of the initialization function after the library
name. For example
! literal'$libdir/mylib:init_mylib'/literal would cause
! literalmylib/ to be preloaded and literalinit_mylib/
to be executed. If more than one library is to be loaded, they
must be delimited with a comma.
/para
para
! If literalmylib/ is not found, the server will fail to
! start. However, if literalinit_mylib/ is not found,
! literalmylib/ will still be preloaded without executing
! the initialization function.
/para
para
By preloading a shared library (and initializing it if
applicable), the library startup time is avoided when the
library is first used. However, the time to start each new
! server process may increase, even if that process never
! uses the library.
/para
/listitem
/varlistentry
--- 1008,1037
can also be optionally specified by adding a colon followed by
the name of the initialization function after the library
name. For example
! literal'$libdir/mylib:mylib_init'/literal would cause
! literalmylib/ to be preloaded and literalmylib_init/
to be executed. If more than one library is to be loaded, they
must be delimited with a comma.
/para
para
! If literalmylib/ or literalmylib_init/ are not found, the
! server will fail to start.
!/para
!
!para
! PostgreSQL Procedural Language libraries may be preloaded in this way,
! typically by using the syntax literal'$libdir/plXXX:plXXX_init'
! /literal where literalXXX/literal is literalpgsql/,
! literalperl/, literaltcl/, or literalpython/.
/para
para