From: Marko Ristola <marko.ristola@kolumbus.fi>
To: Peter Eisentraut <peter_e@gmx.net>
Cc: 'pgsql-odbc@postgresql.org' <pgsql-odbc@postgresql.org>
Subject: Re: Transactions and savepoints
Date: Wed, 30 Mar 2005 22:22:41 +0300
Message-ID: <424AFC81.6020409@kolumbus.fi> (raw)
In-Reply-To: <200503302011.18601.peter_e@gmx.net>
References: <42453163.6060508@kolumbus.fi>
<200503302011.18601.peter_e@gmx.net>
The needed new feature, the savepoint, is implemented
into PostgreSQL 8.0.1.
Tom Zschockelt asked about his savepoint problem
from this list at February 15 this year.
Savepoints are a new great feature in 8.0.
PostgreSQL savepoints are almost equal with a
SQL standard. sql-savepoint.html tells one difference below.
Here are the PostgreSQL documents:
http://www.postgresql.org/docs/8.0/static/sql-savepoint.htmlhttp://www.postgresql.org/docs/8.0/static/sql-release-savepoint.htmlhttp://www.postgresql.org/docs/8.0/static/sql-rollback-to.html
I tested the savepoint a few days back.
Savepoint creation worked, but the following
command failed:
ROLLBACK TO SAVEPOINT my_savepoint;
This failed, because in CC_send_query sees the first ROLLBACK word,
but does not distinquishe between a savepoint rollback and
a transaction rollback.
I found also, that savepoint rollback closes the failed savepoint's cursors.
So here is the cursor problem (with psql):
marko=# begin;
BEGIN
marko=# savepoint aabb;
SAVEPOINT
marko=# declare cc cursor for select * from test1;
DECLARE CURSOR
marko=# rollback to aabb;
ROLLBACK
marko=# close cc;
ERROR: cursor "cc" does not exist
ERROR: cursor "cc" does not exist
marko=# select * from test1;
ERROR: current transaction is aborted, commands ignored until end of
transaction block
ERROR: current transaction is aborted, commands ignored until end of
transaction block
marko=# rollback;
ROLLBACK
So, with open select cursors the ODBC driver does not know
that the backend just closed a cursor with the rollback.
If the ODBC driver tries to close an already closed cursor,
thus making the outer transaction context fail (the case above).
So we need the Transaction* object or something,
to implement the stack for savepoint tracking and to keep track,
in which context each cursor has been created.
Maybe we could get some support from the backend in
PostgreSQL 8.1, and forget the backend state tracking completely?
A needed message might be a notification from the backend
about every closed cursor during savepoint rollback and savepoint commit.
Marko Ristola
Peter Eisentraut wrote:
>Marko Ristola wrote:
>
>
>>I have been thinking about savepoints.
>>What do you think about the following:
>>
>>
>
>The interface and behavior of the ODBC driver is bound by various public
>standards such as the SQL standard and the Microsoft ODBC
>pseudostandard. So any new functionality should be based on either of
>these sources. Does that apply to your proposal?
>
>
>
>>They would keep the knoledge about the following things:
>>- Current transaction state (is in autocommit mode, in transaction,
>> and the savepoint stack structure.
>>
>>
>
>This information is available on the protocol level and does not to be
>tracked.
>
>
>
>>This would make the savepoint rollback work with cursors:
>>
>>
>
>I'm not exactly up to speed on how savepoints interact with cursors
>nowadays. Perhaps you could first explain what problem you are trying
>to solve?
>
>
>
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-odbc@postgresql.org
Cc: marko.ristola@kolumbus.fi, peter_e@gmx.net
Subject: Re: Transactions and savepoints
In-Reply-To: <424AFC81.6020409@kolumbus.fi>
References: <42453163.6060508@kolumbus.fi> <200503302011.18601.peter_e@gmx.net> <424AFC81.6020409@kolumbus.fi>
* 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