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

Re: [HACKERS] ECPG ignores SAVEPOINT if first statement of a transaction

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Michael Fuhr <mike(at)fuhr(dot)org>
Cc: PostgreSQL-interfaces <pgsql-interfaces(at)postgresql(dot)org>,PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: [HACKERS] ECPG ignores SAVEPOINT if first statement of a transaction
Date: 2005-08-13 02:22:32
Message-ID: 200508130222.j7D2MWh29185@candle.pha.pa.us (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-interfacespgsql-patches
Would someone on the interface list look for a fix to this?  Thanks.

---------------------------------------------------------------------------

Michael Fuhr wrote:
> ECPG ignores SAVEPOINT if it's the first statement of a transaction:
> 
> % cat foo.pgc
> int
> main(void)
> {
>     EXEC SQL WHENEVER SQLERROR SQLPRINT;
>     EXEC SQL WHENEVER SQLWARNING SQLPRINT;
> 
>     EXEC SQL CONNECT TO test;
> 
>     EXEC SQL SAVEPOINT foo;
>     EXEC SQL DROP TABLE nosuch_1;
>     EXEC SQL ROLLBACK TO foo;
>     EXEC SQL DROP TABLE nosuch_2;
> 
>     EXEC SQL COMMIT;
>     EXEC SQL DISCONNECT;
> 
>     return 0;
> }
> 
> % ./foo
> sql error 'table "nosuch_1" does not exist' in line 10.
> sql error 'current transaction is aborted, commands ignored until end of transa
> 
> The SAVEPOINT code is generated but apparently ECPGtrans() doesn't
> execute it.  A sniff of the connection doesn't show it, and the
> sniff shows the ROLLBACK TO failing with "no such savepoint."
> 
> If I execute a command before the SAVEPOINT then I get the following,
> which is what I was expecting:
> 
> % ./foo
> sql error 'table "nosuch_1" does not exist' in line 11.
> sql error 'table "nosuch_2" does not exist' in line 13.
> 
> A sniff of this connection shows both the SAVEPOINT and ROLLBACK TO
> being executed and succeeding.
> 
> -- 
> Michael Fuhr
> http://www.fuhr.org/~mfuhr/
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 6: explain analyze is your friend
> 

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman(at)candle(dot)pha(dot)pa(dot)us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

In response to

Responses

pgsql-hackers by date

Next:From: Bruce MomjianDate: 2005-08-13 02:25:00
Subject: Re: Bug in ALTER TABLE/SEQUENCE OWNER TO
Previous:From: Bruce MomjianDate: 2005-08-13 02:22:18
Subject: Re: [HACKERS] ECPG and escape strings

pgsql-patches by date

Next:From: Bruce MomjianDate: 2005-08-13 02:28:13
Subject: Re: [PATCHES] FW: Win32 unicode vs ICU
Previous:From: Bruce MomjianDate: 2005-08-13 02:22:18
Subject: Re: [HACKERS] ECPG and escape strings

pgsql-interfaces by date

Next:From: Bruce MomjianDate: 2005-08-13 02:43:26
Subject: Re: [BUGS] BUG #1815: ECPGdebug causes crash on Windows XP
Previous:From: Bruce MomjianDate: 2005-08-13 02:22:18
Subject: Re: [HACKERS] ECPG and escape strings

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