src/pl/tcl/pltcl.c
void
_PG_init(void)
{
	Tcl_NotifierProcs notifier;
	HASHCTL		hash_ctl;

	/* Be sure we do initialization only once (should be redundant now) */
	if (pltcl_pm_init_done)
		return;

	pg_bindtextdomain(TEXTDOMAIN);

#ifdef WIN32
	/* Required on win32 to prevent error loading init.tcl */
	Tcl_FindExecutable("");
#endif

	/*
	 * Override the functions in the Notifier subsystem.  See comments above.
	 */
	notifier.setTimerProc = pltcl_SetTimer;
	notifier.waitForEventProc = pltcl_WaitForEvent;
	notifier.createFileHandlerProc = pltcl_CreateFileHandler;
	notifier.deleteFileHandlerProc = pltcl_DeleteFileHandler;
	notifier.initNotifierProc = pltcl_InitNotifier;
	notifier.finalizeNotifierProc = pltcl_FinalizeNotifier;
	notifier.alertNotifierProc = pltcl_AlertNotifier;
	notifier.serviceModeHookProc = pltcl_ServiceModeHook;
	Tcl_SetNotifier(&notifier);

	/************************************************************
	 * Create the dummy hold interpreter to prevent close of
	 * stdout and stderr on DeleteInterp
	 ************************************************************/
	if ((pltcl_hold_interp = Tcl_CreateInterp()) == NULL)
		elog(ERROR, "could not create dummy Tcl interpreter");
	if (Tcl_Init(pltcl_hold_interp) == TCL_ERROR)
		elog(ERROR, "could not initialize dummy Tcl interpreter");

	/************************************************************
	 * Create the hash table for working interpreters
	 ************************************************************/
	hash_ctl.keysize = sizeof(Oid);
	hash_ctl.entrysize = sizeof(pltcl_interp_desc);
	pltcl_interp_htab = hash_create("PL/Tcl interpreters",
									8,
									&hash_ctl,
									HASH_ELEM | HASH_BLOBS);

	/************************************************************
	 * Create the hash table for function lookup
	 ************************************************************/
	hash_ctl.keysize = sizeof(pltcl_proc_key);
	hash_ctl.entrysize = sizeof(pltcl_proc_ptr);
	pltcl_proc_htab = hash_create("PL/Tcl functions",
								  100,
								  &hash_ctl,
								  HASH_ELEM | HASH_BLOBS);

	/************************************************************
	 * Define PL/Tcl's custom GUCs
	 ************************************************************/
	DefineCustomStringVariable("pltcl.start_proc",
							   gettext_noop("PL/Tcl function to call once when pltcl is first used."),
							   NULL,
							   &pltcl_start_proc,
							   NULL,
							   PGC_SUSET, 0,
							   NULL, NULL, NULL);
	DefineCustomStringVariable("pltclu.start_proc",
							   gettext_noop("PL/TclU function to call once when pltclu is first used."),
							   NULL,
							   &pltclu_start_proc,
							   NULL,
							   PGC_SUSET, 0,
							   NULL, NULL, NULL);

	EmitWarningsOnPlaceholders("pltcl");
	EmitWarningsOnPlaceholders("pltclu");

	pltcl_pm_init_done = true;
}
/*
 * _PG_init()			- library load-time initialization
 *
 * DO NOT make this static nor change its name!
 *
 * The work done here must be safe to do in the postmaster process,
 * in case the pltcl library is preloaded in the postmaster.
 */
_PG_init()                   - library load-time initialization
DO NOT make this static nor change its name!

The work done here must be safe to do in the postmaster process,
in case the pltcl library is preloaded in the postmaster.
_PG_init () - library load - time initialization DO NOT make this static nor change its name! The work done here must be safe to do in the postmaster process in case the pltcl library is preloaded in the postmaster .
void
_PG_init(void)
{
	Tcl_NotifierProcs notifier;
	HASHCTL		hash_ctl;
	if (pltcl_pm_init_done)
		return;
	pg_bindtextdomain(TEXTDOMAIN);
#ifdef WIN32
	Tcl_FindExecutable("");
#endif
	notifier.setTimerProc = pltcl_SetTimer;
	notifier.waitForEventProc = pltcl_WaitForEvent;
	notifier.createFileHandlerProc = pltcl_CreateFileHandler;
	notifier.deleteFileHandlerProc = pltcl_DeleteFileHandler;
	notifier.initNotifierProc = pltcl_InitNotifier;
	notifier.finalizeNotifierProc = pltcl_FinalizeNotifier;
	notifier.alertNotifierProc = pltcl_AlertNotifier;
	notifier.serviceModeHookProc = pltcl_ServiceModeHook;
	Tcl_SetNotifier(&notifier);
	if ((pltcl_hold_interp = Tcl_CreateInterp()) == NULL)
		elog(ERROR, "could not create dummy Tcl interpreter");
	if (Tcl_Init(pltcl_hold_interp) == TCL_ERROR)
		elog(ERROR, "could not initialize dummy Tcl interpreter");
	hash_ctl.keysize = sizeof(Oid);
	hash_ctl.entrysize = sizeof(pltcl_interp_desc);
	pltcl_interp_htab = hash_create("PL/Tcl interpreters",
									8,
									&hash_ctl,
									HASH_ELEM | HASH_BLOBS);
	hash_ctl.keysize = sizeof(pltcl_proc_key);
	hash_ctl.entrysize = sizeof(pltcl_proc_ptr);
	pltcl_proc_htab = hash_create("PL/Tcl functions",
								  100,
								  &hash_ctl,
								  HASH_ELEM | HASH_BLOBS);
	DefineCustomStringVariable("pltcl.start_proc",
							   gettext_noop("PL/Tcl function to call once when pltcl is first used."),
							   NULL,
							   &pltcl_start_proc,
							   NULL,
							   PGC_SUSET, 0,
							   NULL, NULL, NULL);
	DefineCustomStringVariable("pltclu.start_proc",
							   gettext_noop("PL/TclU function to call once when pltclu is first used."),
							   NULL,
							   &pltclu_start_proc,
							   NULL,
							   PGC_SUSET, 0,
							   NULL, NULL, NULL);
	EmitWarningsOnPlaceholders("pltcl");
	EmitWarningsOnPlaceholders("pltclu");
	pltcl_pm_init_done = true;
}
void _PG_init ( void ) { Tcl_NotifierProcs notifier ; HASHCTL hash_ctl ; if ( pltcl_pm_init_done ) return ; pg_bindtextdomain ( TEXTDOMAIN ) ; #ifdef WIN32 Tcl_FindExecutable ( " " ) ; #endif notifier . setTimerProc = pltcl_SetTimer ; notifier . waitForEventProc = pltcl_WaitForEvent ; notifier . createFileHandlerProc = pltcl_CreateFileHandler ; notifier . deleteFileHandlerProc = pltcl_DeleteFileHandler ; notifier . initNotifierProc = pltcl_InitNotifier ; notifier . finalizeNotifierProc = pltcl_FinalizeNotifier ; notifier . alertNotifierProc = pltcl_AlertNotifier ; notifier . serviceModeHookProc = pltcl_ServiceModeHook ; Tcl_SetNotifier ( & notifier ) ; if ( ( pltcl_hold_interp = Tcl_CreateInterp ( ) ) == NULL ) elog ( ERROR , " " ) ; if ( Tcl_Init ( pltcl_hold_interp ) == TCL_ERROR ) elog ( ERROR , " " ) ; hash_ctl . keysize = sizeof ( Oid ) ; hash_ctl . entrysize = sizeof ( pltcl_interp_desc ) ; pltcl_interp_htab = hash_create ( " " , 8 , & hash_ctl , HASH_ELEM | HASH_BLOBS ) ; hash_ctl . keysize = sizeof ( pltcl_proc_key ) ; hash_ctl . entrysize = sizeof ( pltcl_proc_ptr ) ; pltcl_proc_htab = hash_create ( " " , 100 , & hash_ctl , HASH_ELEM | HASH_BLOBS ) ; DefineCustomStringVariable ( " " , gettext_noop ( " " ) , NULL , & pltcl_start_proc , NULL , PGC_SUSET , 0 , NULL , NULL , NULL ) ; DefineCustomStringVariable ( " " , gettext_noop ( " " ) , NULL , & pltclu_start_proc , NULL , PGC_SUSET , 0 , NULL , NULL , NULL ) ; EmitWarningsOnPlaceholders ( " " ) ; EmitWarningsOnPlaceholders ( " " ) ; pltcl_pm_init_done = true ; }
_PG_init()                   - library load-time initialization
 DO NOT make this static nor change its name!
_PG_init () - library load - time initialization DO NOT make this static nor change its name!
/* Be sure we do initialization only once (should be redundant now) */ /* Required on win32 to prevent error loading init.tcl */ /*
	 * Override the functions in the Notifier subsystem.  See comments above.
	 */ /************************************************************
	 * Create the dummy hold interpreter to prevent close of
	 * stdout and stderr on DeleteInterp
	 ************************************************************/ /************************************************************
	 * Create the hash table for working interpreters
	 ************************************************************/ /************************************************************
	 * Create the hash table for function lookup
	 ************************************************************/ /************************************************************
	 * Define PL/Tcl's custom GUCs
	 ************************************************************/