pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Stephan Szabo <sszabo@megazone.bigpanda.com>
To: Michael Glaesemann <grzm@seespotcode.net>
Cc: Weber, Johann (ISS Kassel) <jweber@iss.net>
Cc: pgsql-sql@postgresql.org
Subject: Re: Atomar SQL Statement
Date: Fri, 7 Jul 2006 11:07:10 -0700 (PDT)
Message-ID: <20060707105847.J77811@megazone.bigpanda.com> (raw)
In-Reply-To: <279E27B5-183F-4520-BC43-A726A50646EF@seespotcode.net>
References: <B8ADDBDA8696F546BDAC69B469D7F0512E06F3@kasmaiexcp01.iss.net>
	<279E27B5-183F-4520-BC43-A726A50646EF@seespotcode.net>


On Fri, 7 Jul 2006, Michael Glaesemann wrote:

>
> On Jul 7, 2006, at 7:55 , Weber, Johann (ISS Kassel) wrote:
>
> > My concern: in a multi threaded environment, can a second thread
> > interrupt this statement and eventually insert the same email
> > address in
> > the table with a different id? Or is this statement atomar?
>
> You're safe. Take a look at the FAQ entries on SERIAL:
>
> http://www.postgresql.org/docs/faqs.FAQ.html#item4.11.2

I don't think he is, because I don't think the issue is the SERIAL
behavior, but instead the NOT EXISTS behavior.  Won't the NOT EXISTS in
read committed potentially be true for both concurrent sessions if the
second happens before the first commits, which then would mean that both
sessions will go on to attempt the insert (with their own respective ids
from the serial)? Without a unique constraint on email I think he can end
up with the same email address with two different ids.





view thread (6+ messages)  latest in thread

Message-ID: <20060707105847.J77811@megazone.bigpanda.com>
Permalink:  ../20060707105847.J77811@megazone.bigpanda.com/
Also on:    postgresql.org/message-id/20060707105847.J77811@megazone.bigpanda.com

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: sszabo@megazone.bigpanda.com, grzm@seespotcode.net, jweber@iss.net
  Subject: Re: Atomar SQL Statement
  In-Reply-To: <20060707105847.J77811@megazone.bigpanda.com>

* 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