diff --git a/src/backend/optimizer/geqo/geqo_misc.c b/src/backend/optimizer/geqo/geqo_misc.c
index 2df8a747f68448b979183e19f7889740936ccf5c..038abd79f8995fb3fc545b6111098028373e089d 100644
--- a/src/backend/optimizer/geqo/geqo_misc.c
+++ b/src/backend/optimizer/geqo/geqo_misc.c
@@ -6,7 +6,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/backend/optimizer/geqo/geqo_misc.c,v 1.45 2006/07/14 14:52:20 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/optimizer/geqo/geqo_misc.c,v 1.46 2006/07/15 03:35:21 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -21,6 +21,7 @@
 
 #include "postgres.h"
 
+#include "optimizer/geqo_misc.h"
 
 
 #ifdef GEQO_DEBUG
diff --git a/src/backend/parser/keywords.c b/src/backend/parser/keywords.c
index 6a022f585db93a19827f3082dcee62065ed4e980..78dd531a56ed06b5d940eba85f20a9ee051587d2 100644
--- a/src/backend/parser/keywords.c
+++ b/src/backend/parser/keywords.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/parser/keywords.c,v 1.172 2006/06/27 03:43:20 momjian Exp $
+ *	  $PostgreSQL: pgsql/src/backend/parser/keywords.c,v 1.173 2006/07/15 03:35:21 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -17,6 +17,7 @@
 #include <ctype.h>
 
 #include "nodes/parsenodes.h"
+#include "parser/gramparse.h"	/* required before parser/parse.h! */
 #include "parser/keywords.h"
 #include "parser/parse.h"
 
diff --git a/src/backend/parser/parser.c b/src/backend/parser/parser.c
index de40e64fa8ae60298a7811812b4b36896e70b293..7f1c926f672277bdcfbceae20e999f437d0d1f48 100644
--- a/src/backend/parser/parser.c
+++ b/src/backend/parser/parser.c
@@ -14,14 +14,14 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/parser/parser.c,v 1.66 2006/05/27 17:38:46 tgl Exp $
+ *	  $PostgreSQL: pgsql/src/backend/parser/parser.c,v 1.67 2006/07/15 03:35:21 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
 
 #include "postgres.h"
 
-#include "parser/gramparse.h"
+#include "parser/gramparse.h"	/* required before parser/parse.h! */
 #include "parser/parse.h"
 #include "parser/parser.h"
 
diff --git a/src/bin/psql/help.c b/src/bin/psql/help.c
index c1e6ec34bdc83a74e394eae3cb3e057842ef58b8..879592a1fa5138ab8a43a151f3907525f81c6f41 100644
--- a/src/bin/psql/help.c
+++ b/src/bin/psql/help.c
@@ -3,11 +3,9 @@
  *
  * Copyright (c) 2000-2006, PostgreSQL Global Development Group
  *
- * $PostgreSQL: pgsql/src/bin/psql/help.c,v 1.113 2006/07/14 14:52:26 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/help.c,v 1.114 2006/07/15 03:35:21 tgl Exp $
  */
 #include "postgres_fe.h"
-#include "common.h"
-#include "help.h"
 
 #include <signal.h>
 
@@ -23,10 +21,13 @@
 
 #include "pqsignal.h"
 
-#include "settings.h"
 #include "common.h"
+#include "help.h"
+#include "input.h"
+#include "settings.h"
 #include "sql_help.h"
 
+
 /*
  * PLEASE:
  * If you change something in this file, also make the same changes
diff --git a/src/bin/psql/prompt.c b/src/bin/psql/prompt.c
index 07928e1db1d3c05cb0e9b106ee35285e7a9a45f1..981e8b6b58e3f2729aa408f31e8f541182ecf027 100644
--- a/src/bin/psql/prompt.c
+++ b/src/bin/psql/prompt.c
@@ -3,14 +3,9 @@
  *
  * Copyright (c) 2000-2006, PostgreSQL Global Development Group
  *
- * $PostgreSQL: pgsql/src/bin/psql/prompt.c,v 1.46 2006/07/14 14:52:26 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/prompt.c,v 1.47 2006/07/15 03:35:21 tgl Exp $
  */
 #include "postgres_fe.h"
-#include "prompt.h"
-
-
-#include "settings.h"
-#include "common.h"
 
 #ifdef WIN32
 #include <io.h>
@@ -22,6 +17,12 @@
 #include <netdb.h>
 #endif
 
+#include "common.h"
+#include "input.h"
+#include "prompt.h"
+#include "settings.h"
+
+
 /*--------------------------
  * get_prompt
  *
diff --git a/src/include/optimizer/geqo_misc.h b/src/include/optimizer/geqo_misc.h
index 49f31de74f41fcb92700fff8320357d2db1c530a..989434bc3ce0f825e4d7b23b49794632afad40b4 100644
--- a/src/include/optimizer/geqo_misc.h
+++ b/src/include/optimizer/geqo_misc.h
@@ -6,7 +6,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/optimizer/geqo_misc.h,v 1.29 2006/07/13 16:49:19 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/optimizer/geqo_misc.h,v 1.30 2006/07/15 03:35:21 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -22,6 +22,7 @@
 #ifndef GEQO_MISC_H
 #define GEQO_MISC_H
 
+#include "optimizer/geqo.h"
 #include "optimizer/geqo_recombination.h"
 
 #ifdef GEQO_DEBUG