OSDN Git Service

Add new columns to pg_store_plans view
[pgstoreplans/pg_store_plans.git] / pgsp_json_text.h
1 /*-------------------------------------------------------------------------
2  *
3  * pgsp_json_text.h: Defenitions for text plan generator for pg_store_plans.
4  *
5  * Copyright (c) 2012-2022, NIPPON TELEGRAPH AND TELEPHONE CORPORATION
6  *
7  * IDENTIFICATION
8  *        pg_store_plans/pgsp_json_text.h
9  *
10  *-------------------------------------------------------------------------
11  */
12
13 typedef struct
14 {
15         const char *sort_keys;
16         List *group_keys;
17         char *key_type;
18 } grouping_set;
19
20 typedef struct
21 {
22         NodeTag nodetag;
23         const char *node_type;
24         const char *operation;
25         const char *subplan_name;
26
27         const char *scan_dir;
28         const char *index_name;
29         const char *obj_name;
30         const char *schema_name;
31
32         const char *filter;
33         const char *join_filter;
34         const char *rows_removed_by_filter;
35         const char *alias;
36         StringInfo output;
37         List       *target_tables;
38         const char *func_call;
39         const char *sort_method;
40         StringInfo sort_key;
41         StringInfo group_key;
42         StringInfo hash_key;
43         List       *grouping_sets;
44         const char *index_cond;
45         const char *merge_cond;
46         const char *hash_cond;
47         const char *tid_cond;
48         const char *recheck_cond;
49         const char *hash_buckets;
50         const char *hash_batches;
51         const char *setopcommand;
52         const char *join_type;
53         const char *org_hash_batches;
54         const char *org_hash_buckets;
55         const char *peak_memory_usage;
56         const char *startup_cost;
57         const char *total_cost;
58         const char *plan_rows;
59         const char *plan_width;
60         const char *sort_space_used;
61         const char *sort_space_type;
62         const char *actual_startup_time;
63         const char *actual_total_time;
64         const char *actual_rows;
65         const char *actual_loops;
66         const char *heap_fetches;
67         const char *shared_hit_blks;
68         const char *shared_read_blks;
69         const char *shared_dirtied_blks;
70         const char *shared_written_blks;
71         const char *local_hit_blks;
72         const char *local_read_blks;
73         const char *local_dirtied_blks;
74         const char *local_written_blks;
75         const char *temp_read_blks;
76         const char *temp_written_blks;
77         const char *io_read_time;
78         const char *io_write_time;
79         const char *filter_removed;
80         const char *idxrchk_removed;
81         const char *trig_name;
82         const char *trig_relation;
83         const char *trig_time;
84         const char *trig_calls;
85         const char *plan_time;
86         const char *exec_time;
87         const char *exact_heap_blks;
88         const char *lossy_heap_blks;
89         const char *joinfilt_removed;
90         const char *conflict_resolution;
91         StringInfo      conflict_arbiter_indexes;
92         const char *tuples_inserted;
93         const char *conflicting_tuples;
94         const char *sampling_method;
95         StringInfo sampling_params;
96         const char *repeatable_seed;
97         bool            parallel_aware;
98         const char *partial_mode;
99         const char *worker_number;
100         const char *workers_planned;
101         const char *workers_launched;
102         bool            inner_unique;
103         bool            async_capable;
104         const char *table_func_name;
105         StringInfo      presorted_key;
106         StringInfo      sortmethod_used;
107         const char *sortspace_mem;
108         const char *group_count;
109         const char *avg_sortspc_used;
110         const char *peak_sortspc_used;
111
112         const char *tmp_obj_name;
113         const char *tmp_schema_name;
114         const char *tmp_alias;
115         List       *_undef;
116         bool            _undef_newelem;
117 } node_vals;
118
119 #define SETTER(name) pgsp_node_set_##name
120
121 #define SETTERDECL(name) extern void SETTER(name)(node_vals *vals, const char *val)
122 #define DEFAULT_SETTER(name) \
123         SETTERDECL(name) { vals->name = val;}
124
125 #define SQLQUOTE_SETTER(name) \
126         SETTERDECL(name) { vals->name = quote_identifier(val);}
127
128 #define BOOL_SETTER(name) \
129         SETTERDECL(name) { vals->name = (strcmp(val, "true") == 0 ? 1 : 0);}
130
131 #define LIST_SETTER(name) \
132         SETTERDECL(name) { \
133                 if (!vals->name || !vals->name->data[0])\
134                 { \
135                         vals->name = makeStringInfo(); \
136                         appendStringInfoString(vals->name, val); \
137                 } \
138                 else \
139                 { \
140                         appendStringInfoString(vals->name, ", "); \
141                         appendStringInfoString(vals->name, val); \
142                 } \
143         }\
144
145 #define CONVERSION_SETTER(name, converter) \
146         SETTERDECL(name) { vals->name = converter(val, PGSP_JSON_TEXTIZE);}
147
148 extern char *pgsp_json_textize(char *json);
149
150 /* Prototypes for setter for node_vals */
151 SETTERDECL(_undef);
152 SETTERDECL(node_type);
153 SETTERDECL(scan_dir);
154 SETTERDECL(obj_name);
155 SETTERDECL(schema_name);
156 SETTERDECL(alias);
157 SETTERDECL(output);
158 SETTERDECL(strategy);
159 SETTERDECL(join_type);
160 SETTERDECL(setopcommand);
161 SETTERDECL(sort_method);
162 SETTERDECL(sort_key);
163 SETTERDECL(group_key);
164 SETTERDECL(group_keys);
165 SETTERDECL(hash_key);
166 SETTERDECL(parallel_aware);
167 SETTERDECL(partial_mode);
168 SETTERDECL(index_name);
169 SETTERDECL(startup_cost);
170 SETTERDECL(total_cost);
171 SETTERDECL(plan_rows);
172 SETTERDECL(plan_width);
173 SETTERDECL(sort_space_used);
174 SETTERDECL(sort_space_type);
175 SETTERDECL(filter);
176 SETTERDECL(join_filter);
177 SETTERDECL(func_call);
178 SETTERDECL(operation);
179 SETTERDECL(subplan_name);
180 SETTERDECL(index_cond);
181 SETTERDECL(hash_cond);
182 SETTERDECL(merge_cond);
183 SETTERDECL(tid_cond);
184 SETTERDECL(recheck_cond);
185 SETTERDECL(hash_buckets);
186 SETTERDECL(hash_batches);
187 SETTERDECL(org_hash_batches);
188 SETTERDECL(org_hash_buckets);
189 SETTERDECL(peak_memory_usage);
190 SETTERDECL(filter_removed);
191 SETTERDECL(idxrchk_removed);
192 SETTERDECL(actual_startup_time);
193 SETTERDECL(actual_total_time);
194 SETTERDECL(actual_rows);
195 SETTERDECL(actual_loops);
196 SETTERDECL(heap_fetches);
197 SETTERDECL(shared_hit_blks);
198 SETTERDECL(shared_read_blks);
199 SETTERDECL(shared_dirtied_blks);
200 SETTERDECL(shared_written_blks);
201 SETTERDECL(local_hit_blks);
202 SETTERDECL(local_read_blks);
203 SETTERDECL(local_dirtied_blks);
204 SETTERDECL(local_written_blks);
205 SETTERDECL(temp_read_blks);
206 SETTERDECL(temp_written_blks);
207 SETTERDECL(io_read_time);
208 SETTERDECL(io_write_time);
209 SETTERDECL(trig_name);
210 SETTERDECL(trig_relation);
211 SETTERDECL(trig_time);
212 SETTERDECL(trig_calls);
213 SETTERDECL(plan_time);
214 SETTERDECL(exec_time);
215 SETTERDECL(exact_heap_blks);
216 SETTERDECL(lossy_heap_blks);
217 SETTERDECL(joinfilt_removed);
218 SETTERDECL(conflict_resolution);
219 SETTERDECL(conflict_arbiter_indexes);
220 SETTERDECL(tuples_inserted);
221 SETTERDECL(conflicting_tuples);
222 SETTERDECL(sampling_method);
223 SETTERDECL(sampling_params);
224 SETTERDECL(repeatable_seed);
225 SETTERDECL(worker_number);
226 SETTERDECL(workers_planned);
227 SETTERDECL(workers_launched);
228 SETTERDECL(inner_unique);
229 SETTERDECL(async_capable);
230 SETTERDECL(table_func_name);
231 SETTERDECL(presorted_key);
232 SETTERDECL(sortmethod_used);
233 SETTERDECL(sortspace_mem);
234 SETTERDECL(group_count);
235 SETTERDECL(avg_sortspc_used);
236 SETTERDECL(peak_sortspc_used);