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: Kirill Reshke <reshkekirill@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-15T04:37:43Z
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
- v16-0023-error-safe-for-user-defined-CREATE-CAST.patch (application/x-patch) patch v16-0023
- v16-0021-error-safe-for-casting-geometry-data-type.patch (application/x-patch) patch v16-0021
- v16-0007-error-safe-for-casting-macaddr8-to-other-types-per-pg_cast.patch (application/x-patch) patch v16-0007
- v16-0022-CAST-expr-AS-newtype-DEFAULT-ON-ERROR.patch (application/x-patch) patch v16-0022
- v16-0020-refactor-point_dt.patch (application/x-patch) patch v16-0020
- v16-0019-introduce-float8-safe-function.patch (application/x-patch) patch v16-0019
- v16-0018-refactor-float_overflow_error-float_underflow_error-float_zero_d.patch (application/x-patch) patch v16-0018
- v16-0017-error-safe-for-casting-jsonb-to-other-types-per-pg_cast.patch (application/x-patch) patch v16-0017
- v16-0016-error-safe-for-casting-timestamp-to-other-types-per-pg_cast.patch (application/x-patch) patch v16-0016
- v16-0015-error-safe-for-casting-timestamptz-to-other-types-per-pg_cast.patch (application/x-patch) patch v16-0015
- v16-0014-error-safe-for-casting-interval-to-other-types-per-pg_cast.patch (application/x-patch) patch v16-0014
- v16-0013-error-safe-for-casting-date-to-other-types-per-pg_cast.patch (application/x-patch) patch v16-0013
- v16-0012-error-safe-for-casting-float8-to-other-types-per-pg_cast.patch (application/x-patch) patch v16-0012
- v16-0010-error-safe-for-casting-numeric-to-other-types-per-pg_cast.patch (application/x-patch) patch v16-0010
- v16-0011-error-safe-for-casting-float4-to-other-types-per-pg_cast.patch (application/x-patch) patch v16-0011
- v16-0008-error-safe-for-casting-integer-to-other-types-per-pg_cast.patch (application/x-patch) patch v16-0008
- v16-0009-error-safe-for-casting-bigint-to-other-types-per-pg_cast.patch (application/x-patch) patch v16-0009
- v16-0006-error-safe-for-casting-inet-to-other-types-per-pg_cast.patch (application/x-patch) patch v16-0006
- v16-0005-error-safe-for-casting-character-varying-to-other-types-per-pg_c.patch (application/x-patch) patch v16-0005
- v16-0004-error-safe-for-casting-text-to-other-types-per-pg_cast.patch (application/x-patch) patch v16-0004
- v16-0003-error-safe-for-casting-character-to-other-types-per-pg_cast.patch (application/x-patch) patch v16-0003
- v16-0002-error-safe-for-casting-bit-varbit-to-other-types-per-pg_cast.patch (application/x-patch) patch v16-0002
- v16-0001-error-safe-for-casting-bytea-to-other-types-per-pg_cast.patch (application/x-patch) patch v16-0001
hi.
On Wed, Dec 10, 2025 at 9:32 PM Kirill Reshke <reshkekirill@gmail.com> wrote:
>
> Hi!
>
> Overall, I think this patch is doing a good thing. Also, are we
> holding it until the next SQL standard release, because sql/23 leaks
> this feature?
>
> Below are my 2c.
>
> 1)
> First of all, I would prefer the `Bumps catversion` comment in the
> commit msg of v15-0022.
>
ok.
> 2)
> In v15-0006, if dont understand when memory allocated by
> `result = (macaddr *) palloc0(sizeof(macaddr));` will be freed. Does
> it persist until the query ends? I tried to get OOM with a query that
> errors out macaddr8 casts repeatedly, but failed.
>
if ((addr->d != 0xFF) || (addr->e != 0xFE))
- ereport(ERROR,
+ ereturn(fcinfo->context, (Datum) 0,
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
errmsg("macaddr8 data out of range to convert to macaddr"),
errhint("Only addresses that have FF and FE as values in the "
the change is minor, changing ereport to ereturn.
The whole refactoring does not related to OOM errror,
OOM errors will behave exactly as they did previously.
> 3)
> > * When error_safe set to true, we will evaluate the constant expression in a
> > * error safe way. If the evaluation fails, return NULL instead of throwing
> > * error.
>
> Somebody has to say it - s/error_safe set/error_safe is set/, also
> s/throwing error/throwing an error/
>
sure.
mainly rebase due to recent palloc_object, palloc_array conflict.
--
jian
https://www.enterprisedb.com/