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

From: Michael Meskes <meskes(at)postgresql(dot)org>
To: pgsql-interfaces(at)postgresql(dot)org
Cc: Michael Fuhr <mike(at)fuhr(dot)org>, Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Subject: Re: [HACKERS] ECPG ignores SAVEPOINT if first statement of a transaction
Date: 2005-08-26 13:09:11
Message-ID: 200508261509.13511.meskes@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-interfaces pgsql-patches

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(at)jabber(dot)org
Go SF 49ers! Go Rhein Fire! Use Debian GNU/Linux! Use PostgreSQL!

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Knut P Lehre 2005-08-26 13:23:18 SSL client crt verification
Previous Message Teodor Sigaev 2005-08-26 12:47:51 Re: VACUUM/t_ctid bug (was Re: GiST concurrency commited)

Browse pgsql-interfaces by date

  From Date Subject
Next Message Kuba Ouhrabka 2005-08-29 08:45:16 Re: ecpg: arrays and nulls
Previous Message Greg Sabino Mullane 2005-08-25 17:06:27 Re: DBD::Pg and "invalid frontend message type 10"

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2005-08-26 13:39:10 Re: force C locale for temp regression installations
Previous Message Andrew Dunstan 2005-08-26 13:00:53 force C locale for temp regression installations