pg.ddx.io  pgsql-odbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Hiroshi Saito <saito@inetrt.skcapi.co.jp>
To: Marko Ristola <marko.ristola@kolumbus.fi>
To: Dave Page <dpage@vale-housing.co.uk>
Cc: pgsql-odbc@postgresql.org
Subject: Re: savepoint
Date: Tue, 6 Sep 2005 18:01:31 +0900
Message-ID: <048501c5b2c1$92d17540$01324d80@hiroshi5jz7dqj> (raw)
References: <E7F85A1B5FF8D44C8A1AF6885BC9A0E4AC9E1C@ratbert.vale-housing.co.uk>
	<4319A1CE.4010007@kolumbus.fi>

Hi Marko.

> BEGIN
> Stmt 1: SAVEPOINT svp
> Stmt 1: CREATE CURSOR CC AS SELECT values from TEST LIMIT 2 -- OK
> Stmt 1: FETCH 1 -- fetched one row
> Stmt 2: INSERT INTO VALUES -- ERROR.
> Stmt 2: ROLLBACK TO svp:
>    Inside PSQLODBC:
>    1. PSQLDODBC calls CLOSE CURSOR CC. Error, because transaction is in 
> ERROR condition.
>    2. ROLLBACK TO svp: this won't be done, because (1) failed already.
>    Correct way here is to NOT CLOSE DEAD CURSORS!
> Stmt 1: FETCH 1 -- fetched one row -- NOT DONE
> CLOSE CURSOR CC -- NOT DONE
> END

Umm, Actually, the cursor name will not be found when it ROLLBACK out of cursor.
It is a phenomenon which happens even if it is not psqlodbc....
I consider the following scenario.

CREATE TABLE svtest (k1 varchar(19) PRIMARY KEY,d1 varchar(10));
INSERT INTO svtest VALUES('X','1');
INSERT INTO svtest VALUES('Y','2');
INSERT INTO svtest VALUES('Z','3');
BEGIN;
SAVEPOINT svp1;
DECLARE CC CURSOR FOR SELECT * from svtest LIMIT 2;
FETCH FIRST FROM CC;
SAVEPOINT svp2;
INSERT INTO svtest values('X','99');
ROLLBACK TO svp2;
INSERT INTO svtest values('A','0');
FETCH FIRST FROM CC;
FETCH NEXT FROM CC;
CLOSE CC;
END;
SELECT * FROM svtest;
DROP TABLE svtest CASCADE;

The above works with psqlodbc. However, Updating cursor is not considered carefully. 

Regards,
Hiroshi Saito




view thread (5+ messages)  latest in thread

Message-ID: <048501c5b2c1$92d17540$01324d80@hiroshi5jz7dqj>
Permalink:  ../048501c5b2c1$92d17540$01324d80@hiroshi5jz7dqj/
Also on:    postgresql.org/message-id/048501c5b2c1$92d17540$01324d80@hiroshi5jz7dqj

 · 

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 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: saito@inetrt.skcapi.co.jp, marko.ristola@kolumbus.fi, dpage@vale-housing.co.uk
  Subject: Re: savepoint
  In-Reply-To: <048501c5b2c1$92d17540$01324d80@hiroshi5jz7dqj>
  References: <E7F85A1B5FF8D44C8A1AF6885BC9A0E4AC9E1C@ratbert.vale-housing.co.uk> <4319A1CE.4010007@kolumbus.fi> <048501c5b2c1$92d17540$01324d80@hiroshi5jz7dqj>

* 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