OSDN Git Service

Avoid duplicate warning on nonstandard escaping of strings
[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-2016, 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 } grouping_set;
18
19 typedef struct
20 {
21         NodeTag nodetag;
22         const char *node_type;
23         const char *operation;
24         const char *subplan_name;
25
26         const char *scan_dir;
27         const char *index_name;
28         const char *obj_name;
29         const char *schema_name;
30
31         const char *filter;
32         const char *join_filter;
33         const char *rows_removed_by_filter;
34         const char *alias;
35         StringInfo output;
36         List       *target_tables;
37         const char *func_call;
38         const char *sort_method;
39         StringInfo sort_key;
40         StringInfo group_key;
41         List       *grouping_sets;
42         const char *index_cond;
43         const char *merge_cond;
44         const char *hash_cond;
45         const char *tid_cond;
46         const char *recheck_cond;
47         const char *hash_buckets;
48         const char *hash_batches;
49         const char *setopcommand;
50         const char *join_type;
51         const char *org_hash_batches;
52         const char *org_hash_buckets;
53         const char *peak_memory_usage;
54         const char *startup_cost;
55         const char *total_cost;
56         const char *plan_rows;
57         const char *plan_width;
58         const char *sort_space_used;
59         const char *sort_space_type;
60         const char *actual_startup_time;
61         const char *actual_total_time;
62         const char *actual_rows;
63         const char *actual_loops;
64         const char *heap_fetches;
65         const char *shared_hit_blks;
66         const char *shared_read_blks;
67         const char *shared_dirtied_blks;
68         const char *shared_written_blks;
69         const char *local_hit_blks;
70         const char *local_read_blks;
71         const char *local_dirtied_blks;
72         const char *local_written_blks;
73         const char *temp_read_blks;
74         const char *temp_written_blks;
75         const char *io_read_time;
76         const char *io_write_time;
77         const char *filter_removed;
78         const char *idxrchk_removed;
79         const char *trig_name;
80         const char *trig_relation;
81         const char *trig_time;
82         const char *trig_calls;
83         const char *plan_time;
84         const char *exec_time;
85         const char *exact_heap_blks;
86         const char *lossy_heap_blks;
87         const char *joinfilt_removed;
88         const char *conflict_resolution;
89         StringInfo      conflict_arbiter_indexes;
90         const char *tuples_inserted;
91         const char *conflicting_tuples;
92         const char *sampling_method;
93         StringInfo sampling_params;
94         const char *repeatable_seed;
95         bool            parallel_aware;
96         const char *worker_number;
97         const char *workers_planned;
98         const char *workers_launched;
99
100         const char *tmp_obj_name;
101         const char *tmp_schema_name;
102         const char *tmp_alias;
103         List       *_undef;
104         bool            _undef_newelem;
105 } node_vals;
106
107 #define SETTER(name) pgsp_node_set_##name
108
109 #define SETTERDECL(name) extern void SETTER(name)(node_vals *vals, const char *val)
110 #define DEFAULT_SETTER(name) \
111         SETTERDECL(name) { vals->name = val;}
112
113 #define SQLQUOTE_SETTER(name) \
114         SETTERDECL(name) { vals->name = quote_identifier(val);}
115
116 #define BOOL_SETTER(name) \
117         SETTERDECL(name) { vals->parallel_aware = (strcmp(val, "true") == 0 ? 1 : 0);}
118
119 #define LIST_SETTER(name) \
120         SETTERDECL(name) { \
121                 if (!vals->name || !vals->name->data[0])\
122                 { \
123                         vals->name = makeStringInfo(); \
124                         appendStringInfoString(vals->name, val); \
125                 } \
126                 else \
127                 { \
128                         appendStringInfoString(vals->name, ", "); \
129                         appendStringInfoString(vals->name, val); \
130                 } \
131         }\
132
133 #define CONVERSION_SETTER(name, converter) \
134         SETTERDECL(name) { vals->name = converter(val, PGSP_JSON_TEXTIZE);}
135
136 extern char *pgsp_json_textize(char *json);
137
138 /* Prototypes for setter for node_vals */
139 SETTERDECL(_undef);
140 SETTERDECL(node_type);
141 SETTERDECL(scan_dir);
142 SETTERDECL(obj_name);
143 SETTERDECL(schema_name);
144 SETTERDECL(alias);
145 SETTERDECL(output);
146 SETTERDECL(strategy);
147 SETTERDECL(join_type);
148 SETTERDECL(setopcommand);
149 SETTERDECL(sort_method);
150 SETTERDECL(sort_key);
151 SETTERDECL(group_key);
152 SETTERDECL(group_keys);
153 SETTERDECL(parallel_aware);
154 SETTERDECL(index_name);
155 SETTERDECL(startup_cost);
156 SETTERDECL(total_cost);
157 SETTERDECL(plan_rows);
158 SETTERDECL(plan_width);
159 SETTERDECL(sort_space_used);
160 SETTERDECL(sort_space_type);
161 SETTERDECL(filter);
162 SETTERDECL(join_filter);
163 SETTERDECL(func_call);
164 SETTERDECL(operation);
165 SETTERDECL(subplan_name);
166 SETTERDECL(index_cond);
167 SETTERDECL(hash_cond);
168 SETTERDECL(merge_cond);
169 SETTERDECL(tid_cond);
170 SETTERDECL(recheck_cond);
171 SETTERDECL(hash_buckets);
172 SETTERDECL(hash_batches);
173 SETTERDECL(org_hash_batches);
174 SETTERDECL(org_hash_buckets);
175 SETTERDECL(peak_memory_usage);
176 SETTERDECL(filter_removed);
177 SETTERDECL(idxrchk_removed);
178 SETTERDECL(actual_startup_time);
179 SETTERDECL(actual_total_time);
180 SETTERDECL(actual_rows);
181 SETTERDECL(actual_loops);
182 SETTERDECL(heap_fetches);
183 SETTERDECL(shared_hit_blks);
184 SETTERDECL(shared_read_blks);
185 SETTERDECL(shared_dirtied_blks);
186 SETTERDECL(shared_written_blks);
187 SETTERDECL(local_hit_blks);
188 SETTERDECL(local_read_blks);
189 SETTERDECL(local_dirtied_blks);
190 SETTERDECL(local_written_blks);
191 SETTERDECL(temp_read_blks);
192 SETTERDECL(temp_written_blks);
193 SETTERDECL(io_read_time);
194 SETTERDECL(io_write_time);
195 SETTERDECL(trig_name);
196 SETTERDECL(trig_relation);
197 SETTERDECL(trig_time);
198 SETTERDECL(trig_calls);
199 SETTERDECL(plan_time);
200 SETTERDECL(exec_time);
201 SETTERDECL(exact_heap_blks);
202 SETTERDECL(lossy_heap_blks);
203 SETTERDECL(joinfilt_removed);
204 SETTERDECL(conflict_resolution);
205 SETTERDECL(conflict_arbiter_indexes);
206 SETTERDECL(tuples_inserted);
207 SETTERDECL(conflicting_tuples);
208 SETTERDECL(sampling_method);
209 SETTERDECL(sampling_params);
210 SETTERDECL(repeatable_seed);
211 SETTERDECL(worker_number);
212 SETTERDECL(workers_planned);
213 SETTERDECL(workers_launched);