Re: BUG #2507: Problem using two-phase commit - Mailing list pgsql-bugs

From Alvaro Herrera
Subject Re: BUG #2507: Problem using two-phase commit
Date
Msg-id 20060701145422.GB7566@surnet.cl
Whole thread Raw
In response to BUG #2507: Problem using two-phase commit  ("N. Ramirez" <noramirez@speedy.com.ar>)
List pgsql-bugs
N. Ramirez escribió:

> I do not have an operation as it must be when use the functions to do
> 2-phase commit
>
> Example create table prueba (a int, b int);
> begin;
> PREPARE TRANSACTION 'aaaa';
> insert into prueba values (1,2);
> ROLLBACK PREPARED 'aaaa';  select * from prueba
> a               b
> -----------------------------
> 1               2
> because?
> it did not do rollback?
> as it is used the method of 2-phase commit?

It did rollback, but you put the insert outside the prepared
transaction, so it was committed independently.  Try this:

alvherre=# create table prueba (a int, b int);
CREATE TABLE
alvherre=# begin;
BEGIN
alvherre=# insert into prueba values (1, 2);
INSERT 0 1
alvherre=# prepare transaction 'aaaa';
PREPARE TRANSACTION
alvherre=# select * from prueba;
 a | b
---+---
(0 filas)

alvherre=# rollback prepared 'aaaa';
ROLLBACK PREPARED
alvherre=# select * from prueba;
 a | b
---+---
(0 filas)

alvherre=# begin;
BEGIN
alvherre=# insert into prueba values (1, 2);
INSERT 0 1
alvherre=# prepare transaction 'bbb';
PREPARE TRANSACTION
alvherre=# select * from prueba;
 a | b
---+---
(0 filas)

alvherre=# commit prepared 'bbb';
COMMIT PREPARED
alvherre=# select * from prueba;
 a | b
---+---
 1 | 2
(1 fila)


> idem for use of dblink

Not sure what you mean here.

--
Alvaro Herrera                                http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

pgsql-bugs by date:

Previous
From: "Paul Röttgerding"
Date:
Subject: BUG #2498: Problem with ADO.RECORDSET.UPDATE
Next
From: "ONG JIIN ME"
Date:
Subject: BUG #2509: ODBC TIMESTAMP UPDATE FAILED