Re: CAST(... ON DEFAULT) - WIP build on top of Error-Safe User Functions

From: Henson Choi <assam258(at)gmail(dot)com>
To: Corey Huinker <corey(dot)huinker(at)gmail(dot)com>, jian he <jian(dot)universality(at)gmail(dot)com>, Peter Eisentraut <peter(at)eisentraut(dot)org>
Cc: Vik Fearing <vik(at)postgresfriends(dot)org>, Amul Sul <sulamul(at)gmail(dot)com>, Kirill Reshke <reshkekirill(at)gmail(dot)com>, Isaac Morland <isaac(dot)morland(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: CAST(... ON DEFAULT) - WIP build on top of Error-Safe User Functions
Date: 2026-06-29 10:36:05
Message-ID: CAAAe_zDuTTbDGy_OPrcw3DEHqcjMdrWoo3954v03r6HogGQ37w@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi hacker,

Before getting into reviewing this feature, I read through the thread
first. I don't understand it in detail yet, but just going by the
discussion, a thought occurred to me:

> About the main feature patch: I'm not a fan of the CREATE CAST
> ... WITH SAFE FUNCTION syntax. First, the CREATE CAST syntax is part
> of the SQL standard. [...] Second, we didn't do this when we
> introduced error-safe type input functions. There is a note on the
> CREATE TYPE man page that use of ereturn() is encouraged, and then we
> left it to extension authors to do the right thing.

To me this reads more like a property of the function than of the cast.
I don't fully understand what "safe" means here, but it seems to be
something a function either does or doesn't, regardless of which cast
references it. So if we mark it anywhere, wouldn't CREATE FUNCTION be a
more natural place than CREATE CAST?

CREATE FUNCTION already carries non-standard attributes of this kind.

If it lived on the function, a cast wouldn't need any marker of its own
-- it would just use whatever function it already references, and
CREATE CAST could stay exactly as the standard has it.

I haven't worked through the details, so this is a direction to consider
rather than a concrete proposal.

Best regards,
Henson

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Shlok Kyal 2026-06-29 10:36:10 Re: Proposal: Conflict log history table for Logical Replication
Previous Message shveta malik 2026-06-29 10:32:16 Re: Support EXCEPT for ALL SEQUENCES publications