diff -cpr HEAD/src/backend/bootstrap/bootstrap.c startup+shutdown_hooks/src/backend/bootstrap/bootstrap.c *** HEAD/src/backend/bootstrap/bootstrap.c Tue Sep 30 19:52:11 2008 --- startup+shutdown_hooks/src/backend/bootstrap/bootstrap.c Mon Oct 27 13:03:17 2008 *************** typedef struct _IndexList *** 193,198 **** --- 193,199 ---- static IndexList *ILHead = NULL; + startup_hook_type startup_hook = NULL; /* * AuxiliaryProcessMain *************** AuxiliaryProcessMain(int argc, char *arg *** 419,424 **** --- 420,427 ---- bootstrap_signals(); StartupXLOG(); BuildFlatFiles(false); + if (startup_hook) + startup_hook(); proc_exit(0); /* startup done */ case BgWriterProcess: diff -cpr HEAD/src/backend/postmaster/bgwriter.c startup+shutdown_hooks/src/backend/postmaster/bgwriter.c *** HEAD/src/backend/postmaster/bgwriter.c Tue Oct 14 17:06:39 2008 --- startup+shutdown_hooks/src/backend/postmaster/bgwriter.c Mon Oct 27 13:03:17 2008 *************** static BgWriterShmemStruct *BgWriterShme *** 141,146 **** --- 141,148 ---- /* interval for calling AbsorbFsyncRequests in CheckpointWriteDelay */ #define WRITES_PER_ABSORB 1000 + shutdown_hook_type shutdown_hook = NULL; + /* * GUC parameters */ *************** BackgroundWriterMain(void) *** 396,401 **** --- 398,405 ---- */ ExitOnAnyError = true; /* Close down the database */ + if (shutdown_hook) + shutdown_hook(); ShutdownXLOG(0, 0); /* Normal exit from the bgwriter is here */ proc_exit(0); /* done */ diff -cpr HEAD/src/backend/storage/lmgr/proc.c startup+shutdown_hooks/src/backend/storage/lmgr/proc.c *** HEAD/src/backend/storage/lmgr/proc.c Tue Jun 10 03:23:05 2008 --- startup+shutdown_hooks/src/backend/storage/lmgr/proc.c Mon Oct 27 13:03:17 2008 *************** InitAuxiliaryProcess(void) *** 383,388 **** --- 383,392 ---- if (MyProc != NULL) elog(ERROR, "you already exist"); + #ifdef EXEC_BACKEND + process_shared_preload_libraries(); + #endif + /* * We use the ProcStructLock to protect assignment and releasing of * AuxiliaryProcs entries. diff -cpr HEAD/src/include/storage/ipc.h startup+shutdown_hooks/src/include/storage/ipc.h *** HEAD/src/include/storage/ipc.h Thu Apr 17 08:59:40 2008 --- startup+shutdown_hooks/src/include/storage/ipc.h Mon Oct 27 13:03:17 2008 *************** *** 20,25 **** --- 20,30 ---- typedef void (*pg_on_exit_callback) (int code, Datum arg); + typedef void (*startup_hook_type) (void); + extern PGDLLIMPORT startup_hook_type startup_hook; + typedef void (*shutdown_hook_type) (void); + extern PGDLLIMPORT shutdown_hook_type shutdown_hook; + /*---------- * API for handling cleanup that must occur during either ereport(ERROR) * or ereport(FATAL) exits from a block of code. (Typical examples are