Thread: [subxacts] Savepoint syntax

[subxacts] Savepoint syntax

From
Alvaro Herrera
Date:
Hackers,

Attached is the savepoints syntax patch, hopefully last try.
Essentially the same as the last patch, with the following differences:

- ROLLBACK TO changes TBLOCK state of the to-be-affected subtransactions
  instead of a static var.

- A new function RollbackAndReleaseSavepoint can be used to rollback to
  a savepoint without creating it again.  There's no way to trigger it
  from the grammar though (mainly for use in functions handlers, I
  think, though we can make it available directly to the user if there
  is a need for it.)

- Tab completion patch from Gaetano is included.

Please review and apply if OK.

--
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
"The West won the world not by the superiority of its ideas or values
or religion but rather by its superiority in applying organized violence.
Westerners often forget this fact, non-Westerners never do."
(Samuel P. Huntington)

Attachment

Re: [subxacts] Savepoint syntax

From
Alvaro Herrera
Date:
On Sun, Jul 25, 2004 at 04:58:01PM -0400, Alvaro Herrera wrote:

> Attached is the savepoints syntax patch, hopefully last try.
> Essentially the same as the last patch, with the following differences:

Brown paper bag patch.  Please disregard.  I'll post a good patch
tomorrow morning.

Sorry for the noise,

--
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
"Having your biases confirmed independently is how scientific progress is
made, and hence made our great society what it is today" (Mary Gardiner)


Re: [subxacts] Savepoint syntax

From
Alvaro Herrera
Date:
On Sun, Jul 25, 2004 at 04:58:01PM -0400, Alvaro Herrera wrote:

Hackers,

This is the good patch.  Actually I was testing the old build and
not the new code at all, because I failed to run my install script
to completion!  I am surprised that it didn't have a lot more errors.

> Attached is the savepoints syntax patch, hopefully last try.
> Essentially the same as the last patch, with the following differences:
>
> - ROLLBACK TO changes TBLOCK state of the to-be-affected subtransactions
>   instead of a static var.
>
> - A new function RollbackAndReleaseSavepoint can be used to rollback to
>   a savepoint without creating it again.  There's no way to trigger it
>   from the grammar though (mainly for use in functions handlers, I
>   think, though we can make it available directly to the user if there
>   is a need for it.)
>
> - Tab completion patch from Gaetano is included.

--
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
"La vida es para el que se aventura"

Attachment

Re: [subxacts] Savepoint syntax

From
Tom Lane
Date:
Alvaro Herrera <alvherre@dcc.uchile.cl> writes:
>> Attached is the savepoints syntax patch, hopefully last try.
>> - Tab completion patch from Gaetano is included.

Reviewed and committed.

I did not apply your changes to spi.c, instead choosing to revert it to
the former coding that disallowed any TransactionStmts.  I don't think
it will possibly work for SPI to execute such commands: if it did,
control would return to the caller with a different active transaction,
different active memory context, etc.

Oracle's PL/SQL behavior seems to posit that the PL/SQL function
executes "outside the database" and can have local state that is not
affected by SAVEPOINT, ROLLBACK, et al.  I'm not sure if we really
want to support that, but in any case there's no chance of doing it
for 7.5.  Our functions very definitely execute inside transactions.

What we could do at the SPI level is to provide functions that
encapsulate start-subxact/execute-command/commit-or-abort-subxact
so that control returns in the same subxact you started in, and you
can get control back if the executed command fails.

            regards, tom lane