Re: BUG #2507: Problem using two-phase commit

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: "N(dot) Ramirez" <noramirez(at)speedy(dot)com(dot)ar>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #2507: Problem using two-phase commit
Date: 2006-07-01 14:54:22
Message-ID: 20060701145422.GB7566@surnet.cl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Soner Demiray 2006-07-01 14:58:43 BUG #2508: TransactionIdGetStatus returns wrong state
Previous Message N. Ramirez 2006-06-30 19:33:35 BUG #2507: Problem using two-phase commit