OSDN Git Service

Follow a change in core.
[pgstoreplans/pg_store_plans.git] / pgsp_json_text.h
1 /*-------------------------------------------------------------------------
2  *
3  * pgsp_json_text.h: Defenitions for text plan generator for pg_store_plan.
4  *
5  * Copyright (c) 2012-2019, NIPPON TELEGRAPH AND TELEPHONE CORPORATION
6  *
7  * IDENTIFICATION
8  *        pg_store_plan/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         const char *table_func_name;
104
105         const char *tmp_obj_name;
106         const char *tmp_schema_name;
107         const char *tmp_alias;
108         List       *_undef;
109         bool            _undef_newelem;
110 } node_vals;
111
112 #define SETTER(name) pgsp_node_set_##name
113
114 #define SETTERDECL(name) extern void SETTER(name)(node_vals *vals, const char *val)
115 #define DEFAULT_SETTER(name) \
116         SETTERDECL(name) { vals->name = val;}
117
118 #define SQLQUOTE_SETTER(name) \
119         SETTERDECL(name) { vals->name = quote_identifier(val);}
120
121 #define BOOL_SETTER(name) \
122         SETTERDECL(name) { vals->parallel_aware = (strcmp(val, "true") == 0 ? 1 : 0);}
123
124 #define LIST_SETTER(name) \
125         SETTERDECL(name) { \
126                 if (!vals->name || !vals->name->data[0])\
127                 { \
128                         vals->name = makeStringInfo(); \
129                         appendStringInfoString(vals->name, val); \
130                 } \
131                 else \
132                 { \
133                         appendStringInfoString(vals->name, ", "); \
134                         appendStringInfoString(vals->name, val); \
135                 } \
136         }\
137
138 #define CONVERSION_SETTER(name, converter) \
139         SETTERDECL(name) { vals->name = converter(val, PGSP_JSON_TEXTIZE);}
140
141 extern char *pgsp_json_textize(char *json);
142
143 /* Prototypes for setter for node_vals */
144 SETTERDECL(_undef);
145 SETTERDECL(node_type);
146 SETTERDECL(scan_dir);
147 SETTERDECL(obj_name);
148 SETTERDECL(schema_name);
149 SETTERDECL(alias);
150 SETTERDECL(output);
151 SETTERDECL(strategy);
152 SETTERDECL(join_type);
153 SETTERDECL(setopcommand);
154 SETTERDECL(sort_method);
155 SETTERDECL(sort_key);
156 SETTERDECL(group_key);
157 SETTERDECL(group_keys);
158 SETTERDECL(hash_key);
159 SETTERDECL(parallel_aware);
160 SETTERDECL(partial_mode);
161 SETTERDECL(index_name);
162 SETTERDECL(startup_cost);
163 SETTERDECL(total_cost);
164 SETTERDECL(plan_rows);
165 SETTERDECL(plan_width);
166 SETTERDECL(sort_space_used);
167 SETTERDECL(sort_space_type);
168 SETTERDECL(filter);
169 SETTERDECL(join_filter);
170 SETTERDECL(func_call);
171 SETTERDECL(operation);
172 SETTERDECL(subplan_name);
173 SETTERDECL(index_cond);
174 SETTERDECL(hash_cond);
175 SETTERDECL(merge_cond);
176 SETTERDECL(tid_cond);
177 SETTERDECL(recheck_cond);
178 SETTERDECL(hash_buckets);
179 SETTERDECL(hash_batches);
180 SETTERDECL(org_hash_batches);
181 SETTERDECL(org_hash_buckets);
182 SETTERDECL(peak_memory_usage);
183 SETTERDECL(filter_removed);
184 SETTERDECL(idxrchk_removed);
185 SETTERDECL(actual_startup_time);
186 SETTERDECL(actual_total_time);
187 SETTERDECL(actual_rows);
188 SETTERDECL(actual_loops);
189 SETTERDECL(heap_fetches);
190 SETTERDECL(shared_hit_blks);
191 SETTERDECL(shared_read_blks);
192 SETTERDECL(shared_dirtied_blks);
193 SETTERDECL(shared_written_blks);
194 SETTERDECL(local_hit_blks);
195 SETTERDECL(local_read_blks);
196 SETTERDECL(local_dirtied_blks);
197 SETTERDECL(local_written_blks);
198 SETTERDECL(temp_read_blks);
199 SETTERDECL(temp_written_blks);
200 SETTERDECL(io_read_time);
201 SETTERDECL(io_write_time);
202 SETTERDECL(trig_name);
203 SETTERDECL(trig_relation);
204 SETTERDECL(trig_time);
205 SETTERDECL(trig_calls);
206 SETTERDECL(plan_time);
207 SETTERDECL(exec_time);
208 SETTERDECL(exact_heap_blks);
209 SETTERDECL(lossy_heap_blks);
210 SETTERDECL(joinfilt_removed);
211 SETTERDECL(conflict_resolution);
212 SETTERDECL(conflict_arbiter_indexes);
213 SETTERDECL(tuples_inserted);
214 SETTERDECL(conflicting_tuples);
215 SETTERDECL(sampling_method);
216 SETTERDECL(sampling_params);
217 SETTERDECL(repeatable_seed);
218 SETTERDECL(worker_number);
219 SETTERDECL(workers_planned);
220 SETTERDECL(workers_launched);
221 SETTERDECL(inner_unique);
222 SETTERDECL(table_func_name);