Re: implement CAST(expr AS type FORMAT 'template') - Mailing list pgsql-hackers

From Robert Haas
Subject Re: implement CAST(expr AS type FORMAT 'template')
Date
Msg-id CA+TgmoaPtGF27SWr9MY4jnzQtuARmikK30tS715Yj0=eB8PtHA@mail.gmail.com
Whole thread
In response to Re: implement CAST(expr AS type FORMAT 'template')  (Haibo Yan <tristan.yim@gmail.com>)
List pgsql-hackers
On Mon, Jul 6, 2026 at 11:56 PM Haibo Yan <tristan.yim@gmail.com> wrote:
> I now think my v2 patch is too broad.  It tries to make CAST(... FORMAT ...)
> a generic user-defined format-cast mechanism, but SQL feature T839 is much
> narrower: formatted casts between datetime types and character strings.
>
> So I think the next version should move back closer to Jian’s original scope:
> support T839 first, rather than introduce pg_format_cast and
> CREATE FORMAT CAST.  I still think we should avoid ad-hoc parser rewrites to
> specific function names, but the feature scope should be the standard
> datetime/string cases, not arbitrary source/target pairs.
>
> I also think it would be useful to retitle this thread around the standard
> feature, for example:
>
>     Support SQL feature T839: formatted casts between datetime and
> character strings
>
> That seems to describe the real target better than a generic format-cast
> facility.

My current point of view is that your patch does exactly the right
thing but it's not clear whether we want it. I mean, if we eventually
want to support this feature with arbitrary types, there is no reason
not to do so from the start. Or at least, none that I can see. But
that does not address the question of whether we want the feature in
the first place, which is debatable.

--
Robert Haas
EDB: http://www.enterprisedb.com



pgsql-hackers by date:

Previous
From: Alexander Pyhalov
Date:
Subject: Re: Function scan FDW pushdown
Next
From: Peter Eisentraut
Date:
Subject: Re: Increased SECURITY RISCS from omitting some compikler options when building PG with meson; e.g. -fcf-protection=full