Create infrastructure for "soft" error reporting.
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 9 Dec 2022 14:58:38 +0000 (09:58 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 9 Dec 2022 14:58:38 +0000 (09:58 -0500)
commitd9f7f5d32f201bec61fef8104aafcb77cecb4dcb
tree07683a0da7bb8a78be11afa43fe23e5b23490896
parentbeecbe8e5001249f0ad51f828d66238dd5160072
Create infrastructure for "soft" error reporting.

Postgres' standard mechanism for reporting errors (ereport() or elog())
is used for all sorts of error conditions.  This means that throwing
an exception via ereport(ERROR) requires an expensive transaction or
subtransaction abort and cleanup, since the exception catcher dare not
make many assumptions about what has gone wrong.  There are situations
where we would rather have a lighter-weight mechanism for dealing
with errors that are known to be safe to recover from without a full
transaction cleanup.  This commit creates infrastructure to let us
adapt existing error-reporting code for that purpose.  See the
included documentation changes for details.  Follow-on commits will
provide test code and usage examples.

The near-term plan is to convert most if not all datatype input
functions to report invalid input "softly".  This will enable
implementing some SQL/JSON features cleanly and without the cost
of subtransactions, and it will also allow creating COPY options
to deal with bad input without cancelling the whole COPY.

This patch is mostly by me, but it owes very substantial debt to
earlier work by Nikita Glukhov, Andrew Dunstan, and Amul Sul.
Thanks also to Andres Freund for review.

Discussion: https://postgr.es/m/3bbbb0df-7382-bf87-9737-340ba096e034@postgrespro.ru
doc/src/sgml/ref/create_type.sgml
src/backend/nodes/Makefile
src/backend/nodes/gen_node_support.pl
src/backend/utils/error/elog.c
src/backend/utils/fmgr/README
src/backend/utils/fmgr/fmgr.c
src/include/fmgr.h
src/include/nodes/meson.build
src/include/nodes/miscnodes.h [new file with mode: 0644]
src/include/utils/elog.h
src/tools/pgindent/typedefs.list