ECPG ignores SAVEPOINT if first statement of a transaction

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: pgsql-hackers(at)postgresql(dot)org
Subject: ECPG ignores SAVEPOINT if first statement of a transaction
Date: 2005-08-03 15:32:23
Message-ID: 20050803153223.GA17861@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-interfaces pgsql-patches

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/

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2005-08-03 15:46:29 Re: openbsd, plpython, missing threading symbols
Previous Message Peter Eisentraut 2005-08-03 14:34:34 Re: #escape_string_warning = off

Browse pgsql-interfaces by date

  From Date Subject
Next Message David 2005-08-09 14:45:39 pgperl vs dbd-perl
Previous Message Michael Fuhr 2005-08-03 14:31:25 ECPG and escape strings

Browse pgsql-patches by date

  From Date Subject
Next Message Matt Miller 2005-08-03 19:58:13 PL/pgSQL: EXCEPTION NOSAVEPOINT
Previous Message Petr Jelinek 2005-08-03 15:15:36 Re: per user/database connections limit again