pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Fuhr <mike@fuhr.org>
To: pgsql-hackers@postgresql.org
Subject: ECPG ignores SAVEPOINT if first statement of a transaction
Date: Wed, 3 Aug 2005 09:32:23 -0600
Message-ID: <20050803153223.GA17861@winnie.fuhr.org> (raw)

ECPG ignores SAVEPOINT if it's the first statement of a transaction:

% cat foo.pgc
int
main(void)
{
    EXEC SQL WHENEVER SQLERROR SQLPRINT;
    EXEC SQL WHENEVER SQLWARNING SQLPRINT;

    EXEC SQL CONNECT TO test;

    EXEC SQL SAVEPOINT foo;
    EXEC SQL DROP TABLE nosuch_1;
    EXEC SQL ROLLBACK TO foo;
    EXEC SQL DROP TABLE nosuch_2;

    EXEC SQL COMMIT;
    EXEC SQL DISCONNECT;

    return 0;
}

% ./foo
sql error 'table "nosuch_1" does not exist' in line 10.
sql error 'current transaction is aborted, commands ignored until end of transa

The SAVEPOINT code is generated but apparently ECPGtrans() doesn't
execute it.  A sniff of the connection doesn't show it, and the
sniff shows the ROLLBACK TO failing with "no such savepoint."

If I execute a command before the SAVEPOINT then I get the following,
which is what I was expecting:

% ./foo
sql error 'table "nosuch_1" does not exist' in line 11.
sql error 'table "nosuch_2" does not exist' in line 13.

A sniff of this connection shows both the SAVEPOINT and ROLLBACK TO
being executed and succeeding.

-- 
Michael Fuhr
http://www.fuhr.org/~mfuhr/



view thread (5+ messages)  latest in thread

Message-ID: <20050803153223.GA17861@winnie.fuhr.org>
Permalink:  ../20050803153223.GA17861@winnie.fuhr.org/
Also on:    postgresql.org/message-id/20050803153223.GA17861@winnie.fuhr.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: mike@fuhr.org, pgsql-hackers@postgresql.org
  Subject: Re: ECPG ignores SAVEPOINT if first statement of a transaction
  In-Reply-To: <20050803153223.GA17861@winnie.fuhr.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