August 1st, 1999, 04:54 PM
I am using a perl script in conjunction with an apache web server to pass queries to a mysql database from html forms.
Can anyone explain to me when (if at all) I need to use table locking ? I assume that I will need to use locking of some description when tables are being updated, to prevent the situation when several users are simultaneously trying to add rows to tables.
Also, is there any danger of tables being locked by a script and remaining locked because of some error-type scenario ocurring ?
I am pretty unclear on the whole area of table locking and would appreciate any guidance which anyone could provide.
September 7th, 1999, 12:24 AM
Sure would be nice if somebody replied to this post. I've read a little on table locking, but wouldn't mind hearing from somebody here whose had some experience.
September 13th, 1999, 01:55 PM
The O'Reilly book MySQL/mSQL explains this pretty well. MySQL is mutithreaded, only one thread can write to a table at a time, all other users (threads) are blocked until the first user is done. Now there is a problem if you need to update two or more tables at the same time. You can use the LOCK() function. MySQL will throw an error if you attempt to access an unlocked table while you have other tables locked, so you should lock those you need, use them, then unlock quickly.