Re: Autonomous subtransactions

From: Gianni Ciolli <gianni(dot)ciolli(at)2ndquadrant(dot)it>
To: Marti Raudsepp <marti(at)juffo(dot)org>
Cc: Simon Riggs <simon(at)2ndquadrant(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Autonomous subtransactions
Date: 2011-12-19 20:43:09
Message-ID: 20111219204309.GC26381@leggeri.gi.lan
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(dot)ciolli(at)2ndquadrant(dot)it | www.2ndquadrant.it

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2011-12-19 20:47:16 Re: Postgres 9.1: Adding rows to table causing too much latency in other queries
Previous Message Gianni Ciolli 2011-12-19 20:21:36 Re: Autonomous subtransactions