From def651f48f6e8e8e2bc8bb604d443f4c10136d5f Mon Sep 17 00:00:00 2001
From: Tom Lane <tgl@sss.pgh.pa.us>
Date: Thu, 19 Oct 2006 18:32:48 +0000
Subject: [PATCH] Clean up local redeclarations of variables with DLLIMPORT,
 per report from Magnus that MSVC complains about this.

---
 contrib/adminpack/adminpack.c                 | 7 ++-----
 contrib/pg_buffercache/pg_buffercache_pages.c | 7 +------
 contrib/pg_freespacemap/pg_freespacemap.c     | 9 +--------
 src/backend/catalog/pg_proc.c                 | 6 +-----
 src/backend/utils/misc/guc.c                  | 7 +++----
 src/include/miscadmin.h                       | 8 ++++----
 src/include/postmaster/syslogger.h            | 6 +++---
 src/include/storage/buf_internals.h           | 4 ++--
 src/include/storage/freespace.h               | 6 +++---
 src/include/utils/guc.h                       | 6 +++---
 src/pl/plperl/plperl.c                        | 6 ++----
 src/pl/plpgsql/src/pl_handler.c               | 5 ++---
 12 files changed, 27 insertions(+), 50 deletions(-)

diff --git a/contrib/adminpack/adminpack.c b/contrib/adminpack/adminpack.c
index ebe92add385..4749bd1a926 100644
--- a/contrib/adminpack/adminpack.c
+++ b/contrib/adminpack/adminpack.c
@@ -8,7 +8,7 @@
  * Author: Andreas Pflug <pgadmin@pse-consulting.de>
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/contrib/adminpack/adminpack.c,v 1.5 2006/10/19 17:48:04 neilc Exp $
+ *	  $PostgreSQL: pgsql/contrib/adminpack/adminpack.c,v 1.6 2006/10/19 18:32:45 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -22,6 +22,7 @@
 #include "miscadmin.h"
 #include "catalog/pg_type.h"
 #include "funcapi.h"
+#include "postmaster/syslogger.h"
 #include "storage/fd.h"
 #include "utils/datetime.h"
 
@@ -37,10 +38,6 @@
 #endif
 #endif
 
-extern DLLIMPORT char *DataDir;
-extern DLLIMPORT char *Log_directory;
-extern DLLIMPORT char *Log_filename;
-
 PG_MODULE_MAGIC;
 
 Datum		pg_file_write(PG_FUNCTION_ARGS);
diff --git a/contrib/pg_buffercache/pg_buffercache_pages.c b/contrib/pg_buffercache/pg_buffercache_pages.c
index 3c8af235d10..a75e8a229b3 100644
--- a/contrib/pg_buffercache/pg_buffercache_pages.c
+++ b/contrib/pg_buffercache/pg_buffercache_pages.c
@@ -3,7 +3,7 @@
  * pg_buffercache_pages.c
  *	  display some contents of the buffer cache
  *
- *	  $PostgreSQL: pgsql/contrib/pg_buffercache/pg_buffercache_pages.c,v 1.9 2006/10/04 00:29:45 momjian Exp $
+ *	  $PostgreSQL: pgsql/contrib/pg_buffercache/pg_buffercache_pages.c,v 1.10 2006/10/19 18:32:46 tgl Exp $
  *-------------------------------------------------------------------------
  */
 #include "postgres.h"
@@ -16,11 +16,6 @@
 
 #define NUM_BUFFERCACHE_PAGES_ELEM	6
 
-#if defined(WIN32) || defined(__CYGWIN__)
-extern DLLIMPORT BufferDesc *BufferDescriptors;
-extern DLLIMPORT volatile uint32 InterruptHoldoffCount;
-#endif
-
 PG_MODULE_MAGIC;
 
 Datum		pg_buffercache_pages(PG_FUNCTION_ARGS);
diff --git a/contrib/pg_freespacemap/pg_freespacemap.c b/contrib/pg_freespacemap/pg_freespacemap.c
index 5486a98d486..cfe5cb0268c 100644
--- a/contrib/pg_freespacemap/pg_freespacemap.c
+++ b/contrib/pg_freespacemap/pg_freespacemap.c
@@ -3,7 +3,7 @@
  * pg_freespacemap.c
  *	  display some contents of the free space relation and page maps.
  *
- *	  $PostgreSQL: pgsql/contrib/pg_freespacemap/pg_freespacemap.c,v 1.8 2006/10/04 00:29:45 momjian Exp $
+ *	  $PostgreSQL: pgsql/contrib/pg_freespacemap/pg_freespacemap.c,v 1.9 2006/10/19 18:32:46 tgl Exp $
  *-------------------------------------------------------------------------
  */
 #include "postgres.h"
@@ -17,13 +17,6 @@
 #define		NUM_FREESPACE_PAGES_ELEM	5
 #define		NUM_FREESPACE_RELATIONS_ELEM	7
 
-#if defined(WIN32) || defined(__CYGWIN__)
-/* Need DLLIMPORT for some things that are not so marked in main headers */
-extern DLLIMPORT int MaxFSMPages;
-extern DLLIMPORT int MaxFSMRelations;
-extern DLLIMPORT volatile uint32 InterruptHoldoffCount;
-#endif
-
 PG_MODULE_MAGIC;
 
 Datum		pg_freespacemap_pages(PG_FUNCTION_ARGS);
diff --git a/src/backend/catalog/pg_proc.c b/src/backend/catalog/pg_proc.c
index 0bad917d697..9fe8ac184fb 100644
--- a/src/backend/catalog/pg_proc.c
+++ b/src/backend/catalog/pg_proc.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/catalog/pg_proc.c,v 1.140 2006/07/13 16:49:13 momjian Exp $
+ *	  $PostgreSQL: pgsql/src/backend/catalog/pg_proc.c,v 1.141 2006/10/19 18:32:46 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -35,10 +35,6 @@
 #include "utils/syscache.h"
 
 
-/* GUC parameter */
-bool		check_function_bodies = true;
-
-
 Datum		fmgr_internal_validator(PG_FUNCTION_ARGS);
 Datum		fmgr_c_validator(PG_FUNCTION_ARGS);
 Datum		fmgr_sql_validator(PG_FUNCTION_ARGS);
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index d118755a3c3..f0ff66fa66a 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -10,7 +10,7 @@
  * Written by Peter Eisentraut <peter_e@gmx.net>.
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.356 2006/10/07 19:25:28 tgl Exp $
+ *	  $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.357 2006/10/19 18:32:47 tgl Exp $
  *
  *--------------------------------------------------------------------
  */
@@ -93,7 +93,6 @@
 
 /* XXX these should appear in other modules' header files */
 extern bool Log_disconnections;
-extern bool check_function_bodies;
 extern int	CommitDelay;
 extern int	CommitSiblings;
 extern char *default_tablespace;
@@ -171,12 +170,12 @@ bool		log_statement_stats = false;		/* this is sort of all three
 												 * above together */
 bool		log_btree_build_stats = false;
 
+bool		check_function_bodies = true;
+bool		default_with_oids = false;
 bool		SQL_inheritance = true;
 
 bool		Password_encryption = true;
 
-bool		default_with_oids = false;
-
 int			log_min_error_statement = PANIC;
 int			log_min_messages = NOTICE;
 int			client_min_messages = NOTICE;
diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h
index 887fe8fdb65..f21717e7b69 100644
--- a/src/include/miscadmin.h
+++ b/src/include/miscadmin.h
@@ -13,7 +13,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/miscadmin.h,v 1.189 2006/09/04 15:07:46 petere Exp $
+ * $PostgreSQL: pgsql/src/include/miscadmin.h,v 1.190 2006/10/19 18:32:47 tgl Exp $
  *
  * NOTES
  *	  some of the information in this file should be moved to other files.
@@ -70,8 +70,8 @@ extern volatile bool ProcDiePending;
 
 /* these are marked volatile because they are examined by signal handlers: */
 extern volatile bool ImmediateInterruptOK;
-extern volatile uint32 InterruptHoldoffCount;
-extern volatile uint32 CritSectionCount;
+extern DLLIMPORT volatile uint32 InterruptHoldoffCount;
+extern DLLIMPORT volatile uint32 CritSectionCount;
 
 /* in tcop/postgres.c */
 extern void ProcessInterrupts(void);
@@ -125,7 +125,7 @@ extern bool IsUnderPostmaster;
 
 extern bool ExitOnAnyError;
 
-extern char *DataDir;
+extern DLLIMPORT char *DataDir;
 
 extern DLLIMPORT int NBuffers;
 extern int	MaxBackends;
diff --git a/src/include/postmaster/syslogger.h b/src/include/postmaster/syslogger.h
index 0629553da9c..000072563e8 100644
--- a/src/include/postmaster/syslogger.h
+++ b/src/include/postmaster/syslogger.h
@@ -5,7 +5,7 @@
  *
  * Copyright (c) 2004-2006, PostgreSQL Global Development Group
  *
- * $PostgreSQL: pgsql/src/include/postmaster/syslogger.h,v 1.6 2006/03/05 15:58:58 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/postmaster/syslogger.h,v 1.7 2006/10/19 18:32:47 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -16,8 +16,8 @@
 extern bool Redirect_stderr;
 extern int	Log_RotationAge;
 extern int	Log_RotationSize;
-extern char *Log_directory;
-extern char *Log_filename;
+extern DLLIMPORT char *Log_directory;
+extern DLLIMPORT char *Log_filename;
 extern bool Log_truncate_on_rotation;
 
 extern bool am_syslogger;
diff --git a/src/include/storage/buf_internals.h b/src/include/storage/buf_internals.h
index 18239176b8e..9b830154c2d 100644
--- a/src/include/storage/buf_internals.h
+++ b/src/include/storage/buf_internals.h
@@ -8,7 +8,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/storage/buf_internals.h,v 1.87 2006/07/23 03:07:58 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/storage/buf_internals.h,v 1.88 2006/10/19 18:32:47 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -162,7 +162,7 @@ typedef struct sbufdesc
 
 
 /* in buf_init.c */
-extern BufferDesc *BufferDescriptors;
+extern DLLIMPORT BufferDesc *BufferDescriptors;
 
 /* in localbuf.c */
 extern BufferDesc *LocalBufferDescriptors;
diff --git a/src/include/storage/freespace.h b/src/include/storage/freespace.h
index 404fb2f9558..f6b54365832 100644
--- a/src/include/storage/freespace.h
+++ b/src/include/storage/freespace.h
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/storage/freespace.h,v 1.23 2006/10/04 00:30:10 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/storage/freespace.h,v 1.24 2006/10/19 18:32:47 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -124,8 +124,8 @@ struct FSMRelation
 
 
 /* GUC variables */
-extern int	MaxFSMRelations;
-extern int	MaxFSMPages;
+extern DLLIMPORT int MaxFSMRelations;
+extern DLLIMPORT int MaxFSMPages;
 
 
 /*
diff --git a/src/include/utils/guc.h b/src/include/utils/guc.h
index 403d022b7a7..db048bf50bb 100644
--- a/src/include/utils/guc.h
+++ b/src/include/utils/guc.h
@@ -7,7 +7,7 @@
  * Copyright (c) 2000-2006, PostgreSQL Global Development Group
  * Written by Peter Eisentraut <peter_e@gmx.net>.
  *
- * $PostgreSQL: pgsql/src/include/utils/guc.h,v 1.75 2006/08/14 02:27:27 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/utils/guc.h,v 1.76 2006/10/19 18:32:47 tgl Exp $
  *--------------------------------------------------------------------
  */
 #ifndef GUC_H
@@ -115,9 +115,9 @@ extern bool log_executor_stats;
 extern bool log_statement_stats;
 extern bool log_btree_build_stats;
 
-extern bool SQL_inheritance;
-
+extern DLLIMPORT bool check_function_bodies;
 extern bool default_with_oids;
+extern bool SQL_inheritance;
 
 extern int	log_min_error_statement;
 extern int	log_min_messages;
diff --git a/src/pl/plperl/plperl.c b/src/pl/plperl/plperl.c
index d645c5c8592..83332b92cde 100644
--- a/src/pl/plperl/plperl.c
+++ b/src/pl/plperl/plperl.c
@@ -1,7 +1,7 @@
 /**********************************************************************
  * plperl.c - perl as a procedural language for PostgreSQL
  *
- *	  $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.120 2006/10/15 18:56:39 tgl Exp $
+ *	  $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.121 2006/10/19 18:32:47 tgl Exp $
  *
  **********************************************************************/
 
@@ -23,13 +23,11 @@
 #include "miscadmin.h"
 #include "nodes/makefuncs.h"
 #include "parser/parse_type.h"
+#include "utils/guc.h"
 #include "utils/lsyscache.h"
 #include "utils/memutils.h"
 #include "utils/typcache.h"
 
-/* define this before the perl headers get a chance to mangle DLLIMPORT */
-extern DLLIMPORT bool check_function_bodies;
-
 /* perl stuff */
 #include "plperl.h"
 
diff --git a/src/pl/plpgsql/src/pl_handler.c b/src/pl/plpgsql/src/pl_handler.c
index 5f08107f91a..3df1c60d9cd 100644
--- a/src/pl/plpgsql/src/pl_handler.c
+++ b/src/pl/plpgsql/src/pl_handler.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_handler.c,v 1.32 2006/10/04 00:30:13 momjian Exp $
+ *	  $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_handler.c,v 1.33 2006/10/19 18:32:48 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -21,11 +21,10 @@
 #include "catalog/pg_type.h"
 #include "funcapi.h"
 #include "utils/builtins.h"
+#include "utils/guc.h"
 #include "utils/lsyscache.h"
 #include "utils/syscache.h"
 
-extern DLLIMPORT bool check_function_bodies;
-
 PG_MODULE_MAGIC;
 
 PLpgSQL_plugin **plugin_ptr = NULL;
-- 
GitLab