mirror of
https://github.com/postgres/postgres.git
synced 2025-06-16 06:01:02 +03:00
Cause library-preload feature to report error if specified initialization
function is not found. Also, make all the PL libraries have initialization functions with standard names. Patch from Joe Conway.
This commit is contained in:
@ -29,7 +29,7 @@
|
||||
* MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/pl/plpython/plpython.c,v 1.35 2003/07/25 23:37:30 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/pl/plpython/plpython.c,v 1.36 2003/07/31 18:36:39 tgl Exp $
|
||||
*
|
||||
*********************************************************************
|
||||
*/
|
||||
@ -170,10 +170,12 @@ typedef struct PLyResultObject
|
||||
/* function declarations
|
||||
*/
|
||||
|
||||
/* the only exported function, with the magic telling Postgresql
|
||||
* what function call interface it implements.
|
||||
/* Two exported functions: first is the magic telling Postgresql
|
||||
* what function call interface it implements. Second allows
|
||||
* preinitialization of the interpreter during postmaster startup.
|
||||
*/
|
||||
Datum plpython_call_handler(PG_FUNCTION_ARGS);
|
||||
void plpython_init(void);
|
||||
|
||||
PG_FUNCTION_INFO_V1(plpython_call_handler);
|
||||
|
||||
@ -329,8 +331,7 @@ plpython_call_handler(PG_FUNCTION_ARGS)
|
||||
|
||||
enter();
|
||||
|
||||
if (PLy_first_call)
|
||||
PLy_init_all();
|
||||
PLy_init_all();
|
||||
|
||||
if (SPI_connect() != SPI_OK_CONNECT)
|
||||
elog(ERROR, "could not connect to SPI manager");
|
||||
@ -2302,11 +2303,22 @@ PLy_spi_error_string(int code)
|
||||
/* language handler and interpreter initialization
|
||||
*/
|
||||
|
||||
/*
|
||||
* plpython_init() - Initialize everything that can be
|
||||
* safely initialized during postmaster
|
||||
* startup.
|
||||
*
|
||||
* DO NOT make this static --- it has to be callable by preload
|
||||
*/
|
||||
void
|
||||
PLy_init_all(void)
|
||||
plpython_init(void)
|
||||
{
|
||||
static volatile int init_active = 0;
|
||||
|
||||
/* Do initialization only once */
|
||||
if (!PLy_first_call)
|
||||
return;
|
||||
|
||||
enter();
|
||||
|
||||
if (init_active)
|
||||
@ -2327,6 +2339,20 @@ PLy_init_all(void)
|
||||
leave();
|
||||
}
|
||||
|
||||
static void
|
||||
PLy_init_all(void)
|
||||
{
|
||||
/* Execute postmaster-startup safe initialization */
|
||||
if (PLy_first_call)
|
||||
plpython_init();
|
||||
|
||||
/*
|
||||
* Any other initialization that must be done each time a new
|
||||
* backend starts -- currently none
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
PLy_init_interp(void)
|
||||
{
|
||||
|
Reference in New Issue
Block a user