pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Make jsonb casts to scalar types translate JSON null to SQL NULL
Date: Fri, 24 Jan 2025 18:20:51 +0000
Message-ID: <E1tbOIV-003JUs-MO@gemulon.postgresql.org> (raw)

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(-)



Message-ID: <E1tbOIV-003JUs-MO@gemulon.postgresql.org>
Permalink:  ../E1tbOIV-003JUs-MO@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1tbOIV-003JUs-MO@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Make jsonb casts to scalar types translate JSON null to SQL NULL
  In-Reply-To: <E1tbOIV-003JUs-MO@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox