X-Original-To: pgsql-interfaces-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 69CB752BEB; Fri, 12 Aug 2005 23:22:29 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 30403-09; Sat, 13 Aug 2005 02:22:27 +0000 (GMT) Received: from candle.pha.pa.us (candle.pha.pa.us [64.139.89.126]) by svr1.postgresql.org (Postfix) with ESMTP id A8F3F52BE3; Fri, 12 Aug 2005 23:22:26 -0300 (ADT) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.11.6) id j7D2MWh29185; Fri, 12 Aug 2005 22:22:32 -0400 (EDT) From: Bruce Momjian Message-Id: <200508130222.j7D2MWh29185@candle.pha.pa.us> Subject: Re: [HACKERS] ECPG ignores SAVEPOINT if first statement of a transaction In-Reply-To: <20050803153223.GA17861@winnie.fuhr.org> To: Michael Fuhr Date: Fri, 12 Aug 2005 22:22:32 -0400 (EDT) Cc: PostgreSQL-interfaces , PostgreSQL-patches X-Mailer: ELM [version 2.4ME+ PL121 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.113 tagged_above=0 required=5 tests=[AWL=-0.094, UPPERCASE_25_50=0.207] X-Spam-Level: X-Archive-Number: 200508/23 X-Sequence-Number: 5694 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@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073