diff --git a/src/sort_transform.c b/src/sort_transform.c index e3154e71c13..4f9230e34a3 100644 --- a/src/sort_transform.c +++ b/src/sort_transform.c @@ -8,12 +8,14 @@ #include #include #include +#include +#include #include +#include #include -#include -#include #include +#include "compat/compat.h" #include "func_cache.h" #include "sort_transform.h" @@ -195,7 +197,6 @@ ts_sort_transform_expr(Expr *orig_expr) if (IsA(orig_expr, FuncExpr)) { FuncExpr *func = (FuncExpr *) orig_expr; - char *func_name = get_func_name(func->funcid); FuncInfo *finfo = ts_func_cache_get_bucketing_func(func->funcid); if (NULL != finfo) @@ -206,10 +207,24 @@ ts_sort_transform_expr(Expr *orig_expr) return finfo->sort_transform(func); } - if (strncmp(func_name, "timestamp", NAMEDATALEN) == 0) + /* Functions of one argument that convert something to timestamp(tz). */ +#if PG14_LT + if (func->funcid == F_DATE_TIMESTAMP || func->funcid == F_TIMESTAMPTZ_TIMESTAMP) +#else + if (func->funcid == F_TIMESTAMP_DATE || func->funcid == F_TIMESTAMP_TIMESTAMPTZ) +#endif + { return transform_timestamp_cast(func); - if (strncmp(func_name, "timestamptz", NAMEDATALEN) == 0) + } + +#if PG14_LT + if (func->funcid == F_DATE_TIMESTAMPTZ || func->funcid == F_TIMESTAMP_TIMESTAMPTZ) +#else + if (func->funcid == F_TIMESTAMPTZ_DATE || func->funcid == F_TIMESTAMPTZ_TIMESTAMP) +#endif + { return transform_timestamptz_cast(func); + } } if (IsA(orig_expr, OpExpr)) {