Yes, the two examples are equivalent.

"UNLOCK TABLES releases any locks held by the current thread. All tables
that are locked by the current thread are implicitly unlocked when the
thread issues another LOCK TABLES..."

So there is a hole there with either example. In order to keep others from
changing your data under you, you'll need a single (WRITE) lock around your
entire operations.

Sad, but true.

Regards,

Jerry Schwartz
Global Information Incorporated
195 Farmington Ave.
Farmington, CT 06032

860.674.8796 / FAX: 860.674.8341


> -----Original Message-----
> From: Denis Solovyov [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, January 10, 2007 2:29 PM
> To: mysql@lists.mysql.com
> Subject: Help me to understand multiple locking the same
> tables (lock; lock; unlock)
>
> Dear friends,
>
> Please  help  me  to  understand several LOCKing the same
> tables without
> unlocking them between "LOCKs". Imagine the following code:
>
> LOCK TABLES t1 READ, t2 READ;
> -- some hard select queries which need that other threads do
> not update tables
> LOCK TABLES t1 WRITE, t2 WRITE;
> -- some easy update queries
> UNLOCK TABLES;
>
> Is this code equal to the following:
>
> LOCK TABLES t1 READ, t2 READ;
> -- some hard select queries which need that other threads do
> not update tables
> UNLOCK TABLES;
> -- here other threads have a moment to update these tables!
> LOCK TABLES t1 WRITE, t2 WRITE;
> -- some easy update queries
> UNLOCK TABLES;
>
> or  t1  and  t2 will not be unlocked even for a moment before
> the second
> lock?
>
> Really,  I  don't  want  to  have  a  single  WRITE LOCK here
> and freeze
> everything for some time, but I can't understand if here is a
> chance for
> other threads to update tables between two lockings or not...
>
> MySQL 4.1, myisam tables (if it is important).
>
> Best regards,
> Denis Solovyov
>
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:
> http://lists.mysql.com/[EMAIL PROTECTED]
>
>




-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to