|
1 | 1 | #ifndef PG_DIFFIX_UTILS_H |
2 | 2 | #define PG_DIFFIX_UTILS_H |
3 | 3 |
|
4 | | -#include "nodes/params.h" |
5 | 4 | #include "nodes/pg_list.h" |
6 | | -#include "nodes/primnodes.h" |
7 | 5 | #include "utils/datum.h" |
8 | 6 |
|
9 | 7 | /*------------------------------------------------------------------------- |
@@ -121,68 +119,4 @@ static inline List *hash_set_union(List *dst_set, const List *src_set) |
121 | 119 |
|
122 | 120 | #endif |
123 | 121 |
|
124 | | -/*------------------------------------------------------------------------- |
125 | | - * Node utils |
126 | | - *------------------------------------------------------------------------- |
127 | | - */ |
128 | | - |
129 | | -static inline ParamExternData *get_param_data(ParamListInfo bound_params, int one_based_paramid) |
130 | | -{ |
131 | | -#if PG_MAJORVERSION_NUM == 13 |
132 | | - int paramid = one_based_paramid; |
133 | | -#else |
134 | | - int paramid = one_based_paramid - 1; |
135 | | -#endif |
136 | | - if (bound_params->paramFetch != NULL) |
137 | | - return bound_params->paramFetch(bound_params, paramid, true, NULL); |
138 | | - else |
139 | | - return &bound_params->params[paramid]; |
140 | | -} |
141 | | - |
142 | | -static inline bool is_simple_constant(Node *node) |
143 | | -{ |
144 | | - return IsA(node, Const) || (IsA(node, Param) && ((Param *)node)->paramkind == PARAM_EXTERN); |
145 | | -} |
146 | | - |
147 | | -static inline void get_simple_constant_typed_value(Node *node, ParamListInfo bound_params, Oid *type, Datum *value, bool *isnull) |
148 | | -{ |
149 | | - if (IsA(node, Const)) |
150 | | - { |
151 | | - Const *const_expr = (Const *)node; |
152 | | - *type = const_expr->consttype; |
153 | | - *value = const_expr->constvalue; |
154 | | - *isnull = const_expr->constisnull; |
155 | | - } |
156 | | - else if (IsA(node, Param) && ((Param *)node)->paramkind == PARAM_EXTERN) |
157 | | - { |
158 | | - Param *param_expr = (Param *)node; |
159 | | - ParamExternData *param_data = get_param_data(bound_params, param_expr->paramid); |
160 | | - *type = param_data->ptype; |
161 | | - *value = param_data->value; |
162 | | - *isnull = param_data->isnull; |
163 | | - } |
164 | | - else |
165 | | - { |
166 | | - FAILWITH("Attempted to get simple constant value of non-Const, non-PARAM_EXTERN node"); |
167 | | - } |
168 | | -} |
169 | | - |
170 | | -static inline int get_simple_constant_location(Node *node) |
171 | | -{ |
172 | | - if (IsA(node, Const)) |
173 | | - { |
174 | | - Const *const_expr = (Const *)node; |
175 | | - return const_expr->location; |
176 | | - } |
177 | | - else if (IsA(node, Param) && ((Param *)node)->paramkind == PARAM_EXTERN) |
178 | | - { |
179 | | - Param *param_expr = (Param *)node; |
180 | | - return param_expr->location; |
181 | | - } |
182 | | - else |
183 | | - { |
184 | | - FAILWITH("Attempted to get simple constant value of non-Const, non-PARAM_EXTERN node"); |
185 | | - } |
186 | | -} |
187 | | - |
188 | 122 | #endif /* PG_DIFFIX_UTILS_H */ |
0 commit comments