pgsql: Make jsonb casts to scalar types translate JSON null to SQL NULL

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Make jsonb casts to scalar types translate JSON null to SQL NULL
Date: 2025-01-24 18:20:51
Message-ID: E1tbOIV-003JUs-MO@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Make jsonb casts to scalar types translate JSON null to SQL NULL.

Formerly, these cases threw an error "cannot cast jsonb null to type
<whatever>". 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

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/a5579a90af05814eb5dc2fd5f68ce803899d2504

Modified Files
--------------
src/backend/utils/adt/jsonb.c | 77 +++++++++++++++++++++++++++++++++----
src/test/regress/expected/jsonb.out | 66 +++++++++++++++++++++++++++++++
src/test/regress/sql/jsonb.sql | 13 +++++++
3 files changed, 149 insertions(+), 7 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Andres Freund 2025-01-24 22:42:08 pgsql: checkpointer: Request checkpoint via latch instead of signal
Previous Message Peter Eisentraut 2025-01-24 16:46:09 pgsql: Fix copy-and-paste typo