Re: implement CAST(expr AS type FORMAT 'template')

From: Haibo Yan <tristan(dot)yim(at)gmail(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Corey Huinker <corey(dot)huinker(at)gmail(dot)com>, jian he <jian(dot)universality(at)gmail(dot)com>, Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>, Vik Fearing <vik(at)postgresfriends(dot)org>, "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: implement CAST(expr AS type FORMAT 'template')
Date: 2026-06-30 17:39:10
Message-ID: CABXr29HF+AHV0FNxQfHyN-ByW6-3+pTBe5Pxm23wRpBYOmfohA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Jun 29, 2026 at 11:14 AM Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
>
> On Mon, Jun 29, 2026 at 1:20 AM Haibo Yan <tristan(dot)yim(at)gmail(dot)com> wrote:
> > I have attached the full patch series for review. Comments are welcome.
>
> This looks good!
>
> I haven't done a detailed review, but I skimmed over all of the
> patches and I like the direction. I think we should consider calling
> it a "format cast" instead of a "formatter". It would avoid needing to
> make "formatter" a parser keyword.
>
> --
> Robert Haas
> EDB: http://www.enterprisedb.com

Hi Robert,

Thanks for looking at the patches.
I liked your suggestion to call these “format casts” rather than
“formatters”, so I changed the series in that direction. The DDL is
now:
------------------------------------------------------
CREATE FORMAT CAST (...)
DROP FORMAT CAST (...)
------------------------------------------------------
rather than CREATE/DROP FORMATTER, so the patch no longer adds
FORMATTER as a keyword.
I also renamed the related catalog and node names, so this now uses
pg_format_cast and CoerceViaFormatCast. The
pg_dump/object-address/comment/extension code and the regression tests
have been updated to use the new terminology as well.
The rest of the design is the same as before: format casts are still
catalog-driven, and both built-in and user-defined cases go through
the same lookup path.

Attached is the updated v2 series.

Regards,
Haibo

Attachment Content-Type Size
v2-0004-Add-built-in-format-casts-for-CAST-FORMAT.patch application/octet-stream 43.5 KB
v2-0002-Add-pg_format_cast-and-CREATE-DROP-FORMAT-CAST.patch application/octet-stream 74.9 KB
v2-0003-Resolve-CAST-FORMAT-with-CoerceViaFormatCast.patch application/octet-stream 44.5 KB
v2-0001-Add-parser-support-for-CAST-FORMAT.patch application/octet-stream 5.6 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Masahiko Sawada 2026-06-30 17:53:18 Re: Optimize UUID parse using SIMD
Previous Message Masahiko Sawada 2026-06-30 17:37:57 Re: Fix race condition in pg_get_publication_tables with concurrent DROP TABLE