MySQL Forums
Forum List  »  InnoDB

Re: Minimal example of using select… for update to isolate rows
Posted by: Rick James
Date: October 07, 2012 04:32PM

Use 2 transactions, not one:
BEGIN;
$id = SELECT id ... FOR UPDATE;
UPDATE x='dirty' ... WHERE id = $id;
COMMIT; -- Release fast!!
Then...
BEGIN;
do your work with $id -- this can take a long time
UPDATE x='free' ... WHERE id = $id;
COMMIT;

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: Minimal example of using select… for update to isolate rows
869
October 07, 2012 04:32PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.