Home > Archive > PostgreSQL Interfaces > August 2005 > Re: [HACKERS] ECPG ignores SAVEPOINT if first statement of a transaction









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

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

2005-08-26, 9:24 am

Am Samstag, 13. August 2005 17:01 schrieb Michael Fuhr:

> On Fri, Aug 12, 2005 at 10:22:32PM -0400, Bruce Momjian wrote:
>
> 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_TRANSA
CTION_RESOLUTION_UNK
NOWN, 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!

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com