On 05/29/2018 08:38 AM, Alvaro Herrera wrote:
On 2018-May-27, Stuart McGraw wrote:
Is there some way to to test if a savepoint of a given name
exists? Or better yet, the number of stacked savepoints of
that name?
What is the use case for this?
I have a process that extracts data from a source and inserts
it into a Postgresql database with one big commit at the end.
The flow is not straight forward: the data is read in blocks
that contain sub-blocks and certain database errors (duplicate
keys, etc) may need to be rolled back to the previous insert,
sub-block or block depending on context. Trying to keep track
of which savepoints are active without "leaking" them (failing
to release when no longer needed) in the presence of many branches
and exception handlers is not impossible but would be much easier
if I could introspect the savepoint state rather than having to
try and track it myself.
Alternatively if there were a setting to tell Postgresql to
follow the SQL standard behavior of overwriting rather stacking
savepoints, that too would also solve my current problem I think.
Perhaps it is just my limited experience but the former behavior
has always seemed more useful in practice than the latter.