1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-28 23:42:10 +03:00

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
This commit is contained in:
Tom Lane
2022-12-09 09:58:38 -05:00
parent beecbe8e50
commit d9f7f5d32f
11 changed files with 397 additions and 0 deletions

View File

@ -900,6 +900,17 @@ CREATE TYPE <replaceable class="parameter">name</replaceable>
function is written in C.
</para>
<para>
In <productname>PostgreSQL</productname> version 16 and later,
it is desirable for base types' input functions to
return <quote>soft</quote> errors using the
new <function>errsave()</function>/<function>ereturn()</function>
mechanism, rather than throwing <function>ereport()</function>
exceptions as in previous versions.
See <filename>src/backend/utils/fmgr/README</filename> for more
information.
</para>
</refsect1>
<refsect1>