Re: duplicates - Mailing list pgsql-admin

From Michael Paesold
Subject Re: duplicates
Date
Msg-id 00ea01c4940d$59f54b30$ad01a8c0@zaphod
Whole thread Raw
In response to duplicates  (Tsirkin Evgeny <tsurkin@mail.jct.ac.il>)
Responses Unable to connect to a specific database  ("Sally Sally" <dedeb17@hotmail.com>)
List pgsql-admin
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



pgsql-admin by date:

Previous
From: Tom Lane
Date:
Subject: Re: Help: my table is corrupt!
Next
From: "Thomas F.O'Connell"
Date:
Subject: Re: Table Partitioning