| From: | jian he <jian(dot)universality(at)gmail(dot)com> |
|---|---|
| To: | Amul Sul <sulamul(at)gmail(dot)com> |
| Cc: | Corey Huinker <corey(dot)huinker(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: | 2025-12-02 07:52:57 |
| Message-ID: | CACJufxHKoQxo6o3B1R1qqCaYNpntD=esj-hWL5GSCzD1K4FNtg@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Mon, Dec 1, 2025 at 8:09 PM Amul Sul <sulamul(at)gmail(dot)com> wrote:
>
> Since you declared float8_div_safe() as static inline, I believe it
> wouldn't have any performance degradation since most compilers
> optimize it. Also, I suggest you pass the ErrorSafeContext to
> float_overflow_error(), float_underflow_error(), and
> float_zero_divide_error() so that you can avoid duplicating error
> messages.
>
hi.
First I want to use ereturn, then I found out
float_overflow_error, float_underflow_error, float_zero_divide_error
used both in float4, float8.
ereturn would not be appropriate for both types.
so I choose errsave.
for these 3 functions, now it looks like:
pg_noinline void
float_overflow_error(struct Node *escontext)
{
errsave(escontext,
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
errmsg("value out of range: overflow")));
}
pg_noinline void
float_underflow_error(struct Node *escontext)
{
errsave(escontext,
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
errmsg("value out of range: underflow")));
}
pg_noinline void
float_zero_divide_error(struct Node *escontext)
{
errsave(escontext,
(errcode(ERRCODE_DIVISION_BY_ZERO),
errmsg("division by zero")));
}
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Michael Paquier | 2025-12-02 07:54:12 | Re: Index functions and INDEX_CREATE_SKIP_BUILD |
| Previous Message | Peter Eisentraut | 2025-12-02 07:44:28 | Re: Consistently use the XLogRecPtrIsInvalid() macro |