0004-Improve-ExplainState-type-handling-in-header-files.patch
text/plain
Filename: 0004-Improve-ExplainState-type-handling-in-header-files.patch
Type: text/plain
Part: 3
Patch
Format: format-patch
Series: patch 0004
Subject: Improve ExplainState type handling in header files
| File | + | − |
|---|---|---|
| doc/src/sgml/fdwhandler.sgml | 1 | 1 |
| src/include/commands/explain_dr.h | 2 | 2 |
| src/include/commands/explain_format.h | 18 | 18 |
| src/include/commands/explain.h | 12 | 12 |
| src/include/commands/explain_state.h | 1 | 1 |
| src/include/foreign/fdwapi.h | 5 | 5 |
From c46b45b7e638f4d9fbf2dab97f7f69d57ea9c03f Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter@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