public inbox for [email protected]  
help / color / mirror / Atom feed
From: Corey Huinker <[email protected]>
To: jian he <[email protected]>
Cc: Amul Sul <[email protected]>
Cc: Kirill Reshke <[email protected]>
Cc: Vik Fearing <[email protected]>
Cc: Isaac Morland <[email protected]>
Cc: [email protected]
Subject: Re: CAST(... ON DEFAULT) - WIP build on top of Error-Safe User Functions
Date: Thu, 12 Mar 2026 23:59:17 -0400
Message-ID: <CADkLM=cZ7N+f4Bj-8MiccFcTASjBB2r1_s3BD9OFbbQOwK01cg@mail.gmail.com> (raw)
In-Reply-To: <CACJufxGO_qmyGjBvkwhCZzm6bWiqj8iyd1dGbL+_guok6yPMCQ@mail.gmail.com>
References: <CADkLM=fv1JfY4Ufa-jcwwNbjQixNViskQ8jZu3Tz_p656i_4hQ@mail.gmail.com>
	<CAMsGm5dpfm2PHL8XZvC-JSd+UPkgx3rpReUA=G=4+rUCH+Ntcw@mail.gmail.com>
	<CADkLM=eD_S8mGhPfu5+hXXvXgR0-cxGpGd9dgPzD+nCuO7HFaQ@mail.gmail.com>
	<CACJufxHCMzrHOW=wRe8L30rMhB3sjwAv1LE928Fa7sxMu1Tx-g@mail.gmail.com>
	<[email protected]>
	<CACJufxGRAnwJzu7nMq4ZP=yqa1Sz=qR+mR1TmY0aCDjJoJRRtg@mail.gmail.com>
	<[email protected]>
	<CACJufxFy+DFpJ2e-czyCTAgSJXNFaQGWFKA4mjbW-LAMGc1YBA@mail.gmail.com>
	<CADkLM=f1Jv81=s5Ckazx3zZq=M5KoBJMJkOZux_-L+gezODCEQ@mail.gmail.com>
	<CACJufxGw_OY7K3rfG4kDb902O2guhT-wgTjTJQ=pWeVWRTHpHQ@mail.gmail.com>
	<CADkLM=cFSg3+6Sk00dLAF7Q7jnrKBk6+N5gRxT5BCxRvaGtR-g@mail.gmail.com>
	<CACJufxE_aO5FtBGwhDym-Fwe7k8oJY7a8jcYDx77=t3maPvG0g@mail.gmail.com>
	<CADkLM=chahh6ddZFjLL6AUdqzL_Px0raTu-5Jzn2WN8yELtmJw@mail.gmail.com>
	<CACJufxE053=bO3pDUpGba6Yz3VGpU_XCbg4HO6Rew5EJ7k7VnQ@mail.gmail.com>
	<CACJufxF--5d=fmoRBHfqJE9Vy38dCURNKYOKKpujRCnoTEQ7nQ@mail.gmail.com>
	<CACJufxHpMJn22Nu_wmG6eV_S8SAM6KM+GhMO7GuzVb=d9q5C4A@mail.gmail.com>
	<CACJufxHM2e3DQmbRdDZvWyG3ZCLyOg6XFifvOz_TGy1tGw7NHw@mail.gmail.com>
	<CADkLM=daTLuRcwzc6Egtwvh4XYgtABWuMBVnEznd-dXqmXfzUw@mail.gmail.com>
	<CACJufxEcrrcaeFW+zYsjgb6r+ijzwszyxeHk3wxGY+3idiA2ZA@mail.gmail.com>
	<CADkLM=ehavqENDBCcYQufPFKboV90+o_uFdhcrh=Ymq_TNqo=A@mail.gmail.com>
	<CADkLM=ecTybe9Z9TSRD-NKZ=-V4DuGVRtXZGO6+F7=m3Gg9GGQ@mail.gmail.com>
	<CACJufxH5OSeY0-qirksn8S2FUycxON-O=iwc0-Nne1MTAguGhQ@mail.gmail.com>
	<CADkLM=eFasBpS1cqf67TpKGbKoUSy00FuT05Yz4RpXQBpqktuw@mail.gmail.com>
	<CACJufxHrE0s7G0xg1frWo2+tFLTLaikKCObixH-4p9zMYKtHFw@mail.gmail.com>
	<CACJufxFEzD3mqc+MDpgzvdt+4Azbn2pF6TWW=dSCqSK7OHoL6A@mail.gmail.com>
	<CALdSSPjd2fJHw8TrugumZSQwJ8VmSVn55OfQ+Wuogaq0ss=HGQ@mail.gmail.com>
	<CACJufxFzqAshLFw-xTqpz3Mu=6nMLnPiD8bBhbqX6KcFPVjEHw@mail.gmail.com>
	<CAAJ_b95nmvAYhxt2NwRAdGtvR-6STbiaFguMSLh3PmjUVE7rdg@mail.gmail.com>
	<CACJufxHw9Y3fvh+rZj4ukLo=v54Dpafzk7Xvee_wi9zFZ6pOfg@mail.gmail.com>
	<CAAJ_b97+iUAQRoOpogZHRHdr+YQug0TaEeAp9GnT5Bnp8-6oMg@mail.gmail.com>
	<CACJufxHGxB7KPAStUHZcWhFEDXsnU06qOugh60X4hHG6J-xoUA@mail.gmail.com>
	<CADkLM=f0xruKRH+6XvCsM1EVic9y4BL4AFo3VUfvRLdu-Qp5Gg@mail.gmail.com>
	<CADkLM=e4y2bLv-6_JY5c6vC9QtweW9VfxVmVJFpcriy8Rs23TA@mail.gmail.com>
	<CACJufxGO_qmyGjBvkwhCZzm6bWiqj8iyd1dGbL+_guok6yPMCQ@mail.gmail.com>

On Thu, Mar 12, 2026 at 9:00 PM jian he <[email protected]> wrote:

> On Wed, Mar 11, 2026 at 12:22 AM Corey Huinker <[email protected]>
> wrote:
> >
> > While I still think the patch order is a bit backwards [1], the order
> chosen does have a sense to it, and whether or not that is the right order
> is up to the committer. Please post a rebase so I can mark it as ready for
> committer.
> >
> >
> > [1] I would have preferred adding the CAST functionality first, then
> switching over each datatype one-by-one, thus demonstrating that non-safe
> datatypes can co-exist with this new functionality. But that's just my
> personal preference.
>
> We can evaluate CoerceViaIO in an error-safe manner in the HEAD.
> However, as discussed in this thread[1], we cannot simply take a FuncExpr
> produced by a TYPE CAST, convert it to a CoerceViaIO node, and rely on
> CoerceViaIO to do the actual soft-error evaluation.
> Therefore to support the CAST(expr AS newtype DEFAULT expr ON CONVERSION
> ERROR)
> syntax, refactoring the existing cast functions to make them error-safe is
> really necessary.
> Overall I think refactoring the existing cast function (replacing
> ereport to ereturn or errsave) should be done first.
>
> I did one more round of comment refactoring and variable renaming.
>

Can you explain this bit below?

@@ -595,13 +605,23 @@ RangeVarGetRelidExtended(const RangeVar *relation,
LOCKMODE lockmode,
  {
  int elevel = (flags & RVR_SKIP_LOCKED) ? DEBUG1 : ERROR;

- if (relation->schemaname)
- ereport(elevel,
+ if (relation->schemaname && elevel == DEBUG1)
+ ereport(DEBUG1,
  (errcode(ERRCODE_LOCK_NOT_AVAILABLE),
  errmsg("could not obtain lock on relation \"%s.%s\"",
  relation->schemaname, relation->relname)));
- else
- ereport(elevel,
+ else if (relation->schemaname && elevel == ERROR)
+ ereturn(escontext, InvalidOid,
+ errcode(ERRCODE_LOCK_NOT_AVAILABLE),
+ errmsg("could not obtain lock on relation \"%s.%s\"",
+   relation->schemaname, relation->relname));
+ else if (elevel == DEBUG1)
+ ereport(DEBUG1,
+ errcode(ERRCODE_LOCK_NOT_AVAILABLE),
+ errmsg("could not obtain lock on relation \"%s\"",
+   relation->relname));
+ else if (elevel == ERROR)
+ ereturn(escontext, InvalidOid,


view thread (75+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]
  Subject: Re: CAST(... ON DEFAULT) - WIP build on top of Error-Safe User Functions
  In-Reply-To: <CADkLM=cZ7N+f4Bj-8MiccFcTASjBB2r1_s3BD9OFbbQOwK01cg@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox