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