Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit d6b059e

Browse files
committed
Document intentional violations of header inclusion policy.
Although there are good reasons for our policy of including postgres.h as the first #include in every .c file, never from .h files, there are two places where it seems expedient to violate the policy because the alternative is to modify externally-supplied .c files. (In the case of the regexp library, the idea that it's externally-supplied is kind of at odds with reality, but I haven't entirely given up hope that it will become a standalone project some day.) Add some comments to make it explicit that this is a policy violation and provide the reasoning. In passing, move #include "miscadmin.h" out of regcomp.c and into regcustom.h, which is where it should be if we're taking this reasoning seriously at all. Discussion: https://postgr.es/m/CAEepm=2zCoeq3QxVwhS5DFeUh=yU6z81pbWMgfOB8OzyiBwxzw@mail.gmail.com Discussion: https://postgr.es/m/11634.1488932128@sss.pgh.pa.us
1 parent 2f899e7 commit d6b059e

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

src/backend/regex/regcomp.c

-2
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@
3434

3535
#include "regex/regguts.h"
3636

37-
#include "miscadmin.h" /* needed by rcancelrequested/rstacktoodeep */
38-
3937
/*
4038
* forward declarations, up here so forward datatypes etc. are defined early
4139
*/

src/include/regex/regcustom.h

+9
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@
2929
*/
3030

3131
/* headers if any */
32+
33+
/*
34+
* It's against Postgres coding conventions to include postgres.h in a
35+
* header file, but we allow the violation here because the regexp library
36+
* files specifically intend this file to supply application-dependent
37+
* headers, and are careful to include this file before anything else.
38+
*/
3239
#include "postgres.h"
3340

3441
#include <ctype.h>
@@ -47,6 +54,8 @@
4754

4855
#include "mb/pg_wchar.h"
4956

57+
#include "miscadmin.h" /* needed by rcancelrequested/rstacktoodeep */
58+
5059

5160
/* overrides for regguts.h definitions, if any */
5261
#define FUNCPTR(name, args) (*name) args

src/include/snowball/header.h

+5
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
#ifndef SNOWBALL_HEADR_H
2323
#define SNOWBALL_HEADR_H
2424

25+
/*
26+
* It's against Postgres coding conventions to include postgres.h in a
27+
* header file, but we allow the violation here because the alternative is
28+
* to modify the machine-generated .c files provided by the Snowball project.
29+
*/
2530
#include "postgres.h"
2631

2732
/* Some platforms define MAXINT and/or MININT, causing conflicts */

0 commit comments

Comments
 (0)