Make cast functions from jsonb error safe

Peter Eisentraut <peter@eisentraut.org>

Commit: 10e4d8aaf46fb46b8b78e026560b68af84a6495b
Author: Peter Eisentraut <peter@eisentraut.org>
Date: 2026-03-28T14:44:13Z
Make cast functions from jsonb error safe

This adjusts cast functions from jsonb to other types to support soft
errors.  This just involves some refactoring of the underlying helper
functions to use ereturn.

This is in preparation for a future feature where conversion errors in
casts can be caught.

Author: jian he <jian.universality@gmail.com>
Reviewed-by: Amul Sul <sulamul@gmail.com>
Reviewed-by: Corey Huinker <corey.huinker@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/CADkLM%3Dfv1JfY4Ufa-jcwwNbjQixNViskQ8jZu3Tz_p656i_4hQ%40mail.gmail.com

Files

PathChange+/−
src/backend/utils/adt/jsonb.c modified +18 −17

Discussion