pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Meskes <meskes@postgresql.org>
To: pgsql-interfaces@postgresql.org
Cc: Michael Fuhr <mike@fuhr.org>
Cc: Bruce Momjian <pgman@candle.pha.pa.us>
Subject: Re: [HACKERS] ECPG ignores SAVEPOINT if first statement of a transaction
Date: Fri, 26 Aug 2005 15:09:11 +0200
Message-ID: <200508261509.13511.meskes@postgresql.org> (raw)
In-Reply-To: <20050813150145.GA87926@winnie.fuhr.org>
References: <20050803153223.GA17861@winnie.fuhr.org>
	<200508130222.j7D2MWh29185@candle.pha.pa.us>
	<20050813150145.GA87926@winnie.fuhr.org>

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!



view thread (5+ messages)  latest in thread

Message-ID: <200508261509.13511.meskes@postgresql.org>
Permalink:  ../200508261509.13511.meskes@postgresql.org/
Also on:    postgresql.org/message-id/200508261509.13511.meskes@postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-interfaces@postgresql.org
  Cc: meskes@postgresql.org, mike@fuhr.org, pgman@candle.pha.pa.us
  Subject: Re: [HACKERS] ECPG ignores SAVEPOINT if first statement of a transaction
  In-Reply-To: <200508261509.13511.meskes@postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox