Convert json_in and jsonb_in to report errors softly.
authorTom Lane <tgl@sss.pgh.pa.us>
Sun, 11 Dec 2022 16:28:15 +0000 (11:28 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Sun, 11 Dec 2022 16:28:15 +0000 (11:28 -0500)
commitc60c9badba9b4db3155eef081ae0b923f983168c
tree60b12d49fa9f01feff7707cef18fac7ebf24ab18
parent50428a301d5ad46316cac2192f2ca8d91898aa3c
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
17 files changed:
src/backend/utils/adt/json.c
src/backend/utils/adt/jsonb.c
src/backend/utils/adt/jsonfuncs.c
src/backend/utils/fmgr/fmgr.c
src/backend/utils/mb/mbutils.c
src/common/jsonapi.c
src/include/common/jsonapi.h
src/include/fmgr.h
src/include/mb/pg_wchar.h
src/include/utils/jsonfuncs.h
src/test/regress/expected/json.out
src/test/regress/expected/json_encoding.out
src/test/regress/expected/json_encoding_1.out
src/test/regress/expected/jsonb.out
src/test/regress/sql/json.sql
src/test/regress/sql/json_encoding.sql
src/test/regress/sql/jsonb.sql