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

Re: rollback to savepoint leads to transaction already in progress

From: David Newall <postgresql(at)davidnewall(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: rollback to savepoint leads to transaction already in progress
Date: 2010-10-14 14:54:04
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-bugspgsql-hackers
On Thu, Oct 14, 2010 at 6:53 AM, Michael Meskes<meskes(at)postgresql(dot)org>  wrote:

> You seem to be answering to an email that I didn't see and couldn't find in
> the archive either. Was it send in private or to the list? If it went to the
> list I might be lagging behind.

On 14/10/10 22:51, Robert Haas wrote:
> I didn't get it either.  The original report was posted to pgsql-bugs
> on October 10.

It might be lag; it'll probably turn up, about 6 seconds after I press *S

-------- Original Message --------
Subject: 	Re: [BUGS] rollback to savepoint leads to transaction already
in progress
Date: 	Thu, 14 Oct 2010 10:44:50 +0900
From: 	Itagaki Takahiro<itagaki(dot)takahiro(at)gmail(dot)com>
To: 	David Newall<postgresql(at)davidnewall(dot)com>, PostgreSQL Hackers
CC: 	pgsql-bugs(at)postgresql(dot)org

On Mon, Oct 11, 2010 at 7:42 AM, David Newall
<postgresql(at)davidnewall(dot)com>   wrote:
>   Trivial program to demonstrate problem:
>   main() {
>       ECPGdebug(1,stderr);
>       exec sql connect to postgres;
>       exec sql set autocommit to off;
>       exec sql start transaction;
>       exec sql savepoint s;
>       exec sql rollback to s;
>       exec sql commit;
>       return 0;
>   }
>   Output:
>   [28397]: ECPGdebug: set to 1
>   [28397]: ECPGconnect: opening database postgres on<DEFAULT>   port<DEFAULT>
>   [28397]: ECPGsetcommit on line 4: action "off"; connection "postgres"
>   [28397]: ECPGtrans on line 5: action "start transaction"; connection "postgres"
>   [28397]: ECPGtrans on line 6: action "savepoint s"; connection "postgres"
>   [28397]: ECPGtrans on line 7: action "rollback to s"; connection "postgres"
>   [28397]: ECPGtrans on line 8: action "commit"; connection "postgres"
>   [28397]: ECPGnoticeReceiver: there is already a transaction in progress
>   [28397]: raising sqlcode -603
>   Problem:
>   It shouldn't raise "there is already a transaction in progress" error,
>   particularly when doing a commit.  Remove "rollback to s" and no problem.
>   Environment:
>   ecpg (PostgreSQL 8.4.5) 4.5.0
>   This appears to be a regression; it doesn't occur with ecpg (PostgreSQL
>   8.3.8) 4.4.1

The bug comes from string-based transaction control in ECPGtrans().
The code cannot distinguish ROLLBACK TRANSACTION and ROLLBACK TO savepoint.
if (strncmp(transaction, "commit", 6) == 0 || strncmp(transaction,
"rollback", 8) == 0)
     con->committed = true;
     con->committed = false;

I think the string-comparison is unreliable. So, I'd like to replace
the code to use PQtransactionStatus(). I have two patches to do it:
The first one (ecpg-trans-quick_20101014.patch) is a quick fix
that replaces only the above test.
The second one (ecpg-trans-full_20101014.patch) replaces all of
struct connection->committed with PQtransactionStatus().

Which solution is better? Or, another idea?

Itagaki Takahiro

In response to

pgsql-hackers by date

Next:From: Tom LaneDate: 2010-10-14 15:00:14
Subject: Re: UNION DISTINCT in doc
Previous:From: Alastair TurnerDate: 2010-10-14 14:53:53
Subject: Re: First patch proposal

pgsql-bugs by date

Next:From: mstone+postgresDate: 2010-10-14 18:00:19
Subject: BUG #5710: lock requires unintuitive privileges
Previous:From: Tom LaneDate: 2010-10-14 14:26:46
Subject: Re: BUG #5709: PostgreSQL server 8.4.5 does not compile with gcc 4.5

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