Skip to content

Commit 08da528

Browse files
committed
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 <stdio.h>; 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
1 parent d6b059e commit 08da528

File tree

7 files changed

+18
-8
lines changed

7 files changed

+18
-8
lines changed

src/pl/plpgsql/src/pl_comp.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*-------------------------------------------------------------------------
1414
*/
1515

16-
#include "plpgsql.h"
16+
#include "postgres.h"
1717

1818
#include <ctype.h>
1919

@@ -33,6 +33,8 @@
3333
#include "utils/rel.h"
3434
#include "utils/syscache.h"
3535

36+
#include "plpgsql.h"
37+
3638

3739
/* ----------
3840
* Our own local and global variables

src/pl/plpgsql/src/pl_exec.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*-------------------------------------------------------------------------
1414
*/
1515

16-
#include "plpgsql.h"
16+
#include "postgres.h"
1717

1818
#include <ctype.h>
1919

@@ -41,6 +41,8 @@
4141
#include "utils/snapmgr.h"
4242
#include "utils/typcache.h"
4343

44+
#include "plpgsql.h"
45+
4446

4547
typedef struct
4648
{

src/pl/plpgsql/src/pl_funcs.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@
1313
*-------------------------------------------------------------------------
1414
*/
1515

16-
#include "plpgsql.h"
16+
#include "postgres.h"
1717

1818
#include "utils/memutils.h"
1919

20+
#include "plpgsql.h"
21+
2022

2123
/* ----------
2224
* Local variables for namespace handling

src/pl/plpgsql/src/pl_gram.y

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*-------------------------------------------------------------------------
1414
*/
1515

16-
#include "plpgsql.h"
16+
#include "postgres.h"
1717

1818
#include "catalog/namespace.h"
1919
#include "catalog/pg_type.h"
@@ -23,6 +23,8 @@
2323
#include "parser/scansup.h"
2424
#include "utils/builtins.h"
2525

26+
#include "plpgsql.h"
27+
2628

2729
/* Location tracking support --- simpler than bison's default */
2830
#define YYLLOC_DEFAULT(Current, Rhs, N) \

src/pl/plpgsql/src/pl_handler.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*-------------------------------------------------------------------------
1414
*/
1515

16-
#include "plpgsql.h"
16+
#include "postgres.h"
1717

1818
#include "access/htup_details.h"
1919
#include "catalog/pg_proc.h"
@@ -26,6 +26,8 @@
2626
#include "utils/syscache.h"
2727
#include "utils/varlena.h"
2828

29+
#include "plpgsql.h"
30+
2931

3032
static bool plpgsql_extra_checks_check_hook(char **newvalue, void **extra, GucSource source);
3133
static void plpgsql_extra_warnings_assign_hook(const char *newvalue, void *extra);

src/pl/plpgsql/src/pl_scanner.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,15 @@
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
16-
#include "plpgsql.h"
16+
#include "postgres.h"
1717

1818
#include "mb/pg_wchar.h"
1919
#include "parser/scanner.h"
2020

21+
#include "plpgsql.h"
2122
#include "pl_gram.h" /* must be after parser/scanner.h */
2223

24+
2325
#define PG_KEYWORD(a,b,c) {a,b,c},
2426

2527

src/pl/plpgsql/src/plpgsql.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
#ifndef PLPGSQL_H
1717
#define PLPGSQL_H
1818

19-
#include "postgres.h"
20-
2119
#include "access/xact.h"
2220
#include "commands/event_trigger.h"
2321
#include "commands/trigger.h"

0 commit comments

Comments
 (0)