| 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-02 21:52:02 |
| Message-ID: | CAKFQuwam6CKm+MJbNwFgoMJYJFuzWQ68+WqMf39ku8Q6kqtXYg@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Thursday, July 2, 2026, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
> On Thu, Jul 2, 2026 at 4:51 PM David G. Johnston
> <david(dot)g(dot)johnston(at)gmail(dot)com> wrote:
> >> and the existence of a
> >> format cast doesn't mean there has to be a regular cast.
> >
> > Disagree
>
> OK, but on what basis?
>
> If I want 'whatever'::thistype::thattype to fail and CAST(thistype AS
> thattype FORMAT 'bumble') to succeed, then I need there to be a format
> cast but not a regular cast
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. But a format does you no
good if there isn’t some cast pathway already available to use it. IOW a
format should never be required - some default exists, like for dates
today, that allows the non-format cast to work. We just need some way to
pass in a format to that cast function if one is specified.
For me the presence of the word cast in the syntax drives this way of
thinking about the problem/design. I’d rather just stick with our
polymorphic to_char functions if we want some way of outputting text with a
format at without having to call doing so a cast.
David J.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Chao Li | 2026-07-02 21:52:03 | Re: Fix RLS checks for UPDATE/DELETE FOR PORTION OF leftover rows |
| Previous Message | Zsolt Parragi | 2026-07-02 21:50:13 | Re: meson vs. llvm bitcode files |