PostgreSQL Source Code git master
Loading...
Searching...
No Matches
explain_state.h
Go to the documentation of this file.
1/*-------------------------------------------------------------------------
2 *
3 * explain_state.h
4 * prototypes for explain_state.c
5 *
6 * Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group
7 * Portions Copyright (c) 1994-5, Regents of the University of California
8 *
9 * src/include/commands/explain_state.h
10 *
11 *-------------------------------------------------------------------------
12 */
13#ifndef EXPLAIN_STATE_H
14#define EXPLAIN_STATE_H
15
16#include "nodes/parsenodes.h"
17#include "nodes/plannodes.h"
18#include "parser/parse_node.h"
19#include "port/pg_bitutils.h"
20
27
35
36typedef struct ExplainWorkersState
37{
38 int num_workers; /* # of worker processes the plan used */
39 bool *worker_inited; /* per-worker state-initialized flags */
40 StringInfoData *worker_str; /* per-worker transient output buffers */
41 int *worker_state_save; /* per-worker grouping state save areas */
42 StringInfo prev_str; /* saved output buffer while redirecting */
44
45typedef struct ExplainState
46{
47 StringInfo str; /* output buffer */
48 /* options */
49 bool verbose; /* be verbose */
50 bool analyze; /* print actual times */
51 bool costs; /* print estimated costs */
52 bool buffers; /* print buffer usage */
53 bool wal; /* print WAL usage */
54 bool timing; /* print detailed node timing */
55 bool summary; /* print total planning and execution timing */
56 bool memory; /* print planner's memory usage information */
57 bool settings; /* print modified settings */
58 bool generic; /* generate a generic plan */
59 ExplainSerializeOption serialize; /* serialize the query's output? */
60 ExplainFormat format; /* output format */
61 /* state for output formatting --- not reset for each new plan tree */
62 int indent; /* current indentation level */
63 List *grouping_stack; /* format-specific grouping state */
64 /* state related to the current plan tree (filled by ExplainPrintPlan) */
65 PlannedStmt *pstmt; /* top of plan */
66 List *rtable; /* range table */
67 List *rtable_names; /* alias names for RTEs */
68 List *deparse_cxt; /* context list for deparsing expressions */
69 Bitmapset *printed_subplans; /* ids of SubPlans we've printed */
70 bool hide_workers; /* set if we find an invisible Gather */
71 int rtable_size; /* length of rtable excluding the RTE_GROUP
72 * entry */
73 /* state related to the current plan node */
74 ExplainWorkersState *workers_state; /* needed if parallel plan */
75 /* extensions */
79
81
82/* Hook to perform additional EXPLAIN options validation */
84 ParseState *pstate);
86
87extern ExplainState *NewExplainState(void);
89 ParseState *pstate);
90
91extern int GetExplainExtensionId(const char *extension_name);
94 void *opaque);
95
96extern void RegisterExtensionExplainOption(const char *option_name,
97 ExplainOptionHandler handler);
99 ParseState *pstate);
100
101#endif /* EXPLAIN_STATE_H */
#define PGDLLIMPORT
Definition c.h:1423
ExplainSerializeOption
@ EXPLAIN_SERIALIZE_TEXT
@ EXPLAIN_SERIALIZE_NONE
@ EXPLAIN_SERIALIZE_BINARY
ExplainState * NewExplainState(void)
void(* ExplainOptionHandler)(ExplainState *, DefElem *, ParseState *)
int GetExplainExtensionId(const char *extension_name)
void * GetExplainExtensionState(ExplainState *es, int extension_id)
void SetExplainExtensionState(ExplainState *es, int extension_id, void *opaque)
void RegisterExtensionExplainOption(const char *option_name, ExplainOptionHandler handler)
ExplainFormat
@ EXPLAIN_FORMAT_XML
@ EXPLAIN_FORMAT_YAML
@ EXPLAIN_FORMAT_TEXT
@ EXPLAIN_FORMAT_JSON
void(* explain_validate_options_hook_type)(ExplainState *es, List *options, ParseState *pstate)
PGDLLIMPORT explain_validate_options_hook_type explain_validate_options_hook
void ParseExplainOptionList(ExplainState *es, List *options, ParseState *pstate)
bool ApplyExtensionExplainOption(ExplainState *es, DefElem *opt, ParseState *pstate)
static int fb(int x)
int extension_state_allocated
Bitmapset * printed_subplans
List * grouping_stack
List * rtable_names
ExplainWorkersState * workers_state
StringInfo str
void ** extension_state
ExplainFormat format
PlannedStmt * pstmt
ExplainSerializeOption serialize
List * deparse_cxt
StringInfoData * worker_str
Definition pg_list.h:54