Thread: Removal of useless include references

Removal of useless include references

From
Bruce Momjian
Date:
It has been years since I ran src/tools/pginclude/pgrminclude to remove
unnecessary include files.  (I have already fixed things so include
files can be compiled on their own.)

The attached patch removes unneeded include references, and marks some
includes as needing to be skipped by pgrminclude.

I am sure applying this patch will break builds on some platforms and
some option combinations so I will monitor the buildfarm when I apply it
and make adjustments.

--
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + It's impossible for everything to be true. +
diff --git a/contrib/btree_gin/btree_gin.c b/contrib/btree_gin/btree_gin.c
new file mode 100644
index 5c4f58b..5e6003f
*** a/contrib/btree_gin/btree_gin.c
--- b/contrib/btree_gin/btree_gin.c
***************
*** 5,11 ****

  #include <limits.h>

- #include "fmgr.h"
  #include "access/skey.h"
  #include "utils/builtins.h"
  #include "utils/bytea.h"
--- 5,10 ----
diff --git a/contrib/btree_gist/btree_bit.c b/contrib/btree_gist/btree_bit.c
new file mode 100644
index 8675d24..eec9e98
*** a/contrib/btree_gist/btree_bit.c
--- b/contrib/btree_gist/btree_bit.c
***************
*** 1,7 ****
  /*
   * contrib/btree_gist/btree_bit.c
   */
- #include "btree_gist.h"
  #include "btree_utils_var.h"
  #include "utils/bytea.h"
  #include "utils/varbit.h"
--- 1,6 ----
diff --git a/contrib/btree_gist/btree_bytea.c b/contrib/btree_gist/btree_bytea.c
new file mode 100644
index e45509d..ae9bdf2
*** a/contrib/btree_gist/btree_bytea.c
--- b/contrib/btree_gist/btree_bytea.c
***************
*** 1,7 ****
  /*
   * contrib/btree_gist/btree_bytea.c
   */
- #include "btree_gist.h"
  #include "btree_utils_var.h"
  #include "utils/bytea.h"

--- 1,6 ----
diff --git a/contrib/btree_gist/btree_cash.c b/contrib/btree_gist/btree_cash.c
new file mode 100644
index 2664a26..5432dd3
*** a/contrib/btree_gist/btree_cash.c
--- b/contrib/btree_gist/btree_cash.c
***************
*** 1,7 ****
  /*
   * contrib/btree_gist/btree_cash.c
   */
- #include "btree_gist.h"
  #include "btree_utils_num.h"
  #include "utils/cash.h"

--- 1,6 ----
diff --git a/contrib/btree_gist/btree_date.c b/contrib/btree_gist/btree_date.c
new file mode 100644
index 8a675e2..e531024
*** a/contrib/btree_gist/btree_date.c
--- b/contrib/btree_gist/btree_date.c
***************
*** 1,7 ****
  /*
   * contrib/btree_gist/btree_date.c
   */
- #include "btree_gist.h"
  #include "btree_utils_num.h"
  #include "utils/date.h"

--- 1,6 ----
diff --git a/contrib/btree_gist/btree_float4.c b/contrib/btree_gist/btree_float4.c
new file mode 100644
index 266256b..481641b
*** a/contrib/btree_gist/btree_float4.c
--- b/contrib/btree_gist/btree_float4.c
***************
*** 1,7 ****
  /*
   * contrib/btree_gist/btree_float4.c
   */
- #include "btree_gist.h"
  #include "btree_utils_num.h"

  typedef struct float4key
--- 1,6 ----
diff --git a/contrib/btree_gist/btree_float8.c b/contrib/btree_gist/btree_float8.c
new file mode 100644
index efbee0f..e8945b2
*** a/contrib/btree_gist/btree_float8.c
--- b/contrib/btree_gist/btree_float8.c
***************
*** 1,7 ****
  /*
   * contrib/btree_gist/btree_float8.c
   */
- #include "btree_gist.h"
  #include "btree_utils_num.h"

  typedef struct float8key
--- 1,6 ----
diff --git a/contrib/btree_gist/btree_gist.c b/contrib/btree_gist/btree_gist.c
new file mode 100644
index 7e1c7e0..75420c5
*** a/contrib/btree_gist/btree_gist.c
--- b/contrib/btree_gist/btree_gist.c
*************** gbtreekey_in(PG_FUNCTION_ARGS)
*** 26,33 ****
      PG_RETURN_POINTER(NULL);
  }

- #include "btree_utils_var.h"
- #include "utils/builtins.h"
  Datum
  gbtreekey_out(PG_FUNCTION_ARGS)
  {
--- 26,31 ----
diff --git a/contrib/btree_gist/btree_gist.h b/contrib/btree_gist/btree_gist.h
new file mode 100644
index 058a3f9..9d5616e
*** a/contrib/btree_gist/btree_gist.h
--- b/contrib/btree_gist/btree_gist.h
***************
*** 5,12 ****
  #define __BTREE_GIST_H__

  #include "postgres.h"
- #include "access/gist.h"
- #include "access/itup.h"
  #include "access/nbtree.h"

  #define BtreeGistNotEqualStrategyNumber 6
--- 5,10 ----
diff --git a/contrib/chkpass/chkpass.c b/contrib/chkpass/chkpass.c
new file mode 100644
index 0c9fec0..ba7a466
*** a/contrib/chkpass/chkpass.c
--- b/contrib/chkpass/chkpass.c
***************
*** 16,22 ****
  #include <crypt.h>
  #endif

- #include "fmgr.h"
  #include "utils/builtins.h"

  PG_MODULE_MAGIC;
--- 16,21 ----
diff --git a/contrib/citext/citext.c b/contrib/citext/citext.c
new file mode 100644
index 31b952b..a584f57
*** a/contrib/citext/citext.c
--- b/contrib/citext/citext.c
***************
*** 5,11 ****

  #include "access/hash.h"
  #include "catalog/pg_collation.h"
- #include "fmgr.h"
  #include "utils/builtins.h"
  #include "utils/formatting.h"

--- 5,10 ----
diff --git a/contrib/cube/cube.c b/contrib/cube/cube.c
new file mode 100644
index 4a207cc..1d119dd
*** a/contrib/cube/cube.c
--- b/contrib/cube/cube.c
***************
*** 13,19 ****

  #include "access/gist.h"
  #include "access/skey.h"
- #include "lib/stringinfo.h"
  #include "utils/array.h"
  #include "utils/builtins.h"

--- 13,18 ----
diff --git a/contrib/dblink/dblink.c b/contrib/dblink/dblink.c
new file mode 100644
index 3963329..62c810a
*** a/contrib/dblink/dblink.c
--- b/contrib/dblink/dblink.c
***************
*** 35,70 ****
  #include <limits.h>

  #include "libpq-fe.h"
- #include "fmgr.h"
  #include "funcapi.h"
- #include "access/genam.h"
- #include "access/heapam.h"
- #include "access/tupdesc.h"
  #include "catalog/indexing.h"
  #include "catalog/namespace.h"
- #include "catalog/pg_index.h"
  #include "catalog/pg_type.h"
- #include "executor/executor.h"
  #include "executor/spi.h"
  #include "foreign/foreign.h"
- #include "lib/stringinfo.h"
  #include "mb/pg_wchar.h"
  #include "miscadmin.h"
- #include "nodes/execnodes.h"
- #include "nodes/nodes.h"
- #include "nodes/pg_list.h"
- #include "parser/parse_type.h"
  #include "parser/scansup.h"
  #include "utils/acl.h"
- #include "utils/array.h"
  #include "utils/builtins.h"
- #include "utils/dynahash.h"
  #include "utils/fmgroids.h"
- #include "utils/hsearch.h"
  #include "utils/lsyscache.h"
  #include "utils/memutils.h"
  #include "utils/rel.h"
- #include "utils/syscache.h"
  #include "utils/tqual.h"

  #include "dblink.h"
--- 35,55 ----
diff --git a/contrib/dict_int/dict_int.c b/contrib/dict_int/dict_int.c
new file mode 100644
index c4ad6ef..9f61447
*** a/contrib/dict_int/dict_int.c
--- b/contrib/dict_int/dict_int.c
***************
*** 13,19 ****
  #include "postgres.h"

  #include "commands/defrem.h"
- #include "fmgr.h"
  #include "tsearch/ts_public.h"

  PG_MODULE_MAGIC;
--- 13,18 ----
diff --git a/contrib/dict_xsyn/dict_xsyn.c b/contrib/dict_xsyn/dict_xsyn.c
new file mode 100644
index ded20fa..a6b413b
*** a/contrib/dict_xsyn/dict_xsyn.c
--- b/contrib/dict_xsyn/dict_xsyn.c
***************
*** 15,21 ****
  #include <ctype.h>

  #include "commands/defrem.h"
- #include "fmgr.h"
  #include "tsearch/ts_locale.h"
  #include "tsearch/ts_utils.h"

--- 15,20 ----
diff --git a/contrib/fuzzystrmatch/fuzzystrmatch.c b/contrib/fuzzystrmatch/fuzzystrmatch.c
new file mode 100644
index dbce1c1..98b95bf
*** a/contrib/fuzzystrmatch/fuzzystrmatch.c
--- b/contrib/fuzzystrmatch/fuzzystrmatch.c
***************
*** 40,46 ****

  #include <ctype.h>

- #include "fmgr.h"
  #include "mb/pg_wchar.h"
  #include "utils/builtins.h"

--- 40,45 ----
diff --git a/contrib/hstore/hstore_compat.c b/contrib/hstore/hstore_compat.c
new file mode 100644
index 5778f74..88764b1
*** a/contrib/hstore/hstore_compat.c
--- b/contrib/hstore/hstore_compat.c
***************
*** 83,89 ****
   */
  #include "postgres.h"

- #include "funcapi.h"

  #include "hstore.h"

--- 83,88 ----
diff --git a/contrib/hstore/hstore_gist.c b/contrib/hstore/hstore_gist.c
new file mode 100644
index 88d89ec..800de48
*** a/contrib/hstore/hstore_gist.c
--- b/contrib/hstore/hstore_gist.c
***************
*** 4,10 ****
  #include "postgres.h"

  #include "access/gist.h"
- #include "access/itup.h"
  #include "access/skey.h"
  #include "catalog/pg_type.h"

--- 4,9 ----
diff --git a/contrib/hstore/hstore_io.c b/contrib/hstore/hstore_io.c
new file mode 100644
index 0d6f0b6..fc39beb
*** a/contrib/hstore/hstore_io.c
--- b/contrib/hstore/hstore_io.c
***************
*** 5,12 ****

  #include <ctype.h>

- #include "access/heapam.h"
- #include "access/htup.h"
  #include "catalog/pg_type.h"
  #include "funcapi.h"
  #include "libpq/pqformat.h"
--- 5,10 ----
diff --git a/contrib/hstore/hstore_op.c b/contrib/hstore/hstore_op.c
new file mode 100644
index 5b278c1..fee2c3c
*** a/contrib/hstore/hstore_op.c
--- b/contrib/hstore/hstore_op.c
***************
*** 4,11 ****
  #include "postgres.h"

  #include "access/hash.h"
- #include "access/heapam.h"
- #include "access/htup.h"
  #include "catalog/pg_type.h"
  #include "funcapi.h"
  #include "utils/builtins.h"
--- 4,9 ----
diff --git a/contrib/intarray/_int_bool.c b/contrib/intarray/_int_bool.c
new file mode 100644
index 4e63f6d..50d7616
*** a/contrib/intarray/_int_bool.c
--- b/contrib/intarray/_int_bool.c
***************
*** 4,10 ****
  #include "postgres.h"

  #include "miscadmin.h"
- #include "utils/builtins.h"

  #include "_int.h"

--- 4,9 ----
diff --git a/contrib/intarray/_int_op.c b/contrib/intarray/_int_op.c
new file mode 100644
index 392e227..4c2aa7a
*** a/contrib/intarray/_int_op.c
--- b/contrib/intarray/_int_op.c
***************
*** 3,9 ****
   */
  #include "postgres.h"

- #include "lib/stringinfo.h"

  #include "_int.h"

--- 3,8 ----
diff --git a/contrib/lo/lo.c b/contrib/lo/lo.c
new file mode 100644
index 6946150..9dbbbce
*** a/contrib/lo/lo.c
--- b/contrib/lo/lo.c
***************
*** 10,16 ****
  #include "commands/trigger.h"
  #include "executor/spi.h"
  #include "libpq/be-fsstubs.h"
- #include "libpq/libpq-fs.h"
  #include "utils/rel.h"


--- 10,15 ----
diff --git a/contrib/ltree/_ltree_gist.c b/contrib/ltree/_ltree_gist.c
new file mode 100644
index c1f509e..f03f633
*** a/contrib/ltree/_ltree_gist.c
--- b/contrib/ltree/_ltree_gist.c
***************
*** 9,15 ****

  #include "access/gist.h"
  #include "access/skey.h"
- #include "utils/array.h"
  #include "crc32.h"
  #include "ltree.h"

--- 9,14 ----
diff --git a/contrib/ltree/_ltree_op.c b/contrib/ltree/_ltree_op.c
new file mode 100644
index f4f0451..1b53af8
*** a/contrib/ltree/_ltree_op.c
--- b/contrib/ltree/_ltree_op.c
***************
*** 9,15 ****

  #include <ctype.h>

- #include "utils/array.h"
  #include "ltree.h"

  PG_FUNCTION_INFO_V1(_ltree_isparent);
--- 9,14 ----
diff --git a/contrib/ltree/lquery_op.c b/contrib/ltree/lquery_op.c
new file mode 100644
index da1086a..31d150d
*** a/contrib/ltree/lquery_op.c
--- b/contrib/ltree/lquery_op.c
***************
*** 8,14 ****
  #include <ctype.h>

  #include "catalog/pg_collation.h"
- #include "utils/array.h"
  #include "utils/formatting.h"
  #include "ltree.h"

--- 8,13 ----
diff --git a/contrib/ltree/ltree_gist.c b/contrib/ltree/ltree_gist.c
new file mode 100644
index 26c3475..1c0fa88
*** a/contrib/ltree/ltree_gist.c
--- b/contrib/ltree/ltree_gist.c
***************
*** 6,14 ****
  #include "postgres.h"

  #include "access/gist.h"
- #include "access/nbtree.h"
  #include "access/skey.h"
- #include "utils/array.h"
  #include "crc32.h"
  #include "ltree.h"

--- 6,12 ----
diff --git a/contrib/ltree/ltree_op.c b/contrib/ltree/ltree_op.c
new file mode 100644
index 2b048d4..4290ad4
*** a/contrib/ltree/ltree_op.c
--- b/contrib/ltree/ltree_op.c
***************
*** 11,17 ****
  #include "utils/builtins.h"
  #include "utils/lsyscache.h"
  #include "utils/selfuncs.h"
- #include "utils/syscache.h"
  #include "ltree.h"

  PG_MODULE_MAGIC;
--- 11,16 ----
diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
new file mode 100644
index 514406a..dbb2158
*** a/contrib/pageinspect/btreefuncs.c
--- b/contrib/pageinspect/btreefuncs.c
***************
*** 27,39 ****

  #include "postgres.h"

- #include "access/heapam.h"
  #include "access/nbtree.h"
  #include "catalog/namespace.h"
- #include "catalog/pg_type.h"
  #include "funcapi.h"
  #include "miscadmin.h"
- #include "storage/bufmgr.h"
  #include "utils/builtins.h"
  #include "utils/rel.h"

--- 27,36 ----
diff --git a/contrib/pageinspect/fsmfuncs.c b/contrib/pageinspect/fsmfuncs.c
new file mode 100644
index 38c4e23..0004f65
*** a/contrib/pageinspect/fsmfuncs.c
--- b/contrib/pageinspect/fsmfuncs.c
***************
*** 18,28 ****
   */

  #include "postgres.h"
- #include "lib/stringinfo.h"
  #include "storage/fsm_internals.h"
  #include "utils/builtins.h"
  #include "miscadmin.h"
- #include "funcapi.h"

  Datum        fsm_page_contents(PG_FUNCTION_ARGS);

--- 18,26 ----
diff --git a/contrib/pageinspect/heapfuncs.c b/contrib/pageinspect/heapfuncs.c
new file mode 100644
index 20bca0d..fa50655
*** a/contrib/pageinspect/heapfuncs.c
--- b/contrib/pageinspect/heapfuncs.c
***************
*** 25,36 ****

  #include "postgres.h"

- #include "fmgr.h"
  #include "funcapi.h"
- #include "access/heapam.h"
- #include "access/transam.h"
- #include "catalog/namespace.h"
- #include "catalog/pg_type.h"
  #include "utils/builtins.h"
  #include "miscadmin.h"

--- 25,31 ----
diff --git a/contrib/pageinspect/rawpage.c b/contrib/pageinspect/rawpage.c
new file mode 100644
index 8fc3a48..362ad84
*** a/contrib/pageinspect/rawpage.c
--- b/contrib/pageinspect/rawpage.c
***************
*** 15,26 ****

  #include "postgres.h"

- #include "access/heapam.h"
- #include "access/transam.h"
  #include "catalog/catalog.h"
  #include "catalog/namespace.h"
- #include "catalog/pg_type.h"
- #include "fmgr.h"
  #include "funcapi.h"
  #include "miscadmin.h"
  #include "storage/bufmgr.h"
--- 15,22 ----
diff --git a/contrib/pg_buffercache/pg_buffercache_pages.c b/contrib/pg_buffercache/pg_buffercache_pages.c
new file mode 100644
index ed88288..27e52b3
*** a/contrib/pg_buffercache/pg_buffercache_pages.c
--- b/contrib/pg_buffercache/pg_buffercache_pages.c
***************
*** 8,19 ****
   */
  #include "postgres.h"

- #include "access/heapam.h"
  #include "catalog/pg_type.h"
  #include "funcapi.h"
  #include "storage/buf_internals.h"
  #include "storage/bufmgr.h"
- #include "utils/relcache.h"


  #define NUM_BUFFERCACHE_PAGES_ELEM    8
--- 8,17 ----
diff --git a/contrib/pg_freespacemap/pg_freespacemap.c b/contrib/pg_freespacemap/pg_freespacemap.c
new file mode 100644
index bf6b0df..f6f7d2e
*** a/contrib/pg_freespacemap/pg_freespacemap.c
--- b/contrib/pg_freespacemap/pg_freespacemap.c
***************
*** 8,16 ****
   */
  #include "postgres.h"

- #include "access/heapam.h"
  #include "funcapi.h"
- #include "storage/block.h"
  #include "storage/freespace.h"


--- 8,14 ----
diff --git a/contrib/pg_stat_statements/pg_stat_statements.c b/contrib/pg_stat_statements/pg_stat_statements.c
new file mode 100644
index 0236b87..eb4c494
*** a/contrib/pg_stat_statements/pg_stat_statements.c
--- b/contrib/pg_stat_statements/pg_stat_statements.c
***************
*** 23,30 ****
  #include <unistd.h>

  #include "access/hash.h"
- #include "catalog/pg_type.h"
- #include "executor/executor.h"
  #include "executor/instrument.h"
  #include "funcapi.h"
  #include "mb/pg_wchar.h"
--- 23,28 ----
***************
*** 35,42 ****
  #include "storage/spin.h"
  #include "tcop/utility.h"
  #include "utils/builtins.h"
- #include "utils/hsearch.h"
- #include "utils/guc.h"


  PG_MODULE_MAGIC;
--- 33,38 ----
diff --git a/contrib/pg_trgm/trgm_gin.c b/contrib/pg_trgm/trgm_gin.c
new file mode 100644
index 43ac0b0..114fb78
*** a/contrib/pg_trgm/trgm_gin.c
--- b/contrib/pg_trgm/trgm_gin.c
***************
*** 6,17 ****
  #include "trgm.h"

  #include "access/gin.h"
- #include "access/itup.h"
  #include "access/skey.h"
- #include "access/tuptoaster.h"
- #include "storage/bufpage.h"
- #include "utils/array.h"
- #include "utils/builtins.h"


  PG_FUNCTION_INFO_V1(gin_extract_trgm);
--- 6,12 ----
diff --git a/contrib/pg_trgm/trgm_gist.c b/contrib/pg_trgm/trgm_gist.c
new file mode 100644
index b328a09..aee060b
*** a/contrib/pg_trgm/trgm_gist.c
--- b/contrib/pg_trgm/trgm_gist.c
***************
*** 5,17 ****

  #include "trgm.h"

- #include "access/gist.h"
- #include "access/itup.h"
  #include "access/skey.h"
- #include "access/tuptoaster.h"
- #include "storage/bufpage.h"
- #include "utils/array.h"
- #include "utils/builtins.h"


  PG_FUNCTION_INFO_V1(gtrgm_in);
--- 5,11 ----
diff --git a/contrib/pg_trgm/trgm_op.c b/contrib/pg_trgm/trgm_op.c
new file mode 100644
index dfb2df5..4e32c6f
*** a/contrib/pg_trgm/trgm_op.c
--- b/contrib/pg_trgm/trgm_op.c
***************
*** 9,15 ****

  #include "catalog/pg_type.h"
  #include "tsearch/ts_locale.h"
- #include "utils/array.h"


  PG_MODULE_MAGIC;
--- 9,14 ----
diff --git a/contrib/pg_upgrade/info.c b/contrib/pg_upgrade/info.c
new file mode 100644
index 10188ca..3ef3429
*** a/contrib/pg_upgrade/info.c
--- b/contrib/pg_upgrade/info.c
*************** get_rel_infos(ClusterInfo *cluster, DbIn
*** 266,275 ****
               "  LEFT OUTER JOIN pg_catalog.pg_tablespace t "
               "       ON c.reltablespace = t.oid "
               "WHERE relkind IN ('r','t', 'i'%s) AND "
!              /* exclude possible orphaned temp tables */
!              "  ((n.nspname !~ '^pg_temp_' AND "
!              "    n.nspname !~ '^pg_toast_temp_' AND "
!              "    n.nspname NOT IN ('pg_catalog', 'information_schema', 'binary_upgrade') AND "
               "      c.oid >= %u) "
               "  OR (n.nspname = 'pg_catalog' AND "
      "    relname IN ('pg_largeobject', 'pg_largeobject_loid_pn_index'%s) )) "
--- 266,274 ----
               "  LEFT OUTER JOIN pg_catalog.pg_tablespace t "
               "       ON c.reltablespace = t.oid "
               "WHERE relkind IN ('r','t', 'i'%s) AND "
!              /* exclude pg_catalog and pg_temp_ (could be orphaned tables) */
!              "  ((n.nspname !~ '^pg_' AND "
!             "     n.nspname NOT IN ('information_schema', 'binary_upgrade') AND "
               "      c.oid >= %u) "
               "  OR (n.nspname = 'pg_catalog' AND "
      "    relname IN ('pg_largeobject', 'pg_largeobject_loid_pn_index'%s) )) "
diff --git a/contrib/pg_upgrade/page.c b/contrib/pg_upgrade/page.c
new file mode 100644
index d9e9f69..439f903
*** a/contrib/pg_upgrade/page.c
--- b/contrib/pg_upgrade/page.c
***************
*** 9,15 ****

  #include "pg_upgrade.h"

- #include "storage/bufpage.h"


  #ifdef PAGE_CONVERSION
--- 9,14 ----
diff --git a/contrib/pg_upgrade/relfilenode.c b/contrib/pg_upgrade/relfilenode.c
new file mode 100644
index df752c5..aa7fc90
*** a/contrib/pg_upgrade/relfilenode.c
--- b/contrib/pg_upgrade/relfilenode.c
***************
*** 9,16 ****

  #include "pg_upgrade.h"

- #include "catalog/pg_class.h"
- #include "access/transam.h"


  static void transfer_single_new_db(pageCnvCtx *pageConverter,
--- 9,14 ----
diff --git a/contrib/pg_upgrade/version.c b/contrib/pg_upgrade/version.c
new file mode 100644
index 46190b1..54dc64a
*** a/contrib/pg_upgrade/version.c
--- b/contrib/pg_upgrade/version.c
***************
*** 9,15 ****

  #include "pg_upgrade.h"

- #include "access/transam.h"


  /*
--- 9,14 ----
diff --git a/contrib/pg_upgrade/version_old_8_3.c b/contrib/pg_upgrade/version_old_8_3.c
new file mode 100644
index d63050c..1c736d2
*** a/contrib/pg_upgrade/version_old_8_3.c
--- b/contrib/pg_upgrade/version_old_8_3.c
*************** old_8_3_check_for_name_data_type_usage(C
*** 59,68 ****
                                  "        NOT a.attisdropped AND "
                                  "        a.atttypid = 'pg_catalog.name'::pg_catalog.regtype AND "
                                  "        c.relnamespace = n.oid AND "
!                                  /* exclude possible orphaned temp tables */
!                                 "          n.nspname !~ '^pg_temp_' AND "
!                                 "        n.nspname !~ '^pg_toast_temp_' AND "
!                                  "        n.nspname NOT IN ('pg_catalog', 'information_schema')");

          ntups = PQntuples(res);
          i_nspname = PQfnumber(res, "nspname");
--- 59,67 ----
                                  "        NOT a.attisdropped AND "
                                  "        a.atttypid = 'pg_catalog.name'::pg_catalog.regtype AND "
                                  "        c.relnamespace = n.oid AND "
!                              /* exclude pg_catalog and pg_temp_ (could be orphaned tables) */
!                                 "   n.nspname !~ '^pg_' AND "
!                          "        n.nspname != 'information_schema'");

          ntups = PQntuples(res);
          i_nspname = PQfnumber(res, "nspname");
*************** old_8_3_check_for_tsquery_usage(ClusterI
*** 150,159 ****
                                  "        NOT a.attisdropped AND "
                                  "        a.atttypid = 'pg_catalog.tsquery'::pg_catalog.regtype AND "
                                  "        c.relnamespace = n.oid AND "
!                                  /* exclude possible orphaned temp tables */
!                                 "          n.nspname !~ '^pg_temp_' AND "
!                                 "        n.nspname !~ '^pg_toast_temp_' AND "
!                                  "        n.nspname NOT IN ('pg_catalog', 'information_schema')");

          ntups = PQntuples(res);
          i_nspname = PQfnumber(res, "nspname");
--- 149,157 ----
                                  "        NOT a.attisdropped AND "
                                  "        a.atttypid = 'pg_catalog.tsquery'::pg_catalog.regtype AND "
                                  "        c.relnamespace = n.oid AND "
!                              /* exclude pg_catalog and pg_temp_ (could be orphaned tables) */
!                                 "   n.nspname !~ '^pg_' AND "
!                          "        n.nspname != 'information_schema'");

          ntups = PQntuples(res);
          i_nspname = PQfnumber(res, "nspname");
*************** old_8_3_rebuild_tsvector_tables(ClusterI
*** 249,258 ****
                                  "        NOT a.attisdropped AND "
                                  "        a.atttypid = 'pg_catalog.tsvector'::pg_catalog.regtype AND "
                                  "        c.relnamespace = n.oid AND "
!                                  /* exclude possible orphaned temp tables */
!                                 "          n.nspname !~ '^pg_temp_' AND "
!                                 "        n.nspname !~ '^pg_toast_temp_' AND "
!                                  "        n.nspname NOT IN ('pg_catalog', 'information_schema')");

  /*
   *    This macro is used below to avoid reindexing indexes already rebuilt
--- 247,255 ----
                                  "        NOT a.attisdropped AND "
                                  "        a.atttypid = 'pg_catalog.tsvector'::pg_catalog.regtype AND "
                                  "        c.relnamespace = n.oid AND "
!                              /* exclude pg_catalog and pg_temp_ (could be orphaned tables) */
!                                 "   n.nspname !~ '^pg_' AND "
!                          "        n.nspname != 'information_schema'");

  /*
   *    This macro is used below to avoid reindexing indexes already rebuilt
*************** old_8_3_create_sequence_script(ClusterIn
*** 622,631 ****
                                  "        pg_catalog.pg_namespace n "
                                  "WHERE    c.relkind = 'S' AND "
                                  "        c.relnamespace = n.oid AND "
!                                  /* exclude possible orphaned temp tables */
!                                 "          n.nspname !~ '^pg_temp_' AND "
!                                 "        n.nspname !~ '^pg_toast_temp_' AND "
!                                  "        n.nspname NOT IN ('pg_catalog', 'information_schema')");

          ntups = PQntuples(res);
          i_nspname = PQfnumber(res, "nspname");
--- 619,627 ----
                                  "        pg_catalog.pg_namespace n "
                                  "WHERE    c.relkind = 'S' AND "
                                  "        c.relnamespace = n.oid AND "
!                              /* exclude pg_catalog and pg_temp_ (could be orphaned tables) */
!                                 "   n.nspname !~ '^pg_' AND "
!                          "        n.nspname != 'information_schema'");

          ntups = PQntuples(res);
          i_nspname = PQfnumber(res, "nspname");
diff --git a/contrib/pg_upgrade_support/pg_upgrade_support.c b/contrib/pg_upgrade_support/pg_upgrade_support.c
new file mode 100644
index 2c23cba..47d6580
*** a/contrib/pg_upgrade_support/pg_upgrade_support.c
--- b/contrib/pg_upgrade_support/pg_upgrade_support.c
***************
*** 11,20 ****

  #include "postgres.h"

- #include "fmgr.h"
- #include "catalog/dependency.h"
  #include "catalog/namespace.h"
- #include "catalog/pg_class.h"
  #include "catalog/pg_type.h"
  #include "commands/extension.h"
  #include "miscadmin.h"
--- 11,17 ----
diff --git a/contrib/pgcrypto/crypt-blowfish.c b/contrib/pgcrypto/crypt-blowfish.c
new file mode 100644
index eebf187..7cca92b
*** a/contrib/pgcrypto/crypt-blowfish.c
--- b/contrib/pgcrypto/crypt-blowfish.c
***************
*** 34,40 ****

  #include "postgres.h"

- #include "px.h"
  #include "px-crypt.h"

  #ifdef __i386__
--- 34,39 ----
diff --git a/contrib/pgcrypto/crypt-des.c b/contrib/pgcrypto/crypt-des.c
new file mode 100644
index 1f49743..e50c1f4
*** a/contrib/pgcrypto/crypt-des.c
--- b/contrib/pgcrypto/crypt-des.c
***************
*** 62,68 ****

  #include "postgres.h"

- #include "px.h"
  #include "px-crypt.h"

  /* for ntohl/htonl */
--- 62,67 ----
diff --git a/contrib/pgcrypto/crypt-gensalt.c b/contrib/pgcrypto/crypt-gensalt.c
new file mode 100644
index 84bf27b..062ab86
*** a/contrib/pgcrypto/crypt-gensalt.c
--- b/contrib/pgcrypto/crypt-gensalt.c
***************
*** 14,20 ****

  #include "postgres.h"

- #include "px.h"
  #include "px-crypt.h"

  typedef unsigned int BF_word;
--- 14,19 ----
diff --git a/contrib/pgcrypto/internal.c b/contrib/pgcrypto/internal.c
new file mode 100644
index fedfe2d..5ceb527
*** a/contrib/pgcrypto/internal.c
--- b/contrib/pgcrypto/internal.c
***************
*** 36,42 ****
  #include "px.h"
  #include "md5.h"
  #include "sha1.h"
- #include "sha2.h"
  #include "blf.h"
  #include "rijndael.h"
  #include "fortuna.h"
--- 36,41 ----
diff --git a/contrib/pgcrypto/md5.c b/contrib/pgcrypto/md5.c
new file mode 100644
index b5071fb..08227a8
*** a/contrib/pgcrypto/md5.c
--- b/contrib/pgcrypto/md5.c
***************
*** 35,41 ****

  #include <sys/param.h>

- #include "px.h"
  #include "md5.h"

  #define SHIFT(X, s) (((X) << (s)) | ((X) >> (32 - (s))))
--- 35,40 ----
diff --git a/contrib/pgcrypto/pgcrypto.c b/contrib/pgcrypto/pgcrypto.c
new file mode 100644
index d271ddc..c758853
*** a/contrib/pgcrypto/pgcrypto.c
--- b/contrib/pgcrypto/pgcrypto.c
***************
*** 33,39 ****

  #include <ctype.h>

- #include "fmgr.h"
  #include "parser/scansup.h"
  #include "utils/builtins.h"

--- 33,38 ----
diff --git a/contrib/pgcrypto/pgp-pgsql.c b/contrib/pgcrypto/pgp-pgsql.c
new file mode 100644
index f1f09cd..c4c6b50
*** a/contrib/pgcrypto/pgp-pgsql.c
--- b/contrib/pgcrypto/pgp-pgsql.c
***************
*** 31,38 ****

  #include "postgres.h"

- #include "fmgr.h"
- #include "parser/scansup.h"
  #include "mb/pg_wchar.h"
  #include "utils/builtins.h"

--- 31,36 ----
diff --git a/contrib/pgcrypto/random.c b/contrib/pgcrypto/random.c
new file mode 100644
index 393a0be..bcfeb7e
*** a/contrib/pgcrypto/random.c
--- b/contrib/pgcrypto/random.c
*************** try_dev_random(uint8 *dst)
*** 105,112 ****
  #define TRY_WIN32_GENRAND
  #define TRY_WIN32_PERFC

! #include <windows.h>
! #include <wincrypt.h>

  /*
   * this function is from libtomcrypt
--- 105,112 ----
  #define TRY_WIN32_GENRAND
  #define TRY_WIN32_PERFC

! #include <windows.h>    /* pgrminclude ignore */
! #include <wincrypt.h>    /* pgrminclude ignore */

  /*
   * this function is from libtomcrypt
diff --git a/contrib/pgcrypto/rijndael.c b/contrib/pgcrypto/rijndael.c
new file mode 100644
index 5651d03..3d31b05
*** a/contrib/pgcrypto/rijndael.c
--- b/contrib/pgcrypto/rijndael.c
*************** Mean:           500 cycles =    51.2 mbits/sec
*** 44,50 ****

  #include <sys/param.h>

- #include "px.h"
  #include "rijndael.h"

  #define PRE_CALC_TABLES
--- 44,49 ----
diff --git a/contrib/pgcrypto/sha1.c b/contrib/pgcrypto/sha1.c
new file mode 100644
index 4ee4f24..ac406fa
*** a/contrib/pgcrypto/sha1.c
--- b/contrib/pgcrypto/sha1.c
***************
*** 40,46 ****

  #include <sys/param.h>

- #include "px.h"
  #include "sha1.h"

  /* constant table */
--- 40,45 ----
diff --git a/contrib/pgrowlocks/pgrowlocks.c b/contrib/pgrowlocks/pgrowlocks.c
new file mode 100644
index 4a49ee3..20beed2
*** a/contrib/pgrowlocks/pgrowlocks.c
--- b/contrib/pgrowlocks/pgrowlocks.c
***************
*** 24,30 ****

  #include "postgres.h"

- #include "access/heapam.h"
  #include "access/multixact.h"
  #include "access/relscan.h"
  #include "access/xact.h"
--- 24,29 ----
diff --git a/contrib/seg/seg.c b/contrib/seg/seg.c
new file mode 100644
index 0a787ff..1c14c49
*** a/contrib/seg/seg.c
--- b/contrib/seg/seg.c
***************
*** 13,19 ****

  #include "access/gist.h"
  #include "access/skey.h"
- #include "utils/builtins.h"

  #include "segdata.h"

--- 13,18 ----
diff --git a/contrib/tablefunc/tablefunc.c b/contrib/tablefunc/tablefunc.c
new file mode 100644
index 4ef9b00..4fd68cd
*** a/contrib/tablefunc/tablefunc.c
--- b/contrib/tablefunc/tablefunc.c
***************
*** 35,48 ****
  #include <math.h>

  #include "catalog/pg_type.h"
- #include "fmgr.h"
  #include "funcapi.h"
  #include "executor/spi.h"
- #include "lib/stringinfo.h"
  #include "miscadmin.h"
  #include "utils/builtins.h"
- #include "utils/guc.h"
- #include "utils/lsyscache.h"

  #include "tablefunc.h"

--- 35,44 ----
diff --git a/contrib/tsearch2/tsearch2.c b/contrib/tsearch2/tsearch2.c
new file mode 100644
index c6ced63..2b3bc3f
*** a/contrib/tsearch2/tsearch2.c
--- b/contrib/tsearch2/tsearch2.c
***************
*** 16,22 ****
  #include "catalog/namespace.h"
  #include "catalog/pg_type.h"
  #include "commands/trigger.h"
- #include "fmgr.h"
  #include "tsearch/ts_utils.h"
  #include "utils/builtins.h"
  #include "utils/guc.h"
--- 16,21 ----
diff --git a/contrib/unaccent/unaccent.c b/contrib/unaccent/unaccent.c
new file mode 100644
index 709f4c4..d9c2eac
*** a/contrib/unaccent/unaccent.c
--- b/contrib/unaccent/unaccent.c
***************
*** 13,22 ****

  #include "postgres.h"

- #include "fmgr.h"
  #include "catalog/namespace.h"
  #include "commands/defrem.h"
- #include "mb/pg_wchar.h"
  #include "tsearch/ts_cache.h"
  #include "tsearch/ts_locale.h"
  #include "tsearch/ts_public.h"
--- 13,20 ----
diff --git a/contrib/vacuumlo/vacuumlo.c b/contrib/vacuumlo/vacuumlo.c
new file mode 100644
index 6818d4a..21b6dbf
*** a/contrib/vacuumlo/vacuumlo.c
--- b/contrib/vacuumlo/vacuumlo.c
***************
*** 22,28 ****
  #endif

  #include "libpq-fe.h"
- #include "libpq/libpq-fs.h"

  #define atooid(x)  ((Oid) strtoul((x), NULL, 10))

--- 22,27 ----
diff --git a/contrib/xml2/xslt_proc.c b/contrib/xml2/xslt_proc.c
new file mode 100644
index a8e481a..05cf6ee
*** a/contrib/xml2/xslt_proc.c
--- b/contrib/xml2/xslt_proc.c
***************
*** 7,32 ****
   */
  #include "postgres.h"

- #include "executor/spi.h"
- #include "fmgr.h"
- #include "funcapi.h"
- #include "miscadmin.h"
- #include "utils/builtins.h"
  #include "utils/xml.h"

  #ifdef USE_LIBXSLT

  /* libxml includes */

- #include <libxml/xpath.h>
- #include <libxml/tree.h>
- #include <libxml/xmlmemory.h>

  /* libxslt includes */

- #include <libxslt/xslt.h>
- #include <libxslt/xsltInternals.h>
- #include <libxslt/transform.h>
  #include <libxslt/xsltutils.h>
  #endif   /* USE_LIBXSLT */

--- 7,21 ----
diff --git a/src/backend/access/common/heaptuple.c b/src/backend/access/common/heaptuple.c
new file mode 100644
index 175e6ea..36b3af8
*** a/src/backend/access/common/heaptuple.c
--- b/src/backend/access/common/heaptuple.c
***************
*** 57,63 ****

  #include "postgres.h"

- #include "access/heapam.h"
  #include "access/sysattr.h"
  #include "access/tuptoaster.h"
  #include "executor/tuptable.h"
--- 57,62 ----
diff --git a/src/backend/access/common/indextuple.c b/src/backend/access/common/indextuple.c
new file mode 100644
index 85c4319..8c0e40c
*** a/src/backend/access/common/indextuple.c
--- b/src/backend/access/common/indextuple.c
***************
*** 16,22 ****

  #include "postgres.h"

- #include "access/heapam.h"
  #include "access/itup.h"
  #include "access/tuptoaster.h"

--- 16,21 ----
diff --git a/src/backend/access/common/reloptions.c b/src/backend/access/common/reloptions.c
new file mode 100644
index 900b222..26bf521
*** a/src/backend/access/common/reloptions.c
--- b/src/backend/access/common/reloptions.c
***************
*** 23,29 ****
  #include "commands/defrem.h"
  #include "commands/tablespace.h"
  #include "nodes/makefuncs.h"
- #include "utils/array.h"
  #include "utils/attoptcache.h"
  #include "utils/builtins.h"
  #include "utils/guc.h"
--- 23,28 ----
diff --git a/src/backend/access/gin/ginfast.c b/src/backend/access/gin/ginfast.c
new file mode 100644
index 60a6d80..4d489d9
*** a/src/backend/access/gin/ginfast.c
--- b/src/backend/access/gin/ginfast.c
***************
*** 19,25 ****
  #include "postgres.h"

  #include "access/gin_private.h"
- #include "catalog/index.h"
  #include "commands/vacuum.h"
  #include "miscadmin.h"
  #include "storage/bufmgr.h"
--- 19,24 ----
diff --git a/src/backend/access/gin/ginget.c b/src/backend/access/gin/ginget.c
new file mode 100644
index 8667858..01ecd9e
*** a/src/backend/access/gin/ginget.c
--- b/src/backend/access/gin/ginget.c
***************
*** 16,22 ****

  #include "access/gin_private.h"
  #include "access/relscan.h"
- #include "catalog/index.h"
  #include "miscadmin.h"
  #include "storage/bufmgr.h"
  #include "utils/datum.h"
--- 16,21 ----
diff --git a/src/backend/access/gin/gininsert.c b/src/backend/access/gin/gininsert.c
new file mode 100644
index bea5f68..c596699
*** a/src/backend/access/gin/gininsert.c
--- b/src/backend/access/gin/gininsert.c
***************
*** 19,25 ****
  #include "miscadmin.h"
  #include "storage/bufmgr.h"
  #include "storage/smgr.h"
- #include "storage/indexfsm.h"
  #include "utils/memutils.h"
  #include "utils/rel.h"

--- 19,24 ----
diff --git a/src/backend/access/gin/ginutil.c b/src/backend/access/gin/ginutil.c
new file mode 100644
index ba142bc..f920fc8
*** a/src/backend/access/gin/ginutil.c
--- b/src/backend/access/gin/ginutil.c
***************
*** 20,26 ****
  #include "catalog/pg_type.h"
  #include "miscadmin.h"
  #include "storage/bufmgr.h"
- #include "storage/freespace.h"
  #include "storage/indexfsm.h"
  #include "storage/lmgr.h"

--- 20,25 ----
diff --git a/src/backend/access/gin/ginvacuum.c b/src/backend/access/gin/ginvacuum.c
new file mode 100644
index 79c54f1..3d20a6c
*** a/src/backend/access/gin/ginvacuum.c
--- b/src/backend/access/gin/ginvacuum.c
***************
*** 15,21 ****
  #include "postgres.h"

  #include "access/gin_private.h"
- #include "catalog/storage.h"
  #include "commands/vacuum.h"
  #include "miscadmin.h"
  #include "postmaster/autovacuum.h"
--- 15,20 ----
diff --git a/src/backend/access/gin/ginxlog.c b/src/backend/access/gin/ginxlog.c
new file mode 100644
index c954bcb..01297c3
*** a/src/backend/access/gin/ginxlog.c
--- b/src/backend/access/gin/ginxlog.c
***************
*** 15,21 ****

  #include "access/gin_private.h"
  #include "access/xlogutils.h"
- #include "storage/bufmgr.h"
  #include "utils/memutils.h"

  static MemoryContext opCtx;        /* working memory for operations */
--- 15,20 ----
diff --git a/src/backend/access/gist/gist.c b/src/backend/access/gist/gist.c
new file mode 100644
index 4fc7a21..fd5f7a4
*** a/src/backend/access/gist/gist.c
--- b/src/backend/access/gist/gist.c
***************
*** 14,26 ****
   */
  #include "postgres.h"

- #include "access/genam.h"
  #include "access/gist_private.h"
  #include "catalog/index.h"
  #include "catalog/pg_collation.h"
  #include "miscadmin.h"
- #include "storage/bufmgr.h"
- #include "storage/indexfsm.h"
  #include "utils/memutils.h"
  #include "utils/rel.h"

--- 14,23 ----
diff --git a/src/backend/access/gist/gistget.c b/src/backend/access/gist/gistget.c
new file mode 100644
index 5d5fd5b..60116df
*** a/src/backend/access/gist/gistget.c
--- b/src/backend/access/gist/gistget.c
***************
*** 16,25 ****

  #include "access/gist_private.h"
  #include "access/relscan.h"
- #include "executor/execdebug.h"
  #include "miscadmin.h"
  #include "pgstat.h"
- #include "storage/bufmgr.h"
  #include "utils/builtins.h"
  #include "utils/memutils.h"
  #include "utils/rel.h"
--- 16,23 ----
diff --git a/src/backend/access/gist/gistscan.c b/src/backend/access/gist/gistscan.c
new file mode 100644
index 5662a3a..97a19aa
*** a/src/backend/access/gist/gistscan.c
--- b/src/backend/access/gist/gistscan.c
***************
*** 14,24 ****
   */
  #include "postgres.h"

- #include "access/genam.h"
  #include "access/gist_private.h"
  #include "access/gistscan.h"
  #include "access/relscan.h"
- #include "storage/bufmgr.h"
  #include "utils/memutils.h"
  #include "utils/rel.h"

--- 14,22 ----
diff --git a/src/backend/access/gist/gistutil.c b/src/backend/access/gist/gistutil.c
new file mode 100644
index 1754a10..448d8bc
*** a/src/backend/access/gist/gistutil.c
--- b/src/backend/access/gist/gistutil.c
***************
*** 17,27 ****

  #include "access/gist_private.h"
  #include "access/reloptions.h"
- #include "storage/freespace.h"
  #include "storage/indexfsm.h"
  #include "storage/lmgr.h"
- #include "storage/bufmgr.h"
- #include "utils/rel.h"

  /*
   * static *S used for temrorary storage (saves stack and palloc() call)
--- 17,24 ----
diff --git a/src/backend/access/gist/gistvacuum.c b/src/backend/access/gist/gistvacuum.c
new file mode 100644
index 50c6270..d650645
*** a/src/backend/access/gist/gistvacuum.c
--- b/src/backend/access/gist/gistvacuum.c
***************
*** 16,29 ****

  #include "access/genam.h"
  #include "access/gist_private.h"
- #include "catalog/storage.h"
  #include "commands/vacuum.h"
  #include "miscadmin.h"
- #include "storage/bufmgr.h"
- #include "storage/freespace.h"
  #include "storage/indexfsm.h"
  #include "storage/lmgr.h"
- #include "utils/memutils.h"


  /*
--- 16,25 ----
diff --git a/src/backend/access/gist/gistxlog.c b/src/backend/access/gist/gistxlog.c
new file mode 100644
index 02c4ec3..09b1d48
*** a/src/backend/access/gist/gistxlog.c
--- b/src/backend/access/gist/gistxlog.c
***************
*** 15,24 ****

  #include "access/gist_private.h"
  #include "access/xlogutils.h"
- #include "miscadmin.h"
- #include "storage/bufmgr.h"
  #include "utils/memutils.h"
- #include "utils/rel.h"

  typedef struct
  {
--- 15,21 ----
diff --git a/src/backend/access/hash/hash.c b/src/backend/access/hash/hash.c
new file mode 100644
index bfb1089..d8d2ff5
*** a/src/backend/access/hash/hash.c
--- b/src/backend/access/hash/hash.c
***************
*** 22,28 ****
  #include "access/relscan.h"
  #include "catalog/index.h"
  #include "commands/vacuum.h"
- #include "optimizer/cost.h"
  #include "optimizer/plancat.h"
  #include "storage/bufmgr.h"
  #include "utils/rel.h"
--- 22,27 ----
diff --git a/src/backend/access/hash/hashpage.c b/src/backend/access/hash/hashpage.c
new file mode 100644
index fe991cf..62cc257
*** a/src/backend/access/hash/hashpage.c
--- b/src/backend/access/hash/hashpage.c
***************
*** 28,40 ****
   */
  #include "postgres.h"

- #include "access/genam.h"
  #include "access/hash.h"
  #include "miscadmin.h"
  #include "storage/bufmgr.h"
  #include "storage/lmgr.h"
  #include "storage/smgr.h"
- #include "utils/lsyscache.h"


  static bool _hash_alloc_buckets(Relation rel, BlockNumber firstblock,
--- 28,38 ----
diff --git a/src/backend/access/hash/hashutil.c b/src/backend/access/hash/hashutil.c
new file mode 100644
index aa68be5..37ed445
*** a/src/backend/access/hash/hashutil.c
--- b/src/backend/access/hash/hashutil.c
***************
*** 16,23 ****

  #include "access/hash.h"
  #include "access/reloptions.h"
- #include "access/relscan.h"
- #include "executor/execdebug.h"
  #include "storage/bufmgr.h"
  #include "utils/lsyscache.h"
  #include "utils/rel.h"
--- 16,21 ----
diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c
new file mode 100644
index 06db65d..c744070
*** a/src/backend/access/heap/heapam.c
--- b/src/backend/access/heap/heapam.c
***************
*** 39,45 ****
   */
  #include "postgres.h"

- #include "access/heapam.h"
  #include "access/hio.h"
  #include "access/multixact.h"
  #include "access/relscan.h"
--- 39,44 ----
***************
*** 54,70 ****
  #include "catalog/namespace.h"
  #include "miscadmin.h"
  #include "pgstat.h"
- #include "storage/bufmgr.h"
  #include "storage/freespace.h"
  #include "storage/lmgr.h"
  #include "storage/predicate.h"
  #include "storage/procarray.h"
  #include "storage/smgr.h"
- #include "storage/standby.h"
  #include "utils/datum.h"
  #include "utils/inval.h"
- #include "utils/lsyscache.h"
- #include "utils/relcache.h"
  #include "utils/snapmgr.h"
  #include "utils/syscache.h"
  #include "utils/tqual.h"
--- 53,65 ----
diff --git a/src/backend/access/heap/pruneheap.c b/src/backend/access/heap/pruneheap.c
new file mode 100644
index 0cfa866..61f2ce4
*** a/src/backend/access/heap/pruneheap.c
--- b/src/backend/access/heap/pruneheap.c
***************
*** 15,26 ****
  #include "postgres.h"

  #include "access/heapam.h"
- #include "access/htup.h"
  #include "access/transam.h"
  #include "miscadmin.h"
  #include "pgstat.h"
  #include "storage/bufmgr.h"
- #include "storage/off.h"
  #include "utils/rel.h"
  #include "utils/tqual.h"

--- 15,24 ----
diff --git a/src/backend/access/heap/syncscan.c b/src/backend/access/heap/syncscan.c
new file mode 100644
index 957d1a1..0f11786
*** a/src/backend/access/heap/syncscan.c
--- b/src/backend/access/heap/syncscan.c
***************
*** 48,55 ****

  #include "access/heapam.h"
  #include "miscadmin.h"
- #include "storage/block.h"
- #include "storage/relfilenode.h"
  #include "utils/rel.h"


--- 48,53 ----
diff --git a/src/backend/access/heap/visibilitymap.c b/src/backend/access/heap/visibilitymap.c
new file mode 100644
index a193520..8bed6ed
*** a/src/backend/access/heap/visibilitymap.c
--- b/src/backend/access/heap/visibilitymap.c
***************
*** 73,79 ****
  #include "access/visibilitymap.h"
  #include "miscadmin.h"
  #include "storage/bufmgr.h"
- #include "storage/bufpage.h"
  #include "storage/lmgr.h"
  #include "storage/smgr.h"

--- 73,78 ----
diff --git a/src/backend/access/index/genam.c b/src/backend/access/index/genam.c
new file mode 100644
index fe3aa3c..98832ad
*** a/src/backend/access/index/genam.c
--- b/src/backend/access/index/genam.c
***************
*** 23,29 ****
  #include "access/transam.h"
  #include "catalog/index.h"
  #include "miscadmin.h"
- #include "pgstat.h"
  #include "storage/bufmgr.h"
  #include "utils/builtins.h"
  #include "utils/lsyscache.h"
--- 23,28 ----
diff --git a/src/backend/access/index/indexam.c b/src/backend/access/index/indexam.c
new file mode 100644
index 13e68d6..230af9b
*** a/src/backend/access/index/indexam.c
--- b/src/backend/access/index/indexam.c
***************
*** 64,76 ****

  #include "access/relscan.h"
  #include "access/transam.h"
- #include "access/xact.h"
  #include "catalog/index.h"
  #include "pgstat.h"
  #include "storage/bufmgr.h"
  #include "storage/lmgr.h"
  #include "storage/predicate.h"
- #include "utils/relcache.h"
  #include "utils/snapmgr.h"
  #include "utils/tqual.h"

--- 64,74 ----
diff --git a/src/backend/access/nbtree/nbtinsert.c b/src/backend/access/nbtree/nbtinsert.c
new file mode 100644
index d758659..872988d
*** a/src/backend/access/nbtree/nbtinsert.c
--- b/src/backend/access/nbtree/nbtinsert.c
***************
*** 19,25 ****
  #include "access/nbtree.h"
  #include "access/transam.h"
  #include "miscadmin.h"
- #include "storage/bufmgr.h"
  #include "storage/lmgr.h"
  #include "storage/predicate.h"
  #include "utils/inval.h"
--- 19,24 ----
diff --git a/src/backend/access/nbtree/nbtpage.c b/src/backend/access/nbtree/nbtpage.c
new file mode 100644
index 4b1a2e9..f9b3e1f
*** a/src/backend/access/nbtree/nbtpage.c
--- b/src/backend/access/nbtree/nbtpage.c
***************
*** 25,32 ****
  #include "access/nbtree.h"
  #include "access/transam.h"
  #include "miscadmin.h"
- #include "storage/bufmgr.h"
- #include "storage/freespace.h"
  #include "storage/indexfsm.h"
  #include "storage/lmgr.h"
  #include "storage/predicate.h"
--- 25,30 ----
diff --git a/src/backend/access/nbtree/nbtree.c b/src/backend/access/nbtree/nbtree.c
new file mode 100644
index ac86eb4..6d8b40b
*** a/src/backend/access/nbtree/nbtree.c
--- b/src/backend/access/nbtree/nbtree.c
***************
*** 18,36 ****
   */
  #include "postgres.h"

- #include "access/genam.h"
  #include "access/nbtree.h"
  #include "access/relscan.h"
  #include "catalog/index.h"
- #include "catalog/storage.h"
  #include "commands/vacuum.h"
- #include "storage/bufmgr.h"
- #include "storage/freespace.h"
  #include "storage/indexfsm.h"
  #include "storage/ipc.h"
  #include "storage/lmgr.h"
  #include "storage/smgr.h"
- #include "tcop/tcopprot.h"
  #include "utils/memutils.h"


--- 18,31 ----
diff --git a/src/backend/access/nbtree/nbtsearch.c b/src/backend/access/nbtree/nbtsearch.c
new file mode 100644
index 5c00fac..313e574
*** a/src/backend/access/nbtree/nbtsearch.c
--- b/src/backend/access/nbtree/nbtsearch.c
***************
*** 15,26 ****

  #include "postgres.h"

- #include "access/genam.h"
  #include "access/nbtree.h"
  #include "access/relscan.h"
  #include "miscadmin.h"
  #include "pgstat.h"
- #include "storage/bufmgr.h"
  #include "storage/predicate.h"
  #include "utils/lsyscache.h"
  #include "utils/rel.h"
--- 15,24 ----
diff --git a/src/backend/access/nbtree/nbtsort.c b/src/backend/access/nbtree/nbtsort.c
new file mode 100644
index 93a928c..7734190
*** a/src/backend/access/nbtree/nbtsort.c
--- b/src/backend/access/nbtree/nbtsort.c
***************
*** 66,72 ****

  #include "postgres.h"

- #include "access/heapam.h"
  #include "access/nbtree.h"
  #include "miscadmin.h"
  #include "storage/smgr.h"
--- 66,71 ----
diff --git a/src/backend/access/nbtree/nbtutils.c b/src/backend/access/nbtree/nbtutils.c
new file mode 100644
index 3996203..3ca75b7
*** a/src/backend/access/nbtree/nbtutils.c
--- b/src/backend/access/nbtree/nbtutils.c
***************
*** 17,31 ****

  #include <time.h>

- #include "access/genam.h"
  #include "access/nbtree.h"
  #include "access/reloptions.h"
  #include "access/relscan.h"
- #include "executor/execdebug.h"
  #include "miscadmin.h"
- #include "storage/bufmgr.h"
- #include "storage/lwlock.h"
- #include "storage/shmem.h"
  #include "utils/lsyscache.h"
  #include "utils/rel.h"

--- 17,26 ----
diff --git a/src/backend/access/nbtree/nbtxlog.c b/src/backend/access/nbtree/nbtxlog.c
new file mode 100644
index 2775ae6..e2ed50f
*** a/src/backend/access/nbtree/nbtxlog.c
--- b/src/backend/access/nbtree/nbtxlog.c
***************
*** 16,25 ****

  #include "access/nbtree.h"
  #include "access/transam.h"
- #include "access/xact.h"
- #include "storage/bufmgr.h"
  #include "storage/procarray.h"
- #include "storage/standby.h"
  #include "miscadmin.h"

  /*
--- 16,22 ----
diff --git a/src/backend/access/transam/xlogutils.c b/src/backend/access/transam/xlogutils.c
new file mode 100644
index cbb61bb..8791230
*** a/src/backend/access/transam/xlogutils.c
--- b/src/backend/access/transam/xlogutils.c
***************
*** 17,22 ****
--- 17,23 ----
   */
  #include "postgres.h"

+ #include "access/xlog.h"
  #include "access/xlogutils.h"
  #include "catalog/catalog.h"
  #include "storage/bufmgr.h"
diff --git a/src/backend/bootstrap/bootstrap.c b/src/backend/bootstrap/bootstrap.c
new file mode 100644
index 08ae863..baea46c
*** a/src/backend/bootstrap/bootstrap.c
--- b/src/backend/bootstrap/bootstrap.c
***************
*** 21,29 ****
  #include <getopt.h>
  #endif

- #include "access/genam.h"
- #include "access/heapam.h"
- #include "access/xact.h"
  #include "bootstrap/bootstrap.h"
  #include "catalog/index.h"
  #include "catalog/pg_collation.h"
--- 21,26 ----
***************
*** 37,43 ****
  #include "storage/bufmgr.h"
  #include "storage/ipc.h"
  #include "storage/proc.h"
- #include "storage/procsignal.h"
  #include "tcop/tcopprot.h"
  #include "utils/builtins.h"
  #include "utils/fmgroids.h"
--- 34,39 ----
diff --git a/src/backend/catalog/dependency.c b/src/backend/catalog/dependency.c
new file mode 100644
index 0526555..290e74a
*** a/src/backend/catalog/dependency.c
--- b/src/backend/catalog/dependency.c
***************
*** 14,27 ****
   */
  #include "postgres.h"

- #include "access/genam.h"
- #include "access/heapam.h"
  #include "access/sysattr.h"
  #include "access/xact.h"
  #include "catalog/dependency.h"
  #include "catalog/heap.h"
  #include "catalog/index.h"
- #include "catalog/indexing.h"
  #include "catalog/namespace.h"
  #include "catalog/pg_amop.h"
  #include "catalog/pg_amproc.h"
--- 14,24 ----
***************
*** 39,45 ****
  #include "catalog/pg_extension.h"
  #include "catalog/pg_foreign_data_wrapper.h"
  #include "catalog/pg_foreign_server.h"
- #include "catalog/pg_foreign_table.h"
  #include "catalog/pg_language.h"
  #include "catalog/pg_largeobject.h"
  #include "catalog/pg_namespace.h"
--- 36,41 ----
diff --git a/src/backend/catalog/heap.c b/src/backend/catalog/heap.c
new file mode 100644
index 7ec6581..2aaf775
*** a/src/backend/catalog/heap.c
--- b/src/backend/catalog/heap.c
***************
*** 29,36 ****
   */
  #include "postgres.h"

- #include "access/genam.h"
- #include "access/heapam.h"
  #include "access/sysattr.h"
  #include "access/transam.h"
  #include "access/xact.h"
--- 29,34 ----
***************
*** 38,45 ****
  #include "catalog/dependency.h"
  #include "catalog/heap.h"
  #include "catalog/index.h"
- #include "catalog/indexing.h"
- #include "catalog/namespace.h"
  #include "catalog/objectaccess.h"
  #include "catalog/pg_attrdef.h"
  #include "catalog/pg_collation.h"
--- 36,41 ----
***************
*** 61,68 ****
  #include "parser/parse_collate.h"
  #include "parser/parse_expr.h"
  #include "parser/parse_relation.h"
- #include "storage/bufmgr.h"
- #include "storage/freespace.h"
  #include "storage/predicate.h"
  #include "storage/smgr.h"
  #include "utils/acl.h"
--- 57,62 ----
diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c
new file mode 100644
index 75b4c14..67ade8f
*** a/src/backend/catalog/index.c
--- b/src/backend/catalog/index.c
***************
*** 23,30 ****

  #include <unistd.h>

- #include "access/genam.h"
- #include "access/heapam.h"
  #include "access/relscan.h"
  #include "access/sysattr.h"
  #include "access/transam.h"
--- 23,28 ----
***************
*** 34,41 ****
  #include "catalog/dependency.h"
  #include "catalog/heap.h"
  #include "catalog/index.h"
- #include "catalog/indexing.h"
- #include "catalog/namespace.h"
  #include "catalog/pg_collation.h"
  #include "catalog/pg_constraint.h"
  #include "catalog/pg_operator.h"
--- 32,37 ----
***************
*** 63,69 ****
  #include "utils/inval.h"
  #include "utils/lsyscache.h"
  #include "utils/memutils.h"
- #include "utils/relcache.h"
  #include "utils/syscache.h"
  #include "utils/tuplesort.h"
  #include "utils/snapmgr.h"
--- 59,64 ----
diff --git a/src/backend/catalog/indexing.c b/src/backend/catalog/indexing.c
new file mode 100644
index 351e6f6..e2e635e
*** a/src/backend/catalog/indexing.c
--- b/src/backend/catalog/indexing.c
***************
*** 15,21 ****
   */
  #include "postgres.h"

- #include "access/genam.h"
  #include "catalog/index.h"
  #include "catalog/indexing.h"
  #include "executor/executor.h"
--- 15,20 ----
diff --git a/src/backend/catalog/namespace.c b/src/backend/catalog/namespace.c
new file mode 100644
index d42f944..fcb41a8
*** a/src/backend/catalog/namespace.c
--- b/src/backend/catalog/namespace.c
***************
*** 21,27 ****

  #include "access/xact.h"
  #include "catalog/dependency.h"
- #include "catalog/namespace.h"
  #include "catalog/pg_authid.h"
  #include "catalog/pg_collation.h"
  #include "catalog/pg_conversion.h"
--- 21,26 ----
***************
*** 42,48 ****
  #include "miscadmin.h"
  #include "nodes/makefuncs.h"
  #include "parser/parse_func.h"
- #include "storage/backendid.h"
  #include "storage/ipc.h"
  #include "storage/lmgr.h"
  #include "storage/sinval.h"
--- 41,46 ----
***************
*** 52,58 ****
  #include "utils/inval.h"
  #include "utils/lsyscache.h"
  #include "utils/memutils.h"
- #include "utils/rel.h"
  #include "utils/syscache.h"


--- 50,55 ----
diff --git a/src/backend/catalog/objectaddress.c b/src/backend/catalog/objectaddress.c
new file mode 100644
index 7f16212..8feb601
*** a/src/backend/catalog/objectaddress.c
--- b/src/backend/catalog/objectaddress.c
***************
*** 15,30 ****

  #include "postgres.h"

- #include "access/heapam.h"
  #include "access/sysattr.h"
  #include "catalog/catalog.h"
- #include "catalog/dependency.h"
  #include "catalog/indexing.h"
- #include "catalog/namespace.h"
  #include "catalog/objectaddress.h"
  #include "catalog/pg_authid.h"
  #include "catalog/pg_cast.h"
- #include "catalog/pg_class.h"
  #include "catalog/pg_collation.h"
  #include "catalog/pg_constraint.h"
  #include "catalog/pg_conversion.h"
--- 15,26 ----
***************
*** 68,74 ****
  #include "utils/fmgroids.h"
  #include "utils/lsyscache.h"
  #include "utils/syscache.h"
- #include "utils/rel.h"
  #include "utils/tqual.h"

  static ObjectAddress get_object_address_unqualified(ObjectType objtype,
--- 64,69 ----
diff --git a/src/backend/catalog/pg_conversion.c b/src/backend/catalog/pg_conversion.c
new file mode 100644
index c84dbc6..e480aeb
*** a/src/backend/catalog/pg_conversion.c
--- b/src/backend/catalog/pg_conversion.c
***************
*** 24,31 ****
  #include "catalog/pg_namespace.h"
  #include "catalog/pg_proc.h"
  #include "mb/pg_wchar.h"
- #include "miscadmin.h"
- #include "utils/acl.h"
  #include "utils/builtins.h"
  #include "utils/fmgroids.h"
  #include "utils/rel.h"
--- 24,29 ----
diff --git a/src/backend/catalog/pg_db_role_setting.c b/src/backend/catalog/pg_db_role_setting.c
new file mode 100644
index 494704f..8162990
*** a/src/backend/catalog/pg_db_role_setting.c
--- b/src/backend/catalog/pg_db_role_setting.c
***************
*** 12,19 ****

  #include "access/genam.h"
  #include "access/heapam.h"
- #include "access/htup.h"
- #include "access/skey.h"
  #include "catalog/indexing.h"
  #include "catalog/pg_db_role_setting.h"
  #include "utils/fmgroids.h"
--- 12,17 ----
diff --git a/src/backend/catalog/pg_enum.c b/src/backend/catalog/pg_enum.c
new file mode 100644
index 61a9322..3665846
*** a/src/backend/catalog/pg_enum.c
--- b/src/backend/catalog/pg_enum.c
***************
*** 24,30 ****
  #include "miscadmin.h"
  #include "utils/builtins.h"
  #include "utils/fmgroids.h"
- #include "utils/rel.h"
  #include "utils/syscache.h"
  #include "utils/tqual.h"

--- 24,29 ----
diff --git a/src/backend/catalog/pg_inherits.c b/src/backend/catalog/pg_inherits.c
new file mode 100644
index 2ed6f1d..ed275d8
*** a/src/backend/catalog/pg_inherits.c
--- b/src/backend/catalog/pg_inherits.c
***************
*** 22,28 ****
  #include "access/genam.h"
  #include "access/heapam.h"
  #include "catalog/indexing.h"
- #include "catalog/pg_class.h"
  #include "catalog/pg_inherits.h"
  #include "catalog/pg_inherits_fn.h"
  #include "parser/parse_type.h"
--- 22,27 ----
diff --git a/src/backend/catalog/pg_largeobject.c b/src/backend/catalog/pg_largeobject.c
new file mode 100644
index 6d6c9e9..24cc0d4
*** a/src/backend/catalog/pg_largeobject.c
--- b/src/backend/catalog/pg_largeobject.c
***************
*** 17,32 ****
  #include "access/genam.h"
  #include "access/heapam.h"
  #include "access/sysattr.h"
- #include "catalog/catalog.h"
  #include "catalog/dependency.h"
  #include "catalog/indexing.h"
- #include "catalog/pg_authid.h"
  #include "catalog/pg_largeobject.h"
  #include "catalog/pg_largeobject_metadata.h"
- #include "catalog/toasting.h"
  #include "miscadmin.h"
  #include "utils/acl.h"
- #include "utils/bytea.h"
  #include "utils/fmgroids.h"
  #include "utils/rel.h"
  #include "utils/tqual.h"
--- 17,28 ----
diff --git a/src/backend/catalog/pg_proc.c b/src/backend/catalog/pg_proc.c
new file mode 100644
index f2f0872..f2b78b6
*** a/src/backend/catalog/pg_proc.c
--- b/src/backend/catalog/pg_proc.c
***************
*** 14,20 ****
   */
  #include "postgres.h"

- #include "access/heapam.h"
  #include "access/xact.h"
  #include "catalog/dependency.h"
  #include "catalog/indexing.h"
--- 14,19 ----
diff --git a/src/backend/catalog/pg_shdepend.c b/src/backend/catalog/pg_shdepend.c
new file mode 100644
index 591352d..1813e86
*** a/src/backend/catalog/pg_shdepend.c
--- b/src/backend/catalog/pg_shdepend.c
***************
*** 33,39 ****
  #include "catalog/pg_opfamily.h"
  #include "catalog/pg_proc.h"
  #include "catalog/pg_shdepend.h"
- #include "catalog/pg_tablespace.h"
  #include "catalog/pg_type.h"
  #include "commands/dbcommands.h"
  #include "commands/collationcmds.h"
--- 33,38 ----
diff --git a/src/backend/catalog/toasting.c b/src/backend/catalog/toasting.c
new file mode 100644
index a09a3ad..a938c98
*** a/src/backend/catalog/toasting.c
--- b/src/backend/catalog/toasting.c
***************
*** 14,26 ****
   */
  #include "postgres.h"

- #include "access/heapam.h"
  #include "access/tuptoaster.h"
  #include "access/xact.h"
  #include "catalog/dependency.h"
  #include "catalog/heap.h"
  #include "catalog/index.h"
- #include "catalog/indexing.h"
  #include "catalog/namespace.h"
  #include "catalog/pg_namespace.h"
  #include "catalog/pg_opclass.h"
--- 14,24 ----
diff --git a/src/backend/commands/alter.c b/src/backend/commands/alter.c
new file mode 100644
index e1be451..c321224
*** a/src/backend/commands/alter.c
--- b/src/backend/commands/alter.c
***************
*** 33,41 ****
  #include "commands/typecmds.h"
  #include "commands/user.h"
  #include "miscadmin.h"
- #include "parser/parse_clause.h"
  #include "tcop/utility.h"
- #include "utils/acl.h"
  #include "utils/builtins.h"
  #include "utils/lsyscache.h"
  #include "utils/rel.h"
--- 33,39 ----
diff --git a/src/backend/commands/analyze.c b/src/backend/commands/analyze.c
new file mode 100644
index a68da59..61ffef8
*** a/src/backend/commands/analyze.c
--- b/src/backend/commands/analyze.c
***************
*** 16,29 ****

  #include <math.h>

- #include "access/heapam.h"
  #include "access/transam.h"
  #include "access/tupconvert.h"
  #include "access/tuptoaster.h"
  #include "access/xact.h"
  #include "catalog/index.h"
  #include "catalog/indexing.h"
- #include "catalog/namespace.h"
  #include "catalog/pg_collation.h"
  #include "catalog/pg_inherits_fn.h"
  #include "catalog/pg_namespace.h"
--- 16,27 ----
diff --git a/src/backend/commands/cluster.c b/src/backend/commands/cluster.c
new file mode 100644
index 670d29e..8200d20
*** a/src/backend/commands/cluster.c
--- b/src/backend/commands/cluster.c
***************
*** 17,24 ****
   */
  #include "postgres.h"

- #include "access/genam.h"
- #include "access/heapam.h"
  #include "access/relscan.h"
  #include "access/rewriteheap.h"
  #include "access/transam.h"
--- 17,22 ----
***************
*** 27,46 ****
  #include "catalog/dependency.h"
  #include "catalog/heap.h"
  #include "catalog/index.h"
- #include "catalog/indexing.h"
- #include "catalog/namespace.h"
- #include "catalog/pg_namespace.h"
  #include "catalog/toasting.h"
  #include "commands/cluster.h"
  #include "commands/tablecmds.h"
- #include "commands/trigger.h"
  #include "commands/vacuum.h"
  #include "miscadmin.h"
  #include "optimizer/planner.h"
  #include "storage/bufmgr.h"
  #include "storage/lmgr.h"
  #include "storage/predicate.h"
- #include "storage/procarray.h"
  #include "storage/smgr.h"
  #include "utils/acl.h"
  #include "utils/fmgroids.h"
--- 25,39 ----
***************
*** 48,54 ****
  #include "utils/lsyscache.h"
  #include "utils/memutils.h"
  #include "utils/pg_rusage.h"
- #include "utils/relcache.h"
  #include "utils/relmapper.h"
  #include "utils/snapmgr.h"
  #include "utils/syscache.h"
--- 41,46 ----
diff --git a/src/backend/commands/collationcmds.c b/src/backend/commands/collationcmds.c
new file mode 100644
index 9e6138b..c43f663
*** a/src/backend/commands/collationcmds.c
--- b/src/backend/commands/collationcmds.c
***************
*** 27,33 ****
  #include "commands/defrem.h"
  #include "mb/pg_wchar.h"
  #include "miscadmin.h"
- #include "utils/acl.h"
  #include "utils/builtins.h"
  #include "utils/lsyscache.h"
  #include "utils/pg_locale.h"
--- 27,32 ----
diff --git a/src/backend/commands/conversioncmds.c b/src/backend/commands/conversioncmds.c
new file mode 100644
index 2c1c6da..cd7ae60
*** a/src/backend/commands/conversioncmds.c
--- b/src/backend/commands/conversioncmds.c
***************
*** 19,32 ****
  #include "catalog/indexing.h"
  #include "catalog/pg_conversion.h"
  #include "catalog/pg_conversion_fn.h"
- #include "catalog/pg_namespace.h"
  #include "catalog/pg_type.h"
  #include "commands/alter.h"
  #include "commands/conversioncmds.h"
  #include "mb/pg_wchar.h"
  #include "miscadmin.h"
  #include "parser/parse_func.h"
- #include "utils/acl.h"
  #include "utils/builtins.h"
  #include "utils/lsyscache.h"
  #include "utils/rel.h"
--- 19,30 ----
diff --git a/src/backend/commands/dbcommands.c b/src/backend/commands/dbcommands.c
new file mode 100644
index 93240ef..2c05814
*** a/src/backend/commands/dbcommands.c
--- b/src/backend/commands/dbcommands.c
***************
*** 26,32 ****

  #include "access/genam.h"
  #include "access/heapam.h"
- #include "access/transam.h"
  #include "access/xact.h"
  #include "access/xlogutils.h"
  #include "catalog/catalog.h"
--- 26,31 ----
***************
*** 45,62 ****
  #include "miscadmin.h"
  #include "pgstat.h"
  #include "postmaster/bgwriter.h"
- #include "storage/bufmgr.h"
  #include "storage/copydir.h"
- #include "storage/fd.h"
  #include "storage/lmgr.h"
  #include "storage/ipc.h"
  #include "storage/procarray.h"
  #include "storage/smgr.h"
- #include "storage/standby.h"
  #include "utils/acl.h"
  #include "utils/builtins.h"
  #include "utils/fmgroids.h"
- #include "utils/lsyscache.h"
  #include "utils/pg_locale.h"
  #include "utils/snapmgr.h"
  #include "utils/syscache.h"
--- 44,57 ----
diff --git a/src/backend/commands/discard.c b/src/backend/commands/discard.c
new file mode 100644
index 85a2ef8..213e2c2
*** a/src/backend/commands/discard.c
--- b/src/backend/commands/discard.c
***************
*** 19,25 ****
  #include "commands/discard.h"
  #include "commands/prepare.h"
  #include "commands/variable.h"
- #include "utils/plancache.h"
  #include "utils/portal.h"

  static void DiscardAll(bool isTopLevel);
--- 19,24 ----
diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c
new file mode 100644
index fee829f..6408d16
*** a/src/backend/commands/explain.c
--- b/src/backend/commands/explain.c
***************
*** 14,36 ****
  #include "postgres.h"

  #include "access/xact.h"
- #include "catalog/pg_constraint.h"
  #include "catalog/pg_type.h"
  #include "commands/defrem.h"
- #include "commands/explain.h"
  #include "commands/prepare.h"
- #include "commands/trigger.h"
  #include "executor/hashjoin.h"
  #include "executor/instrument.h"
  #include "foreign/fdwapi.h"
  #include "optimizer/clauses.h"
- #include "optimizer/planner.h"
- #include "optimizer/var.h"
  #include "parser/parsetree.h"
  #include "rewrite/rewriteHandler.h"
  #include "tcop/tcopprot.h"
  #include "utils/builtins.h"
- #include "utils/guc.h"
  #include "utils/lsyscache.h"
  #include "utils/rel.h"
  #include "utils/snapmgr.h"
--- 14,30 ----
diff --git a/src/backend/commands/extension.c b/src/backend/commands/extension.c
new file mode 100644
index d591bf0..9ffce85
*** a/src/backend/commands/extension.c
--- b/src/backend/commands/extension.c
***************
*** 41,56 ****
  #include "commands/comment.h"
  #include "commands/extension.h"
  #include "commands/schemacmds.h"
- #include "commands/trigger.h"
- #include "executor/executor.h"
  #include "funcapi.h"
  #include "mb/pg_wchar.h"
  #include "miscadmin.h"
- #include "tcop/tcopprot.h"
  #include "tcop/utility.h"
  #include "utils/builtins.h"
  #include "utils/fmgroids.h"
- #include "utils/guc.h"
  #include "utils/lsyscache.h"
  #include "utils/rel.h"
  #include "utils/snapmgr.h"
--- 41,52 ----
diff --git a/src/backend/commands/foreigncmds.c b/src/backend/commands/foreigncmds.c
new file mode 100644
index 3a3c131..d9c27d1
*** a/src/backend/commands/foreigncmds.c
--- b/src/backend/commands/foreigncmds.c
***************
*** 16,22 ****
  #include "access/heapam.h"
  #include "access/xact.h"
  #include "access/reloptions.h"
- #include "catalog/catalog.h"
  #include "catalog/dependency.h"
  #include "catalog/indexing.h"
  #include "catalog/objectaccess.h"
--- 16,21 ----
diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c
new file mode 100644
index 77648b4..69aa5bf
*** a/src/backend/commands/indexcmds.c
--- b/src/backend/commands/indexcmds.c
***************
*** 15,27 ****

  #include "postgres.h"

- #include "access/genam.h"
- #include "access/heapam.h"
  #include "access/reloptions.h"
- #include "access/transam.h"
  #include "access/xact.h"
  #include "catalog/catalog.h"
- #include "catalog/heap.h"
  #include "catalog/index.h"
  #include "catalog/indexing.h"
  #include "catalog/pg_opclass.h"
--- 15,23 ----
***************
*** 29,35 ****
  #include "catalog/pg_tablespace.h"
  #include "commands/dbcommands.h"
  #include "commands/defrem.h"
- #include "commands/tablecmds.h"
  #include "commands/tablespace.h"
  #include "mb/pg_wchar.h"
  #include "miscadmin.h"
--- 25,30 ----
***************
*** 39,45 ****
  #include "parser/parse_coerce.h"
  #include "parser/parse_func.h"
  #include "parser/parse_oper.h"
- #include "parser/parsetree.h"
  #include "storage/lmgr.h"
  #include "storage/proc.h"
  #include "storage/procarray.h"
--- 34,39 ----
***************
*** 49,55 ****
  #include "utils/inval.h"
  #include "utils/lsyscache.h"
  #include "utils/memutils.h"
- #include "utils/relcache.h"
  #include "utils/snapmgr.h"
  #include "utils/syscache.h"
  #include "utils/tqual.h"
--- 43,48 ----
diff --git a/src/backend/commands/opclasscmds.c b/src/backend/commands/opclasscmds.c
new file mode 100644
index 2bb0d4c..3dbc932
*** a/src/backend/commands/opclasscmds.c
--- b/src/backend/commands/opclasscmds.c
***************
*** 37,43 ****
  #include "parser/parse_func.h"
  #include "parser/parse_oper.h"
  #include "parser/parse_type.h"
- #include "utils/acl.h"
  #include "utils/builtins.h"
  #include "utils/fmgroids.h"
  #include "utils/lsyscache.h"
--- 37,42 ----
diff --git a/src/backend/commands/operatorcmds.c b/src/backend/commands/operatorcmds.c
new file mode 100644
index c99de4b..c5c18ee
*** a/src/backend/commands/operatorcmds.c
--- b/src/backend/commands/operatorcmds.c
***************
*** 37,45 ****
  #include "access/heapam.h"
  #include "catalog/dependency.h"
  #include "catalog/indexing.h"
- #include "catalog/namespace.h"
  #include "catalog/pg_operator.h"
- #include "catalog/pg_namespace.h"
  #include "catalog/pg_type.h"
  #include "commands/alter.h"
  #include "commands/defrem.h"
--- 37,43 ----
***************
*** 47,53 ****
  #include "parser/parse_func.h"
  #include "parser/parse_oper.h"
  #include "parser/parse_type.h"
- #include "utils/acl.h"
  #include "utils/lsyscache.h"
  #include "utils/rel.h"
  #include "utils/syscache.h"
--- 45,50 ----
diff --git a/src/backend/commands/prepare.c b/src/backend/commands/prepare.c
new file mode 100644
index dfa2ab0..6cf6da3
*** a/src/backend/commands/prepare.c
--- b/src/backend/commands/prepare.c
***************
*** 28,37 ****
  #include "parser/parse_type.h"
  #include "rewrite/rewriteHandler.h"
  #include "tcop/pquery.h"
- #include "tcop/tcopprot.h"
  #include "tcop/utility.h"
  #include "utils/builtins.h"
- #include "utils/memutils.h"
  #include "utils/snapmgr.h"


--- 28,35 ----
diff --git a/src/backend/commands/schemacmds.c b/src/backend/commands/schemacmds.c
new file mode 100644
index 5dd5763..9d1d653
*** a/src/backend/commands/schemacmds.c
--- b/src/backend/commands/schemacmds.c
***************
*** 14,20 ****
   */
  #include "postgres.h"

- #include "access/heapam.h"
  #include "access/xact.h"
  #include "catalog/catalog.h"
  #include "catalog/dependency.h"
--- 14,19 ----
***************
*** 28,34 ****
  #include "tcop/utility.h"
  #include "utils/acl.h"
  #include "utils/builtins.h"
- #include "utils/lsyscache.h"
  #include "utils/rel.h"
  #include "utils/syscache.h"

--- 27,32 ----
diff --git a/src/backend/commands/seclabel.c b/src/backend/commands/seclabel.c
new file mode 100644
index 0041734..e0fd7ac
*** a/src/backend/commands/seclabel.c
--- b/src/backend/commands/seclabel.c
***************
*** 14,31 ****
  #include "access/heapam.h"
  #include "catalog/catalog.h"
  #include "catalog/indexing.h"
- #include "catalog/namespace.h"
  #include "catalog/pg_seclabel.h"
  #include "catalog/pg_shseclabel.h"
  #include "commands/seclabel.h"
  #include "miscadmin.h"
- #include "utils/acl.h"
  #include "utils/builtins.h"
  #include "utils/fmgroids.h"
- #include "utils/lsyscache.h"
  #include "utils/memutils.h"
  #include "utils/rel.h"
- #include "utils/syscache.h"
  #include "utils/tqual.h"

  typedef struct
--- 14,27 ----
diff --git a/src/backend/commands/sequence.c b/src/backend/commands/sequence.c
new file mode 100644
index de6e2a3..54660f4
*** a/src/backend/commands/sequence.c
--- b/src/backend/commands/sequence.c
***************
*** 14,22 ****
   */
  #include "postgres.h"

- #include "access/heapam.h"
  #include "access/transam.h"
- #include "access/xact.h"
  #include "access/xlogutils.h"
  #include "catalog/dependency.h"
  #include "catalog/namespace.h"
--- 14,20 ----
***************
*** 27,33 ****
  #include "funcapi.h"
  #include "miscadmin.h"
  #include "nodes/makefuncs.h"
- #include "storage/bufmgr.h"
  #include "storage/lmgr.h"
  #include "storage/proc.h"
  #include "storage/smgr.h"
--- 25,30 ----
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
new file mode 100644
index 4509cda..5a9ab72
*** a/src/backend/commands/tablecmds.c
--- b/src/backend/commands/tablecmds.c
***************
*** 14,21 ****
   */
  #include "postgres.h"

- #include "access/genam.h"
- #include "access/heapam.h"
  #include "access/reloptions.h"
  #include "access/relscan.h"
  #include "access/sysattr.h"
--- 14,19 ----
***************
*** 24,30 ****
  #include "catalog/dependency.h"
  #include "catalog/heap.h"
  #include "catalog/index.h"
- #include "catalog/indexing.h"
  #include "catalog/namespace.h"
  #include "catalog/objectaccess.h"
  #include "catalog/pg_collation.h"
--- 22,27 ----
***************
*** 42,48 ****
  #include "catalog/storage.h"
  #include "catalog/toasting.h"
  #include "commands/cluster.h"
- #include "commands/comment.h"
  #include "commands/defrem.h"
  #include "commands/sequence.h"
  #include "commands/tablecmds.h"
--- 39,44 ----
***************
*** 54,67 ****
  #include "miscadmin.h"
  #include "nodes/makefuncs.h"
  #include "nodes/nodeFuncs.h"
- #include "nodes/parsenodes.h"
  #include "optimizer/clauses.h"
  #include "optimizer/planner.h"
  #include "parser/parse_clause.h"
  #include "parser/parse_coerce.h"
  #include "parser/parse_collate.h"
  #include "parser/parse_expr.h"
- #include "parser/parse_oper.h"
  #include "parser/parse_relation.h"
  #include "parser/parse_type.h"
  #include "parser/parse_utilcmd.h"
--- 50,61 ----
***************
*** 70,76 ****
  #include "rewrite/rewriteHandler.h"
  #include "storage/bufmgr.h"
  #include "storage/lmgr.h"
- #include "storage/lock.h"
  #include "storage/predicate.h"
  #include "storage/smgr.h"
  #include "utils/acl.h"
--- 64,69 ----
***************
*** 79,85 ****
  #include "utils/inval.h"
  #include "utils/lsyscache.h"
  #include "utils/memutils.h"
- #include "utils/relcache.h"
  #include "utils/snapmgr.h"
  #include "utils/syscache.h"
  #include "utils/tqual.h"
--- 72,77 ----
diff --git a/src/backend/commands/tablespace.c b/src/backend/commands/tablespace.c
new file mode 100644
index 09ecabb..d223f8c
*** a/src/backend/commands/tablespace.c
--- b/src/backend/commands/tablespace.c
***************
*** 54,60 ****
  #include "access/heapam.h"
  #include "access/reloptions.h"
  #include "access/sysattr.h"
- #include "access/transam.h"
  #include "access/xact.h"
  #include "catalog/catalog.h"
  #include "catalog/dependency.h"
--- 54,59 ----
***************
*** 62,83 ****
  #include "catalog/objectaccess.h"
  #include "catalog/pg_tablespace.h"
  #include "commands/comment.h"
- #include "commands/defrem.h"
  #include "commands/seclabel.h"
  #include "commands/tablespace.h"
  #include "miscadmin.h"
  #include "postmaster/bgwriter.h"
  #include "storage/fd.h"
- #include "storage/procarray.h"
  #include "storage/standby.h"
  #include "utils/acl.h"
  #include "utils/builtins.h"
  #include "utils/fmgroids.h"
  #include "utils/guc.h"
- #include "utils/lsyscache.h"
  #include "utils/memutils.h"
  #include "utils/rel.h"
- #include "utils/syscache.h"
  #include "utils/tqual.h"


--- 61,78 ----
diff --git a/src/backend/commands/trigger.c b/src/backend/commands/trigger.c
new file mode 100644
index 680962a..1a03c2c
*** a/src/backend/commands/trigger.c
--- b/src/backend/commands/trigger.c
***************
*** 13,20 ****
   */
  #include "postgres.h"

- #include "access/genam.h"
- #include "access/heapam.h"
  #include "access/sysattr.h"
  #include "access/xact.h"
  #include "catalog/catalog.h"
--- 13,18 ----
***************
*** 31,37 ****
  #include "executor/executor.h"
  #include "executor/instrument.h"
  #include "miscadmin.h"
- #include "nodes/bitmapset.h"
  #include "nodes/makefuncs.h"
  #include "optimizer/clauses.h"
  #include "optimizer/var.h"
--- 29,34 ----
diff --git a/src/backend/commands/tsearchcmds.c b/src/backend/commands/tsearchcmds.c
new file mode 100644
index deac106..16e6940
*** a/src/backend/commands/tsearchcmds.c
--- b/src/backend/commands/tsearchcmds.c
***************
*** 22,28 ****
  #include "access/xact.h"
  #include "catalog/dependency.h"
  #include "catalog/indexing.h"
- #include "catalog/namespace.h"
  #include "catalog/objectaccess.h"
  #include "catalog/pg_namespace.h"
  #include "catalog/pg_proc.h"
--- 22,27 ----
***************
*** 38,48 ****
  #include "nodes/makefuncs.h"
  #include "parser/parse_func.h"
  #include "tsearch/ts_cache.h"
- #include "tsearch/ts_public.h"
  #include "tsearch/ts_utils.h"
- #include "utils/acl.h"
  #include "utils/builtins.h"
- #include "utils/catcache.h"
  #include "utils/fmgroids.h"
  #include "utils/lsyscache.h"
  #include "utils/rel.h"
--- 37,44 ----
diff --git a/src/backend/commands/typecmds.c b/src/backend/commands/typecmds.c
new file mode 100644
index 7c27f85..b214a69
*** a/src/backend/commands/typecmds.c
--- b/src/backend/commands/typecmds.c
***************
*** 31,43 ****
   */
  #include "postgres.h"

- #include "access/genam.h"
- #include "access/heapam.h"
  #include "access/xact.h"
  #include "catalog/catalog.h"
  #include "catalog/dependency.h"
  #include "catalog/heap.h"
- #include "catalog/indexing.h"
  #include "catalog/pg_collation.h"
  #include "catalog/pg_constraint.h"
  #include "catalog/pg_depend.h"
--- 31,40 ----
diff --git a/src/backend/commands/user.c b/src/backend/commands/user.c
new file mode 100644
index 0367b20..10f4487
*** a/src/backend/commands/user.c
--- b/src/backend/commands/user.c
***************
*** 32,38 ****
  #include "utils/acl.h"
  #include "utils/builtins.h"
  #include "utils/fmgroids.h"
- #include "utils/lsyscache.h"
  #include "utils/syscache.h"
  #include "utils/tqual.h"

--- 32,37 ----
diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c
new file mode 100644
index 889737e..4dc7ea0
*** a/src/backend/commands/vacuum.c
--- b/src/backend/commands/vacuum.c
***************
*** 47,53 ****
  #include "utils/syscache.h"
  #include "utils/tqual.h"

-
  /*
   * GUC parameters
   */
--- 47,52 ----
diff --git a/src/backend/executor/execGrouping.c b/src/backend/executor/execGrouping.c
new file mode 100644
index 17098ef..cc046f7
*** a/src/backend/executor/execGrouping.c
--- b/src/backend/executor/execGrouping.c
***************
*** 20,29 ****

  #include "executor/executor.h"
  #include "miscadmin.h"
- #include "parser/parse_oper.h"
  #include "utils/lsyscache.h"
  #include "utils/memutils.h"
- #include "utils/syscache.h"


  static TupleHashTable CurTupleHashTable = NULL;
--- 20,27 ----
diff --git a/src/backend/executor/execUtils.c b/src/backend/executor/execUtils.c
new file mode 100644
index 63e3d92..4dbf10b
*** a/src/backend/executor/execUtils.c
--- b/src/backend/executor/execUtils.c
***************
*** 42,49 ****

  #include "postgres.h"

- #include "access/genam.h"
- #include "access/heapam.h"
  #include "access/relscan.h"
  #include "access/transam.h"
  #include "catalog/index.h"
--- 42,47 ----
***************
*** 52,58 ****
  #include "parser/parsetree.h"
  #include "storage/lmgr.h"
  #include "utils/memutils.h"
- #include "utils/relcache.h"
  #include "utils/tqual.h"


--- 50,55 ----
diff --git a/src/backend/executor/functions.c b/src/backend/executor/functions.c
new file mode 100644
index 13946ca..398bc40
*** a/src/backend/executor/functions.c
--- b/src/backend/executor/functions.c
***************
*** 17,23 ****
  #include "access/xact.h"
  #include "catalog/pg_proc.h"
  #include "catalog/pg_type.h"
- #include "commands/trigger.h"
  #include "executor/functions.h"
  #include "funcapi.h"
  #include "miscadmin.h"
--- 17,22 ----
diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
new file mode 100644
index c9b540e..8e50fb1
*** a/src/backend/executor/nodeBitmapHeapscan.c
--- b/src/backend/executor/nodeBitmapHeapscan.c
***************
*** 35,41 ****
   */
  #include "postgres.h"

- #include "access/heapam.h"
  #include "access/relscan.h"
  #include "access/transam.h"
  #include "executor/execdebug.h"
--- 35,40 ----
diff --git a/src/backend/executor/nodeBitmapIndexscan.c b/src/backend/executor/nodeBitmapIndexscan.c
new file mode 100644
index 4de54ea..9a56fd4
*** a/src/backend/executor/nodeBitmapIndexscan.c
--- b/src/backend/executor/nodeBitmapIndexscan.c
***************
*** 21,27 ****
   */
  #include "postgres.h"

- #include "access/genam.h"
  #include "executor/execdebug.h"
  #include "executor/instrument.h"
  #include "executor/nodeBitmapIndexscan.h"
--- 21,26 ----
diff --git a/src/backend/executor/nodeFunctionscan.c b/src/backend/executor/nodeFunctionscan.c
new file mode 100644
index dedd255..5d5727e
*** a/src/backend/executor/nodeFunctionscan.c
--- b/src/backend/executor/nodeFunctionscan.c
***************
*** 25,31 ****
  #include "executor/nodeFunctionscan.h"
  #include "funcapi.h"
  #include "nodes/nodeFuncs.h"
- #include "utils/builtins.h"


  static TupleTableSlot *FunctionNext(FunctionScanState *node);
--- 25,30 ----
diff --git a/src/backend/executor/nodeHash.c b/src/backend/executor/nodeHash.c
new file mode 100644
index 1af98c8..2ade2d7
*** a/src/backend/executor/nodeHash.c
--- b/src/backend/executor/nodeHash.c
***************
*** 32,38 ****
  #include "executor/nodeHash.h"
  #include "executor/nodeHashjoin.h"
  #include "miscadmin.h"
- #include "parser/parse_expr.h"
  #include "utils/dynahash.h"
  #include "utils/memutils.h"
  #include "utils/lsyscache.h"
--- 32,37 ----
diff --git a/src/backend/executor/nodeIndexscan.c b/src/backend/executor/nodeIndexscan.c
new file mode 100644
index 263f3b9..955008e
*** a/src/backend/executor/nodeIndexscan.c
--- b/src/backend/executor/nodeIndexscan.c
***************
*** 24,30 ****
   */
  #include "postgres.h"

- #include "access/genam.h"
  #include "access/nbtree.h"
  #include "access/relscan.h"
  #include "executor/execdebug.h"
--- 24,29 ----
diff --git a/src/backend/executor/nodeMergejoin.c b/src/backend/executor/nodeMergejoin.c
new file mode 100644
index 7d27123..e23dd6c
*** a/src/backend/executor/nodeMergejoin.c
--- b/src/backend/executor/nodeMergejoin.c
***************
*** 93,106 ****
  #include "postgres.h"

  #include "access/nbtree.h"
- #include "catalog/pg_amop.h"
  #include "executor/execdebug.h"
  #include "executor/nodeMergejoin.h"
  #include "miscadmin.h"
  #include "utils/acl.h"
  #include "utils/lsyscache.h"
  #include "utils/memutils.h"
- #include "utils/syscache.h"


  /*
--- 93,104 ----
diff --git a/src/backend/executor/nodeSeqscan.c b/src/backend/executor/nodeSeqscan.c
new file mode 100644
index e2cea0e..5b652c9
*** a/src/backend/executor/nodeSeqscan.c
--- b/src/backend/executor/nodeSeqscan.c
***************
*** 24,30 ****
   */
  #include "postgres.h"

- #include "access/heapam.h"
  #include "access/relscan.h"
  #include "executor/execdebug.h"
  #include "executor/nodeSeqscan.h"
--- 24,29 ----
diff --git a/src/backend/executor/nodeTidscan.c b/src/backend/executor/nodeTidscan.c
new file mode 100644
index 28244a1..69f47ff
*** a/src/backend/executor/nodeTidscan.c
--- b/src/backend/executor/nodeTidscan.c
***************
*** 24,30 ****
   */
  #include "postgres.h"

- #include "access/heapam.h"
  #include "access/sysattr.h"
  #include "catalog/pg_type.h"
  #include "executor/execdebug.h"
--- 24,29 ----
diff --git a/src/backend/executor/nodeValuesscan.c b/src/backend/executor/nodeValuesscan.c
new file mode 100644
index 7664073..d5260e4
*** a/src/backend/executor/nodeValuesscan.c
--- b/src/backend/executor/nodeValuesscan.c
***************
*** 25,31 ****

  #include "executor/executor.h"
  #include "executor/nodeValuesscan.h"
- #include "utils/memutils.h"


  static TupleTableSlot *ValuesNext(ValuesScanState *node);
--- 25,30 ----
diff --git a/src/backend/executor/spi.c b/src/backend/executor/spi.c
new file mode 100644
index d71ea60..6d2f357
*** a/src/backend/executor/spi.c
--- b/src/backend/executor/spi.c
***************
*** 19,31 ****
  #include "access/xact.h"
  #include "catalog/heap.h"
  #include "catalog/pg_type.h"
- #include "commands/trigger.h"
  #include "executor/executor.h"
  #include "executor/spi_priv.h"
  #include "tcop/pquery.h"
  #include "tcop/utility.h"
  #include "utils/builtins.h"
- #include "utils/datum.h"
  #include "utils/lsyscache.h"
  #include "utils/memutils.h"
  #include "utils/rel.h"
--- 19,29 ----
diff --git a/src/backend/foreign/foreign.c b/src/backend/foreign/foreign.c
new file mode 100644
index 4a7b2c3..67a4597
*** a/src/backend/foreign/foreign.c
--- b/src/backend/foreign/foreign.c
***************
*** 13,34 ****
  #include "postgres.h"

  #include "access/reloptions.h"
- #include "catalog/namespace.h"
  #include "catalog/pg_foreign_data_wrapper.h"
  #include "catalog/pg_foreign_server.h"
  #include "catalog/pg_foreign_table.h"
- #include "catalog/pg_type.h"
  #include "catalog/pg_user_mapping.h"
  #include "foreign/fdwapi.h"
  #include "foreign/foreign.h"
- #include "funcapi.h"
  #include "miscadmin.h"
- #include "nodes/parsenodes.h"
- #include "utils/acl.h"
- #include "utils/array.h"
  #include "utils/builtins.h"
- #include "utils/lsyscache.h"
- #include "utils/memutils.h"
  #include "utils/syscache.h"


--- 13,26 ----
diff --git a/src/backend/libpq/be-fsstubs.c b/src/backend/libpq/be-fsstubs.c
new file mode 100644
index 155385f..f2a2d2d
*** a/src/backend/libpq/be-fsstubs.c
--- b/src/backend/libpq/be-fsstubs.c
***************
*** 42,48 ****
  #include <sys/stat.h>
  #include <unistd.h>

- #include "catalog/pg_largeobject_metadata.h"
  #include "libpq/be-fsstubs.h"
  #include "libpq/libpq-fs.h"
  #include "miscadmin.h"
--- 42,47 ----
diff --git a/src/backend/libpq/ip.c b/src/backend/libpq/ip.c
new file mode 100644
index cc6c2ab..c044694
*** a/src/backend/libpq/ip.c
--- b/src/backend/libpq/ip.c
*************** run_ifaddr_callback(PgIfAddrCallback cal
*** 531,538 ****

  #ifdef WIN32

! #include <winsock2.h>
! #include <ws2tcpip.h>

  /*
   * Enumerate the system's network interface addresses and call the callback
--- 531,538 ----

  #ifdef WIN32

! #include <winsock2.h>    /* pgrminclude ignore */
! #include <ws2tcpip.h>    /* pgrminclude ignore */

  /*
   * Enumerate the system's network interface addresses and call the callback
diff --git a/src/backend/main/main.c b/src/backend/main/main.c
new file mode 100644
index 8d9cb94..64f0bba
*** a/src/backend/main/main.c
--- b/src/backend/main/main.c
***************
*** 25,31 ****

  #if defined(__alpha) && defined(__osf__)        /* no __alpha__ ? */
  #include <sys/sysinfo.h>
- #include "machine/hal_sysinfo.h"
  #define ASSEMBLER
  #include <sys/proc.h>
  #undef ASSEMBLER
--- 25,30 ----
diff --git a/src/backend/nodes/bitmapset.c b/src/backend/nodes/bitmapset.c
new file mode 100644
index 5546034..e1e9a35
*** a/src/backend/nodes/bitmapset.c
--- b/src/backend/nodes/bitmapset.c
***************
*** 20,26 ****
   */
  #include "postgres.h"

- #include "nodes/bitmapset.h"
  #include "access/hash.h"


--- 20,25 ----
diff --git a/src/backend/nodes/copyfuncs.c b/src/backend/nodes/copyfuncs.c
new file mode 100644
index 108baa6..afc1c61
*** a/src/backend/nodes/copyfuncs.c
--- b/src/backend/nodes/copyfuncs.c
***************
*** 24,31 ****

  #include "miscadmin.h"
  #include "foreign/fdwapi.h"
- #include "nodes/plannodes.h"
- #include "nodes/relation.h"
  #include "utils/datum.h"


--- 24,29 ----
diff --git a/src/backend/nodes/outfuncs.c b/src/backend/nodes/outfuncs.c
new file mode 100644
index 627a8f5..93ab08a
*** a/src/backend/nodes/outfuncs.c
--- b/src/backend/nodes/outfuncs.c
***************
*** 23,32 ****

  #include <ctype.h>

- #include "lib/stringinfo.h"
  #include "foreign/fdwapi.h"
- #include "nodes/plannodes.h"
- #include "nodes/relation.h"
  #include "utils/datum.h"


--- 23,29 ----
diff --git a/src/backend/nodes/params.c b/src/backend/nodes/params.c
new file mode 100644
index 62d766a..047d27c
*** a/src/backend/nodes/params.c
--- b/src/backend/nodes/params.c
***************
*** 16,22 ****
  #include "postgres.h"

  #include "nodes/params.h"
- #include "parser/parse_param.h"
  #include "utils/datum.h"
  #include "utils/lsyscache.h"

--- 16,21 ----
diff --git a/src/backend/nodes/print.c b/src/backend/nodes/print.c
new file mode 100644
index e22824a..0b0cf38
*** a/src/backend/nodes/print.c
--- b/src/backend/nodes/print.c
***************
*** 20,31 ****
  #include "postgres.h"

  #include "access/printtup.h"
- #include "lib/stringinfo.h"
  #include "nodes/print.h"
  #include "optimizer/clauses.h"
  #include "parser/parsetree.h"
  #include "utils/lsyscache.h"
- #include "utils/rel.h"


  /*
--- 20,29 ----
diff --git a/src/backend/optimizer/geqo/geqo_main.c b/src/backend/optimizer/geqo/geqo_main.c
new file mode 100644
index e521bf7..f8bcb65
*** a/src/backend/optimizer/geqo/geqo_main.c
--- b/src/backend/optimizer/geqo/geqo_main.c
***************
*** 27,33 ****
  #include <math.h>

  #include "optimizer/geqo_misc.h"
- #include "optimizer/geqo_mutation.h"
  #include "optimizer/geqo_pool.h"
  #include "optimizer/geqo_random.h"
  #include "optimizer/geqo_selection.h"
--- 27,32 ----
diff --git a/src/backend/optimizer/geqo/geqo_misc.c b/src/backend/optimizer/geqo/geqo_misc.c
new file mode 100644
index a00892d..2c8d9f4
*** a/src/backend/optimizer/geqo/geqo_misc.c
--- b/src/backend/optimizer/geqo/geqo_misc.c
***************
*** 21,27 ****

  #include "postgres.h"

- #include "optimizer/geqo_misc.h"


  #ifdef GEQO_DEBUG
--- 21,26 ----
diff --git a/src/backend/optimizer/path/clausesel.c b/src/backend/optimizer/path/clausesel.c
new file mode 100644
index ca06899..eb9b293
*** a/src/backend/optimizer/path/clausesel.c
--- b/src/backend/optimizer/path/clausesel.c
***************
*** 20,26 ****
  #include "optimizer/cost.h"
  #include "optimizer/pathnode.h"
  #include "optimizer/plancat.h"
- #include "parser/parsetree.h"
  #include "utils/fmgroids.h"
  #include "utils/lsyscache.h"
  #include "utils/selfuncs.h"
--- 20,25 ----
diff --git a/src/backend/optimizer/path/equivclass.c b/src/backend/optimizer/path/equivclass.c
new file mode 100644
index acc4fb1..4a52ecf
*** a/src/backend/optimizer/path/equivclass.c
--- b/src/backend/optimizer/path/equivclass.c
***************
*** 21,27 ****
  #include "nodes/makefuncs.h"
  #include "nodes/nodeFuncs.h"
  #include "optimizer/clauses.h"
- #include "optimizer/cost.h"
  #include "optimizer/paths.h"
  #include "optimizer/planmain.h"
  #include "optimizer/prep.h"
--- 21,26 ----
diff --git a/src/backend/optimizer/plan/createplan.c b/src/backend/optimizer/plan/createplan.c
new file mode 100644
index a3a82ec..e25db4d
*** a/src/backend/optimizer/plan/createplan.c
--- b/src/backend/optimizer/plan/createplan.c
***************
*** 19,25 ****
  #include <limits.h>
  #include <math.h>

- #include "access/skey.h"
  #include "foreign/fdwapi.h"
  #include "miscadmin.h"
  #include "nodes/makefuncs.h"
--- 19,24 ----
***************
*** 33,39 ****
  #include "optimizer/restrictinfo.h"
  #include "optimizer/subselect.h"
  #include "optimizer/tlist.h"
- #include "optimizer/var.h"
  #include "parser/parse_clause.h"
  #include "parser/parsetree.h"
  #include "utils/lsyscache.h"
--- 32,37 ----
diff --git a/src/backend/optimizer/plan/initsplan.c b/src/backend/optimizer/plan/initsplan.c
new file mode 100644
index 9cfc56e..5b170b3
*** a/src/backend/optimizer/plan/initsplan.c
--- b/src/backend/optimizer/plan/initsplan.c
***************
*** 14,24 ****
   */
  #include "postgres.h"

- #include "catalog/pg_operator.h"
  #include "catalog/pg_type.h"
  #include "nodes/nodeFuncs.h"
  #include "optimizer/clauses.h"
- #include "optimizer/cost.h"
  #include "optimizer/joininfo.h"
  #include "optimizer/pathnode.h"
  #include "optimizer/paths.h"
--- 14,22 ----
***************
*** 27,37 ****
  #include "optimizer/prep.h"
  #include "optimizer/restrictinfo.h"
  #include "optimizer/var.h"
- #include "parser/parse_expr.h"
- #include "parser/parse_oper.h"
- #include "utils/builtins.h"
  #include "utils/lsyscache.h"
- #include "utils/syscache.h"


  /* These parameters are set by GUC */
--- 25,31 ----
diff --git a/src/backend/optimizer/plan/planner.c b/src/backend/optimizer/plan/planner.c
new file mode 100644
index 7230fb4..484d441
*** a/src/backend/optimizer/plan/planner.c
--- b/src/backend/optimizer/plan/planner.c
***************
*** 17,23 ****

  #include <limits.h>

- #include "catalog/pg_operator.h"
  #include "executor/executor.h"
  #include "executor/nodeAgg.h"
  #include "miscadmin.h"
--- 17,22 ----
***************
*** 32,48 ****
  #include "optimizer/prep.h"
  #include "optimizer/subselect.h"
  #include "optimizer/tlist.h"
- #include "optimizer/var.h"
  #ifdef OPTIMIZER_DEBUG
  #include "nodes/print.h"
  #endif
  #include "parser/analyze.h"
- #include "parser/parse_expr.h"
- #include "parser/parse_oper.h"
  #include "parser/parsetree.h"
- #include "utils/lsyscache.h"
  #include "utils/rel.h"
- #include "utils/syscache.h"


  /* GUC parameter */
--- 31,42 ----
diff --git a/src/backend/optimizer/plan/setrefs.c b/src/backend/optimizer/plan/setrefs.c
new file mode 100644
index c3a5aac..8508d25
*** a/src/backend/optimizer/plan/setrefs.c
--- b/src/backend/optimizer/plan/setrefs.c
***************
*** 20,29 ****
  #include "catalog/pg_type.h"
  #include "nodes/makefuncs.h"
  #include "nodes/nodeFuncs.h"
- #include "optimizer/clauses.h"
  #include "optimizer/planmain.h"
  #include "optimizer/tlist.h"
- #include "parser/parsetree.h"
  #include "utils/lsyscache.h"
  #include "utils/syscache.h"

--- 20,27 ----
diff --git a/src/backend/optimizer/plan/subselect.c b/src/backend/optimizer/plan/subselect.c
new file mode 100644
index 71ffc17..4d4e6bf
*** a/src/backend/optimizer/plan/subselect.c
--- b/src/backend/optimizer/plan/subselect.c
***************
*** 27,33 ****
  #include "optimizer/subselect.h"
  #include "optimizer/var.h"
  #include "parser/parse_relation.h"
- #include "parser/parsetree.h"
  #include "rewrite/rewriteManip.h"
  #include "utils/builtins.h"
  #include "utils/lsyscache.h"
--- 27,32 ----
diff --git a/src/backend/optimizer/prep/prepjointree.c b/src/backend/optimizer/prep/prepjointree.c
new file mode 100644
index 63a52f2..aeaae8c
*** a/src/backend/optimizer/prep/prepjointree.c
--- b/src/backend/optimizer/prep/prepjointree.c
***************
*** 31,37 ****
  #include "optimizer/prep.h"
  #include "optimizer/subselect.h"
  #include "optimizer/tlist.h"
- #include "optimizer/var.h"
  #include "parser/parse_relation.h"
  #include "parser/parsetree.h"
  #include "rewrite/rewriteManip.h"
--- 31,36 ----
diff --git a/src/backend/optimizer/prep/preptlist.c b/src/backend/optimizer/prep/preptlist.c
new file mode 100644
index fa2514d..077ac49
*** a/src/backend/optimizer/prep/preptlist.c
--- b/src/backend/optimizer/prep/preptlist.c
***************
*** 29,37 ****
  #include "catalog/pg_type.h"
  #include "nodes/makefuncs.h"
  #include "optimizer/prep.h"
- #include "optimizer/subselect.h"
  #include "optimizer/tlist.h"
- #include "optimizer/var.h"
  #include "parser/parsetree.h"
  #include "parser/parse_coerce.h"
  #include "utils/rel.h"
--- 29,35 ----
diff --git a/src/backend/optimizer/prep/prepunion.c b/src/backend/optimizer/prep/prepunion.c
new file mode 100644
index f82ab27..31b101b
*** a/src/backend/optimizer/prep/prepunion.c
--- b/src/backend/optimizer/prep/prepunion.c
***************
*** 31,37 ****

  #include "access/heapam.h"
  #include "access/sysattr.h"
- #include "catalog/namespace.h"
  #include "catalog/pg_inherits_fn.h"
  #include "catalog/pg_type.h"
  #include "miscadmin.h"
--- 31,36 ----
***************
*** 39,50 ****
  #include "nodes/nodeFuncs.h"
  #include "optimizer/cost.h"
  #include "optimizer/pathnode.h"
- #include "optimizer/paths.h"
  #include "optimizer/planmain.h"
  #include "optimizer/planner.h"
  #include "optimizer/prep.h"
  #include "optimizer/tlist.h"
- #include "parser/parse_clause.h"
  #include "parser/parse_coerce.h"
  #include "parser/parsetree.h"
  #include "utils/lsyscache.h"
--- 38,47 ----
diff --git a/src/backend/optimizer/util/pathnode.c b/src/backend/optimizer/util/pathnode.c
new file mode 100644
index 161d5ab..4a1c94a
*** a/src/backend/optimizer/util/pathnode.c
--- b/src/backend/optimizer/util/pathnode.c
***************
*** 16,22 ****

  #include <math.h>

- #include "catalog/pg_operator.h"
  #include "foreign/fdwapi.h"
  #include "miscadmin.h"
  #include "nodes/nodeFuncs.h"
--- 16,21 ----
***************
*** 25,36 ****
  #include "optimizer/pathnode.h"
  #include "optimizer/paths.h"
  #include "optimizer/tlist.h"
- #include "optimizer/var.h"
- #include "parser/parse_expr.h"
  #include "parser/parsetree.h"
  #include "utils/selfuncs.h"
  #include "utils/lsyscache.h"
- #include "utils/syscache.h"


  static List *translate_sub_tlist(List *tlist, int relid);
--- 24,32 ----
diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c
new file mode 100644
index 6259170..8a3a5d8
*** a/src/backend/optimizer/util/plancat.c
--- b/src/backend/optimizer/util/plancat.c
***************
*** 24,30 ****
  #include "catalog/catalog.h"
  #include "miscadmin.h"
  #include "nodes/makefuncs.h"
- #include "nodes/nodeFuncs.h"
  #include "optimizer/clauses.h"
  #include "optimizer/cost.h"
  #include "optimizer/plancat.h"
--- 24,29 ----
diff --git a/src/backend/optimizer/util/predtest.c b/src/backend/optimizer/util/predtest.c
new file mode 100644
index cb10a31..3e4a775
*** a/src/backend/optimizer/util/predtest.c
--- b/src/backend/optimizer/util/predtest.c
***************
*** 15,27 ****
   */
  #include "postgres.h"

- #include "catalog/pg_am.h"
- #include "catalog/pg_amop.h"
  #include "catalog/pg_proc.h"
  #include "catalog/pg_type.h"
  #include "executor/executor.h"
  #include "miscadmin.h"
- #include "nodes/nodeFuncs.h"
  #include "optimizer/clauses.h"
  #include "optimizer/planmain.h"
  #include "optimizer/predtest.h"
--- 15,24 ----
diff --git a/src/backend/optimizer/util/relnode.c b/src/backend/optimizer/util/relnode.c
new file mode 100644
index b7a5845..b59eb09
*** a/src/backend/optimizer/util/relnode.c
--- b/src/backend/optimizer/util/relnode.c
***************
*** 19,26 ****
  #include "optimizer/paths.h"
  #include "optimizer/placeholder.h"
  #include "optimizer/plancat.h"
- #include "optimizer/restrictinfo.h"
- #include "parser/parsetree.h"
  #include "utils/hsearch.h"


--- 19,24 ----
diff --git a/src/backend/optimizer/util/restrictinfo.c b/src/backend/optimizer/util/restrictinfo.c
new file mode 100644
index 93f9aa8..63ff431
*** a/src/backend/optimizer/util/restrictinfo.c
--- b/src/backend/optimizer/util/restrictinfo.c
***************
*** 15,22 ****
  #include "postgres.h"

  #include "optimizer/clauses.h"
- #include "optimizer/cost.h"
- #include "optimizer/paths.h"
  #include "optimizer/predtest.h"
  #include "optimizer/restrictinfo.h"
  #include "optimizer/var.h"
--- 15,20 ----
diff --git a/src/backend/optimizer/util/tlist.c b/src/backend/optimizer/util/tlist.c
new file mode 100644
index 718057a..552540a
*** a/src/backend/optimizer/util/tlist.c
--- b/src/backend/optimizer/util/tlist.c
***************
*** 17,23 ****
  #include "nodes/makefuncs.h"
  #include "nodes/nodeFuncs.h"
  #include "optimizer/tlist.h"
- #include "optimizer/var.h"


  /*****************************************************************************
--- 17,22 ----
diff --git a/src/backend/parser/keywords.c b/src/backend/parser/keywords.c
new file mode 100644
index bb910e7..035bc30
*** a/src/backend/parser/keywords.c
--- b/src/backend/parser/keywords.c
***************
*** 21,27 ****


  const ScanKeyword ScanKeywords[] = {
! #include "parser/kwlist.h"
  };

  const int    NumScanKeywords = lengthof(ScanKeywords);
--- 21,27 ----


  const ScanKeyword ScanKeywords[] = {
! #include "parser/kwlist.h"    /* pgrminclude ignore */
  };

  const int    NumScanKeywords = lengthof(ScanKeywords);
diff --git a/src/backend/parser/parse_agg.c b/src/backend/parser/parse_agg.c
new file mode 100644
index 8356133..ed720dd
*** a/src/backend/parser/parse_agg.c
--- b/src/backend/parser/parse_agg.c
***************
*** 18,30 ****
  #include "nodes/makefuncs.h"
  #include "nodes/nodeFuncs.h"
  #include "optimizer/tlist.h"
- #include "optimizer/var.h"
  #include "parser/parse_agg.h"
  #include "parser/parse_clause.h"
  #include "parser/parsetree.h"
  #include "rewrite/rewriteManip.h"
  #include "utils/builtins.h"
- #include "utils/lsyscache.h"


  typedef struct
--- 18,28 ----
diff --git a/src/backend/parser/parse_clause.c b/src/backend/parser/parse_clause.c
new file mode 100644
index a8549e0..e8177bc
*** a/src/backend/parser/parse_clause.c
--- b/src/backend/parser/parse_clause.c
***************
*** 23,29 ****
  #include "nodes/nodeFuncs.h"
  #include "optimizer/clauses.h"
  #include "optimizer/tlist.h"
- #include "optimizer/var.h"
  #include "parser/analyze.h"
  #include "parser/parsetree.h"
  #include "parser/parse_clause.h"
--- 23,28 ----
diff --git a/src/backend/parser/parse_coerce.c b/src/backend/parser/parse_coerce.c
new file mode 100644
index f26c69a..127818a
*** a/src/backend/parser/parse_coerce.c
--- b/src/backend/parser/parse_coerce.c
***************
*** 22,32 ****
  #include "nodes/makefuncs.h"
  #include "nodes/nodeFuncs.h"
  #include "parser/parse_coerce.h"
- #include "parser/parse_func.h"
  #include "parser/parse_relation.h"
  #include "parser/parse_type.h"
  #include "utils/builtins.h"
- #include "utils/fmgroids.h"
  #include "utils/lsyscache.h"
  #include "utils/syscache.h"
  #include "utils/typcache.h"
--- 22,30 ----
diff --git a/src/backend/parser/parse_node.c b/src/backend/parser/parse_node.c
new file mode 100644
index 7b5c040..494ef5f
*** a/src/backend/parser/parse_node.c
--- b/src/backend/parser/parse_node.c
***************
*** 24,30 ****
  #include "parser/parse_expr.h"
  #include "parser/parse_relation.h"
  #include "utils/builtins.h"
- #include "utils/int8.h"
  #include "utils/lsyscache.h"
  #include "utils/syscache.h"
  #include "utils/varbit.h"
--- 24,29 ----
diff --git a/src/backend/parser/parse_oper.c b/src/backend/parser/parse_oper.c
new file mode 100644
index d4cd1ef..73a91ea
*** a/src/backend/parser/parse_oper.c
--- b/src/backend/parser/parse_oper.c
***************
*** 24,30 ****
  #include "parser/parse_oper.h"
  #include "parser/parse_type.h"
  #include "utils/builtins.h"
- #include "utils/hsearch.h"
  #include "utils/inval.h"
  #include "utils/lsyscache.h"
  #include "utils/syscache.h"
--- 24,29 ----
diff --git a/src/backend/parser/parse_relation.c b/src/backend/parser/parse_relation.c
new file mode 100644
index 3840c2f..9ac28c9
*** a/src/backend/parser/parse_relation.c
--- b/src/backend/parser/parse_relation.c
***************
*** 16,22 ****

  #include <ctype.h>

- #include "access/heapam.h"
  #include "access/sysattr.h"
  #include "catalog/heap.h"
  #include "catalog/namespace.h"
--- 16,21 ----
diff --git a/src/backend/parser/parse_type.c b/src/backend/parser/parse_type.c
new file mode 100644
index 2122032..7cc6734
*** a/src/backend/parser/parse_type.c
--- b/src/backend/parser/parse_type.c
***************
*** 22,28 ****
  #include "parser/parse_type.h"
  #include "utils/array.h"
  #include "utils/builtins.h"
- #include "utils/datum.h"
  #include "utils/lsyscache.h"
  #include "utils/syscache.h"

--- 22,27 ----
diff --git a/src/backend/parser/parse_utilcmd.c b/src/backend/parser/parse_utilcmd.c
new file mode 100644
index 21b54f7..a2a54db
*** a/src/backend/parser/parse_utilcmd.c
--- b/src/backend/parser/parse_utilcmd.c
***************
*** 26,33 ****

  #include "postgres.h"

- #include "access/genam.h"
- #include "access/heapam.h"
  #include "access/reloptions.h"
  #include "catalog/dependency.h"
  #include "catalog/heap.h"
--- 26,31 ----
***************
*** 55,61 ****
  #include "parser/parse_utilcmd.h"
  #include "parser/parser.h"
  #include "rewrite/rewriteManip.h"
- #include "storage/lock.h"
  #include "utils/acl.h"
  #include "utils/builtins.h"
  #include "utils/lsyscache.h"
--- 53,58 ----
diff --git a/src/backend/port/darwin/system.c b/src/backend/port/darwin/system.c
new file mode 100644
index 1385e43..e9cd136
*** a/src/backend/port/darwin/system.c
--- b/src/backend/port/darwin/system.c
***************
*** 2,8 ****
   * src/backend/port/darwin/system.c
   *
   * only needed in OS X 10.1 and possibly early 10.2 releases */
! #include <AvailabilityMacros.h>
  #if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_2 || !defined(MAC_OS_X_VERSION_10_2)

  /*
--- 2,8 ----
   * src/backend/port/darwin/system.c
   *
   * only needed in OS X 10.1 and possibly early 10.2 releases */
! #include <AvailabilityMacros.h>    /* pgrminclude ignore */
  #if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_2 || !defined(MAC_OS_X_VERSION_10_2)

  /*
diff --git a/src/backend/port/dynloader/linux.c b/src/backend/port/dynloader/linux.c
new file mode 100644
index 5b1b78d..21c2b0c
*** a/src/backend/port/dynloader/linux.c
--- b/src/backend/port/dynloader/linux.c
***************
*** 22,29 ****
  #include <dld.h>
  #endif

! #include "dynloader.h"
! #include "miscadmin.h"


  #ifndef HAVE_DLOPEN
--- 22,29 ----
  #include <dld.h>
  #endif

! #include "dynloader.h"    /* pgrminclude ignore */
! #include "miscadmin.h"    /* pgrminclude ignore */


  #ifndef HAVE_DLOPEN
diff --git a/src/backend/port/dynloader/nextstep.h b/src/backend/port/dynloader/nextstep.h
new file mode 100644
index 39057fd..4c680d0
*** a/src/backend/port/dynloader/nextstep.h
--- b/src/backend/port/dynloader/nextstep.h
***************
*** 9,15 ****
  #ifndef PORT_PROTOS_H
  #define PORT_PROTOS_H

! #include "utils/dynamic_loader.h"

  void       *next_dlopen(char *name);
  int            next_dlclose(void *handle);
--- 9,15 ----
  #ifndef PORT_PROTOS_H
  #define PORT_PROTOS_H

! #include "utils/dynamic_loader.h"    /* pgrminclude ignore */

  void       *next_dlopen(char *name);
  int            next_dlclose(void *handle);
diff --git a/src/backend/port/dynloader/win32.h b/src/backend/port/dynloader/win32.h
new file mode 100644
index af6e979..850c07b
*** a/src/backend/port/dynloader/win32.h
--- b/src/backend/port/dynloader/win32.h
***************
*** 4,10 ****
  #ifndef PORT_PROTOS_H
  #define PORT_PROTOS_H

! #include "utils/dynamic_loader.h"

  #define pg_dlopen(f)    dlopen((f), 1)
  #define pg_dlsym        dlsym
--- 4,10 ----
  #ifndef PORT_PROTOS_H
  #define PORT_PROTOS_H

! #include "utils/dynamic_loader.h"    /* pgrminclude ignore */

  #define pg_dlopen(f)    dlopen((f), 1)
  #define pg_dlsym        dlsym
diff --git a/src/backend/port/unix_latch.c b/src/backend/port/unix_latch.c
new file mode 100644
index 0289497..f639d4d
*** a/src/backend/port/unix_latch.c
--- b/src/backend/port/unix_latch.c
***************
*** 50,56 ****
  #include "miscadmin.h"
  #include "postmaster/postmaster.h"
  #include "storage/latch.h"
- #include "storage/shmem.h"

  /* Are we currently in WaitLatch? The signal handler would like to know. */
  static volatile sig_atomic_t waiting = false;
--- 50,55 ----
diff --git a/src/backend/postmaster/autovacuum.c b/src/backend/postmaster/autovacuum.c
new file mode 100644
index e425f9b..be8c050
*** a/src/backend/postmaster/autovacuum.c
--- b/src/backend/postmaster/autovacuum.c
***************
*** 67,73 ****
  #include <time.h>
  #include <unistd.h>

- #include "access/heapam.h"
  #include "access/reloptions.h"
  #include "access/transam.h"
  #include "access/xact.h"
--- 67,72 ----
***************
*** 84,93 ****
  #include "postmaster/postmaster.h"
  #include "storage/bufmgr.h"
  #include "storage/ipc.h"
- #include "storage/latch.h"
  #include "storage/pmsignal.h"
- #include "storage/proc.h"
- #include "storage/procsignal.h"
  #include "storage/sinvaladt.h"
  #include "tcop/tcopprot.h"
  #include "utils/fmgroids.h"
--- 83,89 ----
diff --git a/src/backend/postmaster/bgwriter.c b/src/backend/postmaster/bgwriter.c
new file mode 100644
index 14e592d..dda52a8
*** a/src/backend/postmaster/bgwriter.c
--- b/src/backend/postmaster/bgwriter.c
***************
*** 49,71 ****
  #include <time.h>
  #include <unistd.h>

  #include "access/xlog_internal.h"
- #include "catalog/pg_control.h"
  #include "libpq/pqsignal.h"
  #include "miscadmin.h"
  #include "pgstat.h"
  #include "postmaster/bgwriter.h"
  #include "replication/syncrep.h"
  #include "storage/bufmgr.h"
- #include "storage/fd.h"
  #include "storage/ipc.h"
- #include "storage/lwlock.h"
  #include "storage/pmsignal.h"
- #include "storage/shmem.h"
  #include "storage/smgr.h"
  #include "storage/spin.h"
! #include "tcop/tcopprot.h"
! #include "utils/guc.h"
  #include "utils/memutils.h"
  #include "utils/resowner.h"

--- 49,67 ----
  #include <time.h>
  #include <unistd.h>

+ #include "access/xlog.h"
  #include "access/xlog_internal.h"
  #include "libpq/pqsignal.h"
  #include "miscadmin.h"
  #include "pgstat.h"
  #include "postmaster/bgwriter.h"
  #include "replication/syncrep.h"
  #include "storage/bufmgr.h"
  #include "storage/ipc.h"
  #include "storage/pmsignal.h"
  #include "storage/smgr.h"
  #include "storage/spin.h"
! #include "storage/s_lock.h"
  #include "utils/memutils.h"
  #include "utils/resowner.h"

diff --git a/src/backend/postmaster/walwriter.c b/src/backend/postmaster/walwriter.c
new file mode 100644
index 1411677..23c4aac
*** a/src/backend/postmaster/walwriter.c
--- b/src/backend/postmaster/walwriter.c
***************
*** 50,56 ****
  #include "miscadmin.h"
  #include "postmaster/walwriter.h"
  #include "storage/bufmgr.h"
- #include "storage/fd.h"
  #include "storage/ipc.h"
  #include "storage/lwlock.h"
  #include "storage/pmsignal.h"
--- 50,55 ----
diff --git a/src/backend/regex/regcomp.c b/src/backend/regex/regcomp.c
new file mode 100644
index bd4d4c3..ba0cc30
*** a/src/backend/regex/regcomp.c
--- b/src/backend/regex/regcomp.c
*************** stid(struct subre * t,
*** 1990,1998 ****
  #endif   /* REG_DEBUG */


! #include "regc_lex.c"
! #include "regc_color.c"
! #include "regc_nfa.c"
! #include "regc_cvec.c"
! #include "regc_pg_locale.c"
! #include "regc_locale.c"
--- 1990,1998 ----
  #endif   /* REG_DEBUG */


! #include "regc_lex.c"    /* pgrminclude ignore */
! #include "regc_color.c"    /* pgrminclude ignore */
! #include "regc_nfa.c"    /* pgrminclude ignore */
! #include "regc_cvec.c"    /* pgrminclude ignore */
! #include "regc_pg_locale.c"    /* pgrminclude ignore */
! #include "regc_locale.c"    /* pgrminclude ignore */
diff --git a/src/backend/regex/regerror.c b/src/backend/regex/regerror.c
new file mode 100644
index 21d2c60..9d44eb0
*** a/src/backend/regex/regerror.c
--- b/src/backend/regex/regerror.c
*************** static struct rerr
*** 46,52 ****

  {
      /* the actual table is built from regex.h */
! #include "regex/regerrs.h"
      {
          -1, "", "oops"
      },                            /* explanation special-cased in code */
--- 46,52 ----

  {
      /* the actual table is built from regex.h */
! #include "regex/regerrs.h"    /* pgrminclude ignore */
      {
          -1, "", "oops"
      },                            /* explanation special-cased in code */
diff --git a/src/backend/regex/regexec.c b/src/backend/regex/regexec.c
new file mode 100644
index 7dc0ddb..9c00603
*** a/src/backend/regex/regexec.c
--- b/src/backend/regex/regexec.c
*************** caltdissect(struct vars * v,
*** 1084,1088 ****
  }


!
! #include "rege_dfa.c"
--- 1084,1087 ----
  }


! #include "rege_dfa.c"    /* pgrminclude ignore */
diff --git a/src/backend/replication/libpqwalreceiver/libpqwalreceiver.c
b/src/backend/replication/libpqwalreceiver/libpqwalreceiver.c
new file mode 100644
index 0831b1b..9754644
*** a/src/backend/replication/libpqwalreceiver/libpqwalreceiver.c
--- b/src/backend/replication/libpqwalreceiver/libpqwalreceiver.c
***************
*** 21,27 ****

  #include "libpq-fe.h"
  #include "access/xlog.h"
- #include "miscadmin.h"
  #include "replication/walreceiver.h"
  #include "utils/builtins.h"

--- 21,26 ----
diff --git a/src/backend/replication/syncrep.c b/src/backend/replication/syncrep.c
new file mode 100644
index 56deeeb..1ec2341
*** a/src/backend/replication/syncrep.c
--- b/src/backend/replication/syncrep.c
***************
*** 46,65 ****
  #include <unistd.h>

  #include "access/xact.h"
- #include "access/xlog_internal.h"
  #include "miscadmin.h"
- #include "postmaster/autovacuum.h"
- #include "replication/syncrep.h"
  #include "replication/walsender.h"
- #include "storage/latch.h"
- #include "storage/ipc.h"
  #include "storage/pmsignal.h"
- #include "storage/proc.h"
  #include "tcop/tcopprot.h"
  #include "utils/builtins.h"
- #include "utils/guc.h"
- #include "utils/guc_tables.h"
- #include "utils/memutils.h"
  #include "utils/ps_status.h"

  /* User-settable parameters for sync rep */
--- 46,56 ----
diff --git a/src/backend/replication/walreceiver.c b/src/backend/replication/walreceiver.c
new file mode 100644
index b4ece49..9e05c1f
*** a/src/backend/replication/walreceiver.c
--- b/src/backend/replication/walreceiver.c
***************
*** 38,44 ****
  #include <signal.h>
  #include <unistd.h>

- #include "access/transam.h"
  #include "access/xlog_internal.h"
  #include "libpq/pqsignal.h"
  #include "miscadmin.h"
--- 38,43 ----
***************
*** 48,56 ****
  #include "storage/ipc.h"
  #include "storage/pmsignal.h"
  #include "storage/procarray.h"
- #include "utils/builtins.h"
- #include "utils/guc.h"
- #include "utils/memutils.h"
  #include "utils/ps_status.h"
  #include "utils/resowner.h"

--- 47,52 ----
diff --git a/src/backend/replication/walreceiverfuncs.c b/src/backend/replication/walreceiverfuncs.c
new file mode 100644
index 587949b..29c2f80
*** a/src/backend/replication/walreceiverfuncs.c
--- b/src/backend/replication/walreceiverfuncs.c
***************
*** 25,34 ****

  #include "access/xlog_internal.h"
  #include "replication/walreceiver.h"
- #include "storage/fd.h"
  #include "storage/pmsignal.h"
  #include "storage/shmem.h"
- #include "utils/guc.h"

  WalRcvData *WalRcv = NULL;

--- 25,32 ----
diff --git a/src/backend/rewrite/rewriteHandler.c b/src/backend/rewrite/rewriteHandler.c
new file mode 100644
index 84b5037..3b31108
*** a/src/backend/rewrite/rewriteHandler.c
--- b/src/backend/rewrite/rewriteHandler.c
***************
*** 13,19 ****
   */
  #include "postgres.h"

- #include "access/heapam.h"
  #include "access/sysattr.h"
  #include "catalog/pg_type.h"
  #include "commands/trigger.h"
--- 13,18 ----
diff --git a/src/backend/rewrite/rewriteRemove.c b/src/backend/rewrite/rewriteRemove.c
new file mode 100644
index cec22ac..917bb46
*** a/src/backend/rewrite/rewriteRemove.c
--- b/src/backend/rewrite/rewriteRemove.c
***************
*** 27,33 ****
  #include "utils/fmgroids.h"
  #include "utils/inval.h"
  #include "utils/lsyscache.h"
- #include "utils/rel.h"
  #include "utils/syscache.h"
  #include "utils/tqual.h"

--- 27,32 ----
diff --git a/src/backend/rewrite/rewriteSupport.c b/src/backend/rewrite/rewriteSupport.c
new file mode 100644
index 4d6f508..a0b4300
*** a/src/backend/rewrite/rewriteSupport.c
--- b/src/backend/rewrite/rewriteSupport.c
***************
*** 16,22 ****

  #include "access/heapam.h"
  #include "catalog/indexing.h"
- #include "catalog/pg_class.h"
  #include "catalog/pg_rewrite.h"
  #include "rewrite/rewriteSupport.h"
  #include "utils/fmgroids.h"
--- 16,21 ----
diff --git a/src/backend/storage/buffer/bufmgr.c b/src/backend/storage/buffer/bufmgr.c
new file mode 100644
index 4c7cfb0..8973d8d
*** a/src/backend/storage/buffer/bufmgr.c
--- b/src/backend/storage/buffer/bufmgr.c
***************
*** 43,49 ****
  #include "storage/bufmgr.h"
  #include "storage/ipc.h"
  #include "storage/proc.h"
- #include "storage/smgr.h"
  #include "storage/standby.h"
  #include "utils/rel.h"
  #include "utils/resowner.h"
--- 43,48 ----
diff --git a/src/backend/storage/buffer/localbuf.c b/src/backend/storage/buffer/localbuf.c
new file mode 100644
index 8816a5d..6acb6eb
*** a/src/backend/storage/buffer/localbuf.c
--- b/src/backend/storage/buffer/localbuf.c
***************
*** 19,25 ****
  #include "executor/instrument.h"
  #include "storage/buf_internals.h"
  #include "storage/bufmgr.h"
- #include "storage/smgr.h"
  #include "utils/guc.h"
  #include "utils/memutils.h"
  #include "utils/resowner.h"
--- 19,24 ----
diff --git a/src/backend/storage/file/buffile.c b/src/backend/storage/file/buffile.c
new file mode 100644
index c436d71..702af2a
*** a/src/backend/storage/file/buffile.c
--- b/src/backend/storage/file/buffile.c
***************
*** 37,43 ****
  #include "executor/instrument.h"
  #include "storage/fd.h"
  #include "storage/buffile.h"
- #include "storage/buf_internals.h"

  /*
   * We break BufFiles into gigabyte-sized segments, regardless of RELSEG_SIZE.
--- 37,42 ----
diff --git a/src/backend/storage/file/fd.c b/src/backend/storage/file/fd.c
new file mode 100644
index 9540279..124e195
*** a/src/backend/storage/file/fd.c
--- b/src/backend/storage/file/fd.c
***************
*** 53,59 ****
  #include "access/xact.h"
  #include "catalog/catalog.h"
  #include "catalog/pg_tablespace.h"
- #include "storage/fd.h"
  #include "storage/ipc.h"
  #include "utils/guc.h"
  #include "utils/resowner.h"
--- 53,58 ----
diff --git a/src/backend/storage/freespace/freespace.c b/src/backend/storage/freespace/freespace.c
new file mode 100644
index 1a5a874..931b881
*** a/src/backend/storage/freespace/freespace.c
--- b/src/backend/storage/freespace/freespace.c
***************
*** 26,39 ****
  #include "access/htup.h"
  #include "access/xlogutils.h"
  #include "miscadmin.h"
- #include "storage/bufmgr.h"
- #include "storage/bufpage.h"
  #include "storage/freespace.h"
  #include "storage/fsm_internals.h"
  #include "storage/lmgr.h"
- #include "storage/lwlock.h"
  #include "storage/smgr.h"
- #include "utils/rel.h"


  /*
--- 26,35 ----
diff --git a/src/backend/storage/freespace/indexfsm.c b/src/backend/storage/freespace/indexfsm.c
new file mode 100644
index 0994e61..fa8f49e
*** a/src/backend/storage/freespace/indexfsm.c
--- b/src/backend/storage/freespace/indexfsm.c
***************
*** 24,30 ****

  #include "storage/freespace.h"
  #include "storage/indexfsm.h"
- #include "storage/smgr.h"

  /*
   * Exported routines
--- 24,29 ----
diff --git a/src/backend/storage/ipc/ipci.c b/src/backend/storage/ipc/ipci.c
new file mode 100644
index 56c0bd8..835e61e
*** a/src/backend/storage/ipc/ipci.c
--- b/src/backend/storage/ipc/ipci.c
***************
*** 25,42 ****
  #include "pgstat.h"
  #include "postmaster/autovacuum.h"
  #include "postmaster/bgwriter.h"
- #include "postmaster/postmaster.h"
  #include "replication/walreceiver.h"
  #include "replication/walsender.h"
- #include "storage/bufmgr.h"
  #include "storage/ipc.h"
  #include "storage/pg_shmem.h"
  #include "storage/pmsignal.h"
  #include "storage/predicate.h"
  #include "storage/procarray.h"
- #include "storage/procsignal.h"
  #include "storage/sinvaladt.h"
- #include "storage/spin.h"


  shmem_startup_hook_type shmem_startup_hook = NULL;
--- 25,38 ----
diff --git a/src/backend/storage/ipc/pmsignal.c b/src/backend/storage/ipc/pmsignal.c
new file mode 100644
index eea95b7..34e6013
*** a/src/backend/storage/ipc/pmsignal.c
--- b/src/backend/storage/ipc/pmsignal.c
***************
*** 21,27 ****
  #include "postmaster/postmaster.h"
  #include "replication/walsender.h"
  #include "storage/pmsignal.h"
- #include "storage/shmem.h"


  /*
--- 21,26 ----
diff --git a/src/backend/storage/ipc/procarray.c b/src/backend/storage/ipc/procarray.c
new file mode 100644
index e7593fa..9489012
*** a/src/backend/storage/ipc/procarray.c
--- b/src/backend/storage/ipc/procarray.c
***************
*** 53,59 ****
  #include "miscadmin.h"
  #include "storage/procarray.h"
  #include "storage/spin.h"
- #include "storage/standby.h"
  #include "utils/builtins.h"
  #include "utils/snapmgr.h"

--- 53,58 ----
diff --git a/src/backend/storage/ipc/procsignal.c b/src/backend/storage/ipc/procsignal.c
new file mode 100644
index 28bcaa7..bfabb32
*** a/src/backend/storage/ipc/procsignal.c
--- b/src/backend/storage/ipc/procsignal.c
***************
*** 22,31 ****
  #include "miscadmin.h"
  #include "storage/ipc.h"
  #include "storage/latch.h"
- #include "storage/procsignal.h"
- #include "storage/shmem.h"
  #include "storage/sinval.h"
- #include "storage/standby.h"
  #include "tcop/tcopprot.h"


--- 22,28 ----
diff --git a/src/backend/storage/ipc/sinvaladt.c b/src/backend/storage/ipc/sinvaladt.c
new file mode 100644
index a1d8e26..2f4fcde
*** a/src/backend/storage/ipc/sinvaladt.c
--- b/src/backend/storage/ipc/sinvaladt.c
***************
*** 18,32 ****
  #include <unistd.h>

  #include "miscadmin.h"
- #include "storage/backendid.h"
  #include "storage/ipc.h"
- #include "storage/proc.h"
  #include "storage/procsignal.h"
- #include "storage/shmem.h"
  #include "storage/sinvaladt.h"
  #include "storage/spin.h"

-
  /*
   * Conceptually, the shared cache invalidation messages are stored in an
   * infinite array, where maxMsgNum is the next array subscript to store a
--- 18,28 ----
diff --git a/src/backend/storage/ipc/standby.c b/src/backend/storage/ipc/standby.c
new file mode 100644
index 5673c27..4586927
*** a/src/backend/storage/ipc/standby.c
--- b/src/backend/storage/ipc/standby.c
***************
*** 19,32 ****
  #include "access/transam.h"
  #include "access/twophase.h"
  #include "access/xact.h"
- #include "access/xlog.h"
  #include "miscadmin.h"
  #include "storage/bufmgr.h"
- #include "storage/lmgr.h"
- #include "storage/proc.h"
  #include "storage/procarray.h"
  #include "storage/sinvaladt.h"
- #include "storage/standby.h"
  #include "utils/ps_status.h"

  /* User-settable GUC parameters */
--- 19,28 ----
diff --git a/src/backend/storage/large_object/inv_api.c b/src/backend/storage/large_object/inv_api.c
new file mode 100644
index e0441f5..fed6d2e
*** a/src/backend/storage/large_object/inv_api.c
--- b/src/backend/storage/large_object/inv_api.c
***************
*** 35,55 ****
  #include "access/sysattr.h"
  #include "access/tuptoaster.h"
  #include "access/xact.h"
- #include "catalog/catalog.h"
  #include "catalog/dependency.h"
  #include "catalog/indexing.h"
  #include "catalog/objectaccess.h"
  #include "catalog/pg_largeobject.h"
  #include "catalog/pg_largeobject_metadata.h"
- #include "commands/comment.h"
  #include "libpq/libpq-fs.h"
  #include "miscadmin.h"
  #include "storage/large_object.h"
  #include "utils/fmgroids.h"
  #include "utils/rel.h"
- #include "utils/resowner.h"
  #include "utils/snapmgr.h"
- #include "utils/syscache.h"
  #include "utils/tqual.h"


--- 35,51 ----
diff --git a/src/backend/storage/lmgr/lock.c b/src/backend/storage/lmgr/lock.c
new file mode 100644
index 1787cbc..9cb2a1e
*** a/src/backend/storage/lmgr/lock.c
--- b/src/backend/storage/lmgr/lock.c
***************
*** 32,44 ****
  #include <signal.h>
  #include <unistd.h>

- #include "access/transam.h"
  #include "access/twophase.h"
  #include "access/twophase_rmgr.h"
  #include "miscadmin.h"
  #include "pg_trace.h"
  #include "pgstat.h"
  #include "storage/sinvaladt.h"
  #include "storage/standby.h"
  #include "utils/memutils.h"
  #include "utils/ps_status.h"
--- 32,44 ----
  #include <signal.h>
  #include <unistd.h>

  #include "access/twophase.h"
  #include "access/twophase_rmgr.h"
  #include "miscadmin.h"
  #include "pg_trace.h"
  #include "pgstat.h"
  #include "storage/sinvaladt.h"
+ #include "storage/spin.h"
  #include "storage/standby.h"
  #include "utils/memutils.h"
  #include "utils/ps_status.h"
diff --git a/src/backend/storage/lmgr/lwlock.c b/src/backend/storage/lmgr/lwlock.c
new file mode 100644
index 8fae67e..2800989
*** a/src/backend/storage/lmgr/lwlock.c
--- b/src/backend/storage/lmgr/lwlock.c
***************
*** 27,38 ****
  #include "commands/async.h"
  #include "miscadmin.h"
  #include "pg_trace.h"
- #include "storage/ipc.h"
  #include "storage/predicate.h"
  #include "storage/proc.h"
  #include "storage/spin.h"

-
  /* We use the ShmemLock spinlock to protect LWLockAssign */
  extern slock_t *ShmemLock;

--- 27,36 ----
diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c
new file mode 100644
index f4091ec..d207828
*** a/src/backend/storage/lmgr/proc.c
--- b/src/backend/storage/lmgr/proc.c
***************
*** 45,54 ****
  #include "storage/pmsignal.h"
  #include "storage/proc.h"
  #include "storage/procarray.h"
- #include "storage/procsignal.h"
  #include "storage/spin.h"

-
  /* GUC variables */
  int            DeadlockTimeout = 1000;
  int            StatementTimeout = 0;
--- 45,52 ----
diff --git a/src/backend/storage/lmgr/spin.c b/src/backend/storage/lmgr/spin.c
new file mode 100644
index cb3e126..d99e7f7
*** a/src/backend/storage/lmgr/spin.c
--- b/src/backend/storage/lmgr/spin.c
***************
*** 22,29 ****
   */
  #include "postgres.h"

- #include "miscadmin.h"
- #include "storage/lwlock.h"
  #include "storage/spin.h"


--- 22,27 ----
diff --git a/src/backend/storage/smgr/md.c b/src/backend/storage/smgr/md.c
new file mode 100644
index 7f44606..9da9a3c
*** a/src/backend/storage/smgr/md.c
--- b/src/backend/storage/smgr/md.c
***************
*** 18,23 ****
--- 18,24 ----
  #include <fcntl.h>
  #include <sys/file.h>

+ #include "access/xlog.h"
  #include "catalog/catalog.h"
  #include "miscadmin.h"
  #include "portability/instr_time.h"
diff --git a/src/backend/storage/smgr/smgr.c b/src/backend/storage/smgr/smgr.c
new file mode 100644
index be89ee6..4f607cd
*** a/src/backend/storage/smgr/smgr.c
--- b/src/backend/storage/smgr/smgr.c
***************
*** 17,24 ****
   */
  #include "postgres.h"

- #include "access/xlogutils.h"
- #include "catalog/catalog.h"
  #include "commands/tablespace.h"
  #include "storage/bufmgr.h"
  #include "storage/ipc.h"
--- 17,22 ----
diff --git a/src/backend/tcop/pquery.c b/src/backend/tcop/pquery.c
new file mode 100644
index b7649c6..466727b
*** a/src/backend/tcop/pquery.c
--- b/src/backend/tcop/pquery.c
***************
*** 17,28 ****

  #include "access/xact.h"
  #include "commands/prepare.h"
- #include "commands/trigger.h"
  #include "executor/tstoreReceiver.h"
  #include "miscadmin.h"
  #include "pg_trace.h"
  #include "tcop/pquery.h"
- #include "tcop/tcopprot.h"
  #include "tcop/utility.h"
  #include "utils/memutils.h"
  #include "utils/snapmgr.h"
--- 17,26 ----
diff --git a/src/backend/tcop/utility.c b/src/backend/tcop/utility.c
new file mode 100644
index 0749227..9d1b4c8
*** a/src/backend/tcop/utility.c
--- b/src/backend/tcop/utility.c
***************
*** 32,38 ****
  #include "commands/dbcommands.h"
  #include "commands/defrem.h"
  #include "commands/discard.h"
- #include "commands/explain.h"
  #include "commands/extension.h"
  #include "commands/lockcmds.h"
  #include "commands/portalcmds.h"
--- 32,37 ----
***************
*** 53,63 ****
  #include "postmaster/bgwriter.h"
  #include "rewrite/rewriteDefine.h"
  #include "rewrite/rewriteRemove.h"
- #include "storage/fd.h"
- #include "tcop/pquery.h"
  #include "tcop/utility.h"
- #include "utils/acl.h"
- #include "utils/guc.h"
  #include "utils/syscache.h"


--- 52,58 ----
diff --git a/src/backend/tsearch/dict_ispell.c b/src/backend/tsearch/dict_ispell.c
new file mode 100644
index 31929c0..dd22e3a
*** a/src/backend/tsearch/dict_ispell.c
--- b/src/backend/tsearch/dict_ispell.c
***************
*** 16,24 ****
  #include "commands/defrem.h"
  #include "tsearch/dicts/spell.h"
  #include "tsearch/ts_locale.h"
- #include "tsearch/ts_public.h"
  #include "tsearch/ts_utils.h"
- #include "utils/builtins.h"


  typedef struct
--- 16,22 ----
diff --git a/src/backend/tsearch/dict_simple.c b/src/backend/tsearch/dict_simple.c
new file mode 100644
index 24e9732..d6fac0e
*** a/src/backend/tsearch/dict_simple.c
--- b/src/backend/tsearch/dict_simple.c
***************
*** 15,23 ****

  #include "commands/defrem.h"
  #include "tsearch/ts_locale.h"
- #include "tsearch/ts_public.h"
  #include "tsearch/ts_utils.h"
- #include "utils/builtins.h"


  typedef struct
--- 15,21 ----
diff --git a/src/backend/tsearch/dict_synonym.c b/src/backend/tsearch/dict_synonym.c
new file mode 100644
index d2298b3..0788b3d
*** a/src/backend/tsearch/dict_synonym.c
--- b/src/backend/tsearch/dict_synonym.c
***************
*** 15,23 ****

  #include "commands/defrem.h"
  #include "tsearch/ts_locale.h"
- #include "tsearch/ts_public.h"
  #include "tsearch/ts_utils.h"
- #include "utils/builtins.h"

  typedef struct
  {
--- 15,21 ----
diff --git a/src/backend/tsearch/dict_thesaurus.c b/src/backend/tsearch/dict_thesaurus.c
new file mode 100644
index 7ff28b8..509420f
*** a/src/backend/tsearch/dict_thesaurus.c
--- b/src/backend/tsearch/dict_thesaurus.c
***************
*** 17,23 ****
  #include "commands/defrem.h"
  #include "tsearch/ts_cache.h"
  #include "tsearch/ts_locale.h"
- #include "tsearch/ts_public.h"
  #include "tsearch/ts_utils.h"
  #include "utils/builtins.h"

--- 17,22 ----
diff --git a/src/backend/tsearch/to_tsany.c b/src/backend/tsearch/to_tsany.c
new file mode 100644
index 5284c9c..d143aae
*** a/src/backend/tsearch/to_tsany.c
--- b/src/backend/tsearch/to_tsany.c
***************
*** 13,23 ****
   */
  #include "postgres.h"

- #include "catalog/namespace.h"
  #include "tsearch/ts_cache.h"
  #include "tsearch/ts_utils.h"
  #include "utils/builtins.h"
- #include "utils/syscache.h"


  Datum
--- 13,21 ----
diff --git a/src/backend/tsearch/ts_locale.c b/src/backend/tsearch/ts_locale.c
new file mode 100644
index 93b550a..431820c
*** a/src/backend/tsearch/ts_locale.c
--- b/src/backend/tsearch/ts_locale.c
***************
*** 13,22 ****
   */
  #include "postgres.h"

! #include "catalog/pg_collation.h"
  #include "storage/fd.h"
  #include "tsearch/ts_locale.h"
- #include "tsearch/ts_public.h"

  static void tsearch_readline_callback(void *arg);

--- 13,21 ----
   */
  #include "postgres.h"

! #include "catalog/pg_collation.h"    /* pgrminclude ignore */
  #include "storage/fd.h"
  #include "tsearch/ts_locale.h"

  static void tsearch_readline_callback(void *arg);

diff --git a/src/backend/tsearch/ts_parse.c b/src/backend/tsearch/ts_parse.c
new file mode 100644
index 5c2962c..ddd08c7
*** a/src/backend/tsearch/ts_parse.c
--- b/src/backend/tsearch/ts_parse.c
***************
*** 15,21 ****
  #include "postgres.h"

  #include "tsearch/ts_cache.h"
- #include "tsearch/ts_public.h"
  #include "tsearch/ts_utils.h"

  #define IGNORE_LONGLEXEME    1
--- 15,20 ----
diff --git a/src/backend/tsearch/ts_selfuncs.c b/src/backend/tsearch/ts_selfuncs.c
new file mode 100644
index 366fa2e..f826714
*** a/src/backend/tsearch/ts_selfuncs.c
--- b/src/backend/tsearch/ts_selfuncs.c
***************
*** 16,26 ****
  #include "catalog/pg_statistic.h"
  #include "catalog/pg_type.h"
  #include "miscadmin.h"
- #include "nodes/nodes.h"
  #include "tsearch/ts_type.h"
  #include "utils/lsyscache.h"
  #include "utils/selfuncs.h"
- #include "utils/syscache.h"


  /*
--- 16,24 ----
diff --git a/src/backend/tsearch/ts_typanalyze.c b/src/backend/tsearch/ts_typanalyze.c
new file mode 100644
index 2654d64..1ca5cf0
*** a/src/backend/tsearch/ts_typanalyze.c
--- b/src/backend/tsearch/ts_typanalyze.c
***************
*** 18,24 ****
  #include "commands/vacuum.h"
  #include "tsearch/ts_type.h"
  #include "utils/builtins.h"
- #include "utils/hsearch.h"


  /* A hash key for lexemes */
--- 18,23 ----
diff --git a/src/backend/tsearch/ts_utils.c b/src/backend/tsearch/ts_utils.c
new file mode 100644
index abf53c0..c728ee2
*** a/src/backend/tsearch/ts_utils.c
--- b/src/backend/tsearch/ts_utils.c
***************
*** 18,26 ****

  #include "miscadmin.h"
  #include "tsearch/ts_locale.h"
- #include "tsearch/ts_public.h"
  #include "tsearch/ts_utils.h"
- #include "utils/builtins.h"


  /*
--- 18,24 ----
diff --git a/src/backend/tsearch/wparser.c b/src/backend/tsearch/wparser.c
new file mode 100644
index bda8d26..f81d42e
*** a/src/backend/tsearch/wparser.c
--- b/src/backend/tsearch/wparser.c
***************
*** 14,33 ****
  #include "postgres.h"

  #include "funcapi.h"
- #include "access/genam.h"
- #include "access/skey.h"
- #include "catalog/indexing.h"
  #include "catalog/namespace.h"
- #include "catalog/pg_ts_parser.h"
  #include "catalog/pg_type.h"
  #include "commands/defrem.h"
  #include "tsearch/ts_cache.h"
- #include "tsearch/ts_public.h"
  #include "tsearch/ts_utils.h"
  #include "utils/builtins.h"
- #include "utils/fmgroids.h"
- #include "utils/rel.h"
- #include "utils/syscache.h"


  /******sql-level interface******/
--- 14,25 ----
diff --git a/src/backend/tsearch/wparser_def.c b/src/backend/tsearch/wparser_def.c
new file mode 100644
index 7ba3314..5245e36
*** a/src/backend/tsearch/wparser_def.c
--- b/src/backend/tsearch/wparser_def.c
***************
*** 14,24 ****

  #include "postgres.h"

! #include "catalog/pg_collation.h"
  #include "commands/defrem.h"
  #include "tsearch/ts_locale.h"
- #include "tsearch/ts_public.h"
- #include "tsearch/ts_type.h"
  #include "tsearch/ts_utils.h"
  #include "utils/builtins.h"

--- 14,22 ----

  #include "postgres.h"

! #include "catalog/pg_collation.h"    /* pgrminclude ignore */
  #include "commands/defrem.h"
  #include "tsearch/ts_locale.h"
  #include "tsearch/ts_utils.h"
  #include "utils/builtins.h"

diff --git a/src/backend/utils/adt/arrayfuncs.c b/src/backend/utils/adt/arrayfuncs.c
new file mode 100644
index 3e43e95..bfb6065
*** a/src/backend/utils/adt/arrayfuncs.c
--- b/src/backend/utils/adt/arrayfuncs.c
***************
*** 18,24 ****

  #include "funcapi.h"
  #include "libpq/pqformat.h"
- #include "parser/parse_coerce.h"
  #include "utils/array.h"
  #include "utils/builtins.h"
  #include "utils/datum.h"
--- 18,23 ----
diff --git a/src/backend/utils/adt/domains.c b/src/backend/utils/adt/domains.c
new file mode 100644
index c178fd0..674229a
*** a/src/backend/utils/adt/domains.c
--- b/src/backend/utils/adt/domains.c
***************
*** 33,39 ****

  #include "commands/typecmds.h"
  #include "executor/executor.h"
- #include "lib/stringinfo.h"
  #include "utils/builtins.h"
  #include "utils/lsyscache.h"

--- 33,38 ----
diff --git a/src/backend/utils/adt/enum.c b/src/backend/utils/adt/enum.c
new file mode 100644
index 8f65c84..457925f
*** a/src/backend/utils/adt/enum.c
--- b/src/backend/utils/adt/enum.c
***************
*** 17,23 ****
  #include "access/heapam.h"
  #include "catalog/indexing.h"
  #include "catalog/pg_enum.h"
- #include "fmgr.h"
  #include "libpq/pqformat.h"
  #include "utils/array.h"
  #include "utils/builtins.h"
--- 17,22 ----
diff --git a/src/backend/utils/adt/formatting.c b/src/backend/utils/adt/formatting.c
new file mode 100644
index 726a1f4..0a033d6
*** a/src/backend/utils/adt/formatting.c
--- b/src/backend/utils/adt/formatting.c
***************
*** 83,94 ****
  #endif

  #include "catalog/pg_collation.h"
! #include "mb/pg_wchar.h"
  #include "utils/builtins.h"
  #include "utils/date.h"
  #include "utils/datetime.h"
  #include "utils/formatting.h"
- #include "utils/int8.h"
  #include "utils/numeric.h"
  #include "utils/pg_locale.h"

--- 83,93 ----
  #endif

  #include "catalog/pg_collation.h"
! #include "mb/pg_wchar.h"    /* pgrminclude ignore */
  #include "utils/builtins.h"
  #include "utils/date.h"
  #include "utils/datetime.h"
  #include "utils/formatting.h"
  #include "utils/numeric.h"
  #include "utils/pg_locale.h"

diff --git a/src/backend/utils/adt/genfile.c b/src/backend/utils/adt/genfile.c
new file mode 100644
index 6b3f77f..dfe38f5
*** a/src/backend/utils/adt/genfile.c
--- b/src/backend/utils/adt/genfile.c
***************
*** 28,34 ****
  #include "storage/fd.h"
  #include "utils/builtins.h"
  #include "utils/memutils.h"
- #include "utils/timestamp.h"

  typedef struct
  {
--- 28,33 ----
diff --git a/src/backend/utils/adt/inet_cidr_ntop.c b/src/backend/utils/adt/inet_cidr_ntop.c
new file mode 100644
index 5f2a3d3..7e3fb3b
*** a/src/backend/utils/adt/inet_cidr_ntop.c
--- b/src/backend/utils/adt/inet_cidr_ntop.c
*************** static const char rcsid[] = "Id: inet_ne
*** 28,36 ****
  #include <netinet/in.h>
  #include <arpa/inet.h>

- #include "utils/builtins.h"
  #include "utils/inet.h"
!

  #ifdef SPRINTF_CHAR
  #define SPRINTF(x) strlen(sprintf/**/x)
--- 28,35 ----
  #include <netinet/in.h>
  #include <arpa/inet.h>

  #include "utils/inet.h"
! #include "utils/builtins.h"    /* pgrminclude ignore */

  #ifdef SPRINTF_CHAR
  #define SPRINTF(x) strlen(sprintf/**/x)
diff --git a/src/backend/utils/adt/inet_net_pton.c b/src/backend/utils/adt/inet_net_pton.c
new file mode 100644
index 1d32d2f..0ef217b
*** a/src/backend/utils/adt/inet_net_pton.c
--- b/src/backend/utils/adt/inet_net_pton.c
*************** static const char rcsid[] = "Id: inet_ne
*** 30,36 ****
  #include <assert.h>
  #include <ctype.h>

- #include "utils/builtins.h"
  #include "utils/inet.h"


--- 30,35 ----
diff --git a/src/backend/utils/adt/lockfuncs.c b/src/backend/utils/adt/lockfuncs.c
new file mode 100644
index 0d9f482..0d21f92
*** a/src/backend/utils/adt/lockfuncs.c
--- b/src/backend/utils/adt/lockfuncs.c
***************
*** 16,22 ****
  #include "funcapi.h"
  #include "miscadmin.h"
  #include "storage/predicate_internals.h"
- #include "storage/proc.h"
  #include "utils/builtins.h"


--- 16,21 ----
diff --git a/src/backend/utils/adt/misc.c b/src/backend/utils/adt/misc.c
new file mode 100644
index 5bda4af..5a77340
*** a/src/backend/utils/adt/misc.c
--- b/src/backend/utils/adt/misc.c
***************
*** 19,25 ****
  #include <dirent.h>
  #include <math.h>

- #include "access/xact.h"
  #include "catalog/catalog.h"
  #include "catalog/pg_type.h"
  #include "catalog/pg_tablespace.h"
--- 19,24 ----
diff --git a/src/backend/utils/adt/pg_locale.c b/src/backend/utils/adt/pg_locale.c
new file mode 100644
index 4a2fd28..47887ee
*** a/src/backend/utils/adt/pg_locale.c
--- b/src/backend/utils/adt/pg_locale.c
***************
*** 55,61 ****
  #include <time.h>

  #include "catalog/pg_collation.h"
- #include "catalog/pg_control.h"
  #include "mb/pg_wchar.h"
  #include "utils/hsearch.h"
  #include "utils/memutils.h"
--- 55,60 ----
***************
*** 69,75 ****
   * included, so we don't accidentally use theirs.
   */
  #undef StrNCpy
- #include <shlwapi.h>
  #ifdef StrNCpy
  #undef STrNCpy
  #endif
--- 68,73 ----
diff --git a/src/backend/utils/adt/ri_triggers.c b/src/backend/utils/adt/ri_triggers.c
new file mode 100644
index 4b85b9b..af194f0
*** a/src/backend/utils/adt/ri_triggers.c
--- b/src/backend/utils/adt/ri_triggers.c
***************
*** 42,48 ****
  #include "parser/parse_coerce.h"
  #include "parser/parse_relation.h"
  #include "miscadmin.h"
- #include "utils/acl.h"
  #include "utils/builtins.h"
  #include "utils/fmgroids.h"
  #include "utils/guc.h"
--- 42,47 ----
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
new file mode 100644
index 3fd99e0..8852bf9
*** a/src/backend/utils/adt/ruleutils.c
--- b/src/backend/utils/adt/ruleutils.c
***************
*** 18,24 ****
  #include <unistd.h>
  #include <fcntl.h>

- #include "access/genam.h"
  #include "access/sysattr.h"
  #include "catalog/dependency.h"
  #include "catalog/indexing.h"
--- 18,23 ----
diff --git a/src/backend/utils/adt/selfuncs.c b/src/backend/utils/adt/selfuncs.c
new file mode 100644
index e065826..a0388c1
*** a/src/backend/utils/adt/selfuncs.c
--- b/src/backend/utils/adt/selfuncs.c
***************
*** 108,122 ****
  #include "optimizer/paths.h"
  #include "optimizer/plancat.h"
  #include "optimizer/predtest.h"
- #include "optimizer/restrictinfo.h"
  #include "optimizer/var.h"
- #include "parser/parse_coerce.h"
  #include "parser/parsetree.h"
  #include "utils/builtins.h"
  #include "utils/bytea.h"
  #include "utils/date.h"
  #include "utils/datum.h"
- #include "utils/fmgroids.h"
  #include "utils/lsyscache.h"
  #include "utils/nabstime.h"
  #include "utils/pg_locale.h"
--- 108,119 ----
diff --git a/src/backend/utils/adt/trigfuncs.c b/src/backend/utils/adt/trigfuncs.c
new file mode 100644
index 474878d..c2b4a92
*** a/src/backend/utils/adt/trigfuncs.c
--- b/src/backend/utils/adt/trigfuncs.c
***************
*** 13,19 ****
   */
  #include "postgres.h"

- #include "access/htup.h"
  #include "commands/trigger.h"
  #include "utils/builtins.h"
  #include "utils/rel.h"
--- 13,18 ----
diff --git a/src/backend/utils/adt/tsginidx.c b/src/backend/utils/adt/tsginidx.c
new file mode 100644
index 4cb9611..a971335
*** a/src/backend/utils/adt/tsginidx.c
--- b/src/backend/utils/adt/tsginidx.c
***************
*** 14,21 ****
  #include "postgres.h"

  #include "access/gin.h"
- #include "access/skey.h"
- #include "tsearch/ts_type.h"
  #include "tsearch/ts_utils.h"
  #include "utils/builtins.h"

--- 14,19 ----
diff --git a/src/backend/utils/adt/tsgistidx.c b/src/backend/utils/adt/tsgistidx.c
new file mode 100644
index 2189a1a..1ac2b17
*** a/src/backend/utils/adt/tsgistidx.c
--- b/src/backend/utils/adt/tsgistidx.c
***************
*** 16,24 ****

  #include "access/gist.h"
  #include "access/tuptoaster.h"
- #include "tsearch/ts_type.h"
  #include "tsearch/ts_utils.h"
- #include "utils/pg_crc.h"


  #define SIGLENINT  31            /* >121 => key will toast, so it will not work
--- 16,22 ----
diff --git a/src/backend/utils/adt/tsquery.c b/src/backend/utils/adt/tsquery.c
new file mode 100644
index 5baa02b..a60989a
*** a/src/backend/utils/adt/tsquery.c
--- b/src/backend/utils/adt/tsquery.c
***************
*** 17,27 ****
  #include "libpq/pqformat.h"
  #include "miscadmin.h"
  #include "tsearch/ts_locale.h"
- #include "tsearch/ts_type.h"
  #include "tsearch/ts_utils.h"
  #include "utils/builtins.h"
  #include "utils/memutils.h"
- #include "utils/pg_crc.h"


  struct TSQueryParserStateData
--- 17,25 ----
diff --git a/src/backend/utils/adt/tsquery_cleanup.c b/src/backend/utils/adt/tsquery_cleanup.c
new file mode 100644
index 9feb4b7..3e0b99a
*** a/src/backend/utils/adt/tsquery_cleanup.c
--- b/src/backend/utils/adt/tsquery_cleanup.c
***************
*** 15,21 ****

  #include "postgres.h"

- #include "tsearch/ts_type.h"
  #include "tsearch/ts_utils.h"
  #include "miscadmin.h"

--- 15,20 ----
diff --git a/src/backend/utils/adt/tsquery_gist.c b/src/backend/utils/adt/tsquery_gist.c
new file mode 100644
index 2ecb13e..bef8603
*** a/src/backend/utils/adt/tsquery_gist.c
--- b/src/backend/utils/adt/tsquery_gist.c
***************
*** 16,22 ****

  #include "access/skey.h"
  #include "access/gist.h"
- #include "tsearch/ts_type.h"
  #include "tsearch/ts_utils.h"

  #define GETENTRY(vec,pos) DatumGetTSQuerySign((vec)->vector[pos].key)
--- 16,21 ----
diff --git a/src/backend/utils/adt/tsquery_op.c b/src/backend/utils/adt/tsquery_op.c
new file mode 100644
index 4cf6287..59d9d20
*** a/src/backend/utils/adt/tsquery_op.c
--- b/src/backend/utils/adt/tsquery_op.c
***************
*** 14,23 ****

  #include "postgres.h"

- #include "tsearch/ts_type.h"
- #include "tsearch/ts_locale.h"
  #include "tsearch/ts_utils.h"
- #include "utils/pg_crc.h"

  Datum
  tsquery_numnode(PG_FUNCTION_ARGS)
--- 14,20 ----
diff --git a/src/backend/utils/adt/tsquery_rewrite.c b/src/backend/utils/adt/tsquery_rewrite.c
new file mode 100644
index e2faed2..974ce6a
*** a/src/backend/utils/adt/tsquery_rewrite.c
--- b/src/backend/utils/adt/tsquery_rewrite.c
***************
*** 17,23 ****
  #include "catalog/pg_type.h"
  #include "executor/spi.h"
  #include "miscadmin.h"
- #include "tsearch/ts_type.h"
  #include "tsearch/ts_utils.h"
  #include "utils/builtins.h"

--- 17,22 ----
diff --git a/src/backend/utils/adt/tsquery_util.c b/src/backend/utils/adt/tsquery_util.c
new file mode 100644
index 53093f1..003b83e
*** a/src/backend/utils/adt/tsquery_util.c
--- b/src/backend/utils/adt/tsquery_util.c
***************
*** 14,20 ****

  #include "postgres.h"

- #include "tsearch/ts_type.h"
  #include "tsearch/ts_utils.h"
  #include "miscadmin.h"

--- 14,19 ----
diff --git a/src/backend/utils/adt/tsrank.c b/src/backend/utils/adt/tsrank.c
new file mode 100644
index 8f5941c..564d855
*** a/src/backend/utils/adt/tsrank.c
--- b/src/backend/utils/adt/tsrank.c
***************
*** 15,21 ****

  #include <math.h>

- #include "tsearch/ts_type.h"
  #include "tsearch/ts_utils.h"
  #include "utils/array.h"
  #include "miscadmin.h"
--- 15,20 ----
diff --git a/src/backend/utils/adt/tsvector.c b/src/backend/utils/adt/tsvector.c
new file mode 100644
index 6810615..cb9a87d
*** a/src/backend/utils/adt/tsvector.c
--- b/src/backend/utils/adt/tsvector.c
***************
*** 15,21 ****
  #include "postgres.h"

  #include "libpq/pqformat.h"
- #include "tsearch/ts_type.h"
  #include "tsearch/ts_locale.h"
  #include "tsearch/ts_utils.h"
  #include "utils/memutils.h"
--- 15,20 ----
diff --git a/src/backend/utils/adt/tsvector_op.c b/src/backend/utils/adt/tsvector_op.c
new file mode 100644
index 181bfee..40e527b
*** a/src/backend/utils/adt/tsvector_op.c
--- b/src/backend/utils/adt/tsvector_op.c
***************
*** 21,27 ****
  #include "funcapi.h"
  #include "mb/pg_wchar.h"
  #include "miscadmin.h"
- #include "tsearch/ts_type.h"
  #include "tsearch/ts_utils.h"
  #include "utils/builtins.h"
  #include "utils/lsyscache.h"
--- 21,26 ----
diff --git a/src/backend/utils/adt/tsvector_parser.c b/src/backend/utils/adt/tsvector_parser.c
new file mode 100644
index 65eec00..20349a6
*** a/src/backend/utils/adt/tsvector_parser.c
--- b/src/backend/utils/adt/tsvector_parser.c
***************
*** 14,24 ****

  #include "postgres.h"

- #include "libpq/pqformat.h"
- #include "tsearch/ts_type.h"
  #include "tsearch/ts_locale.h"
  #include "tsearch/ts_utils.h"
- #include "utils/memutils.h"


  /*
--- 14,21 ----
diff --git a/src/backend/utils/adt/xml.c b/src/backend/utils/adt/xml.c
new file mode 100644
index 99b978c..cb55b38
*** a/src/backend/utils/adt/xml.c
--- b/src/backend/utils/adt/xml.c
***************
*** 47,79 ****

  #ifdef USE_LIBXML
  #include <libxml/chvalid.h>
- #include <libxml/parser.h>
- #include <libxml/tree.h>
- #include <libxml/uri.h>
- #include <libxml/xmlerror.h>
- #include <libxml/xmlwriter.h>
- #include <libxml/xpath.h>
  #include <libxml/xpathInternals.h>
  #endif   /* USE_LIBXML */

  #include "catalog/namespace.h"
  #include "catalog/pg_type.h"
  #include "commands/dbcommands.h"
- #include "executor/executor.h"
  #include "executor/spi.h"
- #include "fmgr.h"
- #include "lib/stringinfo.h"
  #include "libpq/pqformat.h"
  #include "mb/pg_wchar.h"
  #include "miscadmin.h"
- #include "nodes/execnodes.h"
- #include "nodes/nodeFuncs.h"
  #include "utils/array.h"
  #include "utils/builtins.h"
  #include "utils/date.h"
  #include "utils/datetime.h"
  #include "utils/lsyscache.h"
- #include "utils/memutils.h"
  #include "utils/rel.h"
  #include "utils/syscache.h"
  #include "utils/xml.h"
--- 47,67 ----
diff --git a/src/backend/utils/cache/attoptcache.c b/src/backend/utils/cache/attoptcache.c
new file mode 100644
index ba39aa8..179e6a6
*** a/src/backend/utils/cache/attoptcache.c
--- b/src/backend/utils/cache/attoptcache.c
***************
*** 17,28 ****
  #include "postgres.h"

  #include "access/reloptions.h"
- #include "catalog/pg_attribute.h"
  #include "utils/attoptcache.h"
- #include "utils/catcache.h"
  #include "utils/hsearch.h"
  #include "utils/inval.h"
- #include "utils/rel.h"
  #include "utils/syscache.h"


--- 17,25 ----
diff --git a/src/backend/utils/cache/catcache.c b/src/backend/utils/cache/catcache.c
new file mode 100644
index f43e418..90512ac
*** a/src/backend/utils/cache/catcache.c
--- b/src/backend/utils/cache/catcache.c
***************
*** 14,26 ****
   */
  #include "postgres.h"

- #include "access/genam.h"
  #include "access/hash.h"
- #include "access/heapam.h"
  #include "access/relscan.h"
  #include "access/sysattr.h"
  #include "access/valid.h"
- #include "catalog/pg_operator.h"
  #include "catalog/pg_type.h"
  #include "miscadmin.h"
  #ifdef CATCACHE_STATS
--- 14,23 ----
***************
*** 31,37 ****
  #include "utils/fmgroids.h"
  #include "utils/inval.h"
  #include "utils/memutils.h"
- #include "utils/rel.h"
  #include "utils/resowner.h"
  #include "utils/syscache.h"
  #include "utils/tqual.h"
--- 28,33 ----
diff --git a/src/backend/utils/cache/inval.c b/src/backend/utils/cache/inval.c
new file mode 100644
index 8792ec4..337fe64
*** a/src/backend/utils/cache/inval.c
--- b/src/backend/utils/cache/inval.c
***************
*** 86,95 ****
   */
  #include "postgres.h"

- #include "access/twophase_rmgr.h"
  #include "access/xact.h"
  #include "catalog/catalog.h"
- #include "catalog/pg_tablespace.h"
  #include "miscadmin.h"
  #include "storage/sinval.h"
  #include "storage/smgr.h"
--- 86,93 ----
diff --git a/src/backend/utils/cache/plancache.c b/src/backend/utils/cache/plancache.c
new file mode 100644
index 1410dec..68b6783
*** a/src/backend/utils/cache/plancache.c
--- b/src/backend/utils/cache/plancache.c
***************
*** 41,47 ****
   */
  #include "postgres.h"

- #include "utils/plancache.h"
  #include "access/transam.h"
  #include "catalog/namespace.h"
  #include "executor/executor.h"
--- 41,46 ----
***************
*** 52,62 ****
  #include "parser/parsetree.h"
  #include "storage/lmgr.h"
  #include "tcop/pquery.h"
- #include "tcop/tcopprot.h"
  #include "tcop/utility.h"
  #include "utils/inval.h"
  #include "utils/memutils.h"
- #include "utils/resowner.h"
  #include "utils/snapmgr.h"
  #include "utils/syscache.h"

--- 51,59 ----
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
new file mode 100644
index d0234a2..4ed463f
*** a/src/backend/utils/cache/relcache.c
--- b/src/backend/utils/cache/relcache.c
***************
*** 30,36 ****
  #include <fcntl.h>
  #include <unistd.h>

- #include "access/genam.h"
  #include "access/reloptions.h"
  #include "access/sysattr.h"
  #include "access/transam.h"
--- 30,35 ----
***************
*** 61,67 ****
  #include "optimizer/prep.h"
  #include "optimizer/var.h"
  #include "rewrite/rewriteDefine.h"
- #include "storage/fd.h"
  #include "storage/lmgr.h"
  #include "storage/smgr.h"
  #include "utils/array.h"
--- 60,65 ----
***************
*** 70,76 ****
  #include "utils/inval.h"
  #include "utils/lsyscache.h"
  #include "utils/memutils.h"
- #include "utils/relcache.h"
  #include "utils/relmapper.h"
  #include "utils/resowner.h"
  #include "utils/syscache.h"
--- 68,73 ----
diff --git a/src/backend/utils/cache/relmapper.c b/src/backend/utils/cache/relmapper.c
new file mode 100644
index b04dc9e..b33a846
*** a/src/backend/utils/cache/relmapper.c
--- b/src/backend/utils/cache/relmapper.c
***************
*** 51,57 ****
  #include "storage/fd.h"
  #include "storage/lwlock.h"
  #include "utils/inval.h"
- #include "utils/pg_crc.h"
  #include "utils/relmapper.h"


--- 51,56 ----
diff --git a/src/backend/utils/cache/spccache.c b/src/backend/utils/cache/spccache.c
new file mode 100644
index b505f21..228e7d1
*** a/src/backend/utils/cache/spccache.c
--- b/src/backend/utils/cache/spccache.c
***************
*** 23,29 ****
  #include "commands/tablespace.h"
  #include "miscadmin.h"
  #include "optimizer/cost.h"
- #include "utils/catcache.h"
  #include "utils/hsearch.h"
  #include "utils/inval.h"
  #include "utils/spccache.h"
--- 23,28 ----
diff --git a/src/backend/utils/cache/ts_cache.c b/src/backend/utils/cache/ts_cache.c
new file mode 100644
index cffa238..be29a91
*** a/src/backend/utils/cache/ts_cache.c
--- b/src/backend/utils/cache/ts_cache.c
***************
*** 36,46 ****
  #include "catalog/pg_ts_dict.h"
  #include "catalog/pg_ts_parser.h"
  #include "catalog/pg_ts_template.h"
- #include "catalog/pg_type.h"
  #include "commands/defrem.h"
- #include "miscadmin.h"
  #include "tsearch/ts_cache.h"
- #include "utils/array.h"
  #include "utils/builtins.h"
  #include "utils/fmgroids.h"
  #include "utils/inval.h"
--- 36,43 ----
diff --git a/src/backend/utils/cache/typcache.c b/src/backend/utils/cache/typcache.c
new file mode 100644
index b16ed6a..924ee57
*** a/src/backend/utils/cache/typcache.c
--- b/src/backend/utils/cache/typcache.c
***************
*** 60,66 ****
  #include "utils/rel.h"
  #include "utils/snapmgr.h"
  #include "utils/syscache.h"
- #include "utils/tqual.h"
  #include "utils/typcache.h"


--- 60,65 ----
diff --git a/src/backend/utils/fmgr/fmgr.c b/src/backend/utils/fmgr/fmgr.c
new file mode 100644
index 21fb5ad..86aa7b5
*** a/src/backend/utils/fmgr/fmgr.c
--- b/src/backend/utils/fmgr/fmgr.c
***************
*** 20,26 ****
  #include "catalog/pg_proc.h"
  #include "executor/functions.h"
  #include "executor/spi.h"
- #include "lib/stringinfo.h"
  #include "miscadmin.h"
  #include "nodes/nodeFuncs.h"
  #include "pgstat.h"
--- 20,25 ----
diff --git a/src/backend/utils/fmgr/funcapi.c b/src/backend/utils/fmgr/funcapi.c
new file mode 100644
index 02ee92b..0911c80
*** a/src/backend/utils/fmgr/funcapi.c
--- b/src/backend/utils/fmgr/funcapi.c
***************
*** 13,19 ****
   */
  #include "postgres.h"

- #include "access/heapam.h"
  #include "catalog/namespace.h"
  #include "catalog/pg_proc.h"
  #include "catalog/pg_type.h"
--- 13,18 ----
diff --git a/src/backend/utils/hash/hashfn.c b/src/backend/utils/hash/hashfn.c
new file mode 100644
index 7406d26..8984755
*** a/src/backend/utils/hash/hashfn.c
--- b/src/backend/utils/hash/hashfn.c
***************
*** 22,28 ****
  #include "postgres.h"

  #include "access/hash.h"
- #include "nodes/bitmapset.h"


  /*
--- 22,27 ----
diff --git a/src/backend/utils/init/miscinit.c b/src/backend/utils/init/miscinit.c
new file mode 100644
index 347a777..2df16bd
*** a/src/backend/utils/init/miscinit.c
--- b/src/backend/utils/init/miscinit.c
***************
*** 30,36 ****
  #endif

  #include "catalog/pg_authid.h"
- #include "mb/pg_wchar.h"
  #include "miscadmin.h"
  #include "postmaster/autovacuum.h"
  #include "postmaster/postmaster.h"
--- 30,35 ----
diff --git a/src/backend/utils/resowner/resowner.c b/src/backend/utils/resowner/resowner.c
new file mode 100644
index e5461e6..2fbe755
*** a/src/backend/utils/resowner/resowner.c
--- b/src/backend/utils/resowner/resowner.c
***************
*** 26,32 ****
  #include "storage/proc.h"
  #include "utils/memutils.h"
  #include "utils/rel.h"
- #include "utils/resowner.h"
  #include "utils/snapmgr.h"


--- 26,31 ----
diff --git a/src/backend/utils/sort/tuplesort.c b/src/backend/utils/sort/tuplesort.c
new file mode 100644
index dcfb8f9..3505236
*** a/src/backend/utils/sort/tuplesort.c
--- b/src/backend/utils/sort/tuplesort.c
***************
*** 100,110 ****

  #include <limits.h>

- #include "access/genam.h"
  #include "access/nbtree.h"
  #include "catalog/index.h"
- #include "catalog/pg_amop.h"
- #include "catalog/pg_operator.h"
  #include "commands/tablespace.h"
  #include "executor/executor.h"
  #include "miscadmin.h"
--- 100,107 ----
***************
*** 115,121 ****
  #include "utils/memutils.h"
  #include "utils/pg_rusage.h"
  #include "utils/rel.h"
- #include "utils/syscache.h"
  #include "utils/tuplesort.h"


--- 112,117 ----
diff --git a/src/backend/utils/sort/tuplestore.c b/src/backend/utils/sort/tuplestore.c
new file mode 100644
index 4d6e3aa..b28532b
*** a/src/backend/utils/sort/tuplestore.c
--- b/src/backend/utils/sort/tuplestore.c
***************
*** 59,65 ****
  #include "storage/buffile.h"
  #include "utils/memutils.h"
  #include "utils/resowner.h"
- #include "utils/tuplestore.h"


  /*
--- 59,64 ----
diff --git a/src/backend/utils/time/snapmgr.c b/src/backend/utils/time/snapmgr.c
new file mode 100644
index ef66466..bb25ac6
*** a/src/backend/utils/time/snapmgr.c
--- b/src/backend/utils/time/snapmgr.c
***************
*** 32,38 ****
  #include "storage/procarray.h"
  #include "utils/memutils.h"
  #include "utils/memutils.h"
- #include "utils/resowner.h"
  #include "utils/snapmgr.h"
  #include "utils/tqual.h"

--- 32,37 ----
diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c
new file mode 100644
index c317355..eabd0ed
*** a/src/bin/initdb/initdb.c
--- b/src/bin/initdb/initdb.c
***************
*** 57,63 ****

  #include "libpq/pqsignal.h"
  #include "mb/pg_wchar.h"
- #include "getaddrinfo.h"
  #include "getopt_long.h"
  #include "miscadmin.h"

--- 57,62 ----
diff --git a/src/bin/pg_config/pg_config.c b/src/bin/pg_config/pg_config.c
new file mode 100644
index 532c4a6..df7fcda
*** a/src/bin/pg_config/pg_config.c
--- b/src/bin/pg_config/pg_config.c
***************
*** 24,30 ****

  #include "postgres_fe.h"

- #include "port.h"

  static const char *progname;
  static char mypath[MAXPGPATH];
--- 24,29 ----
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
new file mode 100644
index 0dbdfe7..be5b95b
*** a/src/bin/pg_ctl/pg_ctl.c
--- b/src/bin/pg_ctl/pg_ctl.c
***************
*** 32,44 ****
  #include <sys/resource.h>
  #endif

- #include "libpq/pqsignal.h"
  #include "getopt_long.h"
  #include "miscadmin.h"

  #if defined(__CYGWIN__)
  #include <sys/cygwin.h>
! #include <windows.h>
  /* Cygwin defines WIN32 in windows.h, but we don't want it. */
  #undef WIN32
  #endif
--- 32,43 ----
  #include <sys/resource.h>
  #endif

  #include "getopt_long.h"
  #include "miscadmin.h"

  #if defined(__CYGWIN__)
  #include <sys/cygwin.h>
! #include <windows.h>    /* pgrminclude ignore */
  /* Cygwin defines WIN32 in windows.h, but we don't want it. */
  #undef WIN32
  #endif
diff --git a/src/bin/pg_dump/keywords.c b/src/bin/pg_dump/keywords.c
new file mode 100644
index e05cdd4..0c70796
*** a/src/bin/pg_dump/keywords.c
--- b/src/bin/pg_dump/keywords.c
***************
*** 24,30 ****
  #define PG_KEYWORD(a,b,c) {a,0,c},

  const ScanKeyword ScanKeywords[] = {
! #include "parser/kwlist.h"
  };

  const int    NumScanKeywords = lengthof(ScanKeywords);
--- 24,30 ----
  #define PG_KEYWORD(a,b,c) {a,0,c},

  const ScanKeyword ScanKeywords[] = {
! #include "parser/kwlist.h"    /* pgrminclude ignore */
  };

  const int    NumScanKeywords = lengthof(ScanKeywords);
diff --git a/src/bin/pg_dump/pg_backup_custom.c b/src/bin/pg_dump/pg_backup_custom.c
new file mode 100644
index 01d5e37..b53a520
*** a/src/bin/pg_dump/pg_backup_custom.c
--- b/src/bin/pg_dump/pg_backup_custom.c
***************
*** 24,30 ****
   *-------------------------------------------------------------------------
   */

- #include "pg_backup_archiver.h"
  #include "compress_io.h"

  /*--------
--- 24,29 ----
diff --git a/src/bin/pg_dump/pg_backup_directory.c b/src/bin/pg_dump/pg_backup_directory.c
new file mode 100644
index 111c3e8..2e110ac
*** a/src/bin/pg_dump/pg_backup_directory.c
--- b/src/bin/pg_dump/pg_backup_directory.c
***************
*** 33,39 ****
   *-------------------------------------------------------------------------
   */

- #include "pg_backup_archiver.h"
  #include "compress_io.h"

  #include <dirent.h>
--- 33,38 ----
diff --git a/src/bin/psql/common.c b/src/bin/psql/common.c
new file mode 100644
index 1015448..ef2c336
*** a/src/bin/psql/common.c
--- b/src/bin/psql/common.c
***************
*** 24,30 ****
  #include "settings.h"
  #include "command.h"
  #include "copy.h"
- #include "mbprint.h"



--- 24,29 ----
diff --git a/src/bin/psql/copy.c b/src/bin/psql/copy.c
new file mode 100644
index ebe5ee9..6fcf3a5
*** a/src/bin/psql/copy.c
--- b/src/bin/psql/copy.c
***************
*** 19,25 ****
  #include "libpq-fe.h"
  #include "pqexpbuffer.h"
  #include "pqsignal.h"
- #include "dumputils.h"

  #include "settings.h"
  #include "common.h"
--- 19,24 ----
diff --git a/src/bin/psql/help.c b/src/bin/psql/help.c
new file mode 100644
index 53e4cd0..81a8093
*** a/src/bin/psql/help.c
--- b/src/bin/psql/help.c
***************
*** 27,33 ****

  #include "common.h"
  #include "help.h"
! #include "input.h"
  #include "settings.h"
  #include "sql_help.h"

--- 27,33 ----

  #include "common.h"
  #include "help.h"
! #include "input.h"    /* pgrminclude ignore */
  #include "settings.h"
  #include "sql_help.h"

diff --git a/src/bin/psql/mainloop.c b/src/bin/psql/mainloop.c
new file mode 100644
index 6c4a079..39a9742
*** a/src/bin/psql/mainloop.c
--- b/src/bin/psql/mainloop.c
*************** MainLoop(FILE *source)
*** 422,425 ****
   * multiple infrastructures for stdio.h and so on.    flex is absolutely
   * uncooperative about that, so we can't compile psqlscan.c on its own.
   */
! #include "psqlscan.c"
--- 422,425 ----
   * multiple infrastructures for stdio.h and so on.    flex is absolutely
   * uncooperative about that, so we can't compile psqlscan.c on its own.
   */
! #include "psqlscan.c"    /* pgrminclude ignore */
diff --git a/src/bin/psql/mbprint.c b/src/bin/psql/mbprint.c
new file mode 100644
index 248a4db..ff9293a
*** a/src/bin/psql/mbprint.c
--- b/src/bin/psql/mbprint.c
***************
*** 12,18 ****

  #include "postgres_fe.h"
  #include "mbprint.h"
- #include "libpq-fe.h"
  #ifndef PGSCRIPTS
  #include "settings.h"
  #endif
--- 12,17 ----
diff --git a/src/bin/psql/prompt.c b/src/bin/psql/prompt.c
new file mode 100644
index aceab70..ff110a9
*** a/src/bin/psql/prompt.c
--- b/src/bin/psql/prompt.c
***************
*** 18,24 ****
  #endif

  #include "common.h"
! #include "input.h"
  #include "prompt.h"
  #include "settings.h"

--- 18,24 ----
  #endif

  #include "common.h"
! #include "input.h"    /* pgrminclude ignore */
  #include "prompt.h"
  #include "settings.h"

diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
new file mode 100644
index 4f7df36..246ad9d
*** a/src/bin/psql/tab-complete.c
--- b/src/bin/psql/tab-complete.c
***************
*** 42,59 ****
   */

  #include "postgres_fe.h"
  #include "tab-complete.h"
- #include "input.h"

  /* If we don't have this, we might as well forget about the whole thing: */
  #ifdef USE_READLINE

  #include <ctype.h>
- #include "libpq-fe.h"
- #include "pqexpbuffer.h"
- #include "common.h"
- #include "settings.h"
- #include "stringutils.h"

  #ifdef HAVE_RL_FILENAME_COMPLETION_FUNCTION
  #define filename_completion_function rl_filename_completion_function
--- 42,58 ----
   */

  #include "postgres_fe.h"
+ #include "common.h"
+ #include "input.h"    /* pgrminclude ignore */
+ #include "libpq-fe.h"
+ #include "settings.h"
+ #include "stringutils.h"
  #include "tab-complete.h"

  /* If we don't have this, we might as well forget about the whole thing: */
  #ifdef USE_READLINE

  #include <ctype.h>

  #ifdef HAVE_RL_FILENAME_COMPLETION_FUNCTION
  #define filename_completion_function rl_filename_completion_function
diff --git a/src/bin/scripts/common.h b/src/bin/scripts/common.h
new file mode 100644
index 694977b..caa9e81
*** a/src/bin/scripts/common.h
--- b/src/bin/scripts/common.h
***************
*** 10,17 ****
  #define COMMON_H

  #include "libpq-fe.h"
! #include "getopt_long.h"
! #include "pqexpbuffer.h"

  enum trivalue
  {
--- 10,17 ----
  #define COMMON_H

  #include "libpq-fe.h"
! #include "getopt_long.h"    /* pgrminclude ignore */
! #include "pqexpbuffer.h"    /* pgrminclude ignore */

  enum trivalue
  {
diff --git a/src/include/access/genam.h b/src/include/access/genam.h
new file mode 100644
index a95b3d7..7154ae3
*** a/src/include/access/genam.h
--- b/src/include/access/genam.h
***************
*** 17,23 ****
  #include "access/sdir.h"
  #include "access/skey.h"
  #include "nodes/tidbitmap.h"
- #include "storage/buf.h"
  #include "storage/lock.h"
  #include "utils/relcache.h"
  #include "utils/snapshot.h"
--- 17,22 ----
diff --git a/src/include/access/heapam.h b/src/include/access/heapam.h
new file mode 100644
index 56036a8..879dc93
*** a/src/include/access/heapam.h
--- b/src/include/access/heapam.h
***************
*** 14,20 ****
  #ifndef HEAPAM_H
  #define HEAPAM_H

- #include "access/htup.h"
  #include "access/sdir.h"
  #include "access/skey.h"
  #include "access/xlog.h"
--- 14,19 ----
diff --git a/src/include/access/twophase.h b/src/include/access/twophase.h
new file mode 100644
index 799bf8b..0019df5
*** a/src/include/access/twophase.h
--- b/src/include/access/twophase.h
***************
*** 14,23 ****
  #ifndef TWOPHASE_H
  #define TWOPHASE_H

- #include "access/xlogdefs.h"
- #include "storage/backendid.h"
  #include "storage/proc.h"
- #include "utils/timestamp.h"

  /*
   * GlobalTransactionData is defined in twophase.c; other places have no
--- 14,20 ----
diff --git a/src/include/access/xact.h b/src/include/access/xact.h
new file mode 100644
index c585752..aaa6204
*** a/src/include/access/xact.h
--- b/src/include/access/xact.h
***************
*** 17,23 ****
  #include "access/xlog.h"
  #include "nodes/pg_list.h"
  #include "storage/relfilenode.h"
- #include "utils/timestamp.h"


  /*
--- 17,22 ----
diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h
new file mode 100644
index 4eaa243..68c0691
*** a/src/include/access/xlog_internal.h
--- b/src/include/access/xlog_internal.h
***************
*** 17,24 ****
  #define XLOG_INTERNAL_H

  #include "access/xlog.h"
- #include "fmgr.h"
- #include "pgtime.h"
  #include "storage/block.h"
  #include "storage/relfilenode.h"

--- 17,22 ----
diff --git a/src/include/access/xlogutils.h b/src/include/access/xlogutils.h
new file mode 100644
index bc3db14..5a26d26
*** a/src/include/access/xlogutils.h
--- b/src/include/access/xlogutils.h
***************
*** 11,21 ****
  #ifndef XLOG_UTILS_H
  #define XLOG_UTILS_H

- #include "storage/buf.h"
  #include "storage/bufmgr.h"
- #include "storage/relfilenode.h"
- #include "storage/block.h"
- #include "utils/relcache.h"


  extern void XLogCheckInvalidPages(void);
--- 11,17 ----
diff --git a/src/include/catalog/catalog.h b/src/include/catalog/catalog.h
new file mode 100644
index e4f1535..1e1e12d
*** a/src/include/catalog/catalog.h
--- b/src/include/catalog/catalog.h
***************
*** 14,20 ****
  #ifndef CATALOG_H
  #define CATALOG_H

- #include "catalog/catversion.h"
  #include "catalog/pg_class.h"
  #include "storage/relfilenode.h"
  #include "utils/relcache.h"
--- 14,19 ----
diff --git a/src/include/catalog/dependency.h b/src/include/catalog/dependency.h
new file mode 100644
index 5dfb25f..5302e50
*** a/src/include/catalog/dependency.h
--- b/src/include/catalog/dependency.h
***************
*** 14,20 ****
  #ifndef DEPENDENCY_H
  #define DEPENDENCY_H

- #include "nodes/parsenodes.h"    /* for DropBehavior */
  #include "catalog/objectaddress.h"


--- 14,19 ----
diff --git a/src/include/catalog/pg_db_role_setting.h b/src/include/catalog/pg_db_role_setting.h
new file mode 100644
index cda9b72..438635c
*** a/src/include/catalog/pg_db_role_setting.h
--- b/src/include/catalog/pg_db_role_setting.h
***************
*** 21,28 ****
  #ifndef PG_DB_ROLE_SETTING_H
  #define PG_DB_ROLE_SETTING_H

- #include "catalog/genbki.h"
- #include "nodes/parsenodes.h"
  #include "utils/guc.h"
  #include "utils/relcache.h"

--- 21,26 ----
diff --git a/src/include/catalog/storage.h b/src/include/catalog/storage.h
new file mode 100644
index 6907d83..8769bfd
*** a/src/include/catalog/storage.h
--- b/src/include/catalog/storage.h
***************
*** 15,21 ****
  #define STORAGE_H

  #include "access/xlog.h"
- #include "lib/stringinfo.h"
  #include "storage/block.h"
  #include "storage/relfilenode.h"
  #include "utils/relcache.h"
--- 15,20 ----
diff --git a/src/include/commands/alter.h b/src/include/commands/alter.h
new file mode 100644
index e942b53..6cf9de1
*** a/src/include/commands/alter.h
--- b/src/include/commands/alter.h
***************
*** 14,20 ****
  #ifndef ALTER_H
  #define ALTER_H

- #include "nodes/parsenodes.h"
  #include "utils/acl.h"
  #include "utils/relcache.h"

--- 14,19 ----
diff --git a/src/include/commands/portalcmds.h b/src/include/commands/portalcmds.h
new file mode 100644
index c64aabf..87c57f4
*** a/src/include/commands/portalcmds.h
--- b/src/include/commands/portalcmds.h
***************
*** 15,21 ****
  #define PORTALCMDS_H

  #include "nodes/parsenodes.h"
- #include "nodes/plannodes.h"
  #include "utils/portal.h"


--- 15,20 ----
diff --git a/src/include/commands/prepare.h b/src/include/commands/prepare.h
new file mode 100644
index 4375fdb..63c06ad
*** a/src/include/commands/prepare.h
--- b/src/include/commands/prepare.h
***************
*** 15,21 ****

  #include "commands/explain.h"
  #include "utils/plancache.h"
- #include "utils/timestamp.h"

  /*
   * The data structure representing a prepared statement.  This is now just
--- 15,20 ----
diff --git a/src/include/commands/seclabel.h b/src/include/commands/seclabel.h
new file mode 100644
index 1a0282c..8c7ecbf
*** a/src/include/commands/seclabel.h
--- b/src/include/commands/seclabel.h
***************
*** 10,17 ****
  #define SECLABEL_H

  #include "catalog/objectaddress.h"
- #include "nodes/primnodes.h"
- #include "nodes/parsenodes.h"

  /*
   * Internal APIs
--- 10,15 ----
diff --git a/src/include/commands/sequence.h b/src/include/commands/sequence.h
new file mode 100644
index 3f3ba52..85452b0
*** a/src/include/commands/sequence.h
--- b/src/include/commands/sequence.h
***************
*** 16,22 ****
  #include "nodes/parsenodes.h"
  #include "storage/relfilenode.h"
  #include "access/xlog.h"
- #include "fmgr.h"


  typedef struct FormData_pg_sequence
--- 16,21 ----
diff --git a/src/include/executor/execdesc.h b/src/include/executor/execdesc.h
new file mode 100644
index 1a636a0..2925deb
*** a/src/include/executor/execdesc.h
--- b/src/include/executor/execdesc.h
***************
*** 16,22 ****
  #define EXECDESC_H

  #include "nodes/execnodes.h"
- #include "nodes/plannodes.h"
  #include "tcop/dest.h"


--- 16,21 ----
diff --git a/src/include/executor/hashjoin.h b/src/include/executor/hashjoin.h
new file mode 100644
index 0c6e06f..85e595b
*** a/src/include/executor/hashjoin.h
--- b/src/include/executor/hashjoin.h
***************
*** 14,20 ****
  #ifndef HASHJOIN_H
  #define HASHJOIN_H

- #include "fmgr.h"
  #include "nodes/execnodes.h"
  #include "storage/buffile.h"

--- 14,19 ----
diff --git a/src/include/executor/spi.h b/src/include/executor/spi.h
new file mode 100644
index 98d194a..7199deb
*** a/src/include/executor/spi.h
--- b/src/include/executor/spi.h
***************
*** 15,22 ****

  #include "nodes/parsenodes.h"
  #include "utils/portal.h"
- #include "utils/relcache.h"
- #include "utils/snapshot.h"


  typedef struct SPITupleTable
--- 15,20 ----
diff --git a/src/include/executor/tuptable.h b/src/include/executor/tuptable.h
new file mode 100644
index f774f2d..69ade2f
*** a/src/include/executor/tuptable.h
--- b/src/include/executor/tuptable.h
***************
*** 15,21 ****
  #define TUPTABLE_H

  #include "access/htup.h"
- #include "access/tupdesc.h"
  #include "storage/buf.h"

  /*----------
--- 15,20 ----
diff --git a/src/include/libpq/hba.h b/src/include/libpq/hba.h
new file mode 100644
index 1e49044..c49f30c
*** a/src/include/libpq/hba.h
--- b/src/include/libpq/hba.h
***************
*** 12,18 ****
  #define HBA_H

  #include "nodes/pg_list.h"
- #include "libpq/pqcomm.h"


  typedef enum UserAuth
--- 12,17 ----
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
new file mode 100644
index 6ed739c..b3eed7d
*** a/src/include/nodes/execnodes.h
--- b/src/include/nodes/execnodes.h
***************
*** 16,28 ****

  #include "access/genam.h"
  #include "access/heapam.h"
- #include "access/skey.h"
  #include "nodes/params.h"
  #include "nodes/plannodes.h"
- #include "nodes/tidbitmap.h"
- #include "utils/hsearch.h"
  #include "utils/reltrigger.h"
- #include "utils/snapshot.h"
  #include "utils/tuplestore.h"


--- 16,24 ----
diff --git a/src/include/nodes/print.h b/src/include/nodes/print.h
new file mode 100644
index 3b87e18..8bac7b0
*** a/src/include/nodes/print.h
--- b/src/include/nodes/print.h
***************
*** 14,20 ****
  #ifndef PRINT_H
  #define PRINT_H

- #include "nodes/parsenodes.h"
  #include "executor/tuptable.h"


--- 14,19 ----
diff --git a/src/include/nodes/relation.h b/src/include/nodes/relation.h
new file mode 100644
index f659269..722567d
*** a/src/include/nodes/relation.h
--- b/src/include/nodes/relation.h
***************
*** 15,21 ****
  #define RELATION_H

  #include "access/sdir.h"
- #include "nodes/bitmapset.h"
  #include "nodes/params.h"
  #include "nodes/parsenodes.h"
  #include "storage/block.h"
--- 15,20 ----
diff --git a/src/include/optimizer/geqo_misc.h b/src/include/optimizer/geqo_misc.h
new file mode 100644
index 83d8067..fcafbcd
*** a/src/include/optimizer/geqo_misc.h
--- b/src/include/optimizer/geqo_misc.h
***************
*** 22,28 ****
  #ifndef GEQO_MISC_H
  #define GEQO_MISC_H

- #include "optimizer/geqo.h"
  #include "optimizer/geqo_recombination.h"

  #ifdef GEQO_DEBUG
--- 22,27 ----
diff --git a/src/include/pg_trace.h b/src/include/pg_trace.h
new file mode 100644
index e8112d3..cd4775e
*** a/src/include/pg_trace.h
--- b/src/include/pg_trace.h
***************
*** 12,17 ****
  #ifndef PG_TRACE_H
  #define PG_TRACE_H

! #include "utils/probes.h"

  #endif   /* PG_TRACE_H */
--- 12,17 ----
  #ifndef PG_TRACE_H
  #define PG_TRACE_H

! #include "utils/probes.h"    /* pgrminclude ignore */

  #endif   /* PG_TRACE_H */
diff --git a/src/include/postmaster/autovacuum.h b/src/include/postmaster/autovacuum.h
new file mode 100644
index cf82363..682cabe
*** a/src/include/postmaster/autovacuum.h
--- b/src/include/postmaster/autovacuum.h
***************
*** 14,20 ****
  #ifndef AUTOVACUUM_H
  #define AUTOVACUUM_H

- #include "storage/lock.h"

  /* GUC variables */
  extern bool autovacuum_start_daemon;
--- 14,19 ----
diff --git a/src/include/replication/syncrep.h b/src/include/replication/syncrep.h
new file mode 100644
index d71047e..0ec9b4a
*** a/src/include/replication/syncrep.h
--- b/src/include/replication/syncrep.h
***************
*** 13,22 ****
  #ifndef _SYNCREP_H
  #define _SYNCREP_H

- #include "access/xlog.h"
  #include "storage/proc.h"
- #include "storage/shmem.h"
- #include "storage/spin.h"
  #include "utils/guc.h"

  #define SyncRepRequested() \
--- 13,19 ----
diff --git a/src/include/replication/walsender.h b/src/include/replication/walsender.h
new file mode 100644
index 876d2aa..d0cee2c
*** a/src/include/replication/walsender.h
--- b/src/include/replication/walsender.h
***************
*** 12,20 ****
  #ifndef _WALSENDER_H
  #define _WALSENDER_H

- #include "access/xlog.h"
- #include "nodes/nodes.h"
- #include "storage/latch.h"
  #include "replication/syncrep.h"
  #include "storage/spin.h"

--- 12,17 ----
diff --git a/src/include/snowball/header.h b/src/include/snowball/header.h
new file mode 100644
index 3ede1a0..6b0aa62
*** a/src/include/snowball/header.h
--- b/src/include/snowball/header.h
***************
*** 33,39 ****
  #endif

  /* Now we can include the original Snowball header.h */
! #include "snowball/libstemmer/header.h"

  /*
   * Redefine standard memory allocation interface to pgsql's one.
--- 33,39 ----
  #endif

  /* Now we can include the original Snowball header.h */
! #include "snowball/libstemmer/header.h"    /* pgrminclude ignore */

  /*
   * Redefine standard memory allocation interface to pgsql's one.
diff --git a/src/include/storage/freespace.h b/src/include/storage/freespace.h
new file mode 100644
index 1c15db8..54dc649
*** a/src/include/storage/freespace.h
--- b/src/include/storage/freespace.h
***************
*** 15,21 ****
  #define FREESPACE_H_

  #include "storage/block.h"
- #include "storage/bufpage.h"
  #include "storage/relfilenode.h"
  #include "utils/relcache.h"

--- 15,20 ----
diff --git a/src/include/storage/fsm_internals.h b/src/include/storage/fsm_internals.h
new file mode 100644
index 4508b7c..8b5a2db
*** a/src/include/storage/fsm_internals.h
--- b/src/include/storage/fsm_internals.h
***************
*** 16,22 ****

  #include "storage/buf.h"
  #include "storage/bufpage.h"
- #include "lib/stringinfo.h"

  /*
   * Structure of a FSM page. See src/backend/storage/freespace/README for
--- 16,21 ----
diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h
new file mode 100644
index 8b09b2a..8926180
*** a/src/include/storage/proc.h
--- b/src/include/storage/proc.h
***************
*** 15,25 ****
  #define _PROC_H_

  #include "access/xlog.h"
- #include "replication/syncrep.h"
  #include "storage/latch.h"
  #include "storage/lock.h"
  #include "storage/pg_sema.h"
- #include "utils/timestamp.h"

  /*
   * Each backend advertises up to PGPROC_MAX_CACHED_SUBXIDS TransactionIds
--- 15,23 ----
diff --git a/src/include/storage/procarray.h b/src/include/storage/procarray.h
new file mode 100644
index 3c20fc4..a11d438
*** a/src/include/storage/procarray.h
--- b/src/include/storage/procarray.h
***************
*** 14,21 ****
  #ifndef PROCARRAY_H
  #define PROCARRAY_H

- #include "storage/lock.h"
- #include "storage/procsignal.h"
  #include "storage/standby.h"
  #include "utils/snapshot.h"

--- 14,19 ----
diff --git a/src/include/storage/smgr.h b/src/include/storage/smgr.h
new file mode 100644
index e479266..96d0642
*** a/src/include/storage/smgr.h
--- b/src/include/storage/smgr.h
***************
*** 14,22 ****
  #ifndef SMGR_H
  #define SMGR_H

- #include "access/xlog.h"
  #include "fmgr.h"
- #include "storage/backendid.h"
  #include "storage/block.h"
  #include "storage/relfilenode.h"

--- 14,20 ----
diff --git a/src/include/tcop/tcopprot.h b/src/include/tcop/tcopprot.h
new file mode 100644
index d5192d9..8b8bbe3
*** a/src/include/tcop/tcopprot.h
--- b/src/include/tcop/tcopprot.h
***************
*** 20,26 ****
  #define TCOPPROT_H

  #include "executor/execdesc.h"
- #include "nodes/parsenodes.h"
  #include "storage/procsignal.h"
  #include "utils/guc.h"

--- 20,25 ----
diff --git a/src/include/tsearch/ts_cache.h b/src/include/tsearch/ts_cache.h
new file mode 100644
index 01550ed..84e451c
*** a/src/include/tsearch/ts_cache.h
--- b/src/include/tsearch/ts_cache.h
***************
*** 13,19 ****
  #ifndef TS_CACHE_H
  #define TS_CACHE_H

- #include "fmgr.h"
  #include "utils/guc.h"


--- 13,18 ----
diff --git a/src/include/utils/inval.h b/src/include/utils/inval.h
new file mode 100644
index 606b778..fbcddbc
*** a/src/include/utils/inval.h
--- b/src/include/utils/inval.h
***************
*** 15,21 ****
  #define INVAL_H

  #include "access/htup.h"
- #include "storage/relfilenode.h"
  #include "utils/relcache.h"


--- 15,20 ----
diff --git a/src/include/utils/lsyscache.h b/src/include/utils/lsyscache.h
new file mode 100644
index f4490ad..2159515
*** a/src/include/utils/lsyscache.h
--- b/src/include/utils/lsyscache.h
***************
*** 13,21 ****
  #ifndef LSYSCACHE_H
  #define LSYSCACHE_H

- #include "access/attnum.h"
  #include "access/htup.h"
- #include "nodes/pg_list.h"

  /* Result list element for get_op_btree_interpretation */
  typedef struct OpBtreeInterpretation
--- 13,19 ----
diff --git a/src/include/utils/portal.h b/src/include/utils/portal.h
new file mode 100644
index 6af1cd5..6ae6b10
*** a/src/include/utils/portal.h
--- b/src/include/utils/portal.h
***************
*** 48,54 ****

  #include "executor/execdesc.h"
  #include "utils/resowner.h"
- #include "utils/timestamp.h"

  /*
   * We have several execution strategies for Portals, depending on what
--- 48,53 ----
diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h
new file mode 100644
index 173dc16..d0b20c9
*** a/src/include/utils/rel.h
--- b/src/include/utils/rel.h
***************
*** 14,27 ****
  #ifndef REL_H
  #define REL_H

- #include "access/tupdesc.h"
  #include "catalog/pg_am.h"
  #include "catalog/pg_class.h"
  #include "catalog/pg_index.h"
  #include "fmgr.h"
- #include "nodes/bitmapset.h"
  #include "rewrite/prs2lock.h"
- #include "storage/block.h"
  #include "storage/relfilenode.h"
  #include "utils/relcache.h"
  #include "utils/reltrigger.h"
--- 14,24 ----
diff --git a/src/include/utils/relcache.h b/src/include/utils/relcache.h
new file mode 100644
index fc49ee3..9aaf969
*** a/src/include/utils/relcache.h
--- b/src/include/utils/relcache.h
***************
*** 16,22 ****

  #include "access/tupdesc.h"
  #include "nodes/bitmapset.h"
- #include "nodes/pg_list.h"


  typedef struct RelationData *Relation;
--- 16,21 ----
diff --git a/src/include/utils/resowner.h b/src/include/utils/resowner.h
new file mode 100644
index 2d08312..cff0ac8
*** a/src/include/utils/resowner.h
--- b/src/include/utils/resowner.h
***************
*** 19,25 ****
  #ifndef RESOWNER_H
  #define RESOWNER_H

- #include "storage/buf.h"
  #include "storage/fd.h"
  #include "utils/catcache.h"
  #include "utils/plancache.h"
--- 19,24 ----
diff --git a/src/include/utils/snapmgr.h b/src/include/utils/snapmgr.h
new file mode 100644
index a7e7d3d..c969a37
*** a/src/include/utils/snapmgr.h
--- b/src/include/utils/snapmgr.h
***************
*** 14,20 ****
  #define SNAPMGR_H

  #include "utils/resowner.h"
- #include "utils/snapshot.h"


  extern bool FirstSnapshotSet;
--- 14,19 ----
diff --git a/src/pl/plpgsql/src/pl_comp.c b/src/pl/plpgsql/src/pl_comp.c
new file mode 100644
index d22fa68..304e2e6
*** a/src/pl/plpgsql/src/pl_comp.c
--- b/src/pl/plpgsql/src/pl_comp.c
***************
*** 18,26 ****
  #include <ctype.h>

  #include "catalog/namespace.h"
- #include "catalog/pg_attrdef.h"
- #include "catalog/pg_attribute.h"
- #include "catalog/pg_class.h"
  #include "catalog/pg_proc.h"
  #include "catalog/pg_proc_fn.h"
  #include "catalog/pg_type.h"
--- 18,23 ----
***************
*** 28,34 ****
  #include "nodes/makefuncs.h"
  #include "parser/parse_type.h"
  #include "tcop/tcopprot.h"
- #include "utils/array.h"
  #include "utils/builtins.h"
  #include "utils/lsyscache.h"
  #include "utils/memutils.h"
--- 25,30 ----
*************** typedef struct
*** 81,87 ****
  } ExceptionLabelMap;

  static const ExceptionLabelMap exception_label_map[] = {
! #include "plerrcodes.h"
      {NULL, 0}
  };

--- 77,83 ----
  } ExceptionLabelMap;

  static const ExceptionLabelMap exception_label_map[] = {
! #include "plerrcodes.h"    /* pgrminclude ignore */
      {NULL, 0}
  };

diff --git a/src/pl/plpgsql/src/pl_exec.c b/src/pl/plpgsql/src/pl_exec.c
new file mode 100644
index de1aece..abfab5c
*** a/src/pl/plpgsql/src/pl_exec.c
--- b/src/pl/plpgsql/src/pl_exec.c
***************
*** 17,25 ****

  #include <ctype.h>

- #include "access/transam.h"
  #include "access/tupconvert.h"
- #include "catalog/pg_proc.h"
  #include "catalog/pg_type.h"
  #include "executor/spi_priv.h"
  #include "funcapi.h"
--- 17,23 ----
***************
*** 27,33 ****
  #include "nodes/nodeFuncs.h"
  #include "parser/scansup.h"
  #include "storage/proc.h"
- #include "tcop/tcopprot.h"
  #include "utils/array.h"
  #include "utils/builtins.h"
  #include "utils/datum.h"
--- 25,30 ----
diff --git a/src/pl/plpgsql/src/plpgsql.h b/src/pl/plpgsql/src/plpgsql.h
new file mode 100644
index c543f1c..ed8fcad
*** a/src/pl/plpgsql/src/plpgsql.h
--- b/src/pl/plpgsql/src/plpgsql.h
***************
*** 19,30 ****
  #include "postgres.h"

  #include "access/xact.h"
- #include "fmgr.h"
  #include "commands/trigger.h"
  #include "executor/spi.h"
- #include "lib/stringinfo.h"
- #include "nodes/bitmapset.h"
- #include "utils/tuplestore.h"

  /**********************************************************************
   * Definitions
--- 19,26 ----
diff --git a/src/pl/tcl/pltcl.c b/src/pl/tcl/pltcl.c
new file mode 100644
index be8fe7a..b1a5a90
*** a/src/pl/tcl/pltcl.c
--- b/src/pl/tcl/pltcl.c
***************
*** 23,33 ****
  #include "catalog/pg_type.h"
  #include "commands/trigger.h"
  #include "executor/spi.h"
- #include "fmgr.h"
  #include "miscadmin.h"
  #include "nodes/makefuncs.h"
  #include "parser/parse_type.h"
- #include "tcop/tcopprot.h"
  #include "utils/builtins.h"
  #include "utils/lsyscache.h"
  #include "utils/memutils.h"
--- 23,31 ----
***************
*** 51,57 ****

  #if defined(UNICODE_CONVERSION) && HAVE_TCL_VERSION(8,1)

- #include "mb/pg_wchar.h"

  static unsigned char *
  utf_u2e(unsigned char *src)
--- 49,54 ----
diff --git a/src/port/open.c b/src/port/open.c
new file mode 100644
index 9831d1d..aee83d9
*** a/src/port/open.c
--- b/src/port/open.c
***************
*** 19,25 ****
  #include "postgres_fe.h"
  #endif

- #include <windows.h>
  #include <fcntl.h>
  #include <assert.h>

--- 19,24 ----
diff --git a/src/tools/pginclude/pgrminclude b/src/tools/pginclude/pgrminclude
new file mode 100755
index a8ec10a..e35a3c0
*** a/src/tools/pginclude/pgrminclude
--- b/src/tools/pginclude/pgrminclude
***************
*** 6,11 ****
--- 6,12 ----
  trap "rm -f /tmp/$$.c /tmp/$$.o /tmp/$$ /tmp/$$a /tmp/$$b" 0 1 2 3 15
  find . \( -name CVS -a -prune \) -o -type f -name '*.[ch]' -print |
  grep -v '\./postgres.h' |
+ grep -v '\./postgres_fe.h' |
  grep -v '\./pg_config.h' |
  grep -v '\./c.h' |
  while read FILE
*************** do
*** 17,22 ****
--- 18,24 ----

      # loop through all includes
      cat "$FILE" | grep "^#include" |
+     grep -v 'pgrminclude  *ignore' |
      sed 's/^#include[     ]*[<"]\([^>"]*\).*$/\1/g' |
      while read INCLUDE
      do
*************** do
*** 27,33 ****
          [ -s /usr/include/$INCLUDE ] && continue
          [ "$INCLUDE" = postgres.h ] && continue
          [ "$INCLUDE" = postgres_fe.h ] && continue
!         [ "$INCLUDE" = config.h ] && continue
          [ "$INCLUDE" = c.h ] && continue

          # preserve configure-specific includes
--- 29,35 ----
          [ -s /usr/include/$INCLUDE ] && continue
          [ "$INCLUDE" = postgres.h ] && continue
          [ "$INCLUDE" = postgres_fe.h ] && continue
!         [ "$INCLUDE" = pg_config.h ] && continue
          [ "$INCLUDE" = c.h ] && continue

          # preserve configure-specific includes

Re: Removal of useless include references

From
Tom Lane
Date:
Bruce Momjian <bruce@momjian.us> writes:
> It has been years since I ran src/tools/pginclude/pgrminclude to remove
> unnecessary include files.  (I have already fixed things so include
> files can be compiled on their own.)

> The attached patch removes unneeded include references, and marks some
> includes as needing to be skipped by pgrminclude.

> I am sure applying this patch will break builds on some platforms and
> some option combinations so I will monitor the buildfarm when I apply it
> and make adjustments.

The last time you did this was in July 2006.  It took us two weeks to
mostly recover, but we were still dealing with some fallout in December,
cf
http://archives.postgresql.org/pgsql-hackers/2006-12/msg00491.php

We had the buildfarm then, had had it for a couple years.  The notion
that watching the buildfarm is enough is fully disproven by history.

Unless you have a better test plan than last time (which this isn't),
I don't think this should be done at all.  The benefits are microscopic
and the pain real.
        regards, tom lane


Re: Removal of useless include references

From
Christian Ullrich
Date:
* Bruce Momjian wrote:

> The attached patch removes unneeded include references, and marks some
> includes as needing to be skipped by pgrminclude.

There are several unrelated changes to pg_upgrade in that patch, too.

-- 
Christian




Re: Removal of useless include references

From
Bruce Momjian
Date:
Tom Lane wrote:
> Bruce Momjian <bruce@momjian.us> writes:
> > It has been years since I ran src/tools/pginclude/pgrminclude to remove
> > unnecessary include files.  (I have already fixed things so include
> > files can be compiled on their own.)
> 
> > The attached patch removes unneeded include references, and marks some
> > includes as needing to be skipped by pgrminclude.
> 
> > I am sure applying this patch will break builds on some platforms and
> > some option combinations so I will monitor the buildfarm when I apply it
> > and make adjustments.
> 
> The last time you did this was in July 2006.  It took us two weeks to
> mostly recover, but we were still dealing with some fallout in December,
> cf
> http://archives.postgresql.org/pgsql-hackers/2006-12/msg00491.php
> 
> We had the buildfarm then, had had it for a couple years.  The notion
> that watching the buildfarm is enough is fully disproven by history.
> 
> Unless you have a better test plan than last time (which this isn't),
> I don't think this should be done at all.  The benefits are microscopic
> and the pain real.

I don't have a better plan.  There are #ifdef code blocks that often
don't get processed and therefore this can't be done better.  I will
abandon the idea.

--  Bruce Momjian  <bruce@momjian.us>        http://momjian.us EnterpriseDB
http://enterprisedb.com
 + It's impossible for everything to be true. +


Re: Removal of useless include references

From
Alvaro Herrera
Date:
Excerpts from Bruce Momjian's message of vie ago 26 01:35:45 -0300 2011:
> It has been years since I ran src/tools/pginclude/pgrminclude to remove
> unnecessary include files.  (I have already fixed things so include
> files can be compiled on their own.)
> 
> The attached patch removes unneeded include references, and marks some
> includes as needing to be skipped by pgrminclude.

In btree_gist I think you should remove #include "postgres.h" from the
.h file and put it in the .c files instead, as is customary.  I think
that would make the other changes incorrect.  ltree.h and pg_upgrade.h
also get this wrong.

-- 
Álvaro Herrera <alvherre@commandprompt.com>
The PostgreSQL Company - Command Prompt, Inc.
PostgreSQL Replication, Consulting, Custom Development, 24x7 support


Re: Removal of useless include references

From
Bruce Momjian
Date:
Bruce Momjian wrote:
> Tom Lane wrote:
> > Bruce Momjian <bruce@momjian.us> writes:
> > > It has been years since I ran src/tools/pginclude/pgrminclude to remove
> > > unnecessary include files.  (I have already fixed things so include
> > > files can be compiled on their own.)
> > 
> > > The attached patch removes unneeded include references, and marks some
> > > includes as needing to be skipped by pgrminclude.
> > 
> > > I am sure applying this patch will break builds on some platforms and
> > > some option combinations so I will monitor the buildfarm when I apply it
> > > and make adjustments.
> > 
> > The last time you did this was in July 2006.  It took us two weeks to
> > mostly recover, but we were still dealing with some fallout in December,
> > cf
> > http://archives.postgresql.org/pgsql-hackers/2006-12/msg00491.php
> > 
> > We had the buildfarm then, had had it for a couple years.  The notion
> > that watching the buildfarm is enough is fully disproven by history.
> > 
> > Unless you have a better test plan than last time (which this isn't),
> > I don't think this should be done at all.  The benefits are microscopic
> > and the pain real.
> 
> I don't have a better plan.  There are #ifdef code blocks that often
> don't get processed and therefore this can't be done better.  I will
> abandon the idea.

OK, try #2.  I already had code that removed #if/#else/#endif code in
*.h files for better testing, so I extended that to all *.c files.  This
reduces the size of the diff from 6.6k lines to 4.7k lines but it makes
it much less likely that there will be problems from running
pgrminclude.

The current patch is here:
http://momjian.us/expire/pgrminclude.diff

I tested the patch on BSD and Linux.

--  Bruce Momjian  <bruce@momjian.us>        http://momjian.us EnterpriseDB
http://enterprisedb.com
 + It's impossible for everything to be true. +


Re: Removal of useless include references

From
Bruce Momjian
Date:
Alvaro Herrera wrote:
> Excerpts from Bruce Momjian's message of vie ago 26 01:35:45 -0300 2011:
> > It has been years since I ran src/tools/pginclude/pgrminclude to remove
> > unnecessary include files.  (I have already fixed things so include
> > files can be compiled on their own.)
> > 
> > The attached patch removes unneeded include references, and marks some
> > includes as needing to be skipped by pgrminclude.
> 
> In btree_gist I think you should remove #include "postgres.h" from the
> .h file and put it in the .c files instead, as is customary.  I think
> that would make the other changes incorrect.  ltree.h and pg_upgrade.h
> also get this wrong.

Thanks, done.

--  Bruce Momjian  <bruce@momjian.us>        http://momjian.us EnterpriseDB
http://enterprisedb.com
 + It's impossible for everything to be true. +


Re: Removal of useless include references

From
Bruce Momjian
Date:
Bruce Momjian wrote:
> Bruce Momjian wrote:
> > Tom Lane wrote:
> > > Bruce Momjian <bruce@momjian.us> writes:
> > > > It has been years since I ran src/tools/pginclude/pgrminclude to remove
> > > > unnecessary include files.  (I have already fixed things so include
> > > > files can be compiled on their own.)
> > > 
> > > > The attached patch removes unneeded include references, and marks some
> > > > includes as needing to be skipped by pgrminclude.
> > > 
> > > > I am sure applying this patch will break builds on some platforms and
> > > > some option combinations so I will monitor the buildfarm when I apply it
> > > > and make adjustments.
> > > 
> > > The last time you did this was in July 2006.  It took us two weeks to
> > > mostly recover, but we were still dealing with some fallout in December,
> > > cf
> > > http://archives.postgresql.org/pgsql-hackers/2006-12/msg00491.php
> > > 
> > > We had the buildfarm then, had had it for a couple years.  The notion
> > > that watching the buildfarm is enough is fully disproven by history.
> > > 
> > > Unless you have a better test plan than last time (which this isn't),
> > > I don't think this should be done at all.  The benefits are microscopic
> > > and the pain real.
> > 
> > I don't have a better plan.  There are #ifdef code blocks that often
> > don't get processed and therefore this can't be done better.  I will
> > abandon the idea.
> 
> OK, try #2.  I already had code that removed #if/#else/#endif code in
> *.h files for better testing, so I extended that to all *.c files.  This
> reduces the size of the diff from 6.6k lines to 4.7k lines but it makes
> it much less likely that there will be problems from running
> pgrminclude.
> 
> The current patch is here:
> 
>     http://momjian.us/expire/pgrminclude.diff
> 
> I tested the patch on BSD and Linux.

I have re-run the script and applied the result, again tested on BSD and
Linux.   I will monitor the buildfarm for possible failures.

This is not something we are going to do regularly, but probably every
five years like this time.

--  Bruce Momjian  <bruce@momjian.us>        http://momjian.us EnterpriseDB
http://enterprisedb.com
 + It's impossible for everything to be true. +


Re: Removal of useless include references

From
Alvaro Herrera
Date:
Excerpts from Bruce Momjian's message of jue sep 01 11:04:33 -0300 2011:
> Bruce Momjian wrote:

> > OK, try #2.  I already had code that removed #if/#else/#endif code in
> > *.h files for better testing, so I extended that to all *.c files.  This
> > reduces the size of the diff from 6.6k lines to 4.7k lines but it makes
> > it much less likely that there will be problems from running
> > pgrminclude.
> > 
> > The current patch is here:
> > 
> >     http://momjian.us/expire/pgrminclude.diff
> > 
> > I tested the patch on BSD and Linux.
> 
> I have re-run the script and applied the result, again tested on BSD and
> Linux.   I will monitor the buildfarm for possible failures.

I think anything of this sort should be tested on Windows too.

-- 
Álvaro Herrera <alvherre@commandprompt.com>
The PostgreSQL Company - Command Prompt, Inc.
PostgreSQL Replication, Consulting, Custom Development, 24x7 support


Re: Removal of useless include references

From
Tom Lane
Date:
Alvaro Herrera <alvherre@commandprompt.com> writes:
> Excerpts from Bruce Momjian's message of jue sep 01 11:04:33 -0300 2011:
>> I have re-run the script and applied the result, again tested on BSD and
>> Linux.   I will monitor the buildfarm for possible failures.

> I think anything of this sort should be tested on Windows too.

Well, if Windows is broken we'll find out soon enough from the
buildfarm.  My recollection from the last go-round is that the pain
points were in non-default #define options that Bruce hadn't tested
and that no buildfarm critter exercised either, such as LOCK_DEBUG.
        regards, tom lane


Re: Removal of useless include references

From
Bruce Momjian
Date:
Alvaro Herrera wrote:
> Excerpts from Bruce Momjian's message of jue sep 01 11:04:33 -0300 2011:
> > Bruce Momjian wrote:
> 
> > > OK, try #2.  I already had code that removed #if/#else/#endif code in
> > > *.h files for better testing, so I extended that to all *.c files.  This
> > > reduces the size of the diff from 6.6k lines to 4.7k lines but it makes
> > > it much less likely that there will be problems from running
> > > pgrminclude.
> > > 
> > > The current patch is here:
> > > 
> > >     http://momjian.us/expire/pgrminclude.diff
> > > 
> > > I tested the patch on BSD and Linux.
> > 
> > I have re-run the script and applied the result, again tested on BSD and
> > Linux.   I will monitor the buildfarm for possible failures.
> 
> I think anything of this sort should be tested on Windows too.

Agreed, but we have so many Windows configurations I figured I would let
the buildfarm test them, no?

--  Bruce Momjian  <bruce@momjian.us>        http://momjian.us EnterpriseDB
http://enterprisedb.com
 + It's impossible for everything to be true. +


Re: Removal of useless include references

From
Bruce Momjian
Date:
Tom Lane wrote:
> Alvaro Herrera <alvherre@commandprompt.com> writes:
> > Excerpts from Bruce Momjian's message of jue sep 01 11:04:33 -0300 2011:
> >> I have re-run the script and applied the result, again tested on BSD and
> >> Linux.   I will monitor the buildfarm for possible failures.
> 
> > I think anything of this sort should be tested on Windows too.
> 
> Well, if Windows is broken we'll find out soon enough from the
> buildfarm.  My recollection from the last go-round is that the pain
> points were in non-default #define options that Bruce hadn't tested
> and that no buildfarm critter exercised either, such as LOCK_DEBUG.

Ah, but this time I only removed includes for files I could compile with
all #if markers removed.  It only got 5.8k diff lines out a possible
6.8k lines, but this seems like an acceptable cost for greater
reliability.

--  Bruce Momjian  <bruce@momjian.us>        http://momjian.us EnterpriseDB
http://enterprisedb.com
 + It's impossible for everything to be true. +