Here is the first of several (to come at a later date) patch sets to
take some advantage of C11 features.
This is, I hope, a very gentle start that shouldn't stress even older
compilers very much, and should bring some tangible benefits that had
already been asked for around here.
In C11, typedef redefinitions are allowed, as long as they are the same. So
typedef int foo;
typedef int foo;
is allowed, where the second occurrence would have led to a diagnostic
in previous C versions.
(C++ also allows this, so this will preserve C++ compatibility of the
headers.)
What is not allowed is something like this of course:
typedef int foo;
typedef double foo;
This will continue to be an error.
This facility is often useful to untangle dependencies between header
files. So instead of having one header include another, now the first
header can just make its own typedef of whatever types it needs. If the
two headers are later included together, then this will not (any more)
be a conflict. This often works together with declaring incomplete
types using struct.
The PostgreSQL code already contains a couple of places that wanted to
do something like this but had to install manual workarounds with #ifdef
guards. These can now be removed. There are also a bunch of struct
forward declarations that can be "upgraded" to full typedefs. This
makes the function prototypes look more consistent.
In this patch set, 0001 is a prerequisite for 0002, 0002 and 0003 remove
some existing workarounds, the remaining patches are additional
opportunities for cleanup and simplification.
All of this is only notational, there are no include changes or API
changes or changes in behavior.
(After this, it would probably be possible to undertake some deeper
efforts to untangle header files, with the help of IWYU. But that is a
separate project.)
From 9cca8a11e0c5107cc4577cd0d14c79a3cd154d62 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <pe...@eisentraut.org>
Date: Fri, 29 Aug 2025 13:18:50 +0200
Subject: [PATCH 1/7] Improve pgbench definition of yyscan_t
It was defining yyscan_t as a macro while the rest of the code uses a
typedef with #ifdef guards around it. The latter is also what the
flex generated code uses. So it seems best to make it look like those
other places for consistency.
The old way also had a potential for conflict if some code included
multiple headers providing yyscan_t. exprscan.l includes
#include "fe_utils/psqlscan_int.h"
#include "pgbench.h"
and fe_utils/psqlscan_int.h contains
#ifndef YY_TYPEDEF_YY_SCANNER_T
#define YY_TYPEDEF_YY_SCANNER_T
typedef void *yyscan_t;
#endif
which was then followed by pgbench.h
#define yyscan_t void *
and then the generated code in exprscan.c
#ifndef YY_TYPEDEF_YY_SCANNER_T
#define YY_TYPEDEF_YY_SCANNER_T
typedef void* yyscan_t;
#endif
This works, but if the #ifdef guard in psqlscan_int.h is removed, this
fails.
We want to move toward allowing repeat typedefs, per C11, but for that
we need to make sure they are all the same.
---
src/bin/pgbench/pgbench.h | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/bin/pgbench/pgbench.h b/src/bin/pgbench/pgbench.h
index e053c9e2eb6..f8b7b497d1e 100644
--- a/src/bin/pgbench/pgbench.h
+++ b/src/bin/pgbench/pgbench.h
@@ -16,11 +16,14 @@
/*
* This file is included outside exprscan.l, in places where we can't see
* flex's definition of typedef yyscan_t. Fortunately, it's documented as
- * being "void *", so we can use a macro to keep the function declarations
+ * being "void *", so we can use typedef to keep the function declarations
* here looking like the definitions in exprscan.l. exprparse.y and
* pgbench.c also use this to be able to declare things as "yyscan_t".
*/
-#define yyscan_t void *
+#ifndef YY_TYPEDEF_YY_SCANNER_T
+#define YY_TYPEDEF_YY_SCANNER_T
+typedef void *yyscan_t;
+#endif
/*
* Likewise, we can't see exprparse.y's definition of union YYSTYPE here,
base-commit: 5d7f58848ce59d9e09b7214d2541ab3ec853f89c
--
2.51.0
From fe3cd22fef977d763baf21c346de73e00c116754 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <pe...@eisentraut.org>
Date: Fri, 29 Aug 2025 13:18:51 +0200
Subject: [PATCH 2/7] Allow redeclaration of typedef yyscan_t
This is allowed in C11, so we don't need the workaround guards against
it anymore. This effectively reverts commit 382092a0cd2 that put
these guards in place.
---
contrib/cube/cubedata.h | 3 ---
contrib/seg/segdata.h | 3 ---
src/backend/utils/adt/jsonpath_internal.h | 3 ---
src/bin/pgbench/pgbench.h | 3 ---
src/include/bootstrap/bootstrap.h | 3 ---
src/include/fe_utils/psqlscan_int.h | 6 ------
src/include/replication/syncrep.h | 3 ---
src/include/replication/walsender_private.h | 3 ---
src/pl/plpgsql/src/plpgsql.h | 3 ---
9 files changed, 30 deletions(-)
diff --git a/contrib/cube/cubedata.h b/contrib/cube/cubedata.h
index ad1e2bd6998..8bfcc6e99a2 100644
--- a/contrib/cube/cubedata.h
+++ b/contrib/cube/cubedata.h
@@ -62,10 +62,7 @@ typedef struct NDBOX
/* for cubescan.l and cubeparse.y */
/* All grammar constructs return strings */
#define YYSTYPE char *
-#ifndef YY_TYPEDEF_YY_SCANNER_T
-#define YY_TYPEDEF_YY_SCANNER_T
typedef void *yyscan_t;
-#endif
/* in cubescan.l */
extern int cube_yylex(YYSTYPE *yylval_param, yyscan_t yyscanner);
diff --git a/contrib/seg/segdata.h b/contrib/seg/segdata.h
index 4347c31c28e..7bc7c83dca3 100644
--- a/contrib/seg/segdata.h
+++ b/contrib/seg/segdata.h
@@ -16,10 +16,7 @@ extern int significant_digits(const char *s);
/* for segscan.l and segparse.y */
union YYSTYPE;
-#ifndef YY_TYPEDEF_YY_SCANNER_T
-#define YY_TYPEDEF_YY_SCANNER_T
typedef void *yyscan_t;
-#endif
/* in segscan.l */
extern int seg_yylex(union YYSTYPE *yylval_param, yyscan_t yyscanner);
diff --git a/src/backend/utils/adt/jsonpath_internal.h
b/src/backend/utils/adt/jsonpath_internal.h
index f78069857d0..19567aca6f7 100644
--- a/src/backend/utils/adt/jsonpath_internal.h
+++ b/src/backend/utils/adt/jsonpath_internal.h
@@ -22,10 +22,7 @@ typedef struct JsonPathString
int total;
} JsonPathString;
-#ifndef YY_TYPEDEF_YY_SCANNER_T
-#define YY_TYPEDEF_YY_SCANNER_T
typedef void *yyscan_t;
-#endif
#include "utils/jsonpath.h"
#include "jsonpath_gram.h"
diff --git a/src/bin/pgbench/pgbench.h b/src/bin/pgbench/pgbench.h
index f8b7b497d1e..d55d30e0ef9 100644
--- a/src/bin/pgbench/pgbench.h
+++ b/src/bin/pgbench/pgbench.h
@@ -20,10 +20,7 @@
* here looking like the definitions in exprscan.l. exprparse.y and
* pgbench.c also use this to be able to declare things as "yyscan_t".
*/
-#ifndef YY_TYPEDEF_YY_SCANNER_T
-#define YY_TYPEDEF_YY_SCANNER_T
typedef void *yyscan_t;
-#endif
/*
* Likewise, we can't see exprparse.y's definition of union YYSTYPE here,
diff --git a/src/include/bootstrap/bootstrap.h
b/src/include/bootstrap/bootstrap.h
index befc4fa1b3d..5ad347ec290 100644
--- a/src/include/bootstrap/bootstrap.h
+++ b/src/include/bootstrap/bootstrap.h
@@ -56,10 +56,7 @@ extern void boot_get_type_io_data(Oid typid,
Oid
*typoutput);
union YYSTYPE;
-#ifndef YY_TYPEDEF_YY_SCANNER_T
-#define YY_TYPEDEF_YY_SCANNER_T
typedef void *yyscan_t;
-#endif
extern int boot_yyparse(yyscan_t yyscanner);
extern int boot_yylex_init(yyscan_t *yyscannerp);
diff --git a/src/include/fe_utils/psqlscan_int.h
b/src/include/fe_utils/psqlscan_int.h
index 2a3a9d7c82a..a1ebf226cf4 100644
--- a/src/include/fe_utils/psqlscan_int.h
+++ b/src/include/fe_utils/psqlscan_int.h
@@ -51,14 +51,8 @@
* validity checking; in actual use, this file should always be included
* from the body of a flex file, where these symbols are already defined.
*/
-#ifndef YY_TYPEDEF_YY_BUFFER_STATE
-#define YY_TYPEDEF_YY_BUFFER_STATE
typedef struct yy_buffer_state *YY_BUFFER_STATE;
-#endif
-#ifndef YY_TYPEDEF_YY_SCANNER_T
-#define YY_TYPEDEF_YY_SCANNER_T
typedef void *yyscan_t;
-#endif
/*
* We use a stack of flex buffers to handle substitution of psql variables.
diff --git a/src/include/replication/syncrep.h
b/src/include/replication/syncrep.h
index 675669a79f7..dc2b118b166 100644
--- a/src/include/replication/syncrep.h
+++ b/src/include/replication/syncrep.h
@@ -97,10 +97,7 @@ extern void SyncRepUpdateSyncStandbysDefined(void);
* in syncrep_gram.y and syncrep_scanner.l
*/
union YYSTYPE;
-#ifndef YY_TYPEDEF_YY_SCANNER_T
-#define YY_TYPEDEF_YY_SCANNER_T
typedef void *yyscan_t;
-#endif
extern int syncrep_yyparse(SyncRepConfigData **syncrep_parse_result_p,
char **syncrep_parse_error_msg_p, yyscan_t yyscanner);
extern int syncrep_yylex(union YYSTYPE *yylval_param, char
**syncrep_parse_error_msg_p, yyscan_t yyscanner);
extern void syncrep_yyerror(SyncRepConfigData **syncrep_parse_result_p, char
**syncrep_parse_error_msg_p, yyscan_t yyscanner, const char *str);
diff --git a/src/include/replication/walsender_private.h
b/src/include/replication/walsender_private.h
index e98701038f5..384b8a78b94 100644
--- a/src/include/replication/walsender_private.h
+++ b/src/include/replication/walsender_private.h
@@ -141,10 +141,7 @@ extern void WalSndSetState(WalSndState state);
* repl_scanner.l
*/
union YYSTYPE;
-#ifndef YY_TYPEDEF_YY_SCANNER_T
-#define YY_TYPEDEF_YY_SCANNER_T
typedef void *yyscan_t;
-#endif
extern int replication_yyparse(Node **replication_parse_result_p, yyscan_t
yyscanner);
extern int replication_yylex(union YYSTYPE *yylval_param, yyscan_t
yyscanner);
pg_noreturn extern void replication_yyerror(Node **replication_parse_result_p,
yyscan_t yyscanner, const char *message);
diff --git a/src/pl/plpgsql/src/plpgsql.h b/src/pl/plpgsql/src/plpgsql.h
index 41e52b8ce71..5f193a37183 100644
--- a/src/pl/plpgsql/src/plpgsql.h
+++ b/src/pl/plpgsql/src/plpgsql.h
@@ -1307,10 +1307,7 @@ extern void plpgsql_dumptree(PLpgSQL_function *func);
*/
union YYSTYPE;
#define YYLTYPE int
-#ifndef YY_TYPEDEF_YY_SCANNER_T
-#define YY_TYPEDEF_YY_SCANNER_T
typedef void *yyscan_t;
-#endif
extern int plpgsql_yylex(union YYSTYPE *yylvalp, YYLTYPE *yyllocp,
yyscan_t yyscanner);
extern int plpgsql_token_length(yyscan_t yyscanner);
extern void plpgsql_push_back_token(int token, union YYSTYPE *yylvalp, YYLTYPE
*yyllocp, yyscan_t yyscanner);
--
2.51.0
From 7f69eb3293cc7ce8b00e0891250581863373d12a Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <pe...@eisentraut.org>
Date: Fri, 29 Aug 2025 13:18:51 +0200
Subject: [PATCH 3/7] Remove workarounds against repeat typedefs
This is allowed in C11, so we don't need the workarounds anymore.
---
src/include/nodes/pathnodes.h | 23 ++++-------------------
src/include/optimizer/optimizer.h | 13 +------------
2 files changed, 5 insertions(+), 31 deletions(-)
diff --git a/src/include/nodes/pathnodes.h b/src/include/nodes/pathnodes.h
index 4a903d1ec18..b12a2508d8c 100644
--- a/src/include/nodes/pathnodes.h
+++ b/src/include/nodes/pathnodes.h
@@ -198,9 +198,6 @@ typedef struct PlannerGlobal
* original Query. Note that at present the planner extensively modifies
* the passed-in Query data structure; someday that should stop.
*
- * For reasons explained in optimizer/optimizer.h, we define the typedef
- * either here or in that header, whichever is read first.
- *
* Not all fields are printed. (In some cases, there is no print support for
* the field type; in others, doing so would lead to infinite recursion or
* bloat dump output more than seems useful.)
@@ -211,10 +208,7 @@ typedef struct PlannerGlobal
* correctly replaced with the keeping one.
*----------
*/
-#ifndef HAVE_PLANNERINFO_TYPEDEF
typedef struct PlannerInfo PlannerInfo;
-#define HAVE_PLANNERINFO_TYPEDEF 1
-#endif
struct PlannerInfo
{
@@ -1161,14 +1155,10 @@ typedef struct RelOptInfo
* (by plancat.c), indrestrictinfo and predOK are set later, in
* check_index_predicates().
*/
-#ifndef HAVE_INDEXOPTINFO_TYPEDEF
-typedef struct IndexOptInfo IndexOptInfo;
-#define HAVE_INDEXOPTINFO_TYPEDEF 1
-#endif
struct IndexPath; /* forward declaration */
-struct IndexOptInfo
+typedef struct IndexOptInfo
{
pg_node_attr(no_copy_equal, no_read, no_query_jumble)
@@ -1270,7 +1260,7 @@ struct IndexOptInfo
/* AM's cost estimator */
/* Rather than include amapi.h here, we declare amcostestimate like
this */
void (*amcostestimate) (struct PlannerInfo *, struct
IndexPath *, double, Cost *, Cost *, Selectivity *, double *, double *)
pg_node_attr(read_write_ignore);
-};
+} IndexOptInfo;
/*
* ForeignKeyOptInfo
@@ -3031,12 +3021,7 @@ typedef struct PlaceHolderVar
* We also create transient SpecialJoinInfos for child joins during
* partitionwise join planning, which are also not present in join_info_list.
*/
-#ifndef HAVE_SPECIALJOININFO_TYPEDEF
-typedef struct SpecialJoinInfo SpecialJoinInfo;
-#define HAVE_SPECIALJOININFO_TYPEDEF 1
-#endif
-
-struct SpecialJoinInfo
+typedef struct SpecialJoinInfo
{
pg_node_attr(no_read, no_query_jumble)
@@ -3057,7 +3042,7 @@ struct SpecialJoinInfo
bool semi_can_hash; /* true if semi_operators are all hash
*/
List *semi_operators; /* OIDs of equality join operators */
List *semi_rhs_exprs; /* righthand-side expressions of these ops
*/
-};
+} SpecialJoinInfo;
/*
* Transient outer-join clause info.
diff --git a/src/include/optimizer/optimizer.h
b/src/include/optimizer/optimizer.h
index 37bc13c2cbd..03b214755c2 100644
--- a/src/include/optimizer/optimizer.h
+++ b/src/include/optimizer/optimizer.h
@@ -28,22 +28,11 @@
* We don't want to include nodes/pathnodes.h here, because non-planner
* code should generally treat PlannerInfo as an opaque typedef.
* But we'd like such code to use that typedef name, so define the
- * typedef either here or in pathnodes.h, whichever is read first.
+ * typedef both here or in pathnodes.h.
*/
-#ifndef HAVE_PLANNERINFO_TYPEDEF
typedef struct PlannerInfo PlannerInfo;
-#define HAVE_PLANNERINFO_TYPEDEF 1
-#endif
-
-/* Likewise for IndexOptInfo and SpecialJoinInfo. */
-#ifndef HAVE_INDEXOPTINFO_TYPEDEF
typedef struct IndexOptInfo IndexOptInfo;
-#define HAVE_INDEXOPTINFO_TYPEDEF 1
-#endif
-#ifndef HAVE_SPECIALJOININFO_TYPEDEF
typedef struct SpecialJoinInfo SpecialJoinInfo;
-#define HAVE_SPECIALJOININFO_TYPEDEF 1
-#endif
/* It also seems best not to include plannodes.h, params.h, or htup.h here */
struct PlannedStmt;
--
2.51.0
From c46b45b7e638f4d9fbf2dab97f7f69d57ea9c03f Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <pe...@eisentraut.org>
Date: Fri, 29 Aug 2025 13:18:51 +0200
Subject: [PATCH 4/7] Improve ExplainState type handling in header files
Now that we can have repeat typedefs with C11, we don't need to use
"struct ExplainState" anymore but can instead make a typedef where
necessary. This doesn't change anything but makes it look nicer.
(There are more opportunities for similar changes, but this is broken
out because there was a separate discussion about it, and it's
somewhat bulky on its own.)
Discussion:
https://www.postgresql.org/message-id/flat/f36c0a45-98cd-40b2-a7cc-f2bf02b12890%40eisentraut.org#a12fb1a2c1089d6d03010f6268871b00
---
doc/src/sgml/fdwhandler.sgml | 2 +-
src/include/commands/explain.h | 24 +++++++++---------
src/include/commands/explain_dr.h | 4 +--
src/include/commands/explain_format.h | 36 +++++++++++++--------------
src/include/commands/explain_state.h | 2 +-
src/include/foreign/fdwapi.h | 10 ++++----
6 files changed, 39 insertions(+), 39 deletions(-)
diff --git a/doc/src/sgml/fdwhandler.sgml b/doc/src/sgml/fdwhandler.sgml
index b80320504d6..c6d66414b8e 100644
--- a/doc/src/sgml/fdwhandler.sgml
+++ b/doc/src/sgml/fdwhandler.sgml
@@ -1320,7 +1320,7 @@ <title>FDW Routines for <command>EXPLAIN</command></title>
ResultRelInfo *rinfo,
List *fdw_private,
int subplan_index,
- struct ExplainState *es);
+ ExplainState *es);
</programlisting>
Print additional <command>EXPLAIN</command> output for a foreign table
update.
diff --git a/src/include/commands/explain.h b/src/include/commands/explain.h
index 3b122f79ed8..6e51d50efc7 100644
--- a/src/include/commands/explain.h
+++ b/src/include/commands/explain.h
@@ -16,13 +16,13 @@
#include "executor/executor.h"
#include "parser/parse_node.h"
-struct ExplainState; /* defined in explain_state.h */
+typedef struct ExplainState ExplainState; /* defined in explain_state.h */
/* Hook for plugins to get control in ExplainOneQuery() */
typedef void (*ExplainOneQuery_hook_type) (Query *query,
int cursorOptions,
IntoClause *into,
-
struct ExplainState *es,
+
ExplainState *es,
const char *queryString,
ParamListInfo params,
QueryEnvironment *queryEnv);
@@ -31,7 +31,7 @@ extern PGDLLIMPORT ExplainOneQuery_hook_type
ExplainOneQuery_hook;
/* Hook for EXPLAIN plugins to print extra information for each plan */
typedef void (*explain_per_plan_hook_type) (PlannedStmt *plannedstmt,
IntoClause *into,
-
struct ExplainState *es,
+
ExplainState *es,
const char *queryString,
ParamListInfo params,
QueryEnvironment *queryEnv);
@@ -42,7 +42,7 @@ typedef void (*explain_per_node_hook_type) (PlanState
*planstate,
List *ancestors,
const char *relationship,
const char *plan_name,
-
struct ExplainState *es);
+
ExplainState *es);
extern PGDLLIMPORT explain_per_node_hook_type explain_per_node_hook;
/* Hook for plugins to get control in explain_get_index_name() */
@@ -53,32 +53,32 @@ extern PGDLLIMPORT explain_get_index_name_hook_type
explain_get_index_name_hook;
extern void ExplainQuery(ParseState *pstate, ExplainStmt *stmt,
ParamListInfo params,
DestReceiver *dest);
extern void standard_ExplainOneQuery(Query *query, int cursorOptions,
-
IntoClause *into, struct ExplainState *es,
+
IntoClause *into, ExplainState *es,
const
char *queryString, ParamListInfo params,
QueryEnvironment *queryEnv);
extern TupleDesc ExplainResultDesc(ExplainStmt *stmt);
extern void ExplainOneUtility(Node *utilityStmt, IntoClause *into,
- struct ExplainState
*es, ParseState *pstate,
+ ExplainState *es,
ParseState *pstate,
ParamListInfo params);
extern void ExplainOnePlan(PlannedStmt *plannedstmt, IntoClause *into,
- struct ExplainState *es,
const char *queryString,
+ ExplainState *es, const char
*queryString,
ParamListInfo params,
QueryEnvironment *queryEnv,
const instr_time
*planduration,
const BufferUsage *bufusage,
const MemoryContextCounters
*mem_counters);
-extern void ExplainPrintPlan(struct ExplainState *es, QueryDesc *queryDesc);
-extern void ExplainPrintTriggers(struct ExplainState *es,
+extern void ExplainPrintPlan(ExplainState *es, QueryDesc *queryDesc);
+extern void ExplainPrintTriggers(ExplainState *es,
QueryDesc
*queryDesc);
-extern void ExplainPrintJITSummary(struct ExplainState *es,
+extern void ExplainPrintJITSummary(ExplainState *es,
QueryDesc
*queryDesc);
-extern void ExplainQueryText(struct ExplainState *es, QueryDesc *queryDesc);
-extern void ExplainQueryParameters(struct ExplainState *es,
+extern void ExplainQueryText(ExplainState *es, QueryDesc *queryDesc);
+extern void ExplainQueryParameters(ExplainState *es,
ParamListInfo params, int maxlen);
#endif /* EXPLAIN_H */
diff --git a/src/include/commands/explain_dr.h
b/src/include/commands/explain_dr.h
index 55da63d66bd..ce424aa2a55 100644
--- a/src/include/commands/explain_dr.h
+++ b/src/include/commands/explain_dr.h
@@ -16,7 +16,7 @@
#include "executor/instrument.h"
#include "tcop/dest.h"
-struct ExplainState; /* avoid including explain.h here */
+typedef struct ExplainState ExplainState; /* avoid including explain.h
here */
/* Instrumentation data for EXPLAIN's SERIALIZE option */
typedef struct SerializeMetrics
@@ -26,7 +26,7 @@ typedef struct SerializeMetrics
BufferUsage bufferUsage; /* buffers accessed during
serialization */
} SerializeMetrics;
-extern DestReceiver *CreateExplainSerializeDestReceiver(struct ExplainState
*es);
+extern DestReceiver *CreateExplainSerializeDestReceiver(ExplainState *es);
extern SerializeMetrics GetSerializationMetrics(DestReceiver *dest);
#endif
diff --git a/src/include/commands/explain_format.h
b/src/include/commands/explain_format.h
index 05045bf8cb4..b4466c9b131 100644
--- a/src/include/commands/explain_format.h
+++ b/src/include/commands/explain_format.h
@@ -15,44 +15,44 @@
#include "nodes/pg_list.h"
-struct ExplainState; /* avoid including explain.h here */
+typedef struct ExplainState ExplainState; /* avoid including explain.h
here */
extern void ExplainPropertyList(const char *qlabel, List *data,
- struct
ExplainState *es);
+ ExplainState
*es);
extern void ExplainPropertyListNested(const char *qlabel, List *data,
-
struct ExplainState *es);
+
ExplainState *es);
extern void ExplainPropertyText(const char *qlabel, const char *value,
- struct
ExplainState *es);
+ ExplainState
*es);
extern void ExplainPropertyInteger(const char *qlabel, const char *unit,
- int64 value,
struct ExplainState *es);
+ int64 value,
ExplainState *es);
extern void ExplainPropertyUInteger(const char *qlabel, const char *unit,
- uint64
value, struct ExplainState *es);
+ uint64
value, ExplainState *es);
extern void ExplainPropertyFloat(const char *qlabel, const char *unit,
double value,
int ndigits,
- struct
ExplainState *es);
+ ExplainState
*es);
extern void ExplainPropertyBool(const char *qlabel, bool value,
- struct
ExplainState *es);
+ ExplainState
*es);
extern void ExplainOpenGroup(const char *objtype, const char *labelname,
- bool labeled, struct
ExplainState *es);
+ bool labeled,
ExplainState *es);
extern void ExplainCloseGroup(const char *objtype, const char *labelname,
- bool labeled, struct
ExplainState *es);
+ bool labeled,
ExplainState *es);
extern void ExplainOpenSetAsideGroup(const char *objtype, const char
*labelname,
bool
labeled, int depth,
- struct
ExplainState *es);
-extern void ExplainSaveGroup(struct ExplainState *es, int depth,
+
ExplainState *es);
+extern void ExplainSaveGroup(ExplainState *es, int depth,
int *state_save);
-extern void ExplainRestoreGroup(struct ExplainState *es, int depth,
+extern void ExplainRestoreGroup(ExplainState *es, int depth,
int
*state_save);
extern void ExplainDummyGroup(const char *objtype, const char *labelname,
- struct ExplainState
*es);
+ ExplainState *es);
-extern void ExplainBeginOutput(struct ExplainState *es);
-extern void ExplainEndOutput(struct ExplainState *es);
-extern void ExplainSeparatePlans(struct ExplainState *es);
+extern void ExplainBeginOutput(ExplainState *es);
+extern void ExplainEndOutput(ExplainState *es);
+extern void ExplainSeparatePlans(ExplainState *es);
-extern void ExplainIndentText(struct ExplainState *es);
+extern void ExplainIndentText(ExplainState *es);
#endif
diff --git a/src/include/commands/explain_state.h
b/src/include/commands/explain_state.h
index 32728f5d1a1..ba073b86918 100644
--- a/src/include/commands/explain_state.h
+++ b/src/include/commands/explain_state.h
@@ -79,7 +79,7 @@ typedef struct ExplainState
typedef void (*ExplainOptionHandler) (ExplainState *, DefElem *, ParseState *);
/* Hook to perform additional EXPLAIN options validation */
-typedef void (*explain_validate_options_hook_type) (struct ExplainState *es,
List *options,
+typedef void (*explain_validate_options_hook_type) (ExplainState *es, List
*options,
ParseState *pstate);
extern PGDLLIMPORT explain_validate_options_hook_type
explain_validate_options_hook;
diff --git a/src/include/foreign/fdwapi.h b/src/include/foreign/fdwapi.h
index b4da4e6a16a..a686887978d 100644
--- a/src/include/foreign/fdwapi.h
+++ b/src/include/foreign/fdwapi.h
@@ -16,8 +16,8 @@
#include "nodes/execnodes.h"
#include "nodes/pathnodes.h"
-/* To avoid including explain.h here, reference ExplainState thus: */
-struct ExplainState;
+/* avoid including explain.h here */
+typedef struct ExplainState ExplainState;
/*
@@ -137,16 +137,16 @@ typedef void (*RefetchForeignRow_function) (EState
*estate,
bool *updated);
typedef void (*ExplainForeignScan_function) (ForeignScanState *node,
-
struct ExplainState *es);
+
ExplainState *es);
typedef void (*ExplainForeignModify_function) (ModifyTableState *mtstate,
ResultRelInfo *rinfo,
List *fdw_private,
int subplan_index,
-
struct ExplainState *es);
+
ExplainState *es);
typedef void (*ExplainDirectModify_function) (ForeignScanState *node,
-
struct ExplainState *es);
+
ExplainState *es);
typedef int (*AcquireSampleRowsFunc) (Relation relation, int elevel,
HeapTuple *rows, int targrows,
--
2.51.0
From 8b70a03986274cb8c1353ef13521e47a3308cf5e Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <pe...@eisentraut.org>
Date: Fri, 29 Aug 2025 13:18:51 +0200
Subject: [PATCH 5/7] Update various forward declarations to use typedef
There are a number of forward declarations that use struct but not the
customary typedef, because that could have led to repeat typedefs,
which was not allowed. This is now allowed in C11, so we can update
these to provide the typedefs as well, so that the later uses of the
types look more consistent.
---
src/include/commands/tablecmds.h | 5 ++--
src/include/common/string.h | 7 +++--
src/include/executor/executor.h | 4 +--
src/include/executor/tablefunc.h | 18 ++++++------
src/include/nodes/execnodes.h | 40 +++++++++++++--------------
src/include/nodes/nodeFuncs.h | 6 ++--
src/include/nodes/params.h | 17 ++++++------
src/include/nodes/subscripting.h | 14 +++++-----
src/include/nodes/supportnodes.h | 26 ++++++++---------
src/include/optimizer/optimizer.h | 14 +++++-----
src/include/parser/parse_utilcmd.h | 4 +--
src/include/partitioning/partbounds.h | 6 ++--
src/include/partitioning/partprune.h | 10 +++----
src/include/rewrite/rewriteManip.h | 4 +--
src/include/storage/bufmgr.h | 24 ++++++++--------
src/include/storage/bulk_write.h | 4 +--
src/include/storage/dsm.h | 4 +--
src/include/storage/shmem.h | 5 ++--
src/include/tcop/pquery.h | 4 +--
src/include/utils/array.h | 6 ++--
src/include/utils/lsyscache.h | 6 ++--
src/include/utils/plancache.h | 14 +++++-----
src/include/utils/ruleutils.h | 8 +++---
src/tools/pgindent/typedefs.list | 1 +
24 files changed, 126 insertions(+), 125 deletions(-)
diff --git a/src/include/commands/tablecmds.h b/src/include/commands/tablecmds.h
index 6832470d387..e9b0fab0767 100644
--- a/src/include/commands/tablecmds.h
+++ b/src/include/commands/tablecmds.h
@@ -21,7 +21,8 @@
#include "storage/lock.h"
#include "utils/relcache.h"
-struct AlterTableUtilityContext; /* avoid including tcop/utility.h here
*/
+typedef struct AlterTableUtilityContext AlterTableUtilityContext; /*
avoid including
+
* tcop/utility.h here
*/
extern ObjectAddress DefineRelation(CreateStmt *stmt, char relkind, Oid
ownerId,
@@ -34,7 +35,7 @@ extern void RemoveRelations(DropStmt *drop);
extern Oid AlterTableLookupRelation(AlterTableStmt *stmt, LOCKMODE
lockmode);
extern void AlterTable(AlterTableStmt *stmt, LOCKMODE lockmode,
- struct AlterTableUtilityContext
*context);
+ AlterTableUtilityContext *context);
extern LOCKMODE AlterTableGetLockLevel(List *cmds);
diff --git a/src/include/common/string.h b/src/include/common/string.h
index ffe5ed51c5d..55ed8774364 100644
--- a/src/include/common/string.h
+++ b/src/include/common/string.h
@@ -12,7 +12,8 @@
#include <signal.h>
-struct StringInfoData; /* avoid including stringinfo.h here */
+typedef struct StringInfoData *StringInfo; /* avoid including stringinfo.h
+
* here */
typedef struct PromptInterruptContext
{
@@ -32,8 +33,8 @@ extern bool pg_is_ascii(const char *str);
/* functions in src/common/pg_get_line.c */
extern char *pg_get_line(FILE *stream, PromptInterruptContext *prompt_ctx);
-extern bool pg_get_line_buf(FILE *stream, struct StringInfoData *buf);
-extern bool pg_get_line_append(FILE *stream, struct StringInfoData *buf,
+extern bool pg_get_line_buf(FILE *stream, StringInfo buf);
+extern bool pg_get_line_append(FILE *stream, StringInfo buf,
PromptInterruptContext *prompt_ctx);
/* functions in src/common/sprompt.c */
diff --git a/src/include/executor/executor.h b/src/include/executor/executor.h
index 10dcea037c3..e7330ae61a7 100644
--- a/src/include/executor/executor.h
+++ b/src/include/executor/executor.h
@@ -100,12 +100,12 @@ extern PGDLLIMPORT ExecutorCheckPerms_hook_type
ExecutorCheckPerms_hook;
/*
* prototypes from functions in execAmi.c
*/
-struct Path; /* avoid including pathnodes.h
here */
+typedef struct Path Path; /* avoid including pathnodes.h here */
extern void ExecReScan(PlanState *node);
extern void ExecMarkPos(PlanState *node);
extern void ExecRestrPos(PlanState *node);
-extern bool ExecSupportsMarkRestore(struct Path *pathnode);
+extern bool ExecSupportsMarkRestore(Path *pathnode);
extern bool ExecSupportsBackwardScan(Plan *node);
extern bool ExecMaterializesOutput(NodeTag plantype);
diff --git a/src/include/executor/tablefunc.h b/src/include/executor/tablefunc.h
index 2c4498c5955..4dd5fef4aea 100644
--- a/src/include/executor/tablefunc.h
+++ b/src/include/executor/tablefunc.h
@@ -14,7 +14,7 @@
#define _TABLEFUNC_H
/* Forward-declare this to avoid including execnodes.h here */
-struct TableFuncScanState;
+typedef struct TableFuncScanState TableFuncScanState;
/*
* TableFuncRoutine holds function pointers used for generating content of
@@ -51,17 +51,17 @@ struct TableFuncScanState;
*/
typedef struct TableFuncRoutine
{
- void (*InitOpaque) (struct TableFuncScanState *state, int
natts);
- void (*SetDocument) (struct TableFuncScanState *state, Datum
value);
- void (*SetNamespace) (struct TableFuncScanState *state,
const char *name,
+ void (*InitOpaque) (TableFuncScanState *state, int natts);
+ void (*SetDocument) (TableFuncScanState *state, Datum value);
+ void (*SetNamespace) (TableFuncScanState *state, const char
*name,
const char
*uri);
- void (*SetRowFilter) (struct TableFuncScanState *state,
const char *path);
- void (*SetColumnFilter) (struct TableFuncScanState *state,
+ void (*SetRowFilter) (TableFuncScanState *state, const char
*path);
+ void (*SetColumnFilter) (TableFuncScanState *state,
const
char *path, int colnum);
- bool (*FetchRow) (struct TableFuncScanState *state);
- Datum (*GetValue) (struct TableFuncScanState *state, int
colnum,
+ bool (*FetchRow) (TableFuncScanState *state);
+ Datum (*GetValue) (TableFuncScanState *state, int colnum,
Oid typid, int32
typmod, bool *isnull);
- void (*DestroyOpaque) (struct TableFuncScanState *state);
+ void (*DestroyOpaque) (TableFuncScanState *state);
} TableFuncRoutine;
#endif /* _TABLEFUNC_H */
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index de782014b2d..9623e53e591 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -49,15 +49,13 @@
#include "utils/tuplesort.h"
#include "utils/tuplestore.h"
-struct PlanState; /* forward references in this
file */
-struct ParallelHashJoinState;
-struct ExecRowMark;
-struct ExprState;
-struct ExprContext;
-struct RangeTblEntry; /* avoid including parsenodes.h here */
-struct ExprEvalStep; /* avoid including execExpr.h
everywhere */
-struct CopyMultiInsertBuffer;
-struct LogicalTapeSet;
+/*
+ * forward references in this file
+ */
+typedef struct PlanState PlanState;
+typedef struct ExecRowMark ExecRowMark;
+typedef struct ExprState ExprState;
+typedef struct ExprContext ExprContext;
/* ----------------
@@ -67,8 +65,8 @@ struct LogicalTapeSet;
* It contains instructions (in ->steps) to evaluate the expression.
* ----------------
*/
-typedef Datum (*ExprStateEvalFunc) (struct ExprState *expression,
- struct
ExprContext *econtext,
+typedef Datum (*ExprStateEvalFunc) (ExprState *expression,
+
ExprContext *econtext,
bool
*isNull);
/* Bits in ExprState->flags (see also execExpr.h for private flag bits): */
@@ -131,7 +129,7 @@ typedef struct ExprState
int steps_alloc; /* allocated length of steps
array */
#define FIELDNO_EXPRSTATE_PARENT 11
- struct PlanState *parent; /* parent PlanState node, if any */
+ PlanState *parent; /* parent PlanState node, if
any */
ParamListInfo ext_params; /* for compiling PARAM_EXTERN nodes */
Datum *innermost_caseval;
@@ -638,8 +636,8 @@ typedef struct ResultRelInfo
*/
typedef struct AsyncRequest
{
- struct PlanState *requestor; /* Node that wants a tuple */
- struct PlanState *requestee; /* Node from which a tuple is wanted */
+ PlanState *requestor; /* Node that wants a tuple */
+ PlanState *requestee; /* Node from which a tuple is wanted */
int request_index; /* Scratch space for requestor
*/
bool callback_pending; /* Callback is needed */
bool request_complete; /* Request complete, result
valid */
@@ -665,8 +663,8 @@ typedef struct EState
Index es_range_table_size; /* size of the range table
arrays */
Relation *es_relations; /* Array of per-range-table-entry
Relation
* pointers, or
NULL if not yet opened */
- struct ExecRowMark **es_rowmarks; /* Array of
per-range-table-entry
-
* ExecRowMarks, or NULL if none */
+ ExecRowMark **es_rowmarks; /* Array of per-range-table-entry
+ *
ExecRowMarks, or NULL if none */
List *es_rteperminfos; /* List of RTEPermissionInfo */
PlannedStmt *es_plannedstmt; /* link to top of plan tree */
List *es_part_prune_infos; /* List of PartitionPruneInfo */
@@ -1006,8 +1004,8 @@ typedef struct SubPlanState
{
NodeTag type;
SubPlan *subplan; /* expression plan node */
- struct PlanState *planstate; /* subselect plan's state tree */
- struct PlanState *parent; /* parent plan node's state tree */
+ PlanState *planstate; /* subselect plan's state tree */
+ PlanState *parent; /* parent plan node's state
tree */
ExprState *testexpr; /* state of combining expression */
HeapTuple curTuple; /* copy of most recent tuple
from subplan */
Datum curArray; /* most recent array from
ARRAY() subplan */
@@ -1144,7 +1142,7 @@ typedef struct JsonExprState
* if no more tuples are available.
* ----------------
*/
-typedef TupleTableSlot *(*ExecProcNodeMtd) (struct PlanState *pstate);
+typedef TupleTableSlot *(*ExecProcNodeMtd) (PlanState *pstate);
/* ----------------
* PlanState node
@@ -1181,8 +1179,8 @@ typedef struct PlanState
* subPlan list, which does not exist in the plan tree).
*/
ExprState *qual; /* boolean qual condition */
- struct PlanState *lefttree; /* input plan tree(s) */
- struct PlanState *righttree;
+ PlanState *lefttree; /* input plan tree(s) */
+ PlanState *righttree;
List *initPlan; /* Init SubPlanState nodes
(un-correlated expr
* subselects)
*/
diff --git a/src/include/nodes/nodeFuncs.h b/src/include/nodes/nodeFuncs.h
index 5653fec8cbe..11c1c140ec4 100644
--- a/src/include/nodes/nodeFuncs.h
+++ b/src/include/nodes/nodeFuncs.h
@@ -15,7 +15,7 @@
#include "nodes/parsenodes.h"
-struct PlanState; /* avoid including execnodes.h
too */
+typedef struct PlanState PlanState; /* avoid including execnodes.h too */
/* flags bits for query_tree_walker and query_tree_mutator */
@@ -38,7 +38,7 @@ typedef bool (*check_function_callback) (Oid func_id, void
*context);
/* callback functions for tree walkers */
typedef bool (*tree_walker_callback) (Node *node, void *context);
-typedef bool (*planstate_tree_walker_callback) (struct PlanState *planstate,
+typedef bool (*planstate_tree_walker_callback) (PlanState *planstate,
void *context);
/* callback functions for tree mutators */
@@ -217,7 +217,7 @@ extern bool raw_expression_tree_walker_impl(Node *node,
tree_walker_callback walker,
void *context);
-extern bool planstate_tree_walker_impl(struct PlanState *planstate,
+extern bool planstate_tree_walker_impl(PlanState *planstate,
planstate_tree_walker_callback walker,
void
*context);
diff --git a/src/include/nodes/params.h b/src/include/nodes/params.h
index 4321ca6329b..3c84df3f79a 100644
--- a/src/include/nodes/params.h
+++ b/src/include/nodes/params.h
@@ -14,11 +14,10 @@
#ifndef PARAMS_H
#define PARAMS_H
-/* Forward declarations, to avoid including other headers */
-struct Bitmapset;
-struct ExprState;
-struct Param;
-struct ParseState;
+/* to avoid including other headers */
+typedef struct ExprState ExprState;
+typedef struct Param Param;
+typedef struct ParseState ParseState;
/*
@@ -101,11 +100,11 @@ typedef ParamExternData *(*ParamFetchHook) (ParamListInfo
params,
int paramid, bool speculative,
ParamExternData *workspace);
-typedef void (*ParamCompileHook) (ParamListInfo params, struct Param *param,
- struct
ExprState *state,
+typedef void (*ParamCompileHook) (ParamListInfo params, Param *param,
+ ExprState
*state,
Datum *resv,
bool *resnull);
-typedef void (*ParserSetupHook) (struct ParseState *pstate, void *arg);
+typedef void (*ParserSetupHook) (ParseState *pstate, void *arg);
typedef struct ParamListInfoData
{
@@ -123,7 +122,7 @@ typedef struct ParamListInfoData
* must be of length numParams.
*/
ParamExternData params[FLEXIBLE_ARRAY_MEMBER];
-} ParamListInfoData;
+} ParamListInfoData;
/* ----------------
diff --git a/src/include/nodes/subscripting.h b/src/include/nodes/subscripting.h
index 234e8ad8012..e991f4bf826 100644
--- a/src/include/nodes/subscripting.h
+++ b/src/include/nodes/subscripting.h
@@ -15,10 +15,10 @@
#include "nodes/primnodes.h"
-/* Forward declarations, to avoid including other headers */
-struct ParseState;
-struct SubscriptingRefState;
-struct SubscriptExecSteps;
+/* to avoid including other headers */
+typedef struct ParseState ParseState;
+typedef struct SubscriptingRefState SubscriptingRefState;
+typedef struct SubscriptExecSteps SubscriptExecSteps;
/*
* The SQL-visible function that defines a subscripting method is declared
@@ -94,7 +94,7 @@ struct SubscriptExecSteps;
*/
typedef void (*SubscriptTransform) (SubscriptingRef *sbsref,
List
*indirection,
- struct
ParseState *pstate,
+
ParseState *pstate,
bool
isSlice,
bool
isAssignment);
@@ -151,8 +151,8 @@ typedef void (*SubscriptTransform) (SubscriptingRef *sbsref,
* Set the relevant pointers to NULL for any omitted methods.
*/
typedef void (*SubscriptExecSetup) (const SubscriptingRef *sbsref,
- struct
SubscriptingRefState *sbsrefstate,
- struct
SubscriptExecSteps *methods);
+
SubscriptingRefState *sbsrefstate,
+
SubscriptExecSteps *methods);
/* Struct returned by the SQL-visible subscript handler function */
typedef struct SubscriptRoutines
diff --git a/src/include/nodes/supportnodes.h b/src/include/nodes/supportnodes.h
index 9c047cc401b..7b623d54058 100644
--- a/src/include/nodes/supportnodes.h
+++ b/src/include/nodes/supportnodes.h
@@ -35,10 +35,10 @@
#include "nodes/plannodes.h"
-struct PlannerInfo; /* avoid including pathnodes.h
here */
-struct IndexOptInfo;
-struct SpecialJoinInfo;
-struct WindowClause;
+typedef struct PlannerInfo PlannerInfo; /* avoid including pathnodes.h here */
+typedef struct IndexOptInfo IndexOptInfo;
+typedef struct SpecialJoinInfo SpecialJoinInfo;
+typedef struct WindowClause WindowClause;
/*
* The Simplify request allows the support function to perform plan-time
@@ -65,7 +65,7 @@ typedef struct SupportRequestSimplify
{
NodeTag type;
- struct PlannerInfo *root; /* Planner's infrastructure */
+ PlannerInfo *root; /* Planner's infrastructure */
FuncExpr *fcall; /* Function call to be
simplified */
} SupportRequestSimplify;
@@ -93,14 +93,14 @@ typedef struct SupportRequestSelectivity
NodeTag type;
/* Input fields: */
- struct PlannerInfo *root; /* Planner's infrastructure */
+ PlannerInfo *root; /* Planner's infrastructure */
Oid funcid; /* function we are
inquiring about */
List *args; /* pre-simplified arguments to
function */
Oid inputcollid; /* function's input collation */
bool is_join; /* is this a join or
restriction case? */
int varRelid; /* if restriction, RTI
of target relation */
JoinType jointype; /* if join, outer join type */
- struct SpecialJoinInfo *sjinfo; /* if outer join, info about join */
+ SpecialJoinInfo *sjinfo; /* if outer join, info about join */
/* Output fields: */
Selectivity selectivity; /* returned selectivity estimate */
@@ -133,7 +133,7 @@ typedef struct SupportRequestCost
NodeTag type;
/* Input fields: */
- struct PlannerInfo *root; /* Planner's infrastructure (could be
NULL) */
+ PlannerInfo *root; /* Planner's infrastructure
(could be NULL) */
Oid funcid; /* function we are
inquiring about */
Node *node; /* parse node invoking
function, or NULL */
@@ -160,7 +160,7 @@ typedef struct SupportRequestRows
NodeTag type;
/* Input fields: */
- struct PlannerInfo *root; /* Planner's infrastructure (could be
NULL) */
+ PlannerInfo *root; /* Planner's infrastructure
(could be NULL) */
Oid funcid; /* function we are
inquiring about */
Node *node; /* parse node invoking function
*/
@@ -225,11 +225,11 @@ typedef struct SupportRequestIndexCondition
NodeTag type;
/* Input fields: */
- struct PlannerInfo *root; /* Planner's infrastructure */
+ PlannerInfo *root; /* Planner's infrastructure */
Oid funcid; /* function we are
inquiring about */
Node *node; /* parse node invoking function
*/
int indexarg; /* index of function
arg matching indexcol */
- struct IndexOptInfo *index; /* planner's info about target index */
+ IndexOptInfo *index; /* planner's info about target index */
int indexcol; /* index of target
index column (0-based) */
Oid opfamily; /* index column's
operator family */
Oid indexcollation; /* index column's collation */
@@ -293,7 +293,7 @@ typedef struct SupportRequestWFuncMonotonic
/* Input fields: */
WindowFunc *window_func; /* Pointer to the window function data
*/
- struct WindowClause *window_clause; /* Pointer to the window clause
data */
+ WindowClause *window_clause; /* Pointer to the window clause data */
/* Output fields: */
MonotonicFunction monotonic;
@@ -336,7 +336,7 @@ typedef struct SupportRequestOptimizeWindowClause
/* Input fields: */
WindowFunc *window_func; /* Pointer to the window function data
*/
- struct WindowClause *window_clause; /* Pointer to the window clause
data */
+ WindowClause *window_clause; /* Pointer to the window clause data */
/* Input/Output fields: */
int frameOptions; /* New frameOptions, or left
untouched if no
diff --git a/src/include/optimizer/optimizer.h
b/src/include/optimizer/optimizer.h
index 03b214755c2..d490ef3b506 100644
--- a/src/include/optimizer/optimizer.h
+++ b/src/include/optimizer/optimizer.h
@@ -35,9 +35,9 @@ typedef struct IndexOptInfo IndexOptInfo;
typedef struct SpecialJoinInfo SpecialJoinInfo;
/* It also seems best not to include plannodes.h, params.h, or htup.h here */
-struct PlannedStmt;
-struct ParamListInfoData;
-struct HeapTupleData;
+typedef struct PlannedStmt PlannedStmt;
+typedef struct ParamListInfoData ParamListInfoData;
+typedef struct HeapTupleData *HeapTuple;
/* in path/clausesel.c: */
@@ -102,9 +102,9 @@ extern PGDLLIMPORT int debug_parallel_query;
extern PGDLLIMPORT bool parallel_leader_participation;
extern PGDLLIMPORT bool enable_distinct_reordering;
-extern struct PlannedStmt *planner(Query *parse, const char *query_string,
- int
cursorOptions,
- struct
ParamListInfoData *boundParams);
+extern PlannedStmt *planner(Query *parse, const char *query_string,
+ int cursorOptions,
+ ParamListInfoData
*boundParams);
extern Expr *expression_planner(Expr *expr);
extern Expr *expression_planner_with_deps(Expr *expr,
@@ -147,7 +147,7 @@ extern bool var_is_nonnullable(PlannerInfo *root, Var *var,
bool use_rel_info);
extern List *expand_function_arguments(List *args, bool include_out_arguments,
Oid
result_type,
-
struct HeapTupleData *func_tuple);
+
HeapTuple func_tuple);
extern ScalarArrayOpExpr *make_SAOP_expr(Oid oper, Node *leftexpr,
Oid coltype, Oid arraycollid,
diff --git a/src/include/parser/parse_utilcmd.h
b/src/include/parser/parse_utilcmd.h
index 9f2b58de797..4965fac4495 100644
--- a/src/include/parser/parse_utilcmd.h
+++ b/src/include/parser/parse_utilcmd.h
@@ -16,7 +16,7 @@
#include "parser/parse_node.h"
-struct AttrMap; /* avoid including
attmap.h here */
+typedef struct AttrMap AttrMap; /* avoid including attmap.h here */
extern List *transformCreateStmt(CreateStmt *stmt, const char *queryString);
@@ -38,7 +38,7 @@ extern List *expandTableLikeClause(RangeVar *heapRel,
TableLikeClause *table_like_clause);
extern IndexStmt *generateClonedIndexStmt(RangeVar *heapRel,
Relation source_idx,
-
const struct AttrMap *attmap,
+
const AttrMap *attmap,
Oid *constraintOid);
#endif /* PARSE_UTILCMD_H */
diff --git a/src/include/partitioning/partbounds.h
b/src/include/partitioning/partbounds.h
index 65f161f7188..083b6e3a88a 100644
--- a/src/include/partitioning/partbounds.h
+++ b/src/include/partitioning/partbounds.h
@@ -15,7 +15,7 @@
#include "parser/parse_node.h"
#include "partitioning/partdefs.h"
-struct RelOptInfo; /* avoid including pathnodes.h
here */
+typedef struct RelOptInfo RelOptInfo; /* avoid including pathnodes.h here */
/*
@@ -114,8 +114,8 @@ extern PartitionBoundInfo
partition_bounds_copy(PartitionBoundInfo src,
extern PartitionBoundInfo partition_bounds_merge(int partnatts,
FmgrInfo *partsupfunc,
Oid *partcollation,
-
struct RelOptInfo *outer_rel,
-
struct RelOptInfo *inner_rel,
+
RelOptInfo *outer_rel,
+
RelOptInfo *inner_rel,
JoinType jointype,
List **outer_parts,
List **inner_parts);
diff --git a/src/include/partitioning/partprune.h
b/src/include/partitioning/partprune.h
index c413734789a..657b436d958 100644
--- a/src/include/partitioning/partprune.h
+++ b/src/include/partitioning/partprune.h
@@ -17,8 +17,8 @@
#include "nodes/execnodes.h"
#include "partitioning/partdefs.h"
-struct PlannerInfo; /* avoid including pathnodes.h
here */
-struct RelOptInfo;
+typedef struct PlannerInfo PlannerInfo; /* avoid including pathnodes.h here */
+typedef struct RelOptInfo RelOptInfo;
/*
@@ -70,11 +70,11 @@ typedef struct PartitionPruneContext
#define PruneCxtStateIdx(partnatts, step_id, keyno) \
((partnatts) * (step_id) + (keyno))
-extern int make_partition_pruneinfo(struct PlannerInfo *root,
- struct
RelOptInfo *parentrel,
+extern int make_partition_pruneinfo(PlannerInfo *root,
+
RelOptInfo *parentrel,
List
*subpaths,
List
*prunequal);
-extern Bitmapset *prune_append_rel_partitions(struct RelOptInfo *rel);
+extern Bitmapset *prune_append_rel_partitions(RelOptInfo *rel);
extern Bitmapset *get_matching_partitions(PartitionPruneContext *context,
List *pruning_steps);
diff --git a/src/include/rewrite/rewriteManip.h
b/src/include/rewrite/rewriteManip.h
index 7c018f2a4e3..74de195deeb 100644
--- a/src/include/rewrite/rewriteManip.h
+++ b/src/include/rewrite/rewriteManip.h
@@ -17,7 +17,7 @@
#include "nodes/parsenodes.h"
#include "nodes/pathnodes.h"
-struct AttrMap; /* avoid including
attmap.h here */
+typedef struct AttrMap AttrMap; /* avoid including attmap.h here */
typedef struct replace_rte_variables_context replace_rte_variables_context;
@@ -101,7 +101,7 @@ extern Node *replace_rte_variables_mutator(Node *node,
extern Node *map_variable_attnos(Node *node,
int
target_varno, int sublevels_up,
- const struct
AttrMap *attno_map,
+ const AttrMap
*attno_map,
Oid
to_rowtype, bool *found_whole_row);
extern Node *ReplaceVarFromTargetList(Var *var,
diff --git a/src/include/storage/bufmgr.h b/src/include/storage/bufmgr.h
index 41fdc1e7693..47360a3d3d8 100644
--- a/src/include/storage/bufmgr.h
+++ b/src/include/storage/bufmgr.h
@@ -93,6 +93,9 @@ typedef enum ExtendBufferedFlags
EB_LOCK_TARGET = (1 << 5),
} ExtendBufferedFlags;
+/* forward declared, to avoid including smgr.h here */
+typedef struct SMgrRelationData *SMgrRelation;
+
/*
* Some functions identify relations either by relation or smgr +
* relpersistence. Used via the BMR_REL()/BMR_SMGR() macros below. This
@@ -101,7 +104,7 @@ typedef enum ExtendBufferedFlags
typedef struct BufferManagerRelation
{
Relation rel;
- struct SMgrRelationData *smgr;
+ SMgrRelation smgr;
char relpersistence;
} BufferManagerRelation;
@@ -122,7 +125,7 @@ struct ReadBuffersOperation
{
/* The following members should be set by the caller. */
Relation rel; /* optional */
- struct SMgrRelationData *smgr;
+ SMgrRelation smgr;
char persistence;
ForkNumber forknum;
BufferAccessStrategy strategy;
@@ -143,11 +146,8 @@ struct ReadBuffersOperation
typedef struct ReadBuffersOperation ReadBuffersOperation;
-/* forward declared, to avoid having to expose buf_internals.h here */
-struct WritebackContext;
-
-/* forward declared, to avoid including smgr.h here */
-struct SMgrRelationData;
+/* to avoid having to expose buf_internals.h here */
+typedef struct WritebackContext WritebackContext;
/* in globals.c ... this duplicates miscadmin.h */
extern PGDLLIMPORT int NBuffers;
@@ -201,7 +201,7 @@ extern PGDLLIMPORT int32 *LocalRefCount;
/*
* prototypes for functions in bufmgr.c
*/
-extern PrefetchBufferResult PrefetchSharedBuffer(struct SMgrRelationData
*smgr_reln,
+extern PrefetchBufferResult PrefetchSharedBuffer(SMgrRelation smgr_reln,
ForkNumber forkNum,
BlockNumber blockNum);
extern PrefetchBufferResult PrefetchBuffer(Relation reln, ForkNumber forkNum,
@@ -268,15 +268,15 @@ extern BlockNumber
RelationGetNumberOfBlocksInFork(Relation relation,
ForkNumber forkNum);
extern void FlushOneBuffer(Buffer buffer);
extern void FlushRelationBuffers(Relation rel);
-extern void FlushRelationsAllBuffers(struct SMgrRelationData **smgrs, int
nrels);
+extern void FlushRelationsAllBuffers(SMgrRelation *smgrs, int nrels);
extern void CreateAndCopyRelationData(RelFileLocator src_rlocator,
RelFileLocator dst_rlocator,
bool
permanent);
extern void FlushDatabaseBuffers(Oid dbid);
-extern void DropRelationBuffers(struct SMgrRelationData *smgr_reln,
+extern void DropRelationBuffers(SMgrRelation smgr_reln,
ForkNumber
*forkNum,
int nforks,
BlockNumber *firstDelBlock);
-extern void DropRelationsAllBuffers(struct SMgrRelationData **smgr_reln,
+extern void DropRelationsAllBuffers(SMgrRelation *smgr_reln,
int
nlocators);
extern void DropDatabaseBuffers(Oid dbid);
@@ -298,7 +298,7 @@ extern bool ConditionalLockBufferForCleanup(Buffer buffer);
extern bool IsBufferCleanupOK(Buffer buffer);
extern bool HoldingBufferPinThatDelaysRecovery(void);
-extern bool BgBufferSync(struct WritebackContext *wb_context);
+extern bool BgBufferSync(WritebackContext *wb_context);
extern uint32 GetPinLimit(void);
extern uint32 GetLocalPinLimit(void);
diff --git a/src/include/storage/bulk_write.h b/src/include/storage/bulk_write.h
index 7885415f6cb..ca359784016 100644
--- a/src/include/storage/bulk_write.h
+++ b/src/include/storage/bulk_write.h
@@ -28,10 +28,10 @@ typedef struct BulkWriteState BulkWriteState;
typedef PGIOAlignedBlock *BulkWriteBuffer;
/* forward declared from smgr.h */
-struct SMgrRelationData;
+typedef struct SMgrRelationData *SMgrRelation;
extern BulkWriteState *smgr_bulk_start_rel(Relation rel, ForkNumber forknum);
-extern BulkWriteState *smgr_bulk_start_smgr(struct SMgrRelationData *smgr,
ForkNumber forknum, bool use_wal);
+extern BulkWriteState *smgr_bulk_start_smgr(SMgrRelation smgr, ForkNumber
forknum, bool use_wal);
extern BulkWriteBuffer smgr_bulk_get_buf(BulkWriteState *bulkstate);
extern void smgr_bulk_write(BulkWriteState *bulkstate, BlockNumber blocknum,
BulkWriteBuffer buf, bool page_std);
diff --git a/src/include/storage/dsm.h b/src/include/storage/dsm.h
index 2302cc7f40b..88cf0962957 100644
--- a/src/include/storage/dsm.h
+++ b/src/include/storage/dsm.h
@@ -20,9 +20,9 @@ typedef struct dsm_segment dsm_segment;
#define DSM_CREATE_NULL_IF_MAXSEGMENTS 0x0001
/* Startup and shutdown functions. */
-struct PGShmemHeader; /* avoid including pg_shmem.h */
+typedef struct PGShmemHeader PGShmemHeader; /* avoid including pg_shmem.h */
extern void dsm_cleanup_using_control_segment(dsm_handle old_control_handle);
-extern void dsm_postmaster_startup(struct PGShmemHeader *);
+extern void dsm_postmaster_startup(PGShmemHeader *);
extern void dsm_backend_shutdown(void);
extern void dsm_detach_all(void);
diff --git a/src/include/storage/shmem.h b/src/include/storage/shmem.h
index 8604feca93b..cd683a9d2d9 100644
--- a/src/include/storage/shmem.h
+++ b/src/include/storage/shmem.h
@@ -27,8 +27,9 @@
/* shmem.c */
extern PGDLLIMPORT slock_t *ShmemLock;
-struct PGShmemHeader; /* avoid including storage/pg_shmem.h
here */
-extern void InitShmemAccess(struct PGShmemHeader *seghdr);
+typedef struct PGShmemHeader PGShmemHeader; /* avoid including
+
* storage/pg_shmem.h here */
+extern void InitShmemAccess(PGShmemHeader *seghdr);
extern void InitShmemAllocation(void);
extern void *ShmemAlloc(Size size);
extern void *ShmemAllocNoError(Size size);
diff --git a/src/include/tcop/pquery.h b/src/include/tcop/pquery.h
index fa3cc5f2dfc..ccd995fc88e 100644
--- a/src/include/tcop/pquery.h
+++ b/src/include/tcop/pquery.h
@@ -17,7 +17,7 @@
#include "nodes/parsenodes.h"
#include "utils/portal.h"
-struct PlannedStmt; /* avoid including plannodes.h
here */
+typedef struct PlannedStmt PlannedStmt; /* avoid including plannodes.h here */
extern PGDLLIMPORT Portal ActivePortal;
@@ -44,7 +44,7 @@ extern uint64 PortalRunFetch(Portal portal,
long count,
DestReceiver *dest);
-extern bool PlannedStmtRequiresSnapshot(struct PlannedStmt *pstmt);
+extern bool PlannedStmtRequiresSnapshot(PlannedStmt *pstmt);
extern void EnsurePortalSnapshotExists(void);
diff --git a/src/include/utils/array.h b/src/include/utils/array.h
index 52f1fbf8d43..3383f16a3bb 100644
--- a/src/include/utils/array.h
+++ b/src/include/utils/array.h
@@ -65,8 +65,8 @@
#include "utils/expandeddatum.h"
/* avoid including execnodes.h here */
-struct ExprState;
-struct ExprContext;
+typedef struct ExprState ExprState;
+typedef struct ExprContext ExprContext;
/*
@@ -384,7 +384,7 @@ extern ArrayType *array_set(ArrayType *array, int
nSubscripts, int *indx,
int arraytyplen, int
elmlen, bool elmbyval, char elmalign);
extern Datum array_map(Datum arrayd,
- struct ExprState *exprstate, struct
ExprContext *econtext,
+ ExprState *exprstate, ExprContext
*econtext,
Oid retType, ArrayMapState *amstate);
extern void array_bitmap_copy(bits8 *destbitmap, int destoffset,
diff --git a/src/include/utils/lsyscache.h b/src/include/utils/lsyscache.h
index c65cee4f24c..50fb149e9ac 100644
--- a/src/include/utils/lsyscache.h
+++ b/src/include/utils/lsyscache.h
@@ -19,7 +19,7 @@
#include "nodes/pg_list.h"
/* avoid including subscripting.h here */
-struct SubscriptRoutines;
+typedef struct SubscriptRoutines SubscriptRoutines;
/* Result list element for get_op_index_interpretation */
typedef struct OpIndexInterpretation
@@ -187,8 +187,8 @@ extern Oid get_typmodin(Oid typid);
extern Oid get_typcollation(Oid typid);
extern bool type_is_collatable(Oid typid);
extern RegProcedure get_typsubscript(Oid typid, Oid *typelemp);
-extern const struct SubscriptRoutines *getSubscriptingRoutines(Oid typid,
-
Oid *typelemp);
+extern const SubscriptRoutines *getSubscriptingRoutines(Oid typid,
+
Oid *typelemp);
extern Oid getBaseType(Oid typid);
extern Oid getBaseTypeAndTypmod(Oid typid, int32 *typmod);
extern int32 get_typavgwidth(Oid typid, int32 typmod);
diff --git a/src/include/utils/plancache.h b/src/include/utils/plancache.h
index 1baa6d50bfd..a82b66d4bc2 100644
--- a/src/include/utils/plancache.h
+++ b/src/include/utils/plancache.h
@@ -24,8 +24,8 @@
/* Forward declarations, to avoid including parsenodes.h here */
-struct Query;
-struct RawStmt;
+typedef struct Query Query;
+typedef struct RawStmt RawStmt;
/* possible values for plan_cache_mode */
typedef enum
@@ -105,8 +105,8 @@ typedef void (*PostRewriteHook) (List *querytree_list, void
*arg);
typedef struct CachedPlanSource
{
int magic; /* should equal
CACHEDPLANSOURCE_MAGIC */
- struct RawStmt *raw_parse_tree; /* output of raw_parser(), or NULL */
- struct Query *analyzed_parse_tree; /* analyzed parse tree, or NULL
*/
+ RawStmt *raw_parse_tree; /* output of raw_parser(), or NULL */
+ Query *analyzed_parse_tree; /* analyzed parse tree, or NULL
*/
const char *query_string; /* source text of query */
CommandTag commandTag; /* command tag for query */
Oid *param_types; /* array of parameter type
OIDs, or NULL */
@@ -202,13 +202,13 @@ extern void ResetPlanCache(void);
extern void ReleaseAllPlanCacheRefsInOwner(ResourceOwner owner);
-extern CachedPlanSource *CreateCachedPlan(struct RawStmt *raw_parse_tree,
+extern CachedPlanSource *CreateCachedPlan(RawStmt *raw_parse_tree,
const char *query_string,
CommandTag commandTag);
-extern CachedPlanSource *CreateCachedPlanForQuery(struct Query
*analyzed_parse_tree,
+extern CachedPlanSource *CreateCachedPlanForQuery(Query *analyzed_parse_tree,
const char *query_string,
CommandTag commandTag);
-extern CachedPlanSource *CreateOneShotCachedPlan(struct RawStmt
*raw_parse_tree,
+extern CachedPlanSource *CreateOneShotCachedPlan(RawStmt *raw_parse_tree,
const char *query_string,
CommandTag commandTag);
extern void CompleteCachedPlan(CachedPlanSource *plansource,
diff --git a/src/include/utils/ruleutils.h b/src/include/utils/ruleutils.h
index 5f2ea2e4d0e..7ba7d887914 100644
--- a/src/include/utils/ruleutils.h
+++ b/src/include/utils/ruleutils.h
@@ -17,8 +17,8 @@
#include "nodes/parsenodes.h"
#include "nodes/pg_list.h"
-struct Plan; /* avoid including plannodes.h
here */
-struct PlannedStmt;
+typedef struct Plan Plan; /* avoid including plannodes.h here */
+typedef struct PlannedStmt PlannedStmt;
/* Flags for pg_get_indexdef_columns_extended() */
#define RULE_INDEXDEF_PRETTY 0x01
@@ -37,10 +37,10 @@ extern char *pg_get_constraintdef_command(Oid constraintId);
extern char *deparse_expression(Node *expr, List *dpcontext,
bool
forceprefix, bool showimplicit);
extern List *deparse_context_for(const char *aliasname, Oid relid);
-extern List *deparse_context_for_plan_tree(struct PlannedStmt *pstmt,
+extern List *deparse_context_for_plan_tree(PlannedStmt *pstmt,
List *rtable_names);
extern List *set_deparse_context_plan(List *dpcontext,
-
struct Plan *plan, List *ancestors);
+ Plan
*plan, List *ancestors);
extern List *select_rtable_names_for_explain(List *rtable,
Bitmapset *rels_used);
extern char *get_window_frame_options_for_explain(int frameOptions,
diff --git a/src/tools/pgindent/typedefs.list b/src/tools/pgindent/typedefs.list
index a13e8162890..d918eda4aaf 100644
--- a/src/tools/pgindent/typedefs.list
+++ b/src/tools/pgindent/typedefs.list
@@ -2083,6 +2083,7 @@ ParamExternData
ParamFetchHook
ParamKind
ParamListInfo
+ParamListInfoData
ParamPathInfo
ParamRef
ParamsErrorCbData
--
2.51.0
From 4505dd4e62776770076f582a3ad01b9c35eafe6c Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <pe...@eisentraut.org>
Date: Fri, 29 Aug 2025 13:18:51 +0200
Subject: [PATCH 6/7] Remove hbaPort type
This was just a workaround to avoid including the header file that
defines the Port type. With C11, we can now just re-define the Port
type without the possibility of a conflict.
---
src/backend/libpq/auth.c | 8 ++++----
src/backend/libpq/hba.c | 6 +++---
src/include/libpq/hba.h | 6 +++---
src/tools/pgindent/typedefs.list | 1 -
4 files changed, 10 insertions(+), 11 deletions(-)
diff --git a/src/backend/libpq/auth.c b/src/backend/libpq/auth.c
index 4da46666439..ec4dbacf015 100644
--- a/src/backend/libpq/auth.c
+++ b/src/backend/libpq/auth.c
@@ -70,14 +70,14 @@ static int CheckMD5Auth(Port *port, char *shadow_pass,
/* Standard TCP port number for Ident service. Assigned by IANA */
#define IDENT_PORT 113
-static int ident_inet(hbaPort *port);
+static int ident_inet(Port *port);
/*----------------------------------------------------------------
* Peer authentication
*----------------------------------------------------------------
*/
-static int auth_peer(hbaPort *port);
+static int auth_peer(Port *port);
/*----------------------------------------------------------------
@@ -1668,7 +1668,7 @@ interpret_ident_response(const char *ident_response,
* latch was set would improve the responsiveness to
timeouts/cancellations.
*/
static int
-ident_inet(hbaPort *port)
+ident_inet(Port *port)
{
const SockAddr remote_addr = port->raddr;
const SockAddr local_addr = port->laddr;
@@ -1853,7 +1853,7 @@ ident_inet(hbaPort *port)
* Iff authorized, return STATUS_OK, otherwise return STATUS_ERROR.
*/
static int
-auth_peer(hbaPort *port)
+auth_peer(Port *port)
{
uid_t uid;
gid_t gid;
diff --git a/src/backend/libpq/hba.c b/src/backend/libpq/hba.c
index fecee8224d0..97a3586000b 100644
--- a/src/backend/libpq/hba.c
+++ b/src/backend/libpq/hba.c
@@ -1075,7 +1075,7 @@ hostname_match(const char *pattern, const char
*actual_hostname)
* Check to see if a connecting IP matches a given host name.
*/
static bool
-check_hostname(hbaPort *port, const char *hostname)
+check_hostname(Port *port, const char *hostname)
{
struct addrinfo *gai_result,
*gai;
@@ -2528,7 +2528,7 @@ parse_hba_auth_opt(char *name, char *val, HbaLine
*hbaline,
* request.
*/
static void
-check_hba(hbaPort *port)
+check_hba(Port *port)
{
Oid roleid;
ListCell *line;
@@ -3125,7 +3125,7 @@ load_ident(void)
* method = uaImplicitReject.
*/
void
-hba_getauthmethod(hbaPort *port)
+hba_getauthmethod(Port *port)
{
check_hba(port);
}
diff --git a/src/include/libpq/hba.h b/src/include/libpq/hba.h
index 3657f182db3..e3748d3c8c9 100644
--- a/src/include/libpq/hba.h
+++ b/src/include/libpq/hba.h
@@ -169,13 +169,13 @@ typedef struct TokenizedAuthLine
char *err_msg; /* Error message if any */
} TokenizedAuthLine;
-/* kluge to avoid including libpq/libpq-be.h here */
-typedef struct Port hbaPort;
+/* avoid including libpq/libpq-be.h here */
+typedef struct Port Port;
extern bool load_hba(void);
extern bool load_ident(void);
extern const char *hba_authname(UserAuth auth_method);
-extern void hba_getauthmethod(hbaPort *port);
+extern void hba_getauthmethod(Port *port);
extern int check_usermap(const char *usermap_name,
const char *pg_user, const
char *system_user,
bool case_insensitive);
diff --git a/src/tools/pgindent/typedefs.list b/src/tools/pgindent/typedefs.list
index d918eda4aaf..0f4974b5fcb 100644
--- a/src/tools/pgindent/typedefs.list
+++ b/src/tools/pgindent/typedefs.list
@@ -3688,7 +3688,6 @@ gss_key_value_set_desc
gss_name_t
gtrgm_consistent_cache
gzFile
-hbaPort
heap_page_items_state
help_handler
hlCheck
--
2.51.0
From 92c1e5672f97eb545f7c561f07f502ad19ab5e06 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <pe...@eisentraut.org>
Date: Fri, 29 Aug 2025 13:18:51 +0200
Subject: [PATCH 7/7] Change fmgr.h typedefs to use original names
fmgr.h defined some types such as fmNodePtr which is just Node *, but
it made its own types to avoid having to include various header files.
With C11, we can now instead typedef the original names without fear
of conflicts.
---
src/backend/utils/fmgr/fmgr.c | 5 ++---
src/include/fmgr.h | 30 +++++++++++++++---------------
src/include/utils/builtins.h | 2 +-
src/tools/pgindent/typedefs.list | 4 ----
4 files changed, 18 insertions(+), 23 deletions(-)
diff --git a/src/backend/utils/fmgr/fmgr.c b/src/backend/utils/fmgr/fmgr.c
index 5543440a33e..b4c1e2c4b21 100644
--- a/src/backend/utils/fmgr/fmgr.c
+++ b/src/backend/utils/fmgr/fmgr.c
@@ -1570,7 +1570,6 @@ InputFunctionCall(FmgrInfo *flinfo, char *str, Oid
typioparam, int32 typmod)
* This is basically like InputFunctionCall, but the converted Datum is
* returned into *result while the function result is true for success or
* false for failure. Also, the caller may pass an ErrorSaveContext node.
- * (We declare that as "fmNodePtr" to avoid including nodes.h in fmgr.h.)
*
* If escontext points to an ErrorSaveContext, any "soft" errors detected by
* the input function will be reported by filling the escontext struct and
@@ -1584,7 +1583,7 @@ InputFunctionCall(FmgrInfo *flinfo, char *str, Oid
typioparam, int32 typmod)
bool
InputFunctionCallSafe(FmgrInfo *flinfo, char *str,
Oid typioparam, int32 typmod,
- fmNodePtr escontext,
+ Node *escontext,
Datum *result)
{
LOCAL_FCINFO(fcinfo, 3);
@@ -1639,7 +1638,7 @@ InputFunctionCallSafe(FmgrInfo *flinfo, char *str,
bool
DirectInputFunctionCallSafe(PGFunction func, char *str,
Oid typioparam, int32
typmod,
- fmNodePtr escontext,
+ Node *escontext,
Datum *result)
{
LOCAL_FCINFO(fcinfo, 3);
diff --git a/src/include/fmgr.h b/src/include/fmgr.h
index c7236e42972..74fe3ea0575 100644
--- a/src/include/fmgr.h
+++ b/src/include/fmgr.h
@@ -19,14 +19,14 @@
#define FMGR_H
/* We don't want to include primnodes.h here, so make some stub references */
-typedef struct Node *fmNodePtr;
-typedef struct Aggref *fmAggrefPtr;
+typedef struct Node Node;
+typedef struct Aggref Aggref;
/* Likewise, avoid including execnodes.h here */
-typedef void (*fmExprContextCallbackFunction) (Datum arg);
+typedef void (*ExprContextCallbackFunction) (Datum arg);
/* Likewise, avoid including stringinfo.h here */
-typedef struct StringInfoData *fmStringInfo;
+typedef struct StringInfoData *StringInfo;
/*
@@ -63,7 +63,7 @@ typedef struct FmgrInfo
unsigned char fn_stats; /* collect stats if track_functions >
this */
void *fn_extra; /* extra space for use by handler */
MemoryContext fn_mcxt; /* memory context to store fn_extra in
*/
- fmNodePtr fn_expr; /* expression parse tree for
call, or NULL */
+ Node *fn_expr; /* expression parse tree for call, or
NULL */
} FmgrInfo;
/*
@@ -85,8 +85,8 @@ typedef struct FmgrInfo
typedef struct FunctionCallInfoBaseData
{
FmgrInfo *flinfo; /* ptr to lookup info used for
this call */
- fmNodePtr context; /* pass info about context of
call */
- fmNodePtr resultinfo; /* pass or return extra info
about result */
+ Node *context; /* pass info about context of call */
+ Node *resultinfo; /* pass or return extra info about
result */
Oid fncollation; /* collation for function to
use */
#define FIELDNO_FUNCTIONCALLINFODATA_ISNULL 4
bool isnull; /* function must set true if
result is NULL */
@@ -742,19 +742,19 @@ extern Datum InputFunctionCall(FmgrInfo *flinfo, char
*str,
Oid typioparam,
int32 typmod);
extern bool InputFunctionCallSafe(FmgrInfo *flinfo, char *str,
Oid
typioparam, int32 typmod,
- fmNodePtr
escontext,
+ Node
*escontext,
Datum
*result);
extern bool DirectInputFunctionCallSafe(PGFunction func, char *str,
Oid typioparam, int32 typmod,
-
fmNodePtr escontext,
+
Node *escontext,
Datum *result);
extern Datum OidInputFunctionCall(Oid functionId, char *str,
Oid
typioparam, int32 typmod);
extern char *OutputFunctionCall(FmgrInfo *flinfo, Datum val);
extern char *OidOutputFunctionCall(Oid functionId, Datum val);
-extern Datum ReceiveFunctionCall(FmgrInfo *flinfo, fmStringInfo buf,
+extern Datum ReceiveFunctionCall(FmgrInfo *flinfo, StringInfo buf,
Oid
typioparam, int32 typmod);
-extern Datum OidReceiveFunctionCall(Oid functionId, fmStringInfo buf,
+extern Datum OidReceiveFunctionCall(Oid functionId, StringInfo buf,
Oid
typioparam, int32 typmod);
extern bytea *SendFunctionCall(FmgrInfo *flinfo, Datum val);
extern bytea *OidSendFunctionCall(Oid functionId, Datum val);
@@ -767,9 +767,9 @@ extern const Pg_finfo_record *fetch_finfo_record(void
*filehandle, const char *f
extern Oid fmgr_internal_function(const char *proname);
extern Oid get_fn_expr_rettype(FmgrInfo *flinfo);
extern Oid get_fn_expr_argtype(FmgrInfo *flinfo, int argnum);
-extern Oid get_call_expr_argtype(fmNodePtr expr, int argnum);
+extern Oid get_call_expr_argtype(Node *expr, int argnum);
extern bool get_fn_expr_arg_stable(FmgrInfo *flinfo, int argnum);
-extern bool get_call_expr_arg_stable(fmNodePtr expr, int argnum);
+extern bool get_call_expr_arg_stable(Node *expr, int argnum);
extern bool get_fn_expr_variadic(FmgrInfo *flinfo);
extern bytea *get_fn_opclass_options(FmgrInfo *flinfo);
extern bool has_fn_opclass_options(FmgrInfo *flinfo);
@@ -814,11 +814,11 @@ extern void RestoreLibraryState(char *start_address);
extern int AggCheckCallContext(FunctionCallInfo fcinfo,
MemoryContext
*aggcontext);
-extern fmAggrefPtr AggGetAggref(FunctionCallInfo fcinfo);
+extern Aggref *AggGetAggref(FunctionCallInfo fcinfo);
extern MemoryContext AggGetTempMemoryContext(FunctionCallInfo fcinfo);
extern bool AggStateIsShared(FunctionCallInfo fcinfo);
extern void AggRegisterCallback(FunctionCallInfo fcinfo,
-
fmExprContextCallbackFunction func,
+
ExprContextCallbackFunction func,
Datum arg);
/*
diff --git a/src/include/utils/builtins.h b/src/include/utils/builtins.h
index 1c98c7d2255..ce6285a2c03 100644
--- a/src/include/utils/builtins.h
+++ b/src/include/utils/builtins.h
@@ -80,7 +80,7 @@ extern PGDLLIMPORT bool quote_all_identifiers;
extern const char *quote_identifier(const char *ident);
extern char *quote_qualified_identifier(const char *qualifier,
const char *ident);
-extern void generate_operator_clause(fmStringInfo buf,
+extern void generate_operator_clause(StringInfo buf,
const
char *leftop, Oid leftoptype,
Oid
opoid,
const
char *rightop, Oid rightoptype);
diff --git a/src/tools/pgindent/typedefs.list b/src/tools/pgindent/typedefs.list
index 0f4974b5fcb..5736a41c91a 100644
--- a/src/tools/pgindent/typedefs.list
+++ b/src/tools/pgindent/typedefs.list
@@ -3636,10 +3636,6 @@ float8
float8KEY
floating_decimal_32
floating_decimal_64
-fmAggrefPtr
-fmExprContextCallbackFunction
-fmNodePtr
-fmStringInfo
fmgr_hook_type
foreign_glob_cxt
foreign_loc_cxt
--
2.51.0