postgresql/src/include/utils
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
..
.gitignore Generate automatically code and documentation related to wait events 2023-07-05 10:53:11 +09:00
acl.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
aclchk_internal.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
array.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
arrayaccess.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
ascii.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
attoptcache.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
backend_progress.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
backend_status.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
builtins.h Adjust populate_record_field() to handle errors softly 2024-01-24 15:04:33 +09:00
bytea.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
cash.h Convert *GetDatum() and DatumGet*() macros to inline functions 2022-09-27 20:50:21 +02:00
catcache.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
combocid.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
conffiles.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
date.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
datetime.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
datum.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
dsa.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
dynahash.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
elog.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
evtcache.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
expandeddatum.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
expandedrecord.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
float.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
fmgrtab.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
formatting.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
freepage.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
geo_decls.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
guc.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
guc_hooks.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
guc_tables.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
help_config.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
hsearch.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
index_selfuncs.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
inet.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
injection_point.h Add backend support for injection points 2024-01-22 10:15:50 +09:00
inval.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
json.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
jsonb.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
jsonfuncs.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
jsonpath.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
logtape.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
lsyscache.h Make attstattarget nullable 2024-01-13 18:14:53 +01:00
memdebug.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
memutils.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
memutils_internal.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
memutils_memorychunk.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
multirangetypes.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
numeric.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
palloc.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
partcache.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
pg_crc.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
pg_locale.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
pg_lsn.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
pg_rusage.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
pgstat_internal.h Add inline incremental hash functions for in-memory use 2024-01-19 12:44:09 +07:00
pidfile.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
plancache.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
portal.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
ps_status.h Speedup and increase usability of set proc title functions 2023-02-20 16:18:27 +13:00
queryenvironment.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
rangetypes.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
regproc.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
rel.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
relcache.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
relfilenumbermap.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
relmapper.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
relptr.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
reltrigger.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
resowner.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
resowner_private.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
rls.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
ruleutils.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
sampling.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
selfuncs.h Teach estimate_array_length() to use statistics where available. 2024-01-04 18:36:19 -05:00
sharedtuplestore.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
snapmgr.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
snapshot.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
sortsupport.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
spccache.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
syscache.h Generate syscache info from catalog files 2024-01-23 07:31:06 +01:00
timeout.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
timestamp.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
tuplesort.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
tuplestore.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
typcache.h Add planner support functions for range operators <@ and @>. 2024-01-20 13:57:54 -05:00
tzparser.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
usercontext.h Perform logical replication actions as the table owner. 2023-04-04 11:25:23 -04:00
uuid.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
varbit.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
varlena.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
wait_event.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
xid8.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
xml.h Update copyright for 2024 2024-01-03 20:49:05 -05:00