public inbox for [email protected]  
help / color / mirror / Atom feed
From: =?gb18030?B?emVuZ21hbg==?= <[email protected]>
To: =?gb18030?B?amlhbiBoZQ==?= <[email protected]>
Cc: =?gb18030?B?RGF2aWQgRy4gSm9obnN0b24=?= <[email protected]>
Cc: =?gb18030?B?Q29yZXkgSHVpbmtlcg==?= <[email protected]>
Cc: =?gb18030?B?cGdzcWwtaGFja2Vycw==?= <[email protected]>
Cc: =?gb18030?B?VmlrIEZlYXJpbmc=?= <[email protected]>
Subject: Re: implement CAST(expr AS type FORMAT 'template')
Date: Sat, 31 Jan 2026 00:17:22 +0800
Message-ID: <[email protected]> (raw)
In-Reply-To: <CACJufxGhOOYnPtmsuVocXVNyx2gB3K68ze67CM4LUqQeW--S8g@mail.gmail.com>
References: <CACJufxGqm7cYQ5C65Eoh1z-f+aMdhv9_7V=NoLH_p6uuyesi6A@mail.gmail.com>
	<[email protected]>
	<CACJufxF4OW=x2rCwa+ZmcgopDwGKDXha09qTfTpCj3QSTG6Y9Q@mail.gmail.com>
	<[email protected]>
	<CACJufxEH-8UPdbPoUoqNRaiOePw+s2W2DG4OpXtoSYDaW30oAg@mail.gmail.com>
	<CAKFQuwZXYxPw4wofq+zZ5D7nH0sHDBwr--qku9jWYv7dS+P8RQ@mail.gmail.com>
	<CACJufxGTeSnHn7w8r-qoQrqwCFQSC+CbiEthzpHKUd+bPr_0mA@mail.gmail.com>
	<[email protected]>
	<CACJufxGbsc3g6RZf0rZpKYxffK6vGkc_OsTmX54uS0kFcVBtvA@mail.gmail.com>
	<CAKFQuwaG00tsXc2oSQwjdSnPQ=JuH+T8Oeejb3sO5TeqUHsfUQ@mail.gmail.com>
	<CADkLM=cvhJBrCj3GV+jXfpb5+U1Z33nsvCXo-=ZkDyaSPbS-1g@mail.gmail.com>
	<CAKFQuwYrwM64YnvZ5aL1DEWG50uW-1SrXesSKkmvpxXXrxTW-g@mail.gmail.com>
	<[email protected]>
	<CACJufxH+soqLj_AuMQj-_jxunVQKX-HBQA_3_3vmV1jTRyZ1hA@mail.gmail.com>
	<CACJufxGhOOYnPtmsuVocXVNyx2gB3K68ze67CM4LUqQeW--S8g@mail.gmail.com>

> 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

Attachments:

  [application/octet-stream] cleanup_suggestions.txt (3.5K, ../[email protected]/2-cleanup_suggestions.txt)
  download

view thread (41+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected], [email protected], [email protected]
  Subject: Re: implement CAST(expr AS type FORMAT 'template')
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox