Dealing with a DAL-type system, I've an issue with savepoint safety: a savepoint is created at the start of a process and either released on successful completion or rolled back on error.
However while it's not normal it's possible that the entire transaction gets committed (or rolled back) by the process being run. This removes the savepoint we're trying to release / rollback. This issue can be worked around by putting an other savepoint around the release/rollback, but obviously it's not possible to SAVEPOINT
a transaction in error.
Is there a way to perform a best-effort handling of this such that the savepoint is released / rollbacked if it exists, and nothing happens otherwise? According to In Postgres, how to get a list of current defined savepoint? there was no way to LBYL at the time, and there seems to be none still.