From: Stuart McGraw <smcg4191@mtneva.com>
To: pgsql-general@postgresql.org
Cc: Alvaro Herrera <alvherre@2ndquadrant.com>
Subject: Re: existence of a savepoint?
Date: Tue, 29 May 2018 16:49:58 -0600
Message-ID: <857d29bf-515d-e624-9e0a-135e9e28e91b@mtneva.com> (raw)
In-Reply-To: <20180529143821.omiz7h54mbgrmfs6@alvherre.pgsql>
References: <20180529143821.omiz7h54mbgrmfs6@alvherre.pgsql>
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.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: smcg4191@mtneva.com, alvherre@2ndquadrant.com
Subject: Re: existence of a savepoint?
In-Reply-To: <857d29bf-515d-e624-9e0a-135e9e28e91b@mtneva.com>
References: <20180529143821.omiz7h54mbgrmfs6@alvherre.pgsql> <857d29bf-515d-e624-9e0a-135e9e28e91b@mtneva.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox