I created a transaction in a stored procedure with some update statements. What will happen if the transaction is running, and one select request the value from the updating table?
A:
MySQL will return the value of the select at that specific point in time. So if the select occurs before the update you will get the before value. If the select occurs after the update you will get the after value.
By default selects are read only so you will not have locking issues.
codingguy3000
2010-09-10 17:30:36
what about update statement? Will MySQL wait for completing transaction then run the update statement?
coolkid
2010-09-10 17:33:17
Yes MySQL would wait until the transaction to release its lock before allowing the update to proceed. A transaction releases its lock after it completes.
codingguy3000
2010-09-10 17:38:50
thanks, I thought about the answer before make the question. I want to ask for sure .
coolkid
2010-09-10 18:05:51