Re: CAST(... ON DEFAULT) - WIP build on top of Error-Safe User Functions
jian he <jian.universality@gmail.com>
From: jian he <jian.universality@gmail.com>
To: Amul Sul <sulamul@gmail.com>
Cc: Corey Huinker <corey.huinker@gmail.com>,
Vik Fearing <vik@postgresfriends.org>, Isaac Morland <isaac.morland@gmail.com>, pgsql-hackers@lists.postgresql.org
Date: 2025-12-02T07:52:57Z
Lists: pgsql-hackers
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Make cast functions to type money error safe
- b36b95640487 19 (unreleased) landed
-
Make cast function from circle to polygon error safe
- 26f9012beecf 19 (unreleased) landed
-
Make geometry cast functions error safe
- 45cdaf3665be 19 (unreleased) landed
-
Make cast functions from jsonb error safe
- 10e4d8aaf46f 19 (unreleased) landed
-
Make many cast functions error safe
- e2f289e5b9b8 19 (unreleased) landed
-
Add SQL/JSON query functions
- 6185c9737cf4 17.0 cited
-
Add soft error handling to some expression nodes
- aaaf9449ec6b 17.0 cited
Attachments
- v13-0018-error-safe-for-casting-geometry-data-type.patch (text/x-patch) patch v13-0018
- v13-0020-CAST-expr-AS-newtype-DEFAULT-ON-ERROR.patch (text/x-patch) patch v13-0020
- v13-0019-invent-some-error-safe-functions.patch (text/x-patch) patch v13-0019
- v13-0016-error-safe-for-casting-timestamp-to-other-types-per-pg_cast.patch (text/x-patch) patch v13-0016
- v13-0015-error-safe-for-casting-timestamptz-to-other-types-per-pg_cast.patch (text/x-patch) patch v13-0015
- v13-0017-error-safe-for-casting-jsonb-to-other-types-per-pg_cast.patch (text/x-patch) patch v13-0017
- v13-0013-error-safe-for-casting-date-to-other-types-per-pg_cast.patch (text/x-patch) patch v13-0013
- v13-0014-error-safe-for-casting-interval-to-other-types-per-pg_cast.patch (text/x-patch) patch v13-0014
- v13-0010-error-safe-for-casting-numeric-to-other-types-per-pg_cast.patch (text/x-patch) patch v13-0010
- v13-0011-error-safe-for-casting-float4-to-other-types-per-pg_cast.patch (text/x-patch) patch v13-0011
- v13-0012-error-safe-for-casting-float8-to-other-types-per-pg_cast.patch (text/x-patch) patch v13-0012
- v13-0009-error-safe-for-casting-bigint-to-other-types-per-pg_cast.patch (text/x-patch) patch v13-0009
- v13-0006-error-safe-for-casting-inet-to-other-types-per-pg_cast.patch (text/x-patch) patch v13-0006
- v13-0007-error-safe-for-casting-macaddr8-to-other-types-per-pg_cast.patch (text/x-patch) patch v13-0007
- v13-0008-error-safe-for-casting-integer-to-other-types-per-pg_cast.patch (text/x-patch) patch v13-0008
- v13-0005-error-safe-for-casting-character-varying-to-other-types-per-pg_c.patch (text/x-patch) patch v13-0005
- v13-0003-error-safe-for-casting-character-to-other-types-per-pg_cast.patch (text/x-patch) patch v13-0003
- v13-0004-error-safe-for-casting-character-to-other-types-per-pg_cast.patch (text/x-patch) patch v13-0004
- v13-0002-error-safe-for-casting-bit-varbit-to-other-types-per-pg_cast.patch (text/x-patch) patch v13-0002
- v13-0001-error-safe-for-casting-bytea-to-other-types-per-pg_cast.patch (text/x-patch) patch v13-0001
On Mon, Dec 1, 2025 at 8:09 PM Amul Sul <sulamul@gmail.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")));
}
--
jian
https://www.enterprisedb.com/