public inbox for [email protected]  
help / color / mirror / Atom feed
From: Amul Sul <[email protected]>
To: Peter Eisentraut <[email protected]>
Cc: jian he <[email protected]>
Cc: Corey Huinker <[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: Mon, 30 Mar 2026 18:39:32 +0530
Message-ID: <CAAJ_b959dfJsorK+_vPdVa8F3QYPdOnb-HzJY8oQQR91N9Tq2A@mail.gmail.com> (raw)
In-Reply-To: <[email protected]>
References: <CADkLM=fv1JfY4Ufa-jcwwNbjQixNViskQ8jZu3Tz_p656i_4hQ@mail.gmail.com>
	<CADkLM=cZ7N+f4Bj-8MiccFcTASjBB2r1_s3BD9OFbbQOwK01cg@mail.gmail.com>
	<CACJufxE7yoH42juViFvYuCQMPwXMWxDVwiugs-BW+N4oUXB=1w@mail.gmail.com>
	<CADkLM=dFZ8-mBJDkiZZ4JadnJy8zLExUoo_b1FOs2Ozrtge=gQ@mail.gmail.com>
	<CACJufxHynx40aHHUCR4wZh1qnL=X0yw6baW4Z-+vkUgT0OhjOg@mail.gmail.com>
	<CADkLM=eCPiVhGKcbNW5bUEYpozUaKNXjd_UmBVR256p2zWtYQQ@mail.gmail.com>
	<CACJufxH4LrCpL63SRYO3zVk46YdD4--VYQoBL7GmHmCm=NCAJQ@mail.gmail.com>
	<CADkLM=cmv_bmxBe8KmZd6rEgiqSdoDfHnJa63u7rdRuAsqOwDA@mail.gmail.com>
	<CACJufxGbw9iNT8QVm4QD9cPFKnDnvDBQp7AGxkoqDa-JjzVXmg@mail.gmail.com>
	<CACJufxFkLLuX1VJ-J3fppCr37PHtxkvwyd_e4zNd+VYK0v0gnQ@mail.gmail.com>
	<[email protected]>
	<CACJufxHx-UfprE6P4_ZB_cOYktHd4pLMNx=jWJFOGGGFj2YZWQ@mail.gmail.com>
	<CACJufxH_1EtEBMb0JvxaM3Gmnt33HYrS37m5eYjJ_OfBkMVFJg@mail.gmail.com>
	<CACJufxHGox47X4zNtVeNw7H=SZ7ATAAD5SEYpvxa2o5mPV0XCA@mail.gmail.com>
	<[email protected]>

On Mon, Mar 30, 2026 at 4:57 PM Peter Eisentraut <[email protected]> wrote:
>
>  From the v25 I have committed everything except 0001 and 0009.  I will
> continue reviewing the rest.
>

I’ve had a glance over the remaining patches; here are a few comments:

V25-0001:

-       if (relation->schemaname)
+       if (escontext == NULL)
            ereport(elevel,
-                   (errcode(ERRCODE_UNDEFINED_TABLE),
-                    errmsg("relation \"%s.%s\" does not exist",
-                           relation->schemaname, relation->relname)));
+                   errcode(ERRCODE_LOCK_NOT_AVAILABLE),
+                   relation->schemaname ?
+                   errmsg("relation \"%s.%s\" does not exist",
+                          relation->schemaname, relation->relname) :
+                   errmsg("relation \"%s\" does not exist",
+                          relation->relname));
        else
-           ereport(elevel,
-                   (errcode(ERRCODE_UNDEFINED_TABLE),
-                    errmsg("relation \"%s\" does not exist",
-                           relation->relname)));
+           ereturn(escontext, InvalidOid,
+                   errcode(ERRCODE_LOCK_NOT_AVAILABLE),
+                   relation->schemaname ?
+                   errmsg("relation \"%s.%s\" does not exist",
+                          relation->schemaname, relation->relname) :
+                   errmsg("relation \"%s\" does not exist",
+                          relation->relname));
    }

The error code changed here -- was this intentional?
--

v25-0009 :

+SELECT CAST('abc'::bpchar AS citext DEFAULT NULL ON CONVERSION ERROR); -- error
+ERROR:  cannot cast type character to citext when DEFAULT expression
is specified in CAST ... ON CONVERSION ERROR
+LINE 1: SELECT CAST('abc'::bpchar AS citext DEFAULT NULL ON CONVERSI...
+                    ^
+HINT:  Safe type cast for user-defined types are not yet supported.


"Should the HINT be this DETAIL? I believe a hint should provide
guidance for the user to handle the error, but here the user cannot do
anything with the given information.
--

 /* Generic macro for applying evaluate_expr */
-#define ece_evaluate_expr(node) \
+#define ece_evaluate_expr(node, escontext) \
    ((Node *) evaluate_expr((Expr *) (node), \
                            exprType((Node *) (node)), \
                            exprTypmod((Node *) (node)), \
-                           exprCollation((Node *) (node))))
+                           exprCollation((Node *) (node)), \
+                           escontext))


I think we can simply cast escontext to Node * here, instead of
having the caller do it.

Regards,
Amul





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], [email protected]
  Subject: Re: CAST(... ON DEFAULT) - WIP build on top of Error-Safe User Functions
  In-Reply-To: <CAAJ_b959dfJsorK+_vPdVa8F3QYPdOnb-HzJY8oQQR91N9Tq2A@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