Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-bugs by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group