postgresql/src/include
Amit Langote 1edb3b491b Adjust populate_record_field() to handle errors softly
This adds a Node *escontext parameter to it and a bunch of functions
downstream to it, replacing any ereport()s in that path by either
errsave() or ereturn() as appropriate.  This also adds code to those
functions where necessary to return early upon encountering a soft
error.

The changes here are mainly intended to suppress errors in the
functions of jsonfuncs.c.  Functions in any external modules, such as
arrayfuncs.c, that those functions may in turn call are not changed
here based on the assumption that the various checks in jsonfuncs.c
functions should ensure that only values that are structurally valid
get passed to the functions in those external modules.  An exception
is made for domain_check() to allow handling domain constraint
violation errors softly.

For testing, this adds a function jsonb_populate_record_valid(),
which returns true if jsonb_populate_record() would finish without
causing an error for the provided JSON object, false otherwise.  Note
that jsonb_populate_record() internally calls populate_record(),
which in turn uses populate_record_field().

Extracted from a much larger patch to add SQL/JSON query functions.

Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Oleg Bartunov <obartunov@gmail.com>
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Andrew Dunstan <andrew@dunslane.net>
Author: Amit Langote <amitlangote09@gmail.com>

Reviewers have included (in no particular order) Andres Freund,
Alexander Korotkov, Pavel Stehule, Andrew Alsup, Erik Rijkers,
Zihong Yu, Himanshu Upadhyaya, Daniel Gustafsson, Justin Pryzby,
Álvaro Herrera, Jian He, Peter Eisentraut

Discussion: https://postgr.es/m/cd0bb935-0158-78a7-08b5-904886deac4b@postgrespro.ru
Discussion: https://postgr.es/m/20220616233130.rparivafipt6doj3@alap3.anarazel.de
Discussion: https://postgr.es/m/abd9b83b-aa66-f230-3d6d-734817f0995d%40postgresql.org
Discussion: https://postgr.es/m/CA+HiwqHROpf9e644D8BRqYvaAPmgBZVup-xKMDPk-nd4EpgzHw@mail.gmail.com
Discussion: https://postgr.es/m/CA+HiwqE4XTdfb1nW=Ojoy_tQSRhYt-q_kb6i5d4xcKyrLC1Nbg@mail.gmail.com
2024-01-24 15:04:33 +09:00
..
access Add stratnum GiST support function 2024-01-19 15:42:13 +01:00
archive Update copyright for 2024 2024-01-03 20:49:05 -05:00
backup Update copyright for 2024 2024-01-03 20:49:05 -05:00
bootstrap Update copyright for 2024 2024-01-03 20:49:05 -05:00
catalog Adjust populate_record_field() to handle errors softly 2024-01-24 15:04:33 +09:00
commands Rename COPY option from SAVE_ERROR_TO to ON_ERROR 2024-01-19 15:15:51 +02:00
common Fixed misspelled byteswap function for big endian machines 2024-01-19 13:26:18 +07:00
datatype Update copyright for 2024 2024-01-03 20:49:05 -05:00
executor Add soft error handling to some expression nodes 2024-01-24 15:04:33 +09:00
fe_utils Update copyright for 2024 2024-01-03 20:49:05 -05:00
foreign Update copyright for 2024 2024-01-03 20:49:05 -05:00
jit Update copyright for 2024 2024-01-03 20:49:05 -05:00
lib Update copyright for 2024 2024-01-03 20:49:05 -05:00
libpq Make dblink interruptible, via new libpqsrv APIs. 2024-01-08 11:39:56 -08:00
mb Update copyright for 2024 2024-01-03 20:49:05 -05:00
nodes Add soft error handling to some expression nodes 2024-01-24 15:04:33 +09:00
optimizer Add better handling of redundant IS [NOT] NULL quals 2024-01-23 18:09:18 +13:00
parser Update copyright for 2024 2024-01-03 20:49:05 -05:00
partitioning Update copyright for 2024 2024-01-03 20:49:05 -05:00
pch Update copyright for 2024 2024-01-03 20:49:05 -05:00
port Update copyright for 2024 2024-01-03 20:49:05 -05:00
portability Update copyright for 2024 2024-01-03 20:49:05 -05:00
postmaster Add missing PGDLLIMPORT markings 2024-01-16 13:53:28 +02:00
regex Update copyright for 2024 2024-01-03 20:49:05 -05:00
replication Update copyright for 2024 2024-01-03 20:49:05 -05:00
rewrite Update copyright for 2024 2024-01-03 20:49:05 -05:00
snowball Update copyright for 2024 2024-01-03 20:49:05 -05:00
statistics Update copyright for 2024 2024-01-03 20:49:05 -05:00
storage Introduce the dynamic shared memory registry. 2024-01-19 14:24:36 -06:00
tcop Update copyright for 2024 2024-01-03 20:49:05 -05:00
tsearch Update copyright for 2024 2024-01-03 20:49:05 -05:00
utils Adjust populate_record_field() to handle errors softly 2024-01-24 15:04:33 +09:00
.gitignore Refactor dlopen() support 2018-09-06 11:33:04 +02:00
Makefile Fix makefiles for newly added files 2024-01-23 16:33:26 +01:00
c.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
fmgr.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
funcapi.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
getopt_long.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
meson.build Update copyright for 2024 2024-01-03 20:49:05 -05:00
miscadmin.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
pg_config.h.in Add backend support for injection points 2024-01-22 10:15:50 +09:00
pg_config_ext.h.in Autoconfiscate selection of 64-bit int type for 64-bit large object API. 2012-10-07 21:52:43 -04:00
pg_config_ext.h.meson meson: Add initial version of meson based build system 2022-09-21 22:37:17 -07:00
pg_config_manual.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
pg_getopt.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
pg_trace.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
pgstat.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
pgtar.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
pgtime.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
port.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
postgres.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
postgres_ext.h Move RelFileNumber declarations to common/relpath.h. 2022-09-27 12:01:57 -04:00
postgres_fe.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
varatt.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
windowapi.h Update copyright for 2024 2024-01-03 20:49:05 -05:00