> Please check the attached new version.
>
> I’ve integrated the CAST FORMAT logic right into coerce_to_target_type and
> coerce_type, see static function coerce_type_with_format. in
> coerce_type_with_format, we first first do source type, target type, format
> expression check, validation, if everything is ok then, construct a FuncCall
> node and let ParseFuncOrColumn do all the remaining job, with that now overall
> the patch looks more neat.
Hi,
This patch looks great, and the tests run well. I found a few minor details,
that you might consider fixing:
Typos
- parse_expr.c:2745: "formmatted" → "formatted"
- parse_coerce.c:156: "Cocerce" → "Coerce"
In `coerce_type_with_format()` (parse_coerce.c):
1. The check `if (fmtcategory != TYPCATEGORY_STRING && fmtcategory != TYPCATEGORY_UNKNOWN)`
could be moved earlier. It doesn't depend on any other
calculations, so failing fast here would avoid unnecessary work.
2. consider using` list_make2(node, format)` instead of `list_make1() + lappend()`.
--
Regards,
Man Zeng