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

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

On Thu, Jul 2, 2026 at 3:23 PM Robert Haas <robertmhaas(at)gmail(dot)com> wrote:

> On Thu, Jul 2, 2026 at 5:52 PM David G. Johnston
> <david(dot)g(dot)johnston(at)gmail(dot)com> wrote:
> > There is no wanting the formatless-variant to fail. There is
> recognition that sometime the formatless variant might fail with a syntax
> error and we have a way to pass a format to make the cast work.
> >
> > If there is no cast from thistype to thattype both will fail with cast
> not found errors. Once a cast exists the first one could pass or fail
> depending on the content being casted. If the content has an internal
> structure/syntax the failure mode would then be a syntax error. Overcoming
> a syntax error is done by specifying a format.
>

> I don't really know how to have a productive conversation about this
> at this point.
>
>
I'm not sure how to make the design less problematic: format is optional,
and for casts that need a format to succeed they provide a default.

But yes, without concrete userspace examples to reason with, this approach
of only being concerned with the userspace perspective leaves much to
resolve when it comes to actual implementation. But I also don't generally
like the idea of choosing how we define the userspace based upon how easy
it might be to implement. Especially if ostensibly the reference design is
coming from the SQL Standard.

But yeah, it is apparent to me I need to try and use the language of
implementation details and not stay conceptual.

David J.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message shveta malik 2026-07-03 04:12:21 Re: Proposal: Conflict log history table for Logical Replication
Previous Message jian he 2026-07-03 03:55:43 Re: Row pattern recognition