public inbox for [email protected]
help / color / mirror / Atom feedFrom: Amul Sul <[email protected]>
To: jian he <[email protected]>
Cc: Kirill Reshke <[email protected]>
Cc: Corey Huinker <[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: Fri, 2 Jan 2026 11:38:16 +0530
Message-ID: <CAAJ_b95nmvAYhxt2NwRAdGtvR-6STbiaFguMSLh3PmjUVE7rdg@mail.gmail.com> (raw)
In-Reply-To: <CACJufxFzqAshLFw-xTqpz3Mu=6nMLnPiD8bBhbqX6KcFPVjEHw@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>
Hi,
I am still thinking through a design that avoids having two different
code paths for type casting. Can't we avoid adding a new SafeTypeCast
structure by simply adding a raw_default variable (name could be
simply default) to the existing TypeCast structure? If we do that, we
would need to update transformTypeCast() and other places (like
ExecInterpExpr()) to handle the raw_default. This approach would allow
us to avoid the extra code required for a new node structure (e.g.,
T_SafeTypeCastExpr) and a separate EEOP_SAFETYPE_CAST step.
Here are few other comments:
vv16-0019:
+float8_div_safe(const float8 val1, const float8 val2, struct Node *escontext)
Patches show an inconsistent use of Node* and struct Note * for the
escontext argument. I suggest standardising on Note * to maintain
consistency throughout the code.
--
v16-0020:
@@ -839,7 +839,7 @@ box_distance(PG_FUNCTION_ARGS)
box_cn(&a, box1);
box_cn(&b, box2);
- PG_RETURN_FLOAT8(point_dt(&a, &b));
+ PG_RETURN_FLOAT8(point_dt(&a, &b, NULL));
I think user-callable functions that accept PG_FUNCTION_ARGS;
should directly pass fcinfo->context instead of NULL.
--
v16-0022:
+Sometimes a type cast may fail; to avoid such fail case, an
<literal>ON ERROR</literal> clause can be
..
+ default <replaceable>expression</replaceable> in <literal>ON
ERROR</literal> clause.
Shouldn't it be ON CONVERSION ERROR instead of ON ERROR ?
--
+ state->escontext = makeNode(ErrorSaveContext);
+ state->escontext->type = T_ErrorSaveContext;
+ state->escontext->error_occurred = false;
+ state->escontext->details_wanted = false;
No need to assign values to the rest of the escontext members;
makeNode(ErrorSaveContext) is sufficient. I also think
ExecInitExprSafe() should receive escontext from the caller. Instead
of passing an error_safe boolean to evaluate_expr, you can pass the
escontext itself; this can then be passed down to ExecInitExprSafe,
helping capture soft error information at a much higher level.
In that way, you can simply call ExecInitExprSafe() from
ExecInitExpr() and pass NULL for the escontext. This reduces code
duplication, since most of the code is similar except for the
aforementioned initialization lines.
Regards,
Amul
view thread (69+ 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: <CAAJ_b95nmvAYhxt2NwRAdGtvR-6STbiaFguMSLh3PmjUVE7rdg@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