Re: Nested Transactions, Abort All

From: Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: Thomas Swan <tswan(at)idigx(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Nested Transactions, Abort All
Date: 2004-07-06 15:56:30
Message-ID: 20040706155630.GC8235@dcc.uchile.cl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Jul 06, 2004 at 11:37:18AM -0400, Bruce Momjian wrote:
> Alvaro Herrera wrote:
> > On Sat, Jul 03, 2004 at 02:32:44AM -0500, Thomas Swan wrote:
> > > Alvaro Herrera wrote:
> >
> > > >What I'd like to do is start the transaction block before the function
> > > >is called if we are not in a transaction block. This would mean that
> > > >when the function calls BEGIN it won't be the first one -- it will
> > > >actually start a subtransaction and will be able to end it without harm.
> > > >I think this can be done automatically at the SPI level.
> > >
> > > Please tell me there is some sanity in this. If I follow you
> > > correctly, at no point should anyone be able to issue an explicit
> > > begin/end because they are already in an explicit/implicit transaction
> > > by default... How is the user/programmer to know when this is the case?
> >
> > I'm not sure I understand you. Of course you can issue begin/end. What
> > you can't do is issue begin/end inside a function -- you always use
> > subbegin/subcommit in that case.
>
> And if you use SUBBEGIN/SUBCOMMIT in a function that isn't already call
> inside from an explicit transaction, it will work because the call
> itself is its own implicit transaction, right?

Right. Note that this doesn't work with the current code -- in fact you
can cause a server crash easily.

--
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
"Doing what he did amounts to sticking his fingers under the hood of the
implementation; if he gets his fingers burnt, it's his problem." (Tom Lane)

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andreas Pflug 2004-07-06 16:05:48 Re: serverlog rotation/functions
Previous Message Bruce Momjian 2004-07-06 15:38:04 Re: A wanna be