Re: Bit by "commands ignored until end of transaction block" again

From: Joshua Tolley <eggyknap(at)gmail(dot)com>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Cc: Glenn Maynard <glenn(at)zewt(dot)org>, Richard Huxton <dev(at)archonet(dot)com>, pgsql-sql(at)postgresql(dot)org
Subject: Re: Bit by "commands ignored until end of transaction block" again
Date: 2009-07-24 18:09:56
Message-ID: 20090724180956.GC6606@eddie
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Fri, Jul 24, 2009 at 12:54:31PM -0400, Alvaro Herrera wrote:
> Joshua Tolley escribió:
>
> > Have you tried this? I expect if you give it a shot, you'll find you don't
> > actually have this problem. Really, everything is always in a transaction. If
> > you haven't explicitly opened one, PostgreSQL opens one for you before each
> > statement, and issues a COMMIT afterwards (or a ROLLBACK, if your statement
> > ran into an error). Statements within functions are always executed within the
> > same transaction, so you can issue SAVEPOINT commands anywhere in PL/pgSQL
> > functions without problems, because you're always in a transaction.
>
> No, actually you can't call SAVEPOINT inside a PL/pgSQL function (or any
> SPI user for that matter -- have you tried savepoints in LOLCODE?)
> Inside PL/pgSQL the only way to use savepoints is with EXCEPTION blocks.
>
> You are correct that you're always in a transaction, but in this context
> not all transactions are equal :-(
>
> (The problem, as we found out, is that the function must always have
> control at the same level of transaction nestedness in SPI; you can't
> just let the user define and release savepoints arbitrarily.)

That makes sense -- and although I did try this before sending the email,
apparently I didn't try it well enough. :)

- Josh / eggyknap

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message nha 2009-07-24 22:41:10 Re: using count in other column
Previous Message Alvaro Herrera 2009-07-24 16:54:31 Re: Bit by "commands ignored until end of transaction block" again