[Dbix-class] Re: DBIx-Class Digest, Vol 46, Issue 11

Justin Hunter justin.d.hunter at gmail.com
Sat Apr 11 14:39:19 GMT 2009


look at 
http://search.cpan.org/~ribasushi/DBIx-Class-0.08099_08/lib/DBIx/Class/ResultSet.pm#for 
<http://search.cpan.org/%7Eribasushi/DBIx-Class-0.08099_08/lib/DBIx/Class/ResultSet.pm#for> 
(very bottom)
> ------------------------------
>
> Message: 2
> Date: Fri, 10 Apr 2009 22:23:36 +0200
> From: Andreas Mock <andreas.mock at drumedar.de>
> Subject: Re: [Dbix-class] Insert or Update (was ANNOUNCE: 0.08099_08)
> To: "DBIx::Class user and developer list"
> 	<dbix-class at lists.scsys.co.uk>
> Message-ID: <1112748266 at web.de>
> Content-Type: text/plain; charset=iso-8859-15
>
>   
>> -----Urspru"ngliche Nachricht-----
>> Von: "Peter Corlett" <abuse at cabal.org.uk>
>> Gesendet: 09.04.09 15:39:05
>> An: "DBIx::Class user and developer list" <dbix-class at lists.scsys.co.uk>
>> Betreff: Re: [Dbix-class] ANNOUNCE: 0.08099_08 (0.08100_RC2)
>>     
>
>   
>> 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.
>>     
>
> O.k. I asked why you have to use savepoints, because I thought you can
> also use transactions.
>
>
>   
>> 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.
>>     
>
> Why do you have to do a rollback when the update is rejected because of dup key?
>
>   
>> 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.
>>     
>
> 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.
>
>
>   
>> 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?
>>     
>
> An interesting question. I would be also interested in that.
>
>
> Best regards
> Andreas
>
>
>
>
> ------------------------------
>
> _______________________________________________
> DBIx-Class mailing list
> DBIx-Class at lists.scsys.co.uk
> http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
>
>
> End of DBIx-Class Digest, Vol 46, Issue 11
> ******************************************
>   

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20090411/a4dbce00/attachment.htm


More information about the DBIx-Class mailing list