X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id EDF995E4853 for ; Mon, 6 Sep 2004 13:30:48 +0100 (BST) 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 86491-10 for ; Mon, 6 Sep 2004 12:30:46 +0000 (GMT) Received: from mail.gmx.net (pop.gmx.de [213.165.64.20]) by svr1.postgresql.org (Postfix) with SMTP id 68E1F5E3632 for ; Mon, 6 Sep 2004 13:30:40 +0100 (BST) Received: (qmail 10677 invoked by uid 65534); 6 Sep 2004 12:30:46 -0000 Received: from office01.emerion.com (EHLO zaphod) (83.64.50.26) by mail.gmx.net (mp005) with SMTP; 06 Sep 2004 14:30:46 +0200 X-Authenticated: #1946847 Message-ID: <00ea01c4940d$59f54b30$ad01a8c0@zaphod> From: "Michael Paesold" To: "Tsirkin Evgeny" Cc: References: <008601c493e5$e0965940$0b00a8c0@forge> <00c701c493eb$def5b9e0$0b00a8c0@forge> <009501c493f6$52932770$ad01a8c0@zaphod> <00a701c493fd$dd44d060$ad01a8c0@zaphod> Subject: Re: duplicates Date: Mon, 6 Sep 2004 14:30:52 +0200 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.1437 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.3 tagged_above=0.0 required=5.0 tests=UPPERCASE_25_50 X-Spam-Level: X-Archive-Number: 200409/53 X-Sequence-Number: 14756 Tsirkin Evgeny wrote: > one moer question ,how did you tested it? > > > I have tested this here. I don't really know if this is just the case with > > Best Regards, > > Michael Paesold First I created the your schedule table. Then I opened two psql sessions... Session A Session B BEGIN; SET TRANSACTION ISOLATION LEVEL SERIALIZABLE; DELETE FROM schedule WHERE studentid = 1; INSERT INTO schedule VALUES (1, 1, 0, 0); BEGIN; SET TRANSACTION ISOLATION LEVEL SERIALIZABLE; DELETE FROM schedule WHERE studentid = 1; -- if there existed records for this delete, -- session B will now wait for session A to -- commit/rollback and error out on commit; -- otherwise no error COMMIT; INSERT INTO schedule VALUES (1, 1, 0, 0); COMMIT; You can also try and rollback the first transaction etc. Again, what really helps is: ALTER TABLE schedule ADD CONSTRAINT uniq_schedule UNIQUE (studentid, groupid); Best Regards, Michael Paesold