| From: | Haibo Yan <tristan(dot)yim(at)gmail(dot)com> |
|---|---|
| To: | Peter Eisentraut <peter(at)eisentraut(dot)org> |
| Cc: | Robert Haas <robertmhaas(at)gmail(dot)com>, 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-07-10 20:39:41 |
| Message-ID: | CABXr29G5MYGf00bimwGxUKKE0RDD5Wvsfcxd6XiZaFrU7EoQug@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Thu, Jul 9, 2026 at 12:20 AM Peter Eisentraut <peter(at)eisentraut(dot)org> wrote:
>
> On 06.07.26 19:14, Haibo Yan wrote:
> > The cases where I think a generic mechanism could be useful are
> > broader than that. For example:
> >
> > text <-> date/time using datetime templates
> > text <-> numeric using number templates
> > text <-> bytea using hex/base64/escape
> > text/bytea <-> extension types
> > using external representations such as
> > WKT/WKB/GeoJSON for geometry types
> One problem I see is that this would dictate that there is only one
> possible format language for each of these conversions.
There are other possible PostgreSQL-extension use cases beyond the standard
datetime/string case, for example bytea encodings, geometry external
representations, UUID display variants, and so on. But your point is that
these do not necessarily share a single natural FORMAT language for each
source/target pair.
For some of those cases, named functions are probably clearer, especially when
the alternatives are different representation families rather than different
templates within one family.
That seems to argue against making the first version a generic format-cast
facility for arbitrary type pairs. The safer scope is probably the standard
T839 case first, where the FORMAT clause has a well-defined datetime template
meaning. We can leave broader PostgreSQL-extension use cases for a later
discussion, if someone can show a model that does not force unrelated
representations through one canonical format function.
Regards,
Haibo
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Peter Geoghegan | 2026-07-10 21:01:42 | Re: s/pg_attribute_always_inline/pg_always_inline/? |
| Previous Message | Noah Misch | 2026-07-10 19:59:02 | CREATE SUBSCRIPTION ... SERVER vs. pg_dump, etc. |