pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jean-Luc Lachance <jllachan@sympatico.ca>
To: Michael Paesold <mpaesold@gmx.at>
Cc: Tsirkin Evgeny <tsurkin@mail.jct.ac.il>
Cc: pgsql-admin@postgresql.org
Subject: Re: duplicates
Date: Mon, 06 Sep 2004 10:36:21 -0400
Message-ID: <413C75E5.7090406@sympatico.ca> (raw)
In-Reply-To: <00ea01c4940d$59f54b30$ad01a8c0@zaphod>
References: <Pine.LNX.4.58.0409060922390.20253@p-roman.jct.ac.il>
	<008601c493e5$e0965940$0b00a8c0@forge>
	<Pine.LNX.4.58.0409061050190.20694@p-roman.jct.ac.il>
	<00c701c493eb$def5b9e0$0b00a8c0@forge>
	<Pine.LNX.4.58.0409061211580.20694@p-roman.jct.ac.il>
	<009501c493f6$52932770$ad01a8c0@zaphod>
	<Pine.LNX.4.58.0409061252510.20694@p-roman.jct.ac.il>
	<00a701c493fd$dd44d060$ad01a8c0@zaphod>
	<Pine.LNX.4.58.0409061509300.23452@p-roman.jct.ac.il>
	<00ea01c4940d$59f54b30$ad01a8c0@zaphod>

If the reccord you are inserting do not depend on data in the record you 
want to delete, why not simply use a trigger?

Before insert delete the record with the same key!



Michael Paesold wrote:

> 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
> 
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
>       subscribe-nomail command to majordomo@postgresql.org so that your
>       message can get through to the mailing list cleanly
> 



view thread (14+ messages)

Message-ID: <413C75E5.7090406@sympatico.ca>
Permalink:  ../413C75E5.7090406@sympatico.ca/
Also on:    postgresql.org/message-id/413C75E5.7090406@sympatico.ca

 · 

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-admin@postgresql.org
  Cc: jllachan@sympatico.ca, mpaesold@gmx.at, tsurkin@mail.jct.ac.il
  Subject: Re: duplicates
  In-Reply-To: <413C75E5.7090406@sympatico.ca>
  References: <Pine.LNX.4.58.0409060922390.20253@p-roman.jct.ac.il> <008601c493e5$e0965940$0b00a8c0@forge> <Pine.LNX.4.58.0409061050190.20694@p-roman.jct.ac.il> <00c701c493eb$def5b9e0$0b00a8c0@forge> <Pine.LNX.4.58.0409061211580.20694@p-roman.jct.ac.il> <009501c493f6$52932770$ad01a8c0@zaphod> <Pine.LNX.4.58.0409061252510.20694@p-roman.jct.ac.il> <00a701c493fd$dd44d060$ad01a8c0@zaphod> <Pine.LNX.4.58.0409061509300.23452@p-roman.jct.ac.il> <00ea01c4940d$59f54b30$ad01a8c0@zaphod> <413C75E5.7090406@sympatico.ca>

* 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