| From: | Amul Sul <sulamul(at)gmail(dot)com> |
|---|---|
| To: | Peter Eisentraut <peter(at)eisentraut(dot)org> |
| Cc: | jian he <jian(dot)universality(at)gmail(dot)com>, Corey Huinker <corey(dot)huinker(at)gmail(dot)com>, Kirill Reshke <reshkekirill(at)gmail(dot)com>, Vik Fearing <vik(at)postgresfriends(dot)org>, 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-03-30 13:09:32 |
| Message-ID: | CAAJ_b959dfJsorK+_vPdVa8F3QYPdOnb-HzJY8oQQR91N9Tq2A@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Mon, Mar 30, 2026 at 4:57 PM Peter Eisentraut <peter(at)eisentraut(dot)org> 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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Andrew Dunstan | 2026-03-30 13:27:08 | scale parallel_tuple_cost by tuple width |
| Previous Message | Лев Николаев | 2026-03-30 13:03:18 | [PATCH] analyze: move elevel calculation into do_analyze_rel() |