Skip navigation links

MySQL Forums :: Transactions :: mysql innodb transaction concurrency


Advanced Search

Re: mysql innodb transaction concurrency
Posted by: venu gopal ()
Date: August 11, 2011 12:28AM

Hi Peter,

Sorry to bother you. I am confused :(

I have read this page.
http://dev.mysql.com/doc/refman/5.5/en/innodb-locking-reads.html
summary: "If you query data and then insert or update related data within the same transaction, the regular SELECT statement does not give enough protection. Other transactions can update or delete the same rows you just queried."

Does it mean below code wont work?
$user_purchased = SELECT count(*) FROM purchases where user_id = 1; (This might return many records)
if (condition) {
UPDATE table SET column = "value" WHERE (...)
... other logic (including INSERT some data) ...
}

so I have to use
$user_purchased = SELECT count(*) FROM purchases where user_id = 1 for update; (This might return many records)
if (condition) {
UPDATE table SET column = "value" WHERE (...)
... other logic (including INSERT some data) ...
}

But still, I have a doubt, will it stop allowing users to insert the records? or just locks whatever I just queried in select ...for update. If so, Please could shed some light on this?

Could you please clarify this? I struck in the middle. Don't know which to follow.

Thanks for your valuable time.



Edited 2 time(s). Last edit at 08/11/2011 12:38AM by venu gopal.

Options: ReplyQuote


Subject Views Written By Posted
mysql innodb transaction concurrency 3456 venu gopal 08/02/2011 09:08AM
Re: mysql innodb transaction concurrency 752 venu gopal 08/02/2011 09:39AM
Re: mysql innodb transaction concurrency 705 venu gopal 08/03/2011 09:56AM
Re: mysql innodb transaction concurrency 772 Peter Brawley 08/03/2011 10:05AM
Re: mysql innodb transaction concurrency 799 venu gopal 08/03/2011 10:13AM
Re: mysql innodb transaction concurrency 709 venu gopal 08/04/2011 10:24AM
Re: mysql innodb transaction concurrency 681 Peter Brawley 08/04/2011 11:40AM
Re: mysql innodb transaction concurrency 758 venu gopal 08/04/2011 11:36PM
Re: mysql innodb transaction concurrency 672 venu gopal 08/06/2011 07:33AM
Re: mysql innodb transaction concurrency 688 Peter Brawley 08/06/2011 12:57PM
Re: mysql innodb transaction concurrency 803 venu gopal 08/09/2011 08:04AM
Re: mysql innodb transaction concurrency 716 Peter Brawley 08/10/2011 08:44PM
Re: mysql innodb transaction concurrency 647 venu gopal 08/11/2011 12:28AM
Re: mysql innodb transaction concurrency 1111 Rick James 08/13/2011 01:45PM
Re: mysql innodb transaction concurrency 1076 venu gopal 08/14/2011 04:47AM
Re: mysql innodb transaction concurrency 886 Peter Brawley 08/14/2011 08:50AM
Re: mysql innodb transaction concurrency 659 venu gopal 08/14/2011 08:57AM
Re: mysql innodb transaction concurrency 964 Rick James 08/14/2011 11:59AM
Re: mysql innodb transaction concurrency 880 venu gopal 08/14/2011 11:46PM
Re: mysql innodb transaction concurrency 638 venu gopal 08/19/2011 11:03AM
Re: mysql innodb transaction concurrency 656 Rick James 08/20/2011 08:52AM
Re: mysql innodb transaction concurrency 606 venu gopal 08/20/2011 09:00AM
Re: mysql innodb transaction concurrency 711 Rick James 08/21/2011 08:38AM
Re: mysql innodb transaction concurrency 642 venu gopal 08/22/2011 12:29AM
Re: mysql innodb transaction concurrency 691 Rick James 08/22/2011 07:38PM
Re: mysql innodb transaction concurrency 648 Peter Brawley 08/14/2011 01:39PM
Re: mysql innodb transaction concurrency 810 venu gopal 08/15/2011 12:07AM


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.