1
0
mirror of https://github.com/postgres/postgres.git synced 2025-10-16 17:07:43 +03:00

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.)

Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/f36c0a45-98cd-40b2-a7cc-f2bf02b12890%40eisentraut.org#a12fb1a2c1089d6d03010f6268871b00
Discussion: https://www.postgresql.org/message-id/flat/10d32190-f31b-40a5-b177-11db55597355@eisentraut.org
This commit is contained in:
Peter Eisentraut
2025-09-15 10:48:30 +02:00
parent 1e3b5edb8e
commit 70407d39b7
6 changed files with 41 additions and 39 deletions

View File

@@ -1320,7 +1320,7 @@ ExplainForeignModify(ModifyTableState *mtstate,
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.

View File

@@ -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 */

View File

@@ -16,7 +16,8 @@
#include "executor/instrument.h"
#include "tcop/dest.h"
struct ExplainState; /* avoid including explain.h here */
/* avoid including explain_state.h here */
typedef struct ExplainState ExplainState;
/* Instrumentation data for EXPLAIN's SERIALIZE option */
typedef struct SerializeMetrics
@@ -26,7 +27,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

View File

@@ -15,44 +15,45 @@
#include "nodes/pg_list.h"
struct ExplainState; /* avoid including explain.h here */
/* avoid including explain_state.h here */
typedef struct ExplainState ExplainState;
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

View File

@@ -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;

View File

@@ -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_state.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,