From a37b006d89b85c4b8ca92ee53580a1c3ea385be7 Mon Sep 17 00:00:00 2001
From: Bruce Momjian <bruce@momjian.us>
Date: Thu, 8 Feb 2007 15:46:04 +0000
Subject: [PATCH] This patch fixes shared_preload_libraries on Windows hosts. 
 It forces ach backend to re-load all shared_preload_libraries.

Korry Douglas
---
 doc/src/sgml/config.sgml            | 13 ++++++++++++-
 src/backend/postmaster/postmaster.c | 11 ++++++++++-
 2 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
index 2d4dfa8bd3a..e5c73b4e361 100644
--- a/doc/src/sgml/config.sgml
+++ b/doc/src/sgml/config.sgml
@@ -1,4 +1,4 @@
-<!-- $PostgreSQL: pgsql/doc/src/sgml/config.sgml,v 1.109 2007/02/08 03:56:42 momjian Exp $ -->
+<!-- $PostgreSQL: pgsql/doc/src/sgml/config.sgml,v 1.110 2007/02/08 15:46:03 momjian Exp $ -->
 
 <chapter Id="runtime-config">
   <title>Server Configuration</title>
@@ -990,6 +990,17 @@ SET ENABLE_SEQSCAN TO OFF;
         libraries that will be used in most sessions. 
        </para>
 
+     <note>
+      <para>
+        On Windows hosts, preloading a library at server start will not reduce
+        the time required to start each new server process; each server process
+        will re-load all preload libraries.  However, <varname>shared_preload_libraries
+        </varname> is still useful on Windows hosts because some shared libraries may 
+        need to perform certain operations that only take place at postmaster start
+        (for example, a shared library may need to reserve lightweight locks
+        or shared memory and you can't do that after the postmaster has started).
+       </para>
+      </note>
        <para>
         If a specified library is not found,
         the server will fail to start.
diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c
index bac1cff46e7..06d8f99a82b 100644
--- a/src/backend/postmaster/postmaster.c
+++ b/src/backend/postmaster/postmaster.c
@@ -37,7 +37,7 @@
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.517 2007/02/07 16:44:48 tgl Exp $
+ *	  $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.518 2007/02/08 15:46:04 momjian Exp $
  *
  * NOTES
  *
@@ -3360,6 +3360,15 @@ SubPostmasterMain(int argc, char *argv[])
 			secure_initialize();
 #endif
 
+		/*
+		 * process any libraries that should be preloaded at postmaster start
+		 *
+		 * NOTE: we have to re-load the shared_preload_libraries here because
+		 * 		 this backend is not fork()ed so we can't inherit any shared
+		 *		 libraries / DLL's from our parent (the postmaster).
+		 */
+		process_shared_preload_libraries();
+
 		/*
 		 * Perform additional initialization and client authentication.
 		 *
-- 
GitLab