X-Original-To: pgsql-odbc-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 7A48DD70DF for ; Tue, 6 Sep 2005 06:01:42 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 92050-01 for ; Tue, 6 Sep 2005 09:01:37 +0000 (GMT) Received: from inetrt.skcapi.co.jp (inetrt.skcapi.co.jp [219.163.131.10]) by svr1.postgresql.org (Postfix) with ESMTP id 3D0D6D70FC for ; Tue, 6 Sep 2005 06:01:36 -0300 (ADT) Received: from hiroshi5jz7dqj (firewall.skcapi.co.jp [219.163.131.14]) by inetrt.skcapi.co.jp (8.13.1/8.13.1) with SMTP id j868x209010302; Tue, 6 Sep 2005 17:59:03 +0900 (JST) (envelope-from saito@inetrt.skcapi.co.jp) Message-ID: <048501c5b2c1$92d17540$01324d80@hiroshi5jz7dqj> From: "Hiroshi Saito" To: "Marko Ristola" , "Dave Page" Cc: References: <4319A1CE.4010007@kolumbus.fi> Subject: Re: savepoint Date: Tue, 6 Sep 2005 18:01:31 +0900 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.126 required=5 tests=[AWL=-0.081, UPPERCASE_25_50=0.207] X-Spam-Level: X-Archive-Number: 200509/66 X-Sequence-Number: 5964 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