From: | Jon Swinth <jswinth(at)atomicpc(dot)com> |
---|---|
To: | Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> |
Cc: | Jean-Luc Lachance <jllachan(at)nsd(dot)ca>, pgsql-general(at)postgresql(dot)org |
Subject: | Re: Two features left |
Date: | 2002-11-27 21:23:52 |
Message-ID: | 200211271323.52998.jswinth@atomicpc.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Ok, so it looks like your nested transactions and savepoints are really the
same thing. The question is, are you going to change the way SQL exceptions
are handled so that simply abort that SQL statement don't require a rollback?
With your enhancement, it sounds like calling BEGIN before each SQL statement
could acheive what I am asking for, but the issue is existing applications
will not expect to have to do so.
On Wednesday 27 November 2002 01:16 pm, Bruce Momjian wrote:
> Jon Swinth wrote:
> > Maybe what you are talking about will not help. The question is are you
> > trying to make nested transactions or savepoints?
> >
> > Nested transactions would be useful for trying to interrupt a transaction
> > and have another action happen or not happen on it's own. An example
> > would be when you want a credit card transaction to generate a log
> > reguardless of whether the out transaction is commited or rolled back.
> > The problem with
>
> Not with my implementation:
> > > BEGIN;
> > > SELECT ...
> > > BEGIN;
> > > UPDATE ...
> > > ABORT;
> > > DELETE ...
> > > COMMIT;
>
> In the above case, the ABORT cancels the UPDATE. If the outer
> transaction ABORTS, everything aborts. Even if you commit a
> subtransaction, _all_ transactions above it must commit for the
> subtransaction to actually commit.
>
> If you want a log entry regardless of the transaction, put it in a
> separate transaction.
>
> > nested transactions is that it is easy to generate deadlocks, especially
> > with the write locks currently on foreign keys.
>
> Again, it isn't really any different from a transaction without
> subtransactions except certain parts of the entire transaction can be
> aborted.
>
> > What may help is the concept of savepoint (if implemented internally).
> > Savepoints are usually named and allow rollback to a specific point in
> > the transaction. There is no issue with deadlock since everything is
> > still in the same transaction. You then don't have to have something
> > call ABORT, you simple need to say ROLLBACK TO <savepoint_name>.
> >
> > BEGIN;
> > SELECT...
> > INSERT...
> > SAVEPOINT a ;
> > UPDATE...
> > ROLLBACK TO a ;
> > DELETE...
> > COMMIT;
>
> Right. It is no change in functionality to add savepoints because we
> can just do a named BEGIN internally as the SAVEPOINT, then do ABORT
> back until we match the nesting level of the savepoint.
From | Date | Subject | |
---|---|---|---|
Next Message | Ron St.Pierre | 2002-11-27 21:38:54 | Sequence (related) Problem |
Previous Message | Medi Montaseri | 2002-11-27 21:20:20 | Re: How was my PG compiled |