Re: existence of a savepoint?

From: Stuart McGraw <smcg4191(at)mtneva(dot)com>
To: pgsql-general(at)postgresql(dot)org
Cc: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
Subject: Re: existence of a savepoint?
Date: 2018-05-29 22:49:58
Message-ID: 857d29bf-515d-e624-9e0a-135e9e28e91b@mtneva.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Stuart McGraw 2018-05-29 22:50:58 Re: existence of a savepoint?
Previous Message Stuart McGraw 2018-05-29 22:49:23 Re: existence of a savepoint?