From 08da52859a1fadeac10aab621c6c793791ec1f2c Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Wed, 8 Mar 2017 17:21:08 -0500 Subject: [PATCH] Bring plpgsql into line with header inclusion policy. We have a project policy that every .c file should start by including postgres.h, postgres_fe.h, or c.h as appropriate; and then there is no need for any .h file to explicitly include any of these. (The core reason for this policy is to make it easy to verify that pg_config_os.h is included before any system headers such as ; without that, we have portability issues on some platforms due to variation in largefile options across different modules in the backend. Also, if .h files were responsible for choosing which of these key headers to include, .h files that need to be includable in either frontend or backend compiles would be in trouble.) plpgsql was blithely ignoring this policy, so whack it upside the head until it complies. I also chose to standardize on including plpgsql's own .h files after all core-system headers that it pulls in. That could've been done either way, but this way seems saner. Discussion: https://postgr.es/m/CAEepm=2zCoeq3QxVwhS5DFeUh=yU6z81pbWMgfOB8OzyiBwxzw@mail.gmail.com Discussion: https://postgr.es/m/11634.1488932128@sss.pgh.pa.us --- src/pl/plpgsql/src/pl_comp.c | 4 +++- src/pl/plpgsql/src/pl_exec.c | 4 +++- src/pl/plpgsql/src/pl_funcs.c | 4 +++- src/pl/plpgsql/src/pl_gram.y | 4 +++- src/pl/plpgsql/src/pl_handler.c | 4 +++- src/pl/plpgsql/src/pl_scanner.c | 4 +++- src/pl/plpgsql/src/plpgsql.h | 2 -- 7 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/pl/plpgsql/src/pl_comp.c b/src/pl/plpgsql/src/pl_comp.c index b25b3f1de0..bed343ea0c 100644 --- a/src/pl/plpgsql/src/pl_comp.c +++ b/src/pl/plpgsql/src/pl_comp.c @@ -13,7 +13,7 @@ *------------------------------------------------------------------------- */ -#include "plpgsql.h" +#include "postgres.h" #include @@ -33,6 +33,8 @@ #include "utils/rel.h" #include "utils/syscache.h" +#include "plpgsql.h" + /* ---------- * Our own local and global variables diff --git a/src/pl/plpgsql/src/pl_exec.c b/src/pl/plpgsql/src/pl_exec.c index 6fc3db07fe..196e518e0d 100644 --- a/src/pl/plpgsql/src/pl_exec.c +++ b/src/pl/plpgsql/src/pl_exec.c @@ -13,7 +13,7 @@ *------------------------------------------------------------------------- */ -#include "plpgsql.h" +#include "postgres.h" #include @@ -41,6 +41,8 @@ #include "utils/snapmgr.h" #include "utils/typcache.h" +#include "plpgsql.h" + typedef struct { diff --git a/src/pl/plpgsql/src/pl_funcs.c b/src/pl/plpgsql/src/pl_funcs.c index 906fe0148d..93f89814b3 100644 --- a/src/pl/plpgsql/src/pl_funcs.c +++ b/src/pl/plpgsql/src/pl_funcs.c @@ -13,10 +13,12 @@ *------------------------------------------------------------------------- */ -#include "plpgsql.h" +#include "postgres.h" #include "utils/memutils.h" +#include "plpgsql.h" + /* ---------- * Local variables for namespace handling diff --git a/src/pl/plpgsql/src/pl_gram.y b/src/pl/plpgsql/src/pl_gram.y index 4a4cd6ae26..29729df550 100644 --- a/src/pl/plpgsql/src/pl_gram.y +++ b/src/pl/plpgsql/src/pl_gram.y @@ -13,7 +13,7 @@ *------------------------------------------------------------------------- */ -#include "plpgsql.h" +#include "postgres.h" #include "catalog/namespace.h" #include "catalog/pg_type.h" @@ -23,6 +23,8 @@ #include "parser/scansup.h" #include "utils/builtins.h" +#include "plpgsql.h" + /* Location tracking support --- simpler than bison's default */ #define YYLLOC_DEFAULT(Current, Rhs, N) \ diff --git a/src/pl/plpgsql/src/pl_handler.c b/src/pl/plpgsql/src/pl_handler.c index 92d15810d7..83ec4530db 100644 --- a/src/pl/plpgsql/src/pl_handler.c +++ b/src/pl/plpgsql/src/pl_handler.c @@ -13,7 +13,7 @@ *------------------------------------------------------------------------- */ -#include "plpgsql.h" +#include "postgres.h" #include "access/htup_details.h" #include "catalog/pg_proc.h" @@ -26,6 +26,8 @@ #include "utils/syscache.h" #include "utils/varlena.h" +#include "plpgsql.h" + static bool plpgsql_extra_checks_check_hook(char **newvalue, void **extra, GucSource source); static void plpgsql_extra_warnings_assign_hook(const char *newvalue, void *extra); diff --git a/src/pl/plpgsql/src/pl_scanner.c b/src/pl/plpgsql/src/pl_scanner.c index c40121308b..553be8c93c 100644 --- a/src/pl/plpgsql/src/pl_scanner.c +++ b/src/pl/plpgsql/src/pl_scanner.c @@ -13,13 +13,15 @@ * *------------------------------------------------------------------------- */ -#include "plpgsql.h" +#include "postgres.h" #include "mb/pg_wchar.h" #include "parser/scanner.h" +#include "plpgsql.h" #include "pl_gram.h" /* must be after parser/scanner.h */ + #define PG_KEYWORD(a,b,c) {a,b,c}, diff --git a/src/pl/plpgsql/src/plpgsql.h b/src/pl/plpgsql/src/plpgsql.h index 3421eed74f..b7e103b514 100644 --- a/src/pl/plpgsql/src/plpgsql.h +++ b/src/pl/plpgsql/src/plpgsql.h @@ -16,8 +16,6 @@ #ifndef PLPGSQL_H #define PLPGSQL_H -#include "postgres.h" - #include "access/xact.h" #include "commands/event_trigger.h" #include "commands/trigger.h" -- 2.40.0