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 6F40D52E8B; Sat, 13 Aug 2005 12:01:56 -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 22544-06; Sat, 13 Aug 2005 15:01:53 +0000 (GMT) Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) by svr1.postgresql.org (Postfix) with ESMTP id 9706752E93; Sat, 13 Aug 2005 12:01:51 -0300 (ADT) Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) by tigger.fuhr.org (8.13.3/8.13.3) with ESMTP id j7DF1jrA000993 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sat, 13 Aug 2005 09:01:48 -0600 (MDT) (envelope-from mfuhr@winnie.fuhr.org) Received: from winnie.fuhr.org (localhost [127.0.0.1]) by winnie.fuhr.org (8.13.3/8.13.3) with ESMTP id j7DF1jq1088424; Sat, 13 Aug 2005 09:01:45 -0600 (MDT) (envelope-from mfuhr@winnie.fuhr.org) Received: (from mfuhr@localhost) by winnie.fuhr.org (8.13.3/8.13.3/Submit) id j7DF1jpF088423; Sat, 13 Aug 2005 09:01:45 -0600 (MDT) (envelope-from mfuhr) Date: Sat, 13 Aug 2005 09:01:45 -0600 From: Michael Fuhr To: Bruce Momjian Cc: PostgreSQL-interfaces , PostgreSQL-patches Subject: Re: [HACKERS] ECPG ignores SAVEPOINT if first statement of a transaction Message-ID: <20050813150145.GA87926@winnie.fuhr.org> References: <20050803153223.GA17861@winnie.fuhr.org> <200508130222.j7D2MWh29185@candle.pha.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200508130222.j7D2MWh29185@candle.pha.pa.us> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.005 tagged_above=0 required=5 tests=[AWL=0.005] X-Spam-Level: X-Archive-Number: 200508/27 X-Sequence-Number: 5698 On Fri, Aug 12, 2005 at 10:22:32PM -0400, Bruce Momjian wrote: > Michael Fuhr wrote: > > ECPG ignores SAVEPOINT if it's the first statement of a transaction: ECPGtrans() ignores the statement because of this check: /* * if we are not in autocommit mode, already have committed the * transaction and get another commit, just ignore it */ if (!con->committed || con->autocommit) { if ((res = PQexec(con->connection, transaction)) == NULL) { ECPGraise(lineno, ECPG_TRANS, ECPG_SQLSTATE_TRANSACTION_RESOLUTION_UNKNOWN, NULL); return FALSE; } PQclear(res); } If no statements have been executed in this transaction then committed is true, so ECPGtrans() ignores the current statement. It looks like the code should make an extra consideration for SAVEPOINT in case it's the first statement. I'm also wondering if the check for a NULL return value from PQexec() is sufficient. Shouldn't it also check for a non-NULL result that's anything other than PGRES_COMMAND_OK? -- Michael Fuhr