Forum Moderators: phranque
Does MySQL do this automatically? If I understand the info on their website correctly, you only need to specifically ask for a lock if you use InnoDB or BDB type tables (whatever those are). Correct?
Thanks!
If you are using a storage engine in MySQL that doesn't support transactions, you must use LOCK TABLES if you want to ensure that no other thread comes between a SELECT and an UPDATE. The example shown here requires LOCK TABLES in order to execute safely:mysql> LOCK TABLES trans READ, customer WRITE;
mysql> SELECT SUM(value) FROM trans WHERE customer_id=some_id;
mysql> UPDATE customer SET total_value=sum_from_previous_statement
-> WHERE customer_id=some_id;
mysql> UNLOCK TABLES;]
There is some other good info on that page.