Sort header includes in a constent order

Inspired by how PostgreSQL does it we support our includes in the
following order:

1. postgres.h
2. System headers
3. PostgreSQL headers
4. pg_tde headers
5. Frontend/backend specific headers

Within every section we sort includes in alphabetical order where
possible, which right now was everywhere except in keyring_kmip_impl.c.
pull/238/head
Andreas Karlsson 3 months ago committed by Andreas Karlsson
parent 8084e6a35a
commit 1749d8ccd8
  1. 22
      contrib/pg_tde/src/access/pg_tde_tdemap.c
  2. 6
      contrib/pg_tde/src/access/pg_tde_xlog.c
  3. 6
      contrib/pg_tde/src/access/pg_tde_xlog_smgr.c
  4. 28
      contrib/pg_tde/src/catalog/tde_keyring.c
  5. 1
      contrib/pg_tde/src/catalog/tde_keyring_parse_opts.c
  6. 34
      contrib/pg_tde/src/catalog/tde_principal_key.c
  7. 6
      contrib/pg_tde/src/common/pg_tde_shmem.c
  8. 4
      contrib/pg_tde/src/common/pg_tde_utils.c
  9. 23
      contrib/pg_tde/src/encryption/enc_aes.c
  10. 12
      contrib/pg_tde/src/encryption/enc_tde.c
  11. 2
      contrib/pg_tde/src/include/pg_tde_fe.h
  12. 14
      contrib/pg_tde/src/keyring/keyring_api.c
  13. 13
      contrib/pg_tde/src/keyring/keyring_file.c
  14. 2
      contrib/pg_tde/src/keyring/keyring_kmip.c
  15. 1
      contrib/pg_tde/src/keyring/keyring_kmip_impl.c
  16. 17
      contrib/pg_tde/src/keyring/keyring_vault.c
  17. 30
      contrib/pg_tde/src/pg_tde.c
  18. 13
      contrib/pg_tde/src/pg_tde_change_key_provider.c
  19. 36
      contrib/pg_tde/src/pg_tde_event_capture.c
  20. 4
      contrib/pg_tde/src/pg_tde_guc.c
  21. 11
      contrib/pg_tde/src/smgr/pg_tde_smgr.c

@ -1,14 +1,18 @@
#include "postgres.h" #include "postgres.h"
#include "access/pg_tde_tdemap.h"
#include "common/file_perm.h" #include <openssl/err.h>
#include "storage/fd.h" #include <openssl/rand.h>
#include "utils/wait_event.h" #include <unistd.h>
#include "utils/memutils.h"
#include "access/xlog.h" #include "access/xlog.h"
#include "access/xlog_internal.h" #include "access/xlog_internal.h"
#include "access/xloginsert.h" #include "access/xloginsert.h"
#include "utils/builtins.h" #include "common/file_perm.h"
#include "miscadmin.h" #include "miscadmin.h"
#include "storage/fd.h"
#include "utils/builtins.h"
#include "utils/memutils.h"
#include "utils/wait_event.h"
#include "access/pg_tde_tdemap.h" #include "access/pg_tde_tdemap.h"
#include "access/pg_tde_xlog.h" #include "access/pg_tde_xlog.h"
@ -18,12 +22,6 @@
#include "encryption/enc_tde.h" #include "encryption/enc_tde.h"
#include "keyring/keyring_api.h" #include "keyring/keyring_api.h"
#include <openssl/rand.h>
#include <openssl/err.h>
#include <unistd.h>
#include "pg_tde_defines.h"
#ifdef FRONTEND #ifdef FRONTEND
#include "pg_tde_fe.h" #include "pg_tde_fe.h"
#endif #endif

@ -12,19 +12,19 @@
#include "postgres.h" #include "postgres.h"
#include "pg_tde.h"
#include "pg_tde_defines.h"
#include "access/xlog.h" #include "access/xlog.h"
#include "access/xlog_internal.h" #include "access/xlog_internal.h"
#include "access/xloginsert.h" #include "access/xloginsert.h"
#include "catalog/tde_keyring.h"
#include "storage/bufmgr.h" #include "storage/bufmgr.h"
#include "storage/shmem.h" #include "storage/shmem.h"
#include "utils/guc.h" #include "utils/guc.h"
#include "utils/memutils.h" #include "utils/memutils.h"
#include "access/pg_tde_xlog.h" #include "access/pg_tde_xlog.h"
#include "catalog/tde_keyring.h"
#include "encryption/enc_tde.h" #include "encryption/enc_tde.h"
#include "pg_tde.h"
#include "pg_tde_defines.h"
#include "smgr/pg_tde_smgr.h" #include "smgr/pg_tde_smgr.h"
static void tdeheap_rmgr_redo(XLogReaderState *record); static void tdeheap_rmgr_redo(XLogReaderState *record);

@ -12,9 +12,6 @@
#include "postgres.h" #include "postgres.h"
#include "pg_tde.h"
#include "pg_tde_defines.h"
#include "pg_tde_guc.h"
#include "access/xlog.h" #include "access/xlog.h"
#include "access/xlog_internal.h" #include "access/xlog_internal.h"
#include "access/xlog_smgr.h" #include "access/xlog_smgr.h"
@ -28,6 +25,9 @@
#include "access/pg_tde_xlog_smgr.h" #include "access/pg_tde_xlog_smgr.h"
#include "catalog/tde_global_space.h" #include "catalog/tde_global_space.h"
#include "encryption/enc_tde.h" #include "encryption/enc_tde.h"
#include "pg_tde.h"
#include "pg_tde_defines.h"
#include "pg_tde_guc.h"
#ifdef FRONTEND #ifdef FRONTEND
#include "pg_tde_fe.h" #include "pg_tde_fe.h"

@ -9,33 +9,37 @@
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
#include "postgres.h" #include "postgres.h"
#include <unistd.h>
#include "access/skey.h"
#include "access/xlog.h" #include "access/xlog.h"
#include "access/xloginsert.h" #include "access/xloginsert.h"
#include "miscadmin.h"
#include "storage/fd.h"
#include "utils/builtins.h"
#include "utils/fmgroids.h"
#include "utils/lsyscache.h"
#include "utils/memutils.h"
#include "utils/snapmgr.h"
#include "access/pg_tde_xlog.h" #include "access/pg_tde_xlog.h"
#include "catalog/tde_global_space.h" #include "catalog/tde_global_space.h"
#include "catalog/tde_keyring.h" #include "catalog/tde_keyring.h"
#include "catalog/tde_principal_key.h" #include "catalog/tde_principal_key.h"
#include "access/skey.h"
#include "utils/lsyscache.h"
#include "utils/memutils.h"
#include "utils/snapmgr.h"
#include "utils/fmgroids.h"
#include "common/pg_tde_utils.h" #include "common/pg_tde_utils.h"
#include "miscadmin.h"
#include "storage/fd.h"
#include "unistd.h"
#include "utils/builtins.h"
#include "pg_tde.h" #include "pg_tde.h"
#ifndef FRONTEND #ifndef FRONTEND
#include "access/heapam.h" #include "access/heapam.h"
#include "common/pg_tde_shmem.h"
#include "funcapi.h"
#include "access/relscan.h"
#include "access/relation.h" #include "access/relation.h"
#include "access/relscan.h"
#include "catalog/namespace.h" #include "catalog/namespace.h"
#include "executor/spi.h" #include "executor/spi.h"
#include "funcapi.h"
#include "common/pg_tde_shmem.h"
#else #else
#include "fe_utils/simple_list.h" #include "fe_utils/simple_list.h"
#include "pg_tde_fe.h" #include "pg_tde_fe.h"

@ -12,6 +12,7 @@
*/ */
#include "postgres.h" #include "postgres.h"
#include "common/jsonapi.h" #include "common/jsonapi.h"
#include "mb/pg_wchar.h" #include "mb/pg_wchar.h"
#include "utils/jsonfuncs.h" #include "utils/jsonfuncs.h"

@ -9,43 +9,45 @@
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
#include "postgres.h" #include "postgres.h"
#include <sys/mman.h>
#include <sys/time.h>
#include "access/xlog.h" #include "access/xlog.h"
#include "access/xloginsert.h" #include "access/xloginsert.h"
#include "catalog/tde_principal_key.h" #include "catalog/pg_database.h"
#include "storage/fd.h"
#include "utils/palloc.h"
#include "utils/memutils.h"
#include "utils/wait_event.h"
#include "utils/timestamp.h"
#include "common/relpath.h" #include "common/relpath.h"
#include "miscadmin.h" #include "miscadmin.h"
#include "storage/fd.h"
#include "utils/builtins.h" #include "utils/builtins.h"
#include "pg_tde.h"
#include "access/pg_tde_xlog.h"
#include <sys/mman.h>
#include <sys/time.h>
#include "utils/fmgroids.h" #include "utils/fmgroids.h"
#include "utils/guc.h" #include "utils/guc.h"
#include "catalog/pg_database.h" #include "utils/memutils.h"
#include "keyring/keyring_api.h" #include "utils/palloc.h"
#include "utils/timestamp.h"
#include "utils/wait_event.h"
#include "access/pg_tde_tdemap.h" #include "access/pg_tde_tdemap.h"
#include "access/pg_tde_xlog.h"
#include "catalog/tde_global_space.h" #include "catalog/tde_global_space.h"
#include "catalog/tde_principal_key.h"
#include "keyring/keyring_api.h"
#include "pg_tde.h"
#include "pg_tde_guc.h"
#ifndef FRONTEND #ifndef FRONTEND
#include "access/genam.h" #include "access/genam.h"
#include "access/table.h" #include "access/table.h"
#include "common/pg_tde_shmem.h"
#include "funcapi.h" #include "funcapi.h"
#include "lib/dshash.h" #include "lib/dshash.h"
#include "storage/lwlock.h" #include "storage/lwlock.h"
#include "storage/shmem.h" #include "storage/shmem.h"
#include "common/pg_tde_shmem.h"
#else #else
#include "pg_tde_fe.h" #include "pg_tde_fe.h"
#endif #endif
#include "pg_tde_guc.h"
#include <sys/time.h>
#ifndef FRONTEND #ifndef FRONTEND

@ -10,13 +10,15 @@
*/ */
#include "postgres.h" #include "postgres.h"
#include "storage/ipc.h"
#include "common/pg_tde_shmem.h"
#include "lib/dshash.h" #include "lib/dshash.h"
#include "nodes/pg_list.h" #include "nodes/pg_list.h"
#include "storage/ipc.h"
#include "storage/lwlock.h" #include "storage/lwlock.h"
#include "storage/shmem.h" #include "storage/shmem.h"
#include "common/pg_tde_shmem.h"
static void tde_shmem_shutdown(int code, Datum arg); static void tde_shmem_shutdown(int code, Datum arg);
List *registeredShmemRequests = NIL; List *registeredShmemRequests = NIL;

@ -15,10 +15,10 @@
#include "pg_tde.h" #include "pg_tde.h"
#ifndef FRONTEND #ifndef FRONTEND
#include "fmgr.h"
#include "smgr/pg_tde_smgr.h"
#include "access/relation.h" #include "access/relation.h"
#include "fmgr.h"
#include "utils/rel.h" #include "utils/rel.h"
#include "smgr/pg_tde_smgr.h"
PG_FUNCTION_INFO_V1(pg_tde_is_encrypted); PG_FUNCTION_INFO_V1(pg_tde_is_encrypted);
Datum Datum

@ -1,22 +1,21 @@
#include "postgres.h" #include "postgres.h"
#ifdef FRONTEND #include <errno.h>
#include "pg_tde_fe.h" #include <fcntl.h>
#endif #include <openssl/crypto.h>
#include <openssl/err.h>
#include "encryption/enc_aes.h" #include <openssl/evp.h>
#include <openssl/ssl.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <errno.h>
#include <fcntl.h>
#include <unistd.h> #include <unistd.h>
#include <openssl/ssl.h> #include "encryption/enc_aes.h"
#include <openssl/crypto.h>
#include <openssl/evp.h> #ifdef FRONTEND
#include <openssl/err.h> #include "pg_tde_fe.h"
#endif
/* Implementation notes /* Implementation notes
* ===================== * =====================

@ -1,19 +1,19 @@
#include "pg_tde_defines.h"
#include "postgres.h" #include "postgres.h"
#include <openssl/err.h>
#include <openssl/rand.h>
#include "storage/bufmgr.h"
#include "access/pg_tde_tdemap.h" #include "access/pg_tde_tdemap.h"
#include "encryption/enc_tde.h" #include "encryption/enc_tde.h"
#include "encryption/enc_aes.h" #include "encryption/enc_aes.h"
#include "storage/bufmgr.h" #include "pg_tde_defines.h"
#ifdef FRONTEND #ifdef FRONTEND
#include "pg_tde_fe.h" #include "pg_tde_fe.h"
#endif #endif
#include <openssl/rand.h>
#include <openssl/err.h>
#define AES_BLOCK_SIZE 16 #define AES_BLOCK_SIZE 16
#define NUM_AES_BLOCKS_IN_BATCH 200 #define NUM_AES_BLOCKS_IN_BATCH 200
#define DATA_BYTES_PER_AES_BATCH (NUM_AES_BLOCKS_IN_BATCH * AES_BLOCK_SIZE) #define DATA_BYTES_PER_AES_BATCH (NUM_AES_BLOCKS_IN_BATCH * AES_BLOCK_SIZE)

@ -13,9 +13,9 @@
#ifdef FRONTEND #ifdef FRONTEND
#include "postgres_fe.h" #include "postgres_fe.h"
#include "utils/elog.h"
#include "common/logging.h" #include "common/logging.h"
#include "common/file_perm.h" #include "common/file_perm.h"
#include "utils/elog.h"
#pragma GCC diagnostic ignored "-Wunused-macros" #pragma GCC diagnostic ignored "-Wunused-macros"
#pragma GCC diagnostic ignored "-Wunused-value" #pragma GCC diagnostic ignored "-Wunused-value"

@ -1,17 +1,19 @@
#include "keyring/keyring_api.h"
#include "postgres.h" #include "postgres.h"
#include <assert.h>
#include <openssl/err.h>
#include <openssl/rand.h>
#include "nodes/pg_list.h" #include "nodes/pg_list.h"
#include "utils/memutils.h" #include "utils/memutils.h"
#include "keyring/keyring_api.h"
#ifdef FRONTEND #ifdef FRONTEND
#include "fe_utils/simple_list.h" #include "fe_utils/simple_list.h"
#include "pg_tde_fe.h" #include "pg_tde_fe.h"
#endif #endif
#include <assert.h>
#include <openssl/rand.h>
#include <openssl/err.h>
typedef struct RegisteredKeyProviderType typedef struct RegisteredKeyProviderType
{ {
TDEKeyringRoutine *routine; TDEKeyringRoutine *routine;

@ -12,20 +12,21 @@
#include "postgres.h" #include "postgres.h"
#include "keyring/keyring_file.h" #include <stdio.h>
#include "catalog/tde_keyring.h" #include <unistd.h>
#include "common/file_perm.h" #include "common/file_perm.h"
#include "keyring/keyring_api.h"
#include "storage/fd.h" #include "storage/fd.h"
#include "utils/wait_event.h" #include "utils/wait_event.h"
#include "catalog/tde_keyring.h"
#include "keyring/keyring_api.h"
#include "keyring/keyring_file.h"
#ifdef FRONTEND #ifdef FRONTEND
#include "pg_tde_fe.h" #include "pg_tde_fe.h"
#endif #endif
#include <stdio.h>
#include <unistd.h>
static KeyInfo *get_key_by_name(GenericKeyring *keyring, const char *key_name, KeyringReturnCodes *return_code); static KeyInfo *get_key_by_name(GenericKeyring *keyring, const char *key_name, KeyringReturnCodes *return_code);
static void set_key_by_name(GenericKeyring *keyring, KeyInfo *key); static void set_key_by_name(GenericKeyring *keyring, KeyInfo *key);
static void validate(GenericKeyring *keyring); static void validate(GenericKeyring *keyring);

@ -14,9 +14,9 @@
#include <openssl/err.h> #include <openssl/err.h>
#include <openssl/ssl.h> #include <openssl/ssl.h>
#include "keyring/keyring_api.h"
#include "keyring/keyring_kmip.h" #include "keyring/keyring_kmip.h"
#include "keyring/keyring_kmip_impl.h" #include "keyring/keyring_kmip_impl.h"
#include "keyring/keyring_api.h"
#ifdef FRONTEND #ifdef FRONTEND
#include "pg_tde_fe.h" #include "pg_tde_fe.h"

@ -2,6 +2,7 @@
* The libkmip specific code need to be in a separate library to avoid * The libkmip specific code need to be in a separate library to avoid
* collissions with PostgreSQL's header files. * collissions with PostgreSQL's header files.
*/ */
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <kmip.h> #include <kmip.h>

@ -11,19 +11,18 @@
#include "postgres.h" #include "postgres.h"
#include "keyring/keyring_vault.h" #include <curl/curl.h>
#include "keyring/keyring_curl.h" #include <stdio.h>
#include "keyring/keyring_api.h"
#include "pg_tde_defines.h" #include "common/base64.h"
#include "common/jsonapi.h" #include "common/jsonapi.h"
#include "mb/pg_wchar.h" #include "mb/pg_wchar.h"
#include "utils/builtins.h" #include "utils/builtins.h"
#include <stdio.h> #include "keyring/keyring_api.h"
#include "keyring/keyring_curl.h"
#include <curl/curl.h> #include "keyring/keyring_vault.h"
#include "pg_tde_defines.h"
#include "common/base64.h"
#ifdef FRONTEND #ifdef FRONTEND
#include "pg_tde_fe.h" #include "pg_tde_fe.h"

@ -11,33 +11,35 @@
*/ */
#include "postgres.h" #include "postgres.h"
#include <sys/stat.h>
#include "access/tableam.h"
#include "access/xlog.h"
#include "access/xloginsert.h"
#include "funcapi.h" #include "funcapi.h"
#include "pg_tde.h"
#include "miscadmin.h" #include "miscadmin.h"
#include "storage/ipc.h" #include "storage/ipc.h"
#include "storage/lwlock.h" #include "storage/lwlock.h"
#include "storage/shmem.h" #include "storage/shmem.h"
#include "utils/builtins.h"
#include "utils/percona.h"
#include "access/pg_tde_tdemap.h"
#include "access/pg_tde_xlog.h" #include "access/pg_tde_xlog.h"
#include "access/pg_tde_xlog_smgr.h" #include "access/pg_tde_xlog_smgr.h"
#include "catalog/tde_global_space.h"
#include "catalog/tde_principal_key.h"
#include "common/pg_tde_shmem.h"
#include "encryption/enc_aes.h" #include "encryption/enc_aes.h"
#include "access/pg_tde_tdemap.h"
#include "access/xlog.h"
#include "access/xloginsert.h"
#include "keyring/keyring_api.h" #include "keyring/keyring_api.h"
#include "common/pg_tde_shmem.h"
#include "catalog/tde_principal_key.h"
#include "keyring/keyring_file.h" #include "keyring/keyring_file.h"
#include "keyring/keyring_vault.h"
#include "keyring/keyring_kmip.h" #include "keyring/keyring_kmip.h"
#include "utils/builtins.h" #include "keyring/keyring_vault.h"
#include "smgr/pg_tde_smgr.h" #include "pg_tde.h"
#include "catalog/tde_global_space.h"
#include "pg_tde_event_capture.h" #include "pg_tde_event_capture.h"
#include "utils/percona.h"
#include "pg_tde_guc.h" #include "pg_tde_guc.h"
#include "access/tableam.h" #include "smgr/pg_tde_smgr.h"
#include <sys/stat.h>
PG_MODULE_MAGIC; PG_MODULE_MAGIC;

@ -1,14 +1,15 @@
#include "postgres_fe.h" #include "postgres_fe.h"
#include "pg_tde.h" #include <stdarg.h>
#include "catalog/tde_keyring.h" #include <stdio.h>
#include "catalog/tde_global_space.h"
#include "common/controldata_utils.h" #include "common/controldata_utils.h"
#include "common/logging.h" #include "common/logging.h"
#include "common/pg_tde_utils.h"
#include <stdarg.h> #include "catalog/tde_global_space.h"
#include <stdio.h> #include "catalog/tde_keyring.h"
#include "common/pg_tde_utils.h"
#include "pg_tde.h"
/* version string we expect back from pg_tde_change_key_provider */ /* version string we expect back from pg_tde_change_key_provider */
#define PROGNAME "pg_tde_change_key_provider (PostgreSQL) " PG_VERSION "\n" #define PROGNAME "pg_tde_change_key_provider (PostgreSQL) " PG_VERSION "\n"

@ -10,34 +10,36 @@
*/ */
#include "postgres.h" #include "postgres.h"
#include "funcapi.h"
#include "fmgr.h" #include "access/heapam.h"
#include "utils/rel.h" #include "access/relation.h"
#include "utils/builtins.h" #include "access/table.h"
#include "utils/lsyscache.h" #include "access/tableam.h"
#include "catalog/namespace.h"
#include "catalog/pg_class.h" #include "catalog/pg_class.h"
#include "catalog/pg_database.h" #include "catalog/pg_database.h"
#include "catalog/pg_event_trigger.h"
#include "catalog/pg_inherits.h" #include "catalog/pg_inherits.h"
#include "commands/defrem.h" #include "commands/defrem.h"
#include "commands/sequence.h"
#include "access/heapam.h"
#include "access/table.h"
#include "access/relation.h"
#include "catalog/pg_event_trigger.h"
#include "catalog/namespace.h"
#include "commands/event_trigger.h" #include "commands/event_trigger.h"
#include "common/pg_tde_utils.h" #include "commands/sequence.h"
#include "fmgr.h"
#include "funcapi.h"
#include "miscadmin.h"
#include "storage/lmgr.h" #include "storage/lmgr.h"
#include "tcop/utility.h" #include "tcop/utility.h"
#include "utils/builtins.h"
#include "utils/fmgroids.h" #include "utils/fmgroids.h"
#include "utils/lsyscache.h"
#include "utils/rel.h"
#include "utils/syscache.h" #include "utils/syscache.h"
#include "pg_tde_event_capture.h"
#include "pg_tde_guc.h"
#include "access/pg_tde_tdemap.h" #include "access/pg_tde_tdemap.h"
#include "catalog/tde_principal_key.h"
#include "miscadmin.h"
#include "access/tableam.h"
#include "catalog/tde_global_space.h" #include "catalog/tde_global_space.h"
#include "catalog/tde_principal_key.h"
#include "common/pg_tde_utils.h"
#include "pg_tde_event_capture.h"
#include "pg_tde_guc.h"
typedef struct typedef struct
{ {

@ -10,10 +10,12 @@
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
#include "pg_tde_guc.h"
#include "postgres.h" #include "postgres.h"
#include "utils/guc.h" #include "utils/guc.h"
#include "pg_tde_guc.h"
#ifndef FRONTEND #ifndef FRONTEND
bool AllowInheritGlobalProviders = true; bool AllowInheritGlobalProviders = true;

@ -1,16 +1,17 @@
#include "postgres.h" #include "postgres.h"
#include "smgr/pg_tde_smgr.h"
#include "storage/smgr.h"
#include "storage/md.h"
#include "access/xloginsert.h" #include "access/xloginsert.h"
#include "catalog/catalog.h" #include "catalog/catalog.h"
#include "storage/md.h"
#include "storage/smgr.h"
#include "utils/hsearch.h"
#include "access/pg_tde_tdemap.h"
#include "access/pg_tde_xlog.h" #include "access/pg_tde_xlog.h"
#include "encryption/enc_aes.h" #include "encryption/enc_aes.h"
#include "encryption/enc_tde.h" #include "encryption/enc_tde.h"
#include "access/pg_tde_tdemap.h"
#include "utils/hsearch.h"
#include "pg_tde_event_capture.h" #include "pg_tde_event_capture.h"
#include "smgr/pg_tde_smgr.h"
typedef enum TDEMgrRelationEncryptionStatus typedef enum TDEMgrRelationEncryptionStatus
{ {

Loading…
Cancel
Save