From 8b70a03986274cb8c1353ef13521e47a3308cf5e Mon Sep 17 00:00:00 2001 From: Peter Eisentraut 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 -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