diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c
index 1f3b6e8cd989c486860441e2e603826cfe885322..f27a83e1f88b41d25fe82bdd7f79a917a500f566 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.576 2009/03/04 13:56:40 heikki Exp $
+ *	  $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.577 2009/04/05 04:19:58 tgl Exp $
  *
  * NOTES
  *
@@ -309,7 +309,7 @@ extern int	optind,
 			opterr;
 
 #ifdef HAVE_INT_OPTRESET
-extern int	optreset;
+extern int	optreset;			/* might not be declared by system headers */
 #endif
 
 /*
diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c
index 546460c38ae767d8cf3c8c18a63870aa7be1a957..6155b094727e8b5b201021c63d94c8d4ba3704d8 100644
--- a/src/bin/initdb/initdb.c
+++ b/src/bin/initdb/initdb.c
@@ -42,7 +42,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  * Portions taken from FreeBSD.
  *
- * $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.169 2009/03/31 18:58:16 mha Exp $
+ * $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.170 2009/04/05 04:19:58 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -62,10 +62,6 @@
 #include "getopt_long.h"
 #include "miscadmin.h"
 
-#ifndef HAVE_INT_OPTRESET
-int			optreset;
-#endif
-
 
 /*
  * these values are passed in by makefile defines
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 245c2f052d7407a346a4bc552c6fc3bb7f11887e..24956d1e4f119fa4317236c383ca628567d1d09b 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -4,7 +4,7 @@
  *
  * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
  *
- * $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.109 2009/02/25 13:03:06 petere Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.110 2009/04/05 04:19:58 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -42,10 +42,6 @@
 #undef WIN32
 #endif
 
-#ifndef HAVE_INT_OPTRESET
-int			optreset;
-#endif
-
 /* PID can be negative for standalone backend */
 typedef long pgpid_t;
 
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index 7d46d80e91fb484d812668a4540570bda7357f88..7e4e7381fc649f7278087cf1179b85165330f18f 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -12,7 +12,7 @@
  *	by PostgreSQL
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.532 2009/04/01 18:54:27 tgl Exp $
+ *	  $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.533 2009/04/05 04:19:58 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -30,10 +30,6 @@
 
 #include "getopt_long.h"
 
-#ifndef HAVE_INT_OPTRESET
-int			optreset;
-#endif
-
 #include "access/attnum.h"
 #include "access/sysattr.h"
 #include "catalog/pg_cast.h"
diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c
index 84b448129cc275334293877bdd2300993934dcdd..949f9cd0f34e26379e6aaf450f08891f130431e2 100644
--- a/src/bin/pg_dump/pg_dumpall.c
+++ b/src/bin/pg_dump/pg_dumpall.c
@@ -6,7 +6,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  *
- * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.120 2009/03/22 16:44:26 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.121 2009/04/05 04:19:58 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -22,10 +22,6 @@
 
 #include "getopt_long.h"
 
-#ifndef HAVE_INT_OPTRESET
-int			optreset;
-#endif
-
 #include "dumputils.h"
 #include "pg_backup.h"
 
diff --git a/src/bin/pg_dump/pg_restore.c b/src/bin/pg_dump/pg_restore.c
index 69c805ce463a0ab83f6c0182852fb2d00d71b84c..4f6a386c14829a017d52d5ebf63808ac7f404c06 100644
--- a/src/bin/pg_dump/pg_restore.c
+++ b/src/bin/pg_dump/pg_restore.c
@@ -34,7 +34,7 @@
  *
  *
  * IDENTIFICATION
- *		$PostgreSQL: pgsql/src/bin/pg_dump/pg_restore.c,v 1.96 2009/03/20 09:21:09 petere Exp $
+ *		$PostgreSQL: pgsql/src/bin/pg_dump/pg_restore.c,v 1.97 2009/04/05 04:19:58 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -55,10 +55,6 @@
 extern char *optarg;
 extern int	optind;
 
-#ifndef HAVE_INT_OPTRESET
-int			optreset;
-#endif
-
 #ifdef ENABLE_NLS
 #include <locale.h>
 #endif
diff --git a/src/bin/psql/startup.c b/src/bin/psql/startup.c
index bea174c0683aa932caafcb416cfcd245eef3d12b..61658de7c33f30fe85d326fa903f38bb0208a5c7 100644
--- a/src/bin/psql/startup.c
+++ b/src/bin/psql/startup.c
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 2000-2009, PostgreSQL Global Development Group
  *
- * $PostgreSQL: pgsql/src/bin/psql/startup.c,v 1.155 2009/02/26 16:02:38 petere Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/startup.c,v 1.156 2009/04/05 04:19:58 tgl Exp $
  */
 #include "postgres_fe.h"
 
@@ -18,13 +18,8 @@
 
 #include "getopt_long.h"
 
-#ifndef HAVE_INT_OPTRESET
-int			optreset;
-#endif
-
 #include <locale.h>
 
-
 #include "command.h"
 #include "common.h"
 #include "describe.h"
diff --git a/src/bin/scripts/common.c b/src/bin/scripts/common.c
index c34115a1ba02d84991d1588df1f19a04b05ed3dc..9cf7f9c4fa450bcf5e9f5531b4bb7fce9f47bf30 100644
--- a/src/bin/scripts/common.c
+++ b/src/bin/scripts/common.c
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/bin/scripts/common.c,v 1.35 2009/02/26 16:02:38 petere Exp $
+ * $PostgreSQL: pgsql/src/bin/scripts/common.c,v 1.36 2009/04/05 04:19:59 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -24,10 +24,6 @@
 static void SetCancelConn(PGconn *conn);
 static void ResetCancelConn(void);
 
-#ifndef HAVE_INT_OPTRESET
-int			optreset;
-#endif
-
 static PGcancel *volatile cancelConn = NULL;
 
 #ifdef WIN32
diff --git a/src/bin/scripts/common.h b/src/bin/scripts/common.h
index 5c94d46add052be5a3b0f765f271741e9ef62c82..9fb14c2db4aa3924187b395eb7d94c6f3c2a2e67 100644
--- a/src/bin/scripts/common.h
+++ b/src/bin/scripts/common.h
@@ -4,7 +4,7 @@
  *
  *	Copyright (c) 2003-2009, PostgreSQL Global Development Group
  *
- *	$PostgreSQL: pgsql/src/bin/scripts/common.h,v 1.22 2009/02/26 16:02:39 petere Exp $
+ *	$PostgreSQL: pgsql/src/bin/scripts/common.h,v 1.23 2009/04/05 04:19:59 tgl Exp $
  */
 #ifndef COMMON_H
 #define COMMON_H
@@ -13,10 +13,6 @@
 #include "getopt_long.h"
 #include "pqexpbuffer.h"
 
-#ifndef HAVE_INT_OPTRESET
-extern int	optreset;
-#endif
-
 enum trivalue
 {
 	TRI_DEFAULT,
diff --git a/src/include/getopt_long.h b/src/include/getopt_long.h
index 13a6a88ddd9023d032293831fa827876811b3330..929151cdd7b40ca4d84aa96f6384c6bed0391320 100644
--- a/src/include/getopt_long.h
+++ b/src/include/getopt_long.h
@@ -4,7 +4,7 @@
  *
  * Portions Copyright (c) 2003-2009, PostgreSQL Global Development Group
  *
- * $PostgreSQL: pgsql/src/include/getopt_long.h,v 1.10 2009/01/01 17:23:55 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/getopt_long.h,v 1.11 2009/04/05 04:19:59 tgl Exp $
  */
 #ifndef GETOPT_LONG_H
 #define GETOPT_LONG_H
@@ -18,8 +18,6 @@ extern int	opterr;
 extern int	optind;
 extern int	optopt;
 extern char *optarg;
-
-/* Some systems have this, otherwise you need to define it somewhere. */
 extern int	optreset;
 
 #ifndef HAVE_STRUCT_OPTION
diff --git a/src/port/getopt_long.c b/src/port/getopt_long.c
index a381939d2ea6a9f797ca7e1b154dab590aa074c1..504e989f02a34c669d7803d6d920f08b3f7e2cca 100644
--- a/src/port/getopt_long.c
+++ b/src/port/getopt_long.c
@@ -31,7 +31,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $PostgreSQL: pgsql/src/port/getopt_long.c,v 1.6 2007/03/26 21:44:11 momjian Exp $
+ * $PostgreSQL: pgsql/src/port/getopt_long.c,v 1.7 2009/04/05 04:19:59 tgl Exp $
  */
 
 #include "c.h"
@@ -40,6 +40,7 @@
 
 #ifndef HAVE_INT_OPTRESET
 int			optreset;
+/* else the "extern" was provided by getopt_long.h */
 #endif
 
 #define BADCH	'?'