PG_FINALLY

Enterprise / PostgreSQL - Peter Eisentraut [eisentraut.org] - 1 November 2019 10:18 EDT

This gives an alternative way of catching exceptions, for the common case where the cleanup code is the same in the error and non-error cases. So instead of

PG_TRY(); { ... code that might throw ereport(ERROR) ... } PG_CATCH(); { cleanup(); PG_RE_THROW(); } PG_END_TRY(); cleanup();

one can write

PG_TRY(); { ... code that might throw ereport(ERROR) ... } (); { cleanup(); } PG_END_TRY();

Discussion: https://www.postgresql.org/message-id/flat/95a822c3-728b-af0e-d7e5-71890507ae0c%402ndquadrant.com

604bd36711 PG_FINALLY
contrib/auto_explain/auto_explain.c | 8 ++---
contrib/dblink/dblink.c | 19 ++--------
contrib/hstore_plpython/hstore_plpython.c | 5 +--
contrib/jsonb_plpython/jsonb_plpython.c | 5 +--
contrib/pg_stat_statements/pg_stat_statements.c | 12 ++-----
contrib/pg_trgm/trgm_regexp.c | 5 +--
contrib/postgres_fdw/connection.c | 5 +--
contrib/postgres_fdw/postgres_fdw.c | 25 +++-----------
contrib/sepgsql/hooks.c | 4 +--
contrib/sepgsql/label.c | 22 +++---------
contrib/sepgsql/selinux.c | 4 +--
contrib/sepgsql/uavc.c | 5 +--
src/backend/catalog/index.c | 8 ++---
src/backend/commands/async.c | 9 +----
src/backend/commands/copy.c | 4 +--
src/backend/commands/event_trigger.c | 10 ++----
src/backend/commands/extension.c | 6 +---
src/backend/commands/subscriptioncmds.c | 13 ++-----
src/backend/commands/trigger.c | 4 +--
src/backend/commands/vacuum.c | 6 +---
src/backend/libpq/be-fsstubs.c | 4 +--
src/backend/tcop/utility.c | 10 ++----
src/backend/utils/adt/xml.c | 20 +++--------
src/include/utils/elog.h | 46 ++++++++++++++++++++-----
src/pl/plperl/plperl.c | 16 ++-------
src/pl/plpgsql/src/pl_handler.c | 9 ++---
src/pl/plpython/plpy_cursorobject.c | 4 +--
src/pl/plpython/plpy_elog.c | 13 +------
src/pl/plpython/plpy_exec.c | 12 ++-----
src/pl/plpython/plpy_spi.c | 4 +--
src/pl/plpython/plpy_typeio.c | 5 +--
src/pl/tcl/pltcl.c | 14 ++------
32 files changed, 91 insertions(+), 245 deletions(-)

Upstream: git.postgresql.org


  • Share