Rollback locks table - why?

From: "Jan Peters" <petersjan(at)gmx(dot)at>
To: pgsql-sql(at)postgresql(dot)org
Subject: Rollback locks table - why?
Date: 2008-03-20 13:44:33
Message-ID: 20080320134433.259270@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hello list,
I am a bit confused. See the code below:

BEGIN;
SAVEPOINT sp1;
INSERT INTO test(id,runde) VALUES(2, 0);
--if there is a unique key violstion:
ROLLBACK TO sp1;
UPDATE test SET id = 1000 WHERE runde = 0;
COMMIT;

When I first run this statement, I do not get any error message, but also there's also no INSERT on table test. If I run just:

INSERT INTO test(id,runde) VALUES(2, 0);

on its own, it works. (i.e. I get a new row). If I run the transaction block from above again I get first a unique key violation (that is ok, because that's what I trying to check for) but there is NO rollback to sp1, only the "Unique Key" error message and after that I get the dreaded "current transaction is aborted" error message and the system reports an EXCLUSIVE LOCK on the table (<IDLE>in transaction).

Any ideas what I am doing wrong?

Using PostGreSQL 8.2.7 on Windows XP.

Regards and many thanks in advance
Jan
--
Psssst! Schon vom neuen GMX MultiMessenger gehört?
Der kann`s mit allen: http://www.gmx.net/de/go/multimessenger

--
GMX startet ShortView.de. Hier findest Du Leute mit Deinen Interessen!
Jetzt dabei sein: http://www.shortview.de/?mc=sv_ext_mf(at)gmx

Browse pgsql-sql by date

  From Date Subject
Next Message Craig Ringer 2008-03-20 13:44:34 Re: Select into
Previous Message Jan Peters 2008-03-20 13:42:08 Rollback locks table - why?