Make jsonb casts to scalar types translate JSON null to SQL NULL.
authorTom Lane
Fri, 24 Jan 2025 18:20:44 +0000 (13:20 -0500)
committerTom Lane
Fri, 24 Jan 2025 18:20:44 +0000 (13:20 -0500)
commita5579a90af05814eb5dc2fd5f68ce803899d2504
tree989556c16196c7447fe081458537ac590957109e
parent13a255c195c9911d6b66179f5c2344597dc47155
Make jsonb casts to scalar types translate JSON null to SQL NULL.

Formerly, these cases threw an error "cannot cast jsonb null to type
".  That seems less than helpful though.  It's also
inconsistent with the behavior of the ->> operator, which translates
JSON null to SQL NULL, as do some other jsonb functions.

Discussion: https://postgr.es/m/3851203.1722552717@sss.pgh.pa.us
src/backend/utils/adt/jsonb.c
src/test/regress/expected/jsonb.out
src/test/regress/sql/jsonb.sql