Re: Autonomous subtransactions - Mailing list pgsql-hackers

From Gianni Ciolli
Subject Re: Autonomous subtransactions
Date
Msg-id 20111219204309.GC26381@leggeri.gi.lan
Whole thread Raw
In response to Re: Autonomous subtransactions  (Marti Raudsepp <marti@juffo.org>)
List pgsql-hackers
On Mon, Dec 19, 2011 at 09:32:06PM +0200, Marti Raudsepp wrote:
> Maybe that's just my paranoia, but the fact that subtransactions
> aren't named means it's pretty easy to accidentally get "out of step"
> and commit the wrong subtransaction. I see app developers often
> messing up BEGIN/COMMIT/ROLLBACK already. This is why I like the
> SAVEPOINT style; it's obvious when there's a bug.

For each COMMIT/ROLLBACK there is only one possible BEGIN
SUBTRANSACTION, therefore naming is not strictly necessary, unlike in
the SAVEPOINT case where you can have more than one option.

However, ISTM that allowing to optionally name each transaction could
provide a nice safety measure that the careful developer can use to
reduce the chances of human error. If subtransactions are not named,
no check is made; but if they are named, then the Xs on BEGIN
SUBTRANSACTION X and COMMIT/ROLLBACK SUBTRANSACTION X must match,
otherwise an exception is raised (and a bug is detected).

Regards,
Dr. Gianni Ciolli - 2ndQuadrant Italia
PostgreSQL Training, Services and Support
gianni.ciolli@2ndquadrant.it | www.2ndquadrant.it


pgsql-hackers by date:

Previous
From: Gianni Ciolli
Date:
Subject: Re: Autonomous subtransactions
Next
From: Tom Lane
Date:
Subject: Re: Postgres 9.1: Adding rows to table causing too much latency in other queries