<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=us-ascii" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
look at <a
 href="http://search.cpan.org/%7Eribasushi/DBIx-Class-0.08099_08/lib/DBIx/Class/ResultSet.pm#for">http://search.cpan.org/~ribasushi/DBIx-Class-0.08099_08/lib/DBIx/Class/ResultSet.pm#for</a>
(very bottom)<br>
<blockquote cite="mid:E1LsawN-0005Dq-0b@jules.scsys.co.uk" type="cite">
  <pre wrap="">------------------------------

Message: 2
Date: Fri, 10 Apr 2009 22:23:36 +0200
From: Andreas Mock <a class="moz-txt-link-rfc2396E" href="mailto:andreas.mock@drumedar.de">&lt;andreas.mock@drumedar.de&gt;</a>
Subject: Re: [Dbix-class] Insert or Update (was ANNOUNCE: 0.08099_08)
To: "DBIx::Class user and developer list"
        <a class="moz-txt-link-rfc2396E" href="mailto:dbix-class@lists.scsys.co.uk">&lt;dbix-class@lists.scsys.co.uk&gt;</a>
Message-ID: <a class="moz-txt-link-rfc2396E" href="mailto:1112748266@web.de">&lt;1112748266@web.de&gt;</a>
Content-Type: text/plain; charset=iso-8859-15

  </pre>
  <blockquote type="cite">
    <pre wrap="">-----Urspr&uuml;ngliche Nachricht-----
Von: "Peter Corlett" <a class="moz-txt-link-rfc2396E" href="mailto:abuse@cabal.org.uk">&lt;abuse@cabal.org.uk&gt;</a>
Gesendet: 09.04.09 15:39:05
An: "DBIx::Class user and developer list" <a class="moz-txt-link-rfc2396E" href="mailto:dbix-class@lists.scsys.co.uk">&lt;dbix-class@lists.scsys.co.uk&gt;</a>
Betreff: Re: [Dbix-class] ANNOUNCE: 0.08099_08 (0.08100_RC2)
    </pre>
  </blockquote>
  <pre wrap=""><!---->
  </pre>
  <blockquote type="cite">
    <pre wrap="">The current implementation does a SELECT followed by an INSERT or UPDATE as
appropriate. This introduces a race condition. The whole thing is a critical
section and needs to be wrapped in a transaction or savepoint.
    </pre>
  </blockquote>
  <pre wrap=""><!---->
O.k. I asked why you have to use savepoints, because I thought you can
also use transactions.


  </pre>
  <blockquote type="cite">
    <pre wrap="">I implemented it by starting a savepoint, then just trying the INSERT. If
that fails (normally due to duplicate UNIQUE keys) then the savepoint is
rolled back and the SELECT and UPDATE is done as before. After the UPDATE,
the savepoint is committed.
    </pre>
  </blockquote>
  <pre wrap=""><!---->
Why do you have to do a rollback when the update is rejected because of dup key?

  </pre>
  <blockquote type="cite">
    <pre wrap="">However, I'm not quite sure this trick completely retains the semantics of
create_or_update, so it wouldn't be a drop-in replacement.
    </pre>
  </blockquote>
  <pre wrap=""><!---->
It would be interesting if you can make it really an atomic operation. I'm asking because
I'm not sure if transactions are enough.


  </pre>
  <blockquote type="cite">
    <pre wrap="">I also suspect that while savepoints may be necessary, they're not
sufficient, and one also needs SELECT FOR UPDATE. How might I express that
in DBIC?
    </pre>
  </blockquote>
  <pre wrap=""><!---->
An interesting question. I would be also interested in that.


Best regards
Andreas




------------------------------

_______________________________________________
DBIx-Class mailing list
<a class="moz-txt-link-abbreviated" href="mailto:DBIx-Class@lists.scsys.co.uk">DBIx-Class@lists.scsys.co.uk</a>
<a class="moz-txt-link-freetext" href="http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class">http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class</a>


End of DBIx-Class Digest, Vol 46, Issue 11
******************************************
  </pre>
</blockquote>
<br>
</body>
</html>