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: Convert json_in and jsonb_in to report errors softly.
Date: Sun, 11 Dec 2022 16:28:24 +0000
Message-ID: <E1p4PBf-003329-Ec@gemulon.postgresql.org> (raw)

Convert json_in and jsonb_in to report errors softly.

This requires a bit of further infrastructure-extension to allow
trapping errors reported by numeric_in and pg_unicode_to_server,
but otherwise it's pretty straightforward.

In the case of jsonb_in, we are only capturing errors reported
during the initial "parse" phase.  The value-construction phase
(JsonbValueToJsonb) can also throw errors if assorted implementation
limits are exceeded.  We should improve that, but it seems like a
separable project.

Andrew Dunstan and Tom Lane

Discussion: https://postgr.es/m/3bac9841-fe07-713d-fa42-606c225567d6@dunslane.net

Branch
------
master

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

Modified Files
--------------
src/backend/utils/adt/json.c                  |  7 ++--
src/backend/utils/adt/jsonb.c                 | 51 ++++++++++++++++--------
src/backend/utils/adt/jsonfuncs.c             | 35 ++++++++++++----
src/backend/utils/fmgr/fmgr.c                 | 45 +++++++++++++++++++++
src/backend/utils/mb/mbutils.c                | 57 +++++++++++++++++++++++++++
src/common/jsonapi.c                          | 17 ++++----
src/include/common/jsonapi.h                  |  1 +
src/include/fmgr.h                            |  4 ++
src/include/mb/pg_wchar.h                     |  1 +
src/include/utils/jsonfuncs.h                 | 13 ++++--
src/test/regress/expected/json.out            | 19 +++++++++
src/test/regress/expected/json_encoding.out   |  7 ++++
src/test/regress/expected/json_encoding_1.out | 31 ++++++++++++---
src/test/regress/expected/jsonb.out           | 25 ++++++++++++
src/test/regress/sql/json.sql                 |  5 +++
src/test/regress/sql/json_encoding.sql        |  4 ++
src/test/regress/sql/jsonb.sql                |  6 +++
17 files changed, 282 insertions(+), 46 deletions(-)



Message-ID: <E1p4PBf-003329-Ec@gemulon.postgresql.org>
Permalink:  ../E1p4PBf-003329-Ec@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1p4PBf-003329-Ec@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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Convert json_in and jsonb_in to report errors softly.
  In-Reply-To: <E1p4PBf-003329-Ec@gemulon.postgresql.org>
  References: <E1p4PBf-003329-Ec@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