Исходный код СУБД RuDB — свободной СУБД с открытым исходным кодом на базе PostgreSQL
rudb
2 days ago bd039d1e92813358c5c5a1e346b49074baf513f2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/*-------------------------------------------------------------------------
 *
 * explain_state.h
 *    prototypes for explain_state.c
 *
 * Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group
 * Portions Copyright (c) 1994-5, Regents of the University of California
 *
 * src/include/commands/explain_state.h
 *
 *-------------------------------------------------------------------------
 */
#ifndef EXPLAIN_STATE_H
#define EXPLAIN_STATE_H
 
#include "nodes/parsenodes.h"
#include "nodes/plannodes.h"
#include "parser/parse_node.h"
#include "port/pg_bitutils.h"
 
typedef enum ExplainSerializeOption
{
    EXPLAIN_SERIALIZE_NONE,
    EXPLAIN_SERIALIZE_TEXT,
    EXPLAIN_SERIALIZE_BINARY,
} ExplainSerializeOption;
 
typedef enum ExplainFormat
{
    EXPLAIN_FORMAT_TEXT,
    EXPLAIN_FORMAT_XML,
    EXPLAIN_FORMAT_JSON,
    EXPLAIN_FORMAT_YAML,
} ExplainFormat;
 
typedef struct ExplainWorkersState
{
    int         num_workers;    /* # of worker processes the plan used */
    bool       *worker_inited;  /* per-worker state-initialized flags */
    StringInfoData *worker_str; /* per-worker transient output buffers */
    int        *worker_state_save;  /* per-worker grouping state save areas */
    StringInfo  prev_str;       /* saved output buffer while redirecting */
} ExplainWorkersState;
 
typedef struct ExplainState
{
    StringInfo  str;            /* output buffer */
    /* options */
    bool        verbose;        /* be verbose */
    bool        analyze;        /* print actual times */
    bool        costs;          /* print estimated costs */
    bool        buffers;        /* print buffer usage */
    bool        wal;            /* print WAL usage */
    bool        timing;         /* print detailed node timing */
    bool        summary;        /* print total planning and execution timing */
    bool        memory;         /* print planner's memory usage information */
    bool        settings;       /* print modified settings */
    bool        io;             /* print info about IO (prefetch, ...) */
    bool        generic;        /* generate a generic plan */
    ExplainSerializeOption serialize;   /* serialize the query's output? */
    ExplainFormat format;       /* output format */
    /* [PG_CUSTOM: PG_QUERY_STATE] EXPLAIN state отдаёт pg_query_state текущее состояние плана. */
    bool        runtime;        /* print intermediate execution state */
    /* state for output formatting --- not reset for each new plan tree */
    int         indent;         /* current indentation level */
    List       *grouping_stack; /* format-specific grouping state */
    /* state related to the current plan tree (filled by ExplainPrintPlan) */
    PlannedStmt *pstmt;         /* top of plan */
    List       *rtable;         /* range table */
    List       *rtable_names;   /* alias names for RTEs */
    List       *deparse_cxt;    /* context list for deparsing expressions */
    Bitmapset  *printed_subplans;   /* ids of SubPlans we've printed */
    bool        hide_workers;   /* set if we find an invisible Gather */
    int         rtable_size;    /* length of rtable excluding the RTE_GROUP
                                 * entry */
    /* state related to the current plan node */
    ExplainWorkersState *workers_state; /* needed if parallel plan */
    /* extensions */
    void      **extension_state;
    int         extension_state_allocated;
    /* [PG_CUSTOM: 1C_DML_EXPLAIN] Число реально обработанных DML-строк передаётся в EXPLAIN/completion tag для 1С. */
    uint64      es_processed;   /* sum of executed plan row counts */
} ExplainState;
 
typedef void (*ExplainOptionHandler) (ExplainState *, DefElem *, ParseState *);
typedef bool (*ExplainOptionGUCCheckHandler) (const char *option_name,
                                              const char *option_value,
                                              NodeTag option_type);
 
/* Hook to perform additional EXPLAIN options validation */
typedef void (*explain_validate_options_hook_type) (ExplainState *es, List *options,
                                                    ParseState *pstate);
extern PGDLLIMPORT explain_validate_options_hook_type explain_validate_options_hook;
 
extern ExplainState *NewExplainState(void);
extern void ParseExplainOptionList(ExplainState *es, List *options,
                                   ParseState *pstate);
 
extern int  GetExplainExtensionId(const char *extension_name);
extern void *GetExplainExtensionState(ExplainState *es, int extension_id);
extern void SetExplainExtensionState(ExplainState *es, int extension_id,
                                     void *opaque);
 
extern void RegisterExtensionExplainOption(const char *option_name,
                                           ExplainOptionHandler handler,
                                           ExplainOptionGUCCheckHandler guc_check_handler);
extern bool ApplyExtensionExplainOption(ExplainState *es, DefElem *opt,
                                        ParseState *pstate);
extern bool GUCCheckExplainExtensionOption(const char *option_name,
                                           const char *option_value,
                                           NodeTag option_type);
 
extern bool GUCCheckBooleanExplainOption(const char *option_name,
                                         const char *option_value,
                                         NodeTag option_type);
 
#endif                          /* EXPLAIN_STATE_H */