Re: Nested xacts: looking for testers and review - Mailing list pgsql-hackers

From Alvaro Herrera
Subject Re: Nested xacts: looking for testers and review
Date
Msg-id 20040609192710.GA10705@dcc.uchile.cl
Whole thread Raw
In response to Re: Nested xacts: looking for testers and review  (Bruce Momjian <pgman@candle.pha.pa.us>)
Responses Re: Nested xacts: looking for testers and review
Re: Nested xacts: looking for testers and review
List pgsql-hackers
On Fri, May 28, 2004 at 04:05:40PM -0400, Bruce Momjian wrote:

Bruce,

> One interesting idea would be for COMMIT to affect the outer
> transaction, and END not affect the outer transaction.  Of course that
> kills the logic that COMMIT and END are the same, but it is an
> interesting idea, and doesn't affect backward compatibility because
> END/COMMIT behave the same in non-nested transactions.

I implemented this behavior by using parameters to COMMIT/END.  I didn't
want to add new keywords to the grammar so I just picked up
"COMMIT WITHOUT ABORT".  (Originally I had thought "COMMIT IGNORE
ERRORS" but those would be two new keywords and I don't want to mess
around with the grammar.  If there are different opinions, tweaking the
grammar is easy).

So the behavior I originally implemented is still there:

alvherre=# begin;
BEGIN
alvherre=# begin;
BEGIN
alvherre=# select foo;
ERROR:  no existe la columna "foo"
alvherre=# commit;
COMMIT
alvherre=# select 1;
ERROR:  transacción abortada, las consultas serán ignoradas hasta el fin de bloque de transacción
alvherre=# commit;
COMMIT


However if one wants to use in script the behavior you propose, use
the following:

alvherre=# begin;
BEGIN
alvherre=# begin;
BEGIN
alvherre=# select foo;
ERROR:  no existe la columna "foo"
alvherre=# commit without abort;
COMMIT
alvherre=# select 1;
 ?column?
----------
        1
(1 fila)

alvherre=# commit;
COMMIT


The patch is attached.  It applies only after the previous patch,
obviously.

--
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
"Ciencias políticas es la ciencia de entender por qué
los políticos actúan como lo hacen"  (netfunny.com)

Attachment

pgsql-hackers by date:

Previous
From: pgsql@mohawksoft.com
Date:
Subject: Re: sequences and "addval('myseq', value)"
Next
From: craig perras
Date:
Subject: transaction aborts in SPI