OSDN Git Service

Support ON CONFLICT in text plan output
[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-2015, 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         NodeTag nodetag;
16         const char *node_type;
17         const char *operation;
18         const char *subplan_name;
19
20         const char *scan_dir;
21         const char *index_name;
22         const char *obj_name;
23         const char *schema_name;
24
25         const char *filter;
26         const char *join_filter;
27         const char *rows_removed_by_filter;
28         const char *alias;
29         StringInfo output;
30         List       *target_tables;
31         const char *func_call;
32         const char *sort_method;
33         StringInfo sort_key;
34         const char *index_cond;
35         const char *merge_cond;
36         const char *hash_cond;
37         const char *tid_cond;
38         const char *recheck_cond;
39         const char *hash_buckets;
40         const char *hash_batches;
41         const char *setopcommand;
42         const char *join_type;
43         const char *org_hash_batches;
44         const char *org_hash_buckets;
45         const char *peak_memory_usage;
46         const char *startup_cost;
47         const char *total_cost;
48         const char *plan_rows;
49         const char *plan_width;
50         const char *sort_space_used;
51         const char *sort_space_type;
52         const char *actual_startup_time;
53         const char *actual_total_time;
54         const char *actual_rows;
55         const char *actual_loops;
56         const char *heap_fetches;
57         const char *shared_hit_blks;
58         const char *shared_read_blks;
59         const char *shared_dirtied_blks;
60         const char *shared_written_blks;
61         const char *local_hit_blks;
62         const char *local_read_blks;
63         const char *local_dirtied_blks;
64         const char *local_written_blks;
65         const char *temp_read_blks;
66         const char *temp_written_blks;
67         const char *io_read_time;
68         const char *io_write_time;
69         const char *filter_removed;
70         const char *idxrchk_removed;
71         const char *trig_name;
72         const char *trig_relation;
73         const char *trig_time;
74         const char *trig_calls;
75         const char *plan_time;
76         const char *exec_time;
77         const char *exact_heap_blks;
78         const char *lossy_heap_blks;
79         const char *joinfilt_removed;
80         const char *conflict_resolution;
81         StringInfo      conflict_arbiter_indexes;
82         const char *tuples_inserted;
83         const char *conflicting_tuples;
84
85         const char *tmp_obj_name;
86         const char *tmp_schema_name;
87         const char *tmp_alias;
88 } node_vals;
89
90 #define SETTER(name) pgsp_node_set_##name
91
92 #define SETTERDECL(name) extern void SETTER(name)(node_vals *vals, const char *val)
93 #define DEFAULT_SETTER(name) \
94         SETTERDECL(name) { vals->name = val;}
95
96 #define SQLQUOTE_SETTER(name) \
97         SETTERDECL(name) { vals->name = quote_identifier(val);}
98
99 #define LIST_SETTER(name) \
100         SETTERDECL(name) { \
101                 if (!vals->name)\
102                 { \
103                         vals->name = makeStringInfo(); \
104                         appendStringInfoString(vals->name, val); \
105                 } \
106                 else \
107                 { \
108                         appendStringInfoString(vals->name, ", "); \
109                         appendStringInfoString(vals->name, val); \
110                 } \
111         }\
112
113 #define CONVERSION_SETTER(name, converter) \
114         SETTERDECL(name) { vals->name = converter(val, PGSP_JSON_TEXTIZE);}
115
116 extern char *pgsp_json_textize(char *json);
117
118 /* Prototypes for setter for node_vals */
119 SETTERDECL(node_type);
120 SETTERDECL(scan_dir);
121 SETTERDECL(obj_name);
122 SETTERDECL(schema_name);
123 SETTERDECL(alias);
124 SETTERDECL(output);
125 SETTERDECL(strategy);
126 SETTERDECL(join_type);
127 SETTERDECL(setopcommand);
128 SETTERDECL(sort_method);
129 SETTERDECL(sort_key);
130 SETTERDECL(index_name);
131 SETTERDECL(startup_cost);
132 SETTERDECL(total_cost);
133 SETTERDECL(plan_rows);
134 SETTERDECL(plan_width);
135 SETTERDECL(sort_space_used);
136 SETTERDECL(sort_space_type);
137 SETTERDECL(filter);
138 SETTERDECL(join_filter);
139 SETTERDECL(func_call);
140 SETTERDECL(operation);
141 SETTERDECL(subplan_name);
142 SETTERDECL(index_cond);
143 SETTERDECL(hash_cond);
144 SETTERDECL(merge_cond);
145 SETTERDECL(tid_cond);
146 SETTERDECL(recheck_cond);
147 SETTERDECL(hash_buckets);
148 SETTERDECL(hash_batches);
149 SETTERDECL(org_hash_batches);
150 SETTERDECL(org_hash_buckets);
151 SETTERDECL(peak_memory_usage);
152 SETTERDECL(filter_removed);
153 SETTERDECL(idxrchk_removed);
154 SETTERDECL(actual_startup_time);
155 SETTERDECL(actual_total_time);
156 SETTERDECL(actual_rows);
157 SETTERDECL(actual_loops);
158 SETTERDECL(heap_fetches);
159 SETTERDECL(shared_hit_blks);
160 SETTERDECL(shared_read_blks);
161 SETTERDECL(shared_dirtied_blks);
162 SETTERDECL(shared_written_blks);
163 SETTERDECL(local_hit_blks);
164 SETTERDECL(local_read_blks);
165 SETTERDECL(local_dirtied_blks);
166 SETTERDECL(local_written_blks);
167 SETTERDECL(temp_read_blks);
168 SETTERDECL(temp_written_blks);
169 SETTERDECL(io_read_time);
170 SETTERDECL(io_write_time);
171 SETTERDECL(trig_name);
172 SETTERDECL(trig_relation);
173 SETTERDECL(trig_time);
174 SETTERDECL(trig_calls);
175 SETTERDECL(plan_time);
176 SETTERDECL(exec_time);
177 SETTERDECL(exact_heap_blks);
178 SETTERDECL(lossy_heap_blks);
179 SETTERDECL(joinfilt_removed);
180 SETTERDECL(conflict_resolution);
181 SETTERDECL(conflict_arbiter_indexes);
182 SETTERDECL(tuples_inserted);
183 SETTERDECL(conflicting_tuples);