From 93903fcfd13435d31ad5c1b2080c978dbf24b57d Mon Sep 17 00:00:00 2001
From: vignesh <vignesh@localhost.localdomain>
Date: Fri, 15 Nov 2019 09:53:29 +0530
Subject: [PATCH] Make the order of the header file includes consistent.

The basic rule we follow here is to always first include 'postgres.h' or
'postgres_fe.h' whichever is applicable, then system header includes and
then Postgres header includes.  In this, we also follow that all the
Postgres header includes are in order based on their ASCII value.  We
generally follow these rules, but the code has deviated in many places.
This commit makes it consistent.

Author: Vignesh C
Discussion: https://postgr.es/m/CALDaNm2Sznv8RR6Ex-iJO6xAdsxgWhCoETkaYX=+9DW3q0QCfA@mail.gmail.com
---
 contrib/bloom/bloom.h                                    |  2 +-
 contrib/btree_gist/btree_gist.h                          |  2 +-
 contrib/btree_gist/btree_utils_num.h                     |  8 ++++----
 contrib/btree_gist/btree_utils_var.h                     |  3 +--
 contrib/postgres_fdw/postgres_fdw.h                      |  3 +--
 src/backend/libpq/auth.c                                 |  1 -
 src/bin/pg_basebackup/receivelog.h                       |  3 +--
 src/bin/pg_basebackup/streamutil.h                       |  3 +--
 src/bin/pg_dump/pg_backup_archiver.h                     |  4 +---
 src/bin/pg_rewind/datapagemap.h                          |  3 +--
 src/bin/pg_rewind/filemap.h                              |  5 ++---
 src/bin/pg_rewind/pg_rewind.h                            |  4 +---
 src/bin/pg_waldump/pg_waldump.c                          |  2 +-
 src/bin/psql/command.c                                   | 16 +++++++---------
 src/bin/psql/command.h                                   |  3 +--
 src/bin/psql/common.h                                    |  2 +-
 src/bin/psql/prompt.h                                    |  2 +-
 src/bin/psql/settings.h                                  |  3 +--
 src/bin/psql/tab-complete.c                              |  6 +++---
 src/bin/scripts/common.h                                 |  2 +-
 src/include/access/gin_private.h                         |  2 +-
 src/include/access/hio.h                                 |  3 +--
 src/include/access/htup_details.h                        |  2 +-
 src/include/access/relation.h                            |  3 +--
 src/include/access/table.h                               |  3 +--
 src/include/access/twophase.h                            |  2 +-
 src/include/catalog/pg_constraint.h                      |  3 +--
 src/include/catalog/pg_conversion.h                      |  3 +--
 src/include/catalog/pg_operator.h                        |  3 +--
 src/include/catalog/pg_proc.h                            |  3 +--
 src/include/catalog/pg_publication.h                     |  3 +--
 src/include/catalog/pg_replication_origin.h              |  3 +--
 src/include/catalog/pg_subscription_rel.h                |  3 +--
 src/include/catalog/pg_type.h                            |  3 +--
 src/include/commands/event_trigger.h                     |  2 +-
 src/include/executor/nodeBitmapHeapscan.h                |  2 +-
 src/include/executor/nodeIndexonlyscan.h                 |  2 +-
 src/include/executor/tuptable.h                          |  2 +-
 src/include/funcapi.h                                    |  3 +--
 src/include/jit/llvmjit.h                                |  4 +---
 src/include/nodes/execnodes.h                            |  7 +++----
 src/include/replication/decode.h                         |  2 +-
 src/include/replication/logical.h                        |  3 +--
 src/include/replication/walreceiver.h                    |  2 +-
 src/include/rewrite/rewriteHandler.h                     |  2 +-
 src/include/statistics/extended_stats_internal.h         |  3 +--
 src/include/storage/buf_internals.h                      |  3 +--
 src/include/storage/condition_variable.h                 |  2 +-
 src/include/storage/lock.h                               |  3 +--
 src/include/storage/lwlock.h                             |  2 +-
 src/include/storage/standby.h                            |  2 +-
 src/include/tsearch/ts_locale.h                          |  2 +-
 src/include/utils/date.h                                 |  2 +-
 src/include/utils/jsonpath.h                             |  2 +-
 src/include/utils/pg_lsn.h                               |  2 +-
 src/include/utils/xml.h                                  |  2 +-
 src/interfaces/ecpg/ecpglib/descriptor.c                 |  2 +-
 src/interfaces/ecpg/ecpglib/ecpglib_extern.h             |  6 +++---
 src/interfaces/ecpg/ecpglib/misc.c                       |  2 +-
 src/interfaces/ecpg/include/ecpglib.h                    |  5 +++--
 src/interfaces/ecpg/preproc/preproc_extern.h             |  3 +--
 src/pl/plperl/plperl.c                                   |  5 ++---
 src/pl/plpython/plpy_cursorobject.c                      |  8 ++------
 src/pl/plpython/plpy_elog.c                              |  6 +-----
 src/pl/plpython/plpy_exec.c                              | 16 ++++++----------
 src/pl/plpython/plpy_main.c                              | 16 ++++++----------
 src/pl/plpython/plpy_planobject.c                        |  7 ++-----
 src/pl/plpython/plpy_plpymodule.c                        | 12 ++++--------
 src/pl/plpython/plpy_procedure.c                         | 12 ++++--------
 src/pl/plpython/plpy_resultobject.c                      |  6 ++----
 src/pl/plpython/plpy_spi.c                               | 12 ++++--------
 src/pl/plpython/plpy_spi.h                               |  3 +--
 src/pl/plpython/plpy_subxactobject.c                     | 10 +++-------
 src/pl/plpython/plpy_subxactobject.h                     |  3 +--
 src/pl/plpython/plpy_typeio.c                            | 12 ++++--------
 src/pl/plpython/plpy_typeio.h                            |  3 +--
 src/pl/plpython/plpy_util.c                              | 10 +++-------
 .../modules/test_ginpostinglist/test_ginpostinglist.c    |  2 +-
 78 files changed, 125 insertions(+), 208 deletions(-)

diff --git a/contrib/bloom/bloom.h b/contrib/bloom/bloom.h
index 010148e..a717998 100644
--- a/contrib/bloom/bloom.h
+++ b/contrib/bloom/bloom.h
@@ -17,8 +17,8 @@
 #include "access/generic_xlog.h"
 #include "access/itup.h"
 #include "access/xlog.h"
-#include "nodes/pathnodes.h"
 #include "fmgr.h"
+#include "nodes/pathnodes.h"
 
 /* Support procedures numbers */
 #define BLOOM_HASH_PROC			1
diff --git a/contrib/btree_gist/btree_gist.h b/contrib/btree_gist/btree_gist.h
index 011285a..14c7c8e 100644
--- a/contrib/btree_gist/btree_gist.h
+++ b/contrib/btree_gist/btree_gist.h
@@ -4,8 +4,8 @@
 #ifndef __BTREE_GIST_H__
 #define __BTREE_GIST_H__
 
-#include "fmgr.h"
 #include "access/nbtree.h"
+#include "fmgr.h"
 
 #define BtreeGistNotEqualStrategyNumber 6
 
diff --git a/contrib/btree_gist/btree_utils_num.h b/contrib/btree_gist/btree_utils_num.h
index 50907b3..1fedfbe 100644
--- a/contrib/btree_gist/btree_utils_num.h
+++ b/contrib/btree_gist/btree_utils_num.h
@@ -4,13 +4,13 @@
 #ifndef __BTREE_UTILS_NUM_H__
 #define __BTREE_UTILS_NUM_H__
 
-#include "btree_gist.h"
-#include "access/gist.h"
-#include "utils/rel.h"
-
 #include <math.h>
 #include <float.h>
 
+#include "access/gist.h"
+#include "btree_gist.h"
+#include "utils/rel.h"
+
 typedef char GBT_NUMKEY;
 
 /* Better readable key */
diff --git a/contrib/btree_gist/btree_utils_var.h b/contrib/btree_gist/btree_utils_var.h
index 1f2ca43..2f8def6 100644
--- a/contrib/btree_gist/btree_utils_var.h
+++ b/contrib/btree_gist/btree_utils_var.h
@@ -4,9 +4,8 @@
 #ifndef __BTREE_UTILS_VAR_H__
 #define __BTREE_UTILS_VAR_H__
 
-#include "btree_gist.h"
-
 #include "access/gist.h"
+#include "btree_gist.h"
 #include "mb/pg_wchar.h"
 
 /* Variable length key */
diff --git a/contrib/postgres_fdw/postgres_fdw.h b/contrib/postgres_fdw/postgres_fdw.h
index 6acb7dc..bdefe0c 100644
--- a/contrib/postgres_fdw/postgres_fdw.h
+++ b/contrib/postgres_fdw/postgres_fdw.h
@@ -15,11 +15,10 @@
 
 #include "foreign/foreign.h"
 #include "lib/stringinfo.h"
+#include "libpq-fe.h"
 #include "nodes/pathnodes.h"
 #include "utils/relcache.h"
 
-#include "libpq-fe.h"
-
 /*
  * FDW-specific planner information kept in RelOptInfo.fdw_private for a
  * postgres_fdw foreign table.  For a baserel, this struct is created by
diff --git a/src/backend/libpq/auth.c b/src/backend/libpq/auth.c
index 909d736..c12b810 100644
--- a/src/backend/libpq/auth.c
+++ b/src/backend/libpq/auth.c
@@ -39,7 +39,6 @@
 #include "utils/memutils.h"
 #include "utils/timestamp.h"
 
-
 /*----------------------------------------------------------------
  * Global authentication functions
  *----------------------------------------------------------------
diff --git a/src/bin/pg_basebackup/receivelog.h b/src/bin/pg_basebackup/receivelog.h
index b6e2743..edf1ce6 100644
--- a/src/bin/pg_basebackup/receivelog.h
+++ b/src/bin/pg_basebackup/receivelog.h
@@ -12,11 +12,10 @@
 #ifndef RECEIVELOG_H
 #define RECEIVELOG_H
 
+#include "access/xlogdefs.h"
 #include "libpq-fe.h"
 #include "walmethods.h"
 
-#include "access/xlogdefs.h"
-
 /*
  * Called before trying to read more data or when a segment is
  * finished. Return true to stop streaming.
diff --git a/src/bin/pg_basebackup/streamutil.h b/src/bin/pg_basebackup/streamutil.h
index a756eee..1edfc94 100644
--- a/src/bin/pg_basebackup/streamutil.h
+++ b/src/bin/pg_basebackup/streamutil.h
@@ -12,10 +12,9 @@
 #ifndef STREAMUTIL_H
 #define STREAMUTIL_H
 
-#include "libpq-fe.h"
-
 #include "access/xlogdefs.h"
 #include "datatype/timestamp.h"
+#include "libpq-fe.h"
 
 extern const char *progname;
 extern char *connection_string;
diff --git a/src/bin/pg_dump/pg_backup_archiver.h b/src/bin/pg_dump/pg_backup_archiver.h
index fa2c6ef..6768f92 100644
--- a/src/bin/pg_dump/pg_backup_archiver.h
+++ b/src/bin/pg_dump/pg_backup_archiver.h
@@ -24,12 +24,10 @@
 #ifndef __PG_BACKUP_ARCHIVE__
 #define __PG_BACKUP_ARCHIVE__
 
-
 #include <time.h>
 
-#include "pg_backup.h"
-
 #include "libpq-fe.h"
+#include "pg_backup.h"
 #include "pqexpbuffer.h"
 
 #define LOBBUFSIZE 16384
diff --git a/src/bin/pg_rewind/datapagemap.h b/src/bin/pg_rewind/datapagemap.h
index c2baaae..d5bcfa6 100644
--- a/src/bin/pg_rewind/datapagemap.h
+++ b/src/bin/pg_rewind/datapagemap.h
@@ -9,9 +9,8 @@
 #ifndef DATAPAGEMAP_H
 #define DATAPAGEMAP_H
 
-#include "storage/relfilenode.h"
 #include "storage/block.h"
-
+#include "storage/relfilenode.h"
 
 struct datapagemap
 {
diff --git a/src/bin/pg_rewind/filemap.h b/src/bin/pg_rewind/filemap.h
index 5882284..0aa822d 100644
--- a/src/bin/pg_rewind/filemap.h
+++ b/src/bin/pg_rewind/filemap.h
@@ -8,10 +8,9 @@
 #ifndef FILEMAP_H
 #define FILEMAP_H
 
-#include "storage/relfilenode.h"
-#include "storage/block.h"
-
 #include "datapagemap.h"
+#include "storage/block.h"
+#include "storage/relfilenode.h"
 
 /*
  * For every file found in the local or remote system, we have a file entry
diff --git a/src/bin/pg_rewind/pg_rewind.h b/src/bin/pg_rewind/pg_rewind.h
index aa3a0ce..360b2b3 100644
--- a/src/bin/pg_rewind/pg_rewind.h
+++ b/src/bin/pg_rewind/pg_rewind.h
@@ -11,15 +11,13 @@
 #ifndef PG_REWIND_H
 #define PG_REWIND_H
 
-#include "datapagemap.h"
-
 #include "access/timeline.h"
 #include "common/logging.h"
+#include "datapagemap.h"
 #include "libpq-fe.h"
 #include "storage/block.h"
 #include "storage/relfilenode.h"
 
-
 /* Configuration options */
 extern char *datadir_target;
 extern char *datadir_source;
diff --git a/src/bin/pg_waldump/pg_waldump.c b/src/bin/pg_waldump/pg_waldump.c
index 1524e5e..d6695f7 100644
--- a/src/bin/pg_waldump/pg_waldump.c
+++ b/src/bin/pg_waldump/pg_waldump.c
@@ -16,10 +16,10 @@
 #include <sys/stat.h>
 #include <unistd.h>
 
+#include "access/transam.h"
 #include "access/xlog_internal.h"
 #include "access/xlogreader.h"
 #include "access/xlogrecord.h"
-#include "access/transam.h"
 #include "common/fe_memutils.h"
 #include "common/logging.h"
 #include "getopt_long.h"
diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c
index b981ae8..a9299a9 100644
--- a/src/bin/psql/command.c
+++ b/src/bin/psql/command.c
@@ -6,7 +6,6 @@
  * src/bin/psql/command.c
  */
 #include "postgres_fe.h"
-#include "command.h"
 
 #include <ctype.h>
 #include <time.h>
@@ -24,22 +23,21 @@
 #endif
 
 #include "catalog/pg_class_d.h"
-#include "portability/instr_time.h"
-
-#include "libpq-fe.h"
-#include "pqexpbuffer.h"
-#include "common/logging.h"
-#include "fe_utils/print.h"
-#include "fe_utils/string_utils.h"
-
+#include "command.h"
 #include "common.h"
+#include "common/logging.h"
 #include "copy.h"
 #include "crosstabview.h"
 #include "describe.h"
+#include "fe_utils/print.h"
+#include "fe_utils/string_utils.h"
 #include "help.h"
 #include "input.h"
 #include "large_obj.h"
+#include "libpq-fe.h"
 #include "mainloop.h"
+#include "portability/instr_time.h"
+#include "pqexpbuffer.h"
 #include "psqlscanslash.h"
 #include "settings.h"
 #include "variables.h"
diff --git a/src/bin/psql/command.h b/src/bin/psql/command.h
index 33791b6..6d39b90 100644
--- a/src/bin/psql/command.h
+++ b/src/bin/psql/command.h
@@ -8,10 +8,9 @@
 #ifndef COMMAND_H
 #define COMMAND_H
 
+#include "fe_utils/conditional.h"
 #include "fe_utils/print.h"
 #include "fe_utils/psqlscan.h"
-#include "fe_utils/conditional.h"
-
 
 typedef enum _backslashResult
 {
diff --git a/src/bin/psql/common.h b/src/bin/psql/common.h
index 282a520..292dc54 100644
--- a/src/bin/psql/common.h
+++ b/src/bin/psql/common.h
@@ -10,9 +10,9 @@
 
 #include <setjmp.h>
 
-#include "libpq-fe.h"
 #include "fe_utils/print.h"
 #include "fe_utils/psqlscan.h"
+#include "libpq-fe.h"
 
 extern bool openQueryOutputFile(const char *fname, FILE **fout, bool *is_pipe);
 extern bool setQFout(const char *fname);
diff --git a/src/bin/psql/prompt.h b/src/bin/psql/prompt.h
index 905ee3d..683e361 100644
--- a/src/bin/psql/prompt.h
+++ b/src/bin/psql/prompt.h
@@ -8,9 +8,9 @@
 #ifndef PROMPT_H
 #define PROMPT_H
 
+#include "fe_utils/conditional.h"
 /* enum promptStatus_t is now defined by psqlscan.h */
 #include "fe_utils/psqlscan.h"
-#include "fe_utils/conditional.h"
 
 char	   *get_prompt(promptStatus_t status, ConditionalStack cstack);
 
diff --git a/src/bin/psql/settings.h b/src/bin/psql/settings.h
index 5be5091..7cd6d5f 100644
--- a/src/bin/psql/settings.h
+++ b/src/bin/psql/settings.h
@@ -8,9 +8,8 @@
 #ifndef SETTINGS_H
 #define SETTINGS_H
 
-
-#include "variables.h"
 #include "fe_utils/print.h"
+#include "variables.h"
 
 #define DEFAULT_CSV_FIELD_SEP ','
 #define DEFAULT_FIELD_SEP "|"
diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
index 98c917b..8a6bfa5 100644
--- a/src/bin/psql/tab-complete.c
+++ b/src/bin/psql/tab-complete.c
@@ -33,8 +33,9 @@
  */
 
 #include "postgres_fe.h"
-#include "tab-complete.h"
+
 #include "input.h"
+#include "tab-complete.h"
 
 /* If we don't have this, we might as well forget about the whole thing: */
 #ifdef USE_READLINE
@@ -43,10 +44,9 @@
 
 #include "catalog/pg_am_d.h"
 #include "catalog/pg_class_d.h"
-
+#include "common.h"
 #include "libpq-fe.h"
 #include "pqexpbuffer.h"
-#include "common.h"
 #include "settings.h"
 #include "stringutils.h"
 
diff --git a/src/bin/scripts/common.h b/src/bin/scripts/common.h
index f36b26a..b8580f9 100644
--- a/src/bin/scripts/common.h
+++ b/src/bin/scripts/common.h
@@ -10,8 +10,8 @@
 #define COMMON_H
 
 #include "common/username.h"
-#include "libpq-fe.h"
 #include "getopt_long.h"		/* pgrminclude ignore */
+#include "libpq-fe.h"
 #include "pqexpbuffer.h"		/* pgrminclude ignore */
 
 enum trivalue
diff --git a/src/include/access/gin_private.h b/src/include/access/gin_private.h
index 78fcd82..7d0cbcc 100644
--- a/src/include/access/gin_private.h
+++ b/src/include/access/gin_private.h
@@ -15,8 +15,8 @@
 #include "access/ginblock.h"
 #include "access/itup.h"
 #include "fmgr.h"
-#include "storage/bufmgr.h"
 #include "lib/rbtree.h"
+#include "storage/bufmgr.h"
 
 /*
  * Storage type for GIN's reloptions
diff --git a/src/include/access/hio.h b/src/include/access/hio.h
index dbaabcc..ad6da6d 100644
--- a/src/include/access/hio.h
+++ b/src/include/access/hio.h
@@ -15,9 +15,8 @@
 #define HIO_H
 
 #include "access/htup.h"
-#include "utils/relcache.h"
 #include "storage/buf.h"
-
+#include "utils/relcache.h"
 
 /*
  * state for bulk inserts --- private to heapam.c and hio.c
diff --git a/src/include/access/htup_details.h b/src/include/access/htup_details.h
index 66d61fd..7e94719 100644
--- a/src/include/access/htup_details.h
+++ b/src/include/access/htup_details.h
@@ -15,9 +15,9 @@
 #define HTUP_DETAILS_H
 
 #include "access/htup.h"
+#include "access/transam.h"
 #include "access/tupdesc.h"
 #include "access/tupmacs.h"
-#include "access/transam.h"
 #include "storage/bufpage.h"
 
 /*
diff --git a/src/include/access/relation.h b/src/include/access/relation.h
index 38acaa5..0a1de35 100644
--- a/src/include/access/relation.h
+++ b/src/include/access/relation.h
@@ -15,9 +15,8 @@
 #define ACCESS_RELATION_H
 
 #include "nodes/primnodes.h"
-#include "utils/relcache.h"
 #include "storage/lockdefs.h"
-
+#include "utils/relcache.h"
 
 extern Relation relation_open(Oid relationId, LOCKMODE lockmode);
 extern Relation try_relation_open(Oid relationId, LOCKMODE lockmode);
diff --git a/src/include/access/table.h b/src/include/access/table.h
index cb9b438..071b254 100644
--- a/src/include/access/table.h
+++ b/src/include/access/table.h
@@ -15,9 +15,8 @@
 #define TABLE_H
 
 #include "nodes/primnodes.h"
-#include "utils/relcache.h"
 #include "storage/lockdefs.h"
-
+#include "utils/relcache.h"
 
 extern Relation table_open(Oid relationId, LOCKMODE lockmode);
 extern Relation table_openrv(const RangeVar *relation, LOCKMODE lockmode);
diff --git a/src/include/access/twophase.h b/src/include/access/twophase.h
index 1093085..02b5315 100644
--- a/src/include/access/twophase.h
+++ b/src/include/access/twophase.h
@@ -14,8 +14,8 @@
 #ifndef TWOPHASE_H
 #define TWOPHASE_H
 
-#include "access/xlogdefs.h"
 #include "access/xact.h"
+#include "access/xlogdefs.h"
 #include "datatype/timestamp.h"
 #include "storage/lock.h"
 
diff --git a/src/include/catalog/pg_constraint.h b/src/include/catalog/pg_constraint.h
index c1e60c7..cbb5d9a 100644
--- a/src/include/catalog/pg_constraint.h
+++ b/src/include/catalog/pg_constraint.h
@@ -18,10 +18,9 @@
 #ifndef PG_CONSTRAINT_H
 #define PG_CONSTRAINT_H
 
+#include "catalog/dependency.h"
 #include "catalog/genbki.h"
 #include "catalog/pg_constraint_d.h"
-
-#include "catalog/dependency.h"
 #include "nodes/pg_list.h"
 
 /* ----------------
diff --git a/src/include/catalog/pg_conversion.h b/src/include/catalog/pg_conversion.h
index 49c7070..fc523c2 100644
--- a/src/include/catalog/pg_conversion.h
+++ b/src/include/catalog/pg_conversion.h
@@ -18,9 +18,8 @@
 #define PG_CONVERSION_H
 
 #include "catalog/genbki.h"
-#include "catalog/pg_conversion_d.h"
-
 #include "catalog/objectaddress.h"
+#include "catalog/pg_conversion_d.h"
 
 /* ----------------
  *		pg_conversion definition.  cpp turns this into
diff --git a/src/include/catalog/pg_operator.h b/src/include/catalog/pg_operator.h
index 7c4f686..3157fc5 100644
--- a/src/include/catalog/pg_operator.h
+++ b/src/include/catalog/pg_operator.h
@@ -19,9 +19,8 @@
 #define PG_OPERATOR_H
 
 #include "catalog/genbki.h"
-#include "catalog/pg_operator_d.h"
-
 #include "catalog/objectaddress.h"
+#include "catalog/pg_operator_d.h"
 #include "nodes/pg_list.h"
 
 /* ----------------
diff --git a/src/include/catalog/pg_proc.h b/src/include/catalog/pg_proc.h
index dc29c06..e6c1909 100644
--- a/src/include/catalog/pg_proc.h
+++ b/src/include/catalog/pg_proc.h
@@ -18,9 +18,8 @@
 #define PG_PROC_H
 
 #include "catalog/genbki.h"
-#include "catalog/pg_proc_d.h"
-
 #include "catalog/objectaddress.h"
+#include "catalog/pg_proc_d.h"
 #include "nodes/pg_list.h"
 
 /* ----------------
diff --git a/src/include/catalog/pg_publication.h b/src/include/catalog/pg_publication.h
index 20a2f0a..ea22aa6 100644
--- a/src/include/catalog/pg_publication.h
+++ b/src/include/catalog/pg_publication.h
@@ -18,9 +18,8 @@
 #define PG_PUBLICATION_H
 
 #include "catalog/genbki.h"
-#include "catalog/pg_publication_d.h"
-
 #include "catalog/objectaddress.h"
+#include "catalog/pg_publication_d.h"
 
 /* ----------------
  *		pg_publication definition.  cpp turns this into
diff --git a/src/include/catalog/pg_replication_origin.h b/src/include/catalog/pg_replication_origin.h
index b768584..613d07e 100644
--- a/src/include/catalog/pg_replication_origin.h
+++ b/src/include/catalog/pg_replication_origin.h
@@ -18,11 +18,10 @@
 #ifndef PG_REPLICATION_ORIGIN_H
 #define PG_REPLICATION_ORIGIN_H
 
+#include "access/xlogdefs.h"
 #include "catalog/genbki.h"
 #include "catalog/pg_replication_origin_d.h"
 
-#include "access/xlogdefs.h"
-
 /* ----------------
  *		pg_replication_origin.  cpp turns this into
  *		typedef struct FormData_pg_replication_origin
diff --git a/src/include/catalog/pg_subscription_rel.h b/src/include/catalog/pg_subscription_rel.h
index f7df814..21b4ac2 100644
--- a/src/include/catalog/pg_subscription_rel.h
+++ b/src/include/catalog/pg_subscription_rel.h
@@ -18,10 +18,9 @@
 #ifndef PG_SUBSCRIPTION_REL_H
 #define PG_SUBSCRIPTION_REL_H
 
+#include "access/xlogdefs.h"
 #include "catalog/genbki.h"
 #include "catalog/pg_subscription_rel_d.h"
-
-#include "access/xlogdefs.h"
 #include "nodes/pg_list.h"
 
 /* ----------------
diff --git a/src/include/catalog/pg_type.h b/src/include/catalog/pg_type.h
index 2a584b4..0c273a0 100644
--- a/src/include/catalog/pg_type.h
+++ b/src/include/catalog/pg_type.h
@@ -19,9 +19,8 @@
 #define PG_TYPE_H
 
 #include "catalog/genbki.h"
-#include "catalog/pg_type_d.h"
-
 #include "catalog/objectaddress.h"
+#include "catalog/pg_type_d.h"
 #include "nodes/nodes.h"
 
 /* ----------------
diff --git a/src/include/commands/event_trigger.h b/src/include/commands/event_trigger.h
index 575e924..6eeb720 100644
--- a/src/include/commands/event_trigger.h
+++ b/src/include/commands/event_trigger.h
@@ -17,8 +17,8 @@
 #include "catalog/objectaddress.h"
 #include "catalog/pg_event_trigger.h"
 #include "nodes/parsenodes.h"
-#include "utils/aclchk_internal.h"
 #include "tcop/deparse_utility.h"
+#include "utils/aclchk_internal.h"
 
 typedef struct EventTriggerData
 {
diff --git a/src/include/executor/nodeBitmapHeapscan.h b/src/include/executor/nodeBitmapHeapscan.h
index 112def1..2c31d6f 100644
--- a/src/include/executor/nodeBitmapHeapscan.h
+++ b/src/include/executor/nodeBitmapHeapscan.h
@@ -14,8 +14,8 @@
 #ifndef NODEBITMAPHEAPSCAN_H
 #define NODEBITMAPHEAPSCAN_H
 
-#include "nodes/execnodes.h"
 #include "access/parallel.h"
+#include "nodes/execnodes.h"
 
 extern BitmapHeapScanState *ExecInitBitmapHeapScan(BitmapHeapScan *node, EState *estate, int eflags);
 extern void ExecEndBitmapHeapScan(BitmapHeapScanState *node);
diff --git a/src/include/executor/nodeIndexonlyscan.h b/src/include/executor/nodeIndexonlyscan.h
index 644166b..d85cd12 100644
--- a/src/include/executor/nodeIndexonlyscan.h
+++ b/src/include/executor/nodeIndexonlyscan.h
@@ -14,8 +14,8 @@
 #ifndef NODEINDEXONLYSCAN_H
 #define NODEINDEXONLYSCAN_H
 
-#include "nodes/execnodes.h"
 #include "access/parallel.h"
+#include "nodes/execnodes.h"
 
 extern IndexOnlyScanState *ExecInitIndexOnlyScan(IndexOnlyScan *node, EState *estate, int eflags);
 extern void ExecEndIndexOnlyScan(IndexOnlyScanState *node);
diff --git a/src/include/executor/tuptable.h b/src/include/executor/tuptable.h
index b7f9772..04feaba 100644
--- a/src/include/executor/tuptable.h
+++ b/src/include/executor/tuptable.h
@@ -15,9 +15,9 @@
 #define TUPTABLE_H
 
 #include "access/htup.h"
+#include "access/htup_details.h"
 #include "access/sysattr.h"
 #include "access/tupdesc.h"
-#include "access/htup_details.h"
 #include "storage/buf.h"
 
 /*----------
diff --git a/src/include/funcapi.h b/src/include/funcapi.h
index 1a88b52..1aa1f4d 100644
--- a/src/include/funcapi.h
+++ b/src/include/funcapi.h
@@ -17,11 +17,10 @@
 #ifndef FUNCAPI_H
 #define FUNCAPI_H
 
-#include "fmgr.h"
 #include "access/tupdesc.h"
 #include "executor/executor.h"
 #include "executor/tuptable.h"
-
+#include "fmgr.h"
 
 /*-------------------------------------------------------------------------
  *	Support to ease writing Functions returning composite types
diff --git a/src/include/jit/llvmjit.h b/src/include/jit/llvmjit.h
index 6178864..8b441df 100644
--- a/src/include/jit/llvmjit.h
+++ b/src/include/jit/llvmjit.h
@@ -30,12 +30,10 @@ extern "C"
 {
 #endif
 
-
+#include "access/tupdesc.h"
 #include "fmgr.h"
 #include "jit/jit.h"
 #include "nodes/pg_list.h"
-#include "access/tupdesc.h"
-
 
 typedef struct LLVMJitContext
 {
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index 44f7608..6eb6472 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -20,18 +20,17 @@
 #include "lib/pairingheap.h"
 #include "nodes/params.h"
 #include "nodes/plannodes.h"
+#include "nodes/tidbitmap.h"
 #include "partitioning/partdefs.h"
+#include "storage/condition_variable.h"
 #include "utils/hsearch.h"
 #include "utils/queryenvironment.h"
 #include "utils/reltrigger.h"
 #include "utils/sharedtuplestore.h"
 #include "utils/snapshot.h"
 #include "utils/sortsupport.h"
-#include "utils/tuplestore.h"
 #include "utils/tuplesort.h"
-#include "nodes/tidbitmap.h"
-#include "storage/condition_variable.h"
-
+#include "utils/tuplestore.h"
 
 struct PlanState;				/* forward references in this file */
 struct PartitionRoutingInfo;
diff --git a/src/include/replication/decode.h b/src/include/replication/decode.h
index 89689a0..3f87724 100644
--- a/src/include/replication/decode.h
+++ b/src/include/replication/decode.h
@@ -11,8 +11,8 @@
 
 #include "access/xlogreader.h"
 #include "access/xlogrecord.h"
-#include "replication/reorderbuffer.h"
 #include "replication/logical.h"
+#include "replication/reorderbuffer.h"
 
 void		LogicalDecodingProcessRecord(LogicalDecodingContext *ctx,
 										 XLogReaderState *record);
diff --git a/src/include/replication/logical.h b/src/include/replication/logical.h
index 31c796b..6879a2e 100644
--- a/src/include/replication/logical.h
+++ b/src/include/replication/logical.h
@@ -9,11 +9,10 @@
 #ifndef LOGICAL_H
 #define LOGICAL_H
 
-#include "replication/slot.h"
-
 #include "access/xlog.h"
 #include "access/xlogreader.h"
 #include "replication/output_plugin.h"
+#include "replication/slot.h"
 
 struct LogicalDecodingContext;
 
diff --git a/src/include/replication/walreceiver.h b/src/include/replication/walreceiver.h
index e12a934..41714ea 100644
--- a/src/include/replication/walreceiver.h
+++ b/src/include/replication/walreceiver.h
@@ -15,11 +15,11 @@
 #include "access/xlog.h"
 #include "access/xlogdefs.h"
 #include "getaddrinfo.h"		/* for NI_MAXHOST */
+#include "pgtime.h"
 #include "replication/logicalproto.h"
 #include "replication/walsender.h"
 #include "storage/latch.h"
 #include "storage/spin.h"
-#include "pgtime.h"
 #include "utils/tuplestore.h"
 
 /* user-settable parameters */
diff --git a/src/include/rewrite/rewriteHandler.h b/src/include/rewrite/rewriteHandler.h
index c55fe81..e5b66e1 100644
--- a/src/include/rewrite/rewriteHandler.h
+++ b/src/include/rewrite/rewriteHandler.h
@@ -14,8 +14,8 @@
 #ifndef REWRITEHANDLER_H
 #define REWRITEHANDLER_H
 
-#include "utils/relcache.h"
 #include "nodes/parsenodes.h"
+#include "utils/relcache.h"
 
 extern List *QueryRewrite(Query *parsetree);
 extern void AcquireRewriteLocks(Query *parsetree,
diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h
index fcf4e8a..8ff1ef3 100644
--- a/src/include/statistics/extended_stats_internal.h
+++ b/src/include/statistics/extended_stats_internal.h
@@ -14,9 +14,8 @@
 #ifndef EXTENDED_STATS_INTERNAL_H
 #define EXTENDED_STATS_INTERNAL_H
 
-#include "utils/sortsupport.h"
 #include "statistics/statistics.h"
-
+#include "utils/sortsupport.h"
 
 typedef struct
 {
diff --git a/src/include/storage/buf_internals.h b/src/include/storage/buf_internals.h
index 6ffe184..d540c0a 100644
--- a/src/include/storage/buf_internals.h
+++ b/src/include/storage/buf_internals.h
@@ -15,17 +15,16 @@
 #ifndef BUFMGR_INTERNALS_H
 #define BUFMGR_INTERNALS_H
 
+#include "port/atomics.h"
 #include "storage/buf.h"
 #include "storage/bufmgr.h"
 #include "storage/latch.h"
 #include "storage/lwlock.h"
 #include "storage/shmem.h"
 #include "storage/smgr.h"
-#include "port/atomics.h"
 #include "storage/spin.h"
 #include "utils/relcache.h"
 
-
 /*
  * Buffer state is a single 32-bit variable where following data is combined.
  *
diff --git a/src/include/storage/condition_variable.h b/src/include/storage/condition_variable.h
index ee06e05..0aad8cc 100644
--- a/src/include/storage/condition_variable.h
+++ b/src/include/storage/condition_variable.h
@@ -22,8 +22,8 @@
 #ifndef CONDITION_VARIABLE_H
 #define CONDITION_VARIABLE_H
 
-#include "storage/s_lock.h"
 #include "storage/proclist_types.h"
+#include "storage/s_lock.h"
 
 typedef struct
 {
diff --git a/src/include/storage/lock.h b/src/include/storage/lock.h
index 6efb7a9..e8b50fe 100644
--- a/src/include/storage/lock.h
+++ b/src/include/storage/lock.h
@@ -18,12 +18,11 @@
 #error "lock.h may not be included from frontend code"
 #endif
 
-#include "storage/lockdefs.h"
 #include "storage/backendid.h"
+#include "storage/lockdefs.h"
 #include "storage/lwlock.h"
 #include "storage/shmem.h"
 
-
 /* struct PGPROC is declared in proc.h, but must forward-reference it */
 typedef struct PGPROC PGPROC;
 
diff --git a/src/include/storage/lwlock.h b/src/include/storage/lwlock.h
index f627dfe..f9450da 100644
--- a/src/include/storage/lwlock.h
+++ b/src/include/storage/lwlock.h
@@ -18,9 +18,9 @@
 #error "lwlock.h may not be included from frontend code"
 #endif
 
+#include "port/atomics.h"
 #include "storage/proclist_types.h"
 #include "storage/s_lock.h"
-#include "port/atomics.h"
 
 struct PGPROC;
 
diff --git a/src/include/storage/standby.h b/src/include/storage/standby.h
index a3f8f82..6ba90c6 100644
--- a/src/include/storage/standby.h
+++ b/src/include/storage/standby.h
@@ -14,10 +14,10 @@
 #ifndef STANDBY_H
 #define STANDBY_H
 
-#include "storage/standbydefs.h"
 #include "storage/lock.h"
 #include "storage/procsignal.h"
 #include "storage/relfilenode.h"
+#include "storage/standbydefs.h"
 
 /* User-settable GUC parameters */
 extern int	vacuum_defer_cleanup_age;
diff --git a/src/include/tsearch/ts_locale.h b/src/include/tsearch/ts_locale.h
index 9e8cd77..b7db7b2 100644
--- a/src/include/tsearch/ts_locale.h
+++ b/src/include/tsearch/ts_locale.h
@@ -15,8 +15,8 @@
 #include <ctype.h>
 #include <limits.h>
 
-#include "utils/pg_locale.h"
 #include "mb/pg_wchar.h"
+#include "utils/pg_locale.h"
 
 /*
  * towlower() and friends should be in <wctype.h>, but some pre-C99 systems
diff --git a/src/include/utils/date.h b/src/include/utils/date.h
index 7352b1f..6015983 100644
--- a/src/include/utils/date.h
+++ b/src/include/utils/date.h
@@ -16,9 +16,9 @@
 
 #include <math.h>
 
+#include "datatype/timestamp.h"
 #include "fmgr.h"
 #include "pgtime.h"
-#include "datatype/timestamp.h"
 
 typedef int32 DateADT;
 
diff --git a/src/include/utils/jsonpath.h b/src/include/utils/jsonpath.h
index 0f2b08e..9af9ffd 100644
--- a/src/include/utils/jsonpath.h
+++ b/src/include/utils/jsonpath.h
@@ -15,8 +15,8 @@
 #define JSONPATH_H
 
 #include "fmgr.h"
-#include "utils/jsonb.h"
 #include "nodes/pg_list.h"
+#include "utils/jsonb.h"
 
 typedef struct
 {
diff --git a/src/include/utils/pg_lsn.h b/src/include/utils/pg_lsn.h
index 70d8640..8b371c5 100644
--- a/src/include/utils/pg_lsn.h
+++ b/src/include/utils/pg_lsn.h
@@ -15,8 +15,8 @@
 #ifndef PG_LSN_H
 #define PG_LSN_H
 
-#include "fmgr.h"
 #include "access/xlogdefs.h"
+#include "fmgr.h"
 
 #define DatumGetLSN(X) ((XLogRecPtr) DatumGetInt64(X))
 #define LSNGetDatum(X) (Int64GetDatum((int64) (X)))
diff --git a/src/include/utils/xml.h b/src/include/utils/xml.h
index 90d08b1..69e9a9c 100644
--- a/src/include/utils/xml.h
+++ b/src/include/utils/xml.h
@@ -15,10 +15,10 @@
 #ifndef XML_H
 #define XML_H
 
+#include "executor/tablefunc.h"
 #include "fmgr.h"
 #include "nodes/execnodes.h"
 #include "nodes/primnodes.h"
-#include "executor/tablefunc.h"
 
 typedef struct varlena xmltype;
 
diff --git a/src/interfaces/ecpg/ecpglib/descriptor.c b/src/interfaces/ecpg/ecpglib/descriptor.c
index 7bd0534..f71f539 100644
--- a/src/interfaces/ecpg/ecpglib/descriptor.c
+++ b/src/interfaces/ecpg/ecpglib/descriptor.c
@@ -12,9 +12,9 @@
 #include "ecpglib.h"
 #include "ecpglib_extern.h"
 #include "ecpgtype.h"
+#include "sql3types.h"
 #include "sqlca.h"
 #include "sqlda.h"
-#include "sql3types.h"
 
 static void descriptor_free(struct descriptor *desc);
 
diff --git a/src/interfaces/ecpg/ecpglib/ecpglib_extern.h b/src/interfaces/ecpg/ecpglib/ecpglib_extern.h
index 4bf55fe..1a98dea 100644
--- a/src/interfaces/ecpg/ecpglib/ecpglib_extern.h
+++ b/src/interfaces/ecpg/ecpglib/ecpglib_extern.h
@@ -3,12 +3,12 @@
 #ifndef _ECPG_ECPGLIB_EXTERN_H
 #define _ECPG_ECPGLIB_EXTERN_H
 
+#include "ecpg_config.h"
+#include "ecpgtype.h"
 #include "libpq-fe.h"
 #include "sqlca.h"
-#include "sqlda-native.h"
 #include "sqlda-compat.h"
-#include "ecpg_config.h"
-#include "ecpgtype.h"
+#include "sqlda-native.h"
 
 #ifndef CHAR_BIT
 #include <limits.h>
diff --git a/src/interfaces/ecpg/ecpglib/misc.c b/src/interfaces/ecpg/ecpglib/misc.c
index c4b2183..a07d0df 100644
--- a/src/interfaces/ecpg/ecpglib/misc.c
+++ b/src/interfaces/ecpg/ecpglib/misc.c
@@ -11,11 +11,11 @@
 #include "ecpglib.h"
 #include "ecpglib_extern.h"
 #include "ecpgtype.h"
+#include "pg_config_paths.h"
 #include "pgtypes_date.h"
 #include "pgtypes_interval.h"
 #include "pgtypes_numeric.h"
 #include "pgtypes_timestamp.h"
-#include "pg_config_paths.h"
 #include "sqlca.h"
 
 #ifndef LONG_LONG_MIN
diff --git a/src/interfaces/ecpg/include/ecpglib.h b/src/interfaces/ecpg/include/ecpglib.h
index c65073f..0024010 100644
--- a/src/interfaces/ecpg/include/ecpglib.h
+++ b/src/interfaces/ecpg/include/ecpglib.h
@@ -7,11 +7,12 @@
 #ifndef _ECPGLIB_H
 #define _ECPGLIB_H
 
-#include "libpq-fe.h"
+#include <string.h>
+
 #include "ecpg_config.h"
 #include "ecpgtype.h"
+#include "libpq-fe.h"
 #include "sqlca.h"
-#include <string.h>
 
 /*
  * This is a small extract from c.h since we don't want to leak all postgres
diff --git a/src/interfaces/ecpg/preproc/preproc_extern.h b/src/interfaces/ecpg/preproc/preproc_extern.h
index 323fd5c..51d5f94 100644
--- a/src/interfaces/ecpg/preproc/preproc_extern.h
+++ b/src/interfaces/ecpg/preproc/preproc_extern.h
@@ -3,9 +3,8 @@
 #ifndef _ECPG_PREPROC_EXTERN_H
 #define _ECPG_PREPROC_EXTERN_H
 
-#include "type.h"
-
 #include "common/keywords.h"
+#include "type.h"
 
 #ifndef CHAR_BIT
 #include <limits.h>
diff --git a/src/pl/plperl/plperl.c b/src/pl/plperl/plperl.c
index 90f7cf1..0b224b9 100644
--- a/src/pl/plperl/plperl.c
+++ b/src/pl/plperl/plperl.c
@@ -44,11 +44,10 @@
 #define TEXTDOMAIN PG_TEXTDOMAIN("plperl")
 
 /* perl stuff */
-#include "plperl.h"
-#include "plperl_helpers.h"
-
 /* string literal macros defining chunks of perl code */
 #include "perlchunks.h"
+#include "plperl.h"
+#include "plperl_helpers.h"
 /* defines PLPERL_SET_OPMASK */
 #include "plperl_opmask.h"
 
diff --git a/src/pl/plpython/plpy_cursorobject.c b/src/pl/plpython/plpy_cursorobject.c
index b44ce7e..4c37ff8 100644
--- a/src/pl/plpython/plpy_cursorobject.c
+++ b/src/pl/plpython/plpy_cursorobject.c
@@ -11,19 +11,15 @@
 #include "access/xact.h"
 #include "catalog/pg_type.h"
 #include "mb/pg_wchar.h"
-#include "utils/memutils.h"
-
-#include "plpython.h"
-
 #include "plpy_cursorobject.h"
-
 #include "plpy_elog.h"
 #include "plpy_main.h"
 #include "plpy_planobject.h"
 #include "plpy_procedure.h"
 #include "plpy_resultobject.h"
 #include "plpy_spi.h"
-
+#include "plpython.h"
+#include "utils/memutils.h"
 
 static PyObject *PLy_cursor_query(const char *query);
 static void PLy_cursor_dealloc(PyObject *arg);
diff --git a/src/pl/plpython/plpy_elog.c b/src/pl/plpython/plpy_elog.c
index 15cc444..eb56282 100644
--- a/src/pl/plpython/plpy_elog.c
+++ b/src/pl/plpython/plpy_elog.c
@@ -7,14 +7,10 @@
 #include "postgres.h"
 
 #include "lib/stringinfo.h"
-
-#include "plpython.h"
-
 #include "plpy_elog.h"
-
 #include "plpy_main.h"
 #include "plpy_procedure.h"
-
+#include "plpython.h"
 
 PyObject   *PLy_exc_error = NULL;
 PyObject   *PLy_exc_fatal = NULL;
diff --git a/src/pl/plpython/plpy_exec.c b/src/pl/plpython/plpy_exec.c
index 1aec1b2..c6f6a6f 100644
--- a/src/pl/plpython/plpy_exec.c
+++ b/src/pl/plpython/plpy_exec.c
@@ -12,20 +12,16 @@
 #include "commands/trigger.h"
 #include "executor/spi.h"
 #include "funcapi.h"
-#include "utils/builtins.h"
-#include "utils/lsyscache.h"
-#include "utils/rel.h"
-#include "utils/typcache.h"
-
-#include "plpython.h"
-
-#include "plpy_exec.h"
-
 #include "plpy_elog.h"
+#include "plpy_exec.h"
 #include "plpy_main.h"
 #include "plpy_procedure.h"
 #include "plpy_subxactobject.h"
-
+#include "plpython.h"
+#include "utils/builtins.h"
+#include "utils/lsyscache.h"
+#include "utils/rel.h"
+#include "utils/typcache.h"
 
 /* saved state for a set-returning function */
 typedef struct PLySRFState
diff --git a/src/pl/plpython/plpy_main.c b/src/pl/plpython/plpy_main.c
index 6edfcf2..faaec55 100644
--- a/src/pl/plpython/plpy_main.c
+++ b/src/pl/plpython/plpy_main.c
@@ -12,21 +12,17 @@
 #include "commands/trigger.h"
 #include "executor/spi.h"
 #include "miscadmin.h"
-#include "utils/guc.h"
-#include "utils/memutils.h"
-#include "utils/rel.h"
-#include "utils/syscache.h"
-
-#include "plpython.h"
-
-#include "plpy_main.h"
-
 #include "plpy_elog.h"
 #include "plpy_exec.h"
+#include "plpy_main.h"
 #include "plpy_plpymodule.h"
 #include "plpy_procedure.h"
 #include "plpy_subxactobject.h"
-
+#include "plpython.h"
+#include "utils/guc.h"
+#include "utils/memutils.h"
+#include "utils/rel.h"
+#include "utils/syscache.h"
 
 /*
  * exported functions
diff --git a/src/pl/plpython/plpy_planobject.c b/src/pl/plpython/plpy_planobject.c
index 96ea24c..c23e79f 100644
--- a/src/pl/plpython/plpy_planobject.c
+++ b/src/pl/plpython/plpy_planobject.c
@@ -6,16 +6,13 @@
 
 #include "postgres.h"
 
-#include "plpython.h"
-
-#include "plpy_planobject.h"
-
 #include "plpy_cursorobject.h"
 #include "plpy_elog.h"
+#include "plpy_planobject.h"
 #include "plpy_spi.h"
+#include "plpython.h"
 #include "utils/memutils.h"
 
-
 static void PLy_plan_dealloc(PyObject *arg);
 static PyObject *PLy_plan_cursor(PyObject *self, PyObject *args);
 static PyObject *PLy_plan_execute(PyObject *self, PyObject *args);
diff --git a/src/pl/plpython/plpy_plpymodule.c b/src/pl/plpython/plpy_plpymodule.c
index c80b350..e308c61 100644
--- a/src/pl/plpython/plpy_plpymodule.c
+++ b/src/pl/plpython/plpy_plpymodule.c
@@ -8,21 +8,17 @@
 
 #include "access/xact.h"
 #include "mb/pg_wchar.h"
-#include "utils/builtins.h"
-#include "utils/snapmgr.h"
-
-#include "plpython.h"
-
-#include "plpy_plpymodule.h"
-
 #include "plpy_cursorobject.h"
 #include "plpy_elog.h"
 #include "plpy_main.h"
 #include "plpy_planobject.h"
+#include "plpy_plpymodule.h"
 #include "plpy_resultobject.h"
 #include "plpy_spi.h"
 #include "plpy_subxactobject.h"
-
+#include "plpython.h"
+#include "utils/builtins.h"
+#include "utils/snapmgr.h"
 
 HTAB	   *PLy_spi_exceptions = NULL;
 
diff --git a/src/pl/plpython/plpy_procedure.c b/src/pl/plpython/plpy_procedure.c
index 6e08c03..9e15839 100644
--- a/src/pl/plpython/plpy_procedure.c
+++ b/src/pl/plpython/plpy_procedure.c
@@ -11,6 +11,10 @@
 #include "funcapi.h"
 #include "catalog/pg_proc.h"
 #include "catalog/pg_type.h"
+#include "plpy_elog.h"
+#include "plpy_main.h"
+#include "plpy_procedure.h"
+#include "plpython.h"
 #include "utils/builtins.h"
 #include "utils/hsearch.h"
 #include "utils/inval.h"
@@ -18,14 +22,6 @@
 #include "utils/memutils.h"
 #include "utils/syscache.h"
 
-#include "plpython.h"
-
-#include "plpy_procedure.h"
-
-#include "plpy_elog.h"
-#include "plpy_main.h"
-
-
 static HTAB *PLy_procedure_cache = NULL;
 
 static PLyProcedure *PLy_procedure_create(HeapTuple procTup, Oid fn_oid, bool is_trigger);
diff --git a/src/pl/plpython/plpy_resultobject.c b/src/pl/plpython/plpy_resultobject.c
index 20cf3ed..b31dbda 100644
--- a/src/pl/plpython/plpy_resultobject.c
+++ b/src/pl/plpython/plpy_resultobject.c
@@ -6,11 +6,9 @@
 
 #include "postgres.h"
 
-#include "plpython.h"
-
-#include "plpy_resultobject.h"
 #include "plpy_elog.h"
-
+#include "plpy_resultobject.h"
+#include "plpython.h"
 
 static void PLy_result_dealloc(PyObject *arg);
 static PyObject *PLy_result_colnames(PyObject *self, PyObject *unused);
diff --git a/src/pl/plpython/plpy_spi.c b/src/pl/plpython/plpy_spi.c
index ed2eee0..99c1b4f 100644
--- a/src/pl/plpython/plpy_spi.c
+++ b/src/pl/plpython/plpy_spi.c
@@ -14,20 +14,16 @@
 #include "executor/spi.h"
 #include "mb/pg_wchar.h"
 #include "parser/parse_type.h"
-#include "utils/memutils.h"
-#include "utils/syscache.h"
-
-#include "plpython.h"
-
-#include "plpy_spi.h"
-
 #include "plpy_elog.h"
 #include "plpy_main.h"
 #include "plpy_planobject.h"
 #include "plpy_plpymodule.h"
 #include "plpy_procedure.h"
 #include "plpy_resultobject.h"
-
+#include "plpy_spi.h"
+#include "plpython.h"
+#include "utils/memutils.h"
+#include "utils/syscache.h"
 
 static PyObject *PLy_spi_execute_query(char *query, long limit);
 static PyObject *PLy_spi_execute_fetch_result(SPITupleTable *tuptable,
diff --git a/src/pl/plpython/plpy_spi.h b/src/pl/plpython/plpy_spi.h
index ec7b689..a5e2e60 100644
--- a/src/pl/plpython/plpy_spi.h
+++ b/src/pl/plpython/plpy_spi.h
@@ -5,9 +5,8 @@
 #ifndef PLPY_SPI_H
 #define PLPY_SPI_H
 
-#include "utils/resowner.h"
-
 #include "plpython.h"
+#include "utils/resowner.h"
 
 extern PyObject *PLy_spi_prepare(PyObject *self, PyObject *args);
 extern PyObject *PLy_spi_execute(PyObject *self, PyObject *args);
diff --git a/src/pl/plpython/plpy_subxactobject.c b/src/pl/plpython/plpy_subxactobject.c
index 5dfb8a4..98d7c90 100644
--- a/src/pl/plpython/plpy_subxactobject.c
+++ b/src/pl/plpython/plpy_subxactobject.c
@@ -7,14 +7,10 @@
 #include "postgres.h"
 
 #include "access/xact.h"
-#include "utils/memutils.h"
-
-#include "plpython.h"
-
-#include "plpy_subxactobject.h"
-
 #include "plpy_elog.h"
-
+#include "plpy_subxactobject.h"
+#include "plpython.h"
+#include "utils/memutils.h"
 
 List	   *explicit_subtransactions = NIL;
 
diff --git a/src/pl/plpython/plpy_subxactobject.h b/src/pl/plpython/plpy_subxactobject.h
index 1ee85c0..5b6f863 100644
--- a/src/pl/plpython/plpy_subxactobject.h
+++ b/src/pl/plpython/plpy_subxactobject.h
@@ -6,9 +6,8 @@
 #define PLPY_SUBXACTOBJECT
 
 #include "nodes/pg_list.h"
-#include "utils/resowner.h"
-
 #include "plpython.h"
+#include "utils/resowner.h"
 
 /* a list of nested explicit subtransactions */
 extern List *explicit_subtransactions;
diff --git a/src/pl/plpython/plpy_typeio.c b/src/pl/plpython/plpy_typeio.c
index e1a0524..e734b0d 100644
--- a/src/pl/plpython/plpy_typeio.c
+++ b/src/pl/plpython/plpy_typeio.c
@@ -11,20 +11,16 @@
 #include "funcapi.h"
 #include "mb/pg_wchar.h"
 #include "miscadmin.h"
+#include "plpy_elog.h"
+#include "plpy_main.h"
+#include "plpy_typeio.h"
+#include "plpython.h"
 #include "utils/array.h"
 #include "utils/builtins.h"
 #include "utils/fmgroids.h"
 #include "utils/lsyscache.h"
 #include "utils/memutils.h"
 
-#include "plpython.h"
-
-#include "plpy_typeio.h"
-
-#include "plpy_elog.h"
-#include "plpy_main.h"
-
-
 /* conversion from Datums to Python objects */
 static PyObject *PLyBool_FromBool(PLyDatumToOb *arg, Datum d);
 static PyObject *PLyFloat_FromFloat4(PLyDatumToOb *arg, Datum d);
diff --git a/src/pl/plpython/plpy_typeio.h b/src/pl/plpython/plpy_typeio.h
index 3412a98..d11e6ae 100644
--- a/src/pl/plpython/plpy_typeio.h
+++ b/src/pl/plpython/plpy_typeio.h
@@ -7,9 +7,8 @@
 
 #include "access/htup.h"
 #include "fmgr.h"
-#include "utils/typcache.h"
-
 #include "plpython.h"
+#include "utils/typcache.h"
 
 struct PLyProcedure;			/* avoid requiring plpy_procedure.h here */
 
diff --git a/src/pl/plpython/plpy_util.c b/src/pl/plpython/plpy_util.c
index 2128acb..4a7d726 100644
--- a/src/pl/plpython/plpy_util.c
+++ b/src/pl/plpython/plpy_util.c
@@ -7,14 +7,10 @@
 #include "postgres.h"
 
 #include "mb/pg_wchar.h"
-#include "utils/memutils.h"
-
-#include "plpython.h"
-
-#include "plpy_util.h"
-
 #include "plpy_elog.h"
-
+#include "plpy_util.h"
+#include "plpython.h"
+#include "utils/memutils.h"
 
 /*
  * Convert a Python unicode object to a Python string/bytes object in
diff --git a/src/test/modules/test_ginpostinglist/test_ginpostinglist.c b/src/test/modules/test_ginpostinglist/test_ginpostinglist.c
index 7e9d7de..be318a6 100644
--- a/src/test/modules/test_ginpostinglist/test_ginpostinglist.c
+++ b/src/test/modules/test_ginpostinglist/test_ginpostinglist.c
@@ -12,8 +12,8 @@
  */
 #include "postgres.h"
 
-#include "access/ginblock.h"
 #include "access/gin_private.h"
+#include "access/ginblock.h"
 #include "access/htup_details.h"
 #include "fmgr.h"
 
-- 
1.8.3.1

