|
15 | 15 | static const char *const g_allowed_casts[] = { |
16 | 16 | "i2tod", "i2tof", "i2toi4", "i4toi2", "i4tod", "i4tof", "i8tod", "i8tof", "int48", "int84", |
17 | 17 | "ftod", "dtof", |
18 | | - "int4_numeric", "float4_numeric", "float8_numeric", |
| 18 | + "int2_numeric", "int4_numeric", "int8_numeric", "float4_numeric", "float8_numeric", |
19 | 19 | "numeric_float4", "numeric_float8", |
20 | 20 | "date_timestamptz", |
21 | 21 | /**/ |
@@ -138,12 +138,6 @@ static const char *const g_extract_functions[] = { |
138 | 138 | /**/ |
139 | 139 | }; |
140 | 140 |
|
141 | | -static const char *const g_integer_extract_fields[] = { |
142 | | - "minute", "hour", "day", "dow", "isodow", "doy", "week", "month", "quarter", "year", "isoyear", "decade", |
143 | | - "century", "millennium", |
144 | | - /**/ |
145 | | -}; |
146 | | - |
147 | 141 | static void prepare_pg_catalog_allowed(Oid relation_oid, AllowedCols *allowed_cols) |
148 | 142 | { |
149 | 143 | MemoryContext old_context = MemoryContextSwitchTo(TopMemoryContext); |
@@ -256,27 +250,14 @@ bool is_allowed_cast(const FuncExpr *func_expr) |
256 | 250 | } |
257 | 251 | else if (is_funcname_member_of(func_expr->funcid, g_decimal_integer_casts, ARRAY_LENGTH(g_decimal_integer_casts))) |
258 | 252 | { |
259 | | - /* |
260 | | - * Special case, where a `numeric_int4` cast is called on variants of `extract` which return |
261 | | - * integer numbers, e.g. `cast(extract(minute from ...) as integer)`. |
262 | | - */ |
| 253 | + /* Handle cases like `cast(extract(minute from ...) as integer)`. */ |
263 | 254 | Node *cast_arg = linitial(func_expr->args); |
264 | 255 | if (IsA(cast_arg, FuncExpr)) |
265 | 256 | { |
266 | 257 | FuncExpr *cast_arg_expr = (FuncExpr *)cast_arg; |
267 | 258 | if (is_funcname_member_of(cast_arg_expr->funcid, g_extract_functions, ARRAY_LENGTH(g_extract_functions)) || |
268 | 259 | cast_arg_expr->funcid == F_DATE_PART_TEXT_DATE) |
269 | | - { |
270 | | - Node *extract_field = linitial(cast_arg_expr->args); |
271 | | - if (IsA(extract_field, Const)) |
272 | | - { |
273 | | - Const *extract_field_const = (Const *)extract_field; |
274 | | - Assert(extract_field_const->consttype == TEXTOID); |
275 | | - const char *field = TextDatumGetCString(extract_field_const->constvalue); |
276 | | - |
277 | | - return is_member_of(field, g_integer_extract_fields, ARRAY_LENGTH(g_integer_extract_fields)); |
278 | | - } |
279 | | - } |
| 260 | + return true; |
280 | 261 | } |
281 | 262 | } |
282 | 263 | return false; |
|
0 commit comments