X-Original-To: pgsql-interfaces-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 439DED793A for ; Fri, 26 Aug 2005 10:09:30 -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 74248-08 for ; Fri, 26 Aug 2005 13:09:25 +0000 (GMT) Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.126.188]) by svr1.postgresql.org (Postfix) with ESMTP id 1C864D7931 for ; Fri, 26 Aug 2005 10:09:23 -0300 (ADT) Received: from p50895629.dip.t-dialin.net [80.137.86.41] (helo=feivel) by mrelayeu.kundenserver.de with ESMTP (Nemesis), id 0ML2Dk-1E8dxP41pA-0001gI; Fri, 26 Aug 2005 15:09:19 +0200 Received: from feivel (feivel [127.0.0.1]) by feivel (Postfix) with ESMTP id 8ABBA8326; Fri, 26 Aug 2005 15:09:18 +0200 (CEST) From: Michael Meskes To: pgsql-interfaces@postgresql.org Subject: Re: [HACKERS] ECPG ignores SAVEPOINT if first statement of a transaction Date: Fri, 26 Aug 2005 15:09:11 +0200 User-Agent: KMail/1.8.1 Cc: Michael Fuhr , Bruce Momjian References: <20050803153223.GA17861@winnie.fuhr.org> <200508130222.j7D2MWh29185@candle.pha.pa.us> <20050813150145.GA87926@winnie.fuhr.org> In-Reply-To: <20050813150145.GA87926@winnie.fuhr.org> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200508261509.13511.meskes@postgresql.org> X-Provags-ID: kundenserver.de abuse@kundenserver.de login:da5cff6069dd6897c77170232368d0ba X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.722 required=5 tests=[AWL=-0.654, DNS_FROM_RFC_POST=1.376] X-Spam-Level: X-Archive-Number: 200508/49 X-Sequence-Number: 5720 Am Samstag, 13. August 2005 17:01 schrieb Michael Fuhr: > 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 I have to admit that this code is so old I have to think quite a bit about why it is done this way. > like the code should make an extra consideration for SAVEPOINT in > case it's the first statement. Yes, I agree. > 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? Seems to make sense too. The NULL return value would just mean that the statement wasn't even started. If it is but returns an error, it is considered valid here, right? Michael -- Michael Meskes Email: Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org) ICQ: 179140304, AIM/Yahoo: michaelmeskes, Jabber: meskes@jabber.org Go SF 49ers! Go Rhein Fire! Use Debian GNU/Linux! Use PostgreSQL!