0

I did a read lock with my table 'Client', after i did an update in my table 'Client' just to see the error message. So here's what I did:

mysql> LOCK TABLES Client READ;

Query OK, 0 rows affected (0.00 sec)

mysql> UPDATE Client SET pays = 'Suisse' WHERE id = 4;

I expected the error message: ERROR 1100(HY000): Table 'Client' was locked with a READ lock and can't be updated

But i have this message: ERROR 1100 (HY000): Table 'adoption' was not locked with LOCK TABLES

'adoption' is another table in my database ! I hope you will help me, thank you

Yacine Rouizi
  • 1,360
  • 2
  • 15
  • 31
  • "A session that requires locks must acquire *all* the locks that it needs in a *single* LOCK TABLES statement. While the locks thus obtained are held, the session can access *only* the locked tables." https://dev.mysql.com/doc/refman/8.0/en/lock-tables.html#table-lock-acquisition – spencer7593 May 16 '19 at 22:18
  • Explicit locking of tables can be avoided with transactional tables (innodb) and correct SQL. This will potentially improve the concurrency of updates to these tables. If you'd like to know more ask a question and explain why you are using explicit locks. – danblack May 16 '19 at 23:32
  • https://stackoverflow.com/questions/36467298/mysql-table-my-table-was-not-locked-with-lock-tables/52009798#52009798 – spencer7593 May 17 '19 at 14:23
  • I'm taking a MySQL course and in this course we make a lock table and then an update in this table to see the error message. – Yacine Rouizi May 17 '19 at 16:24

0 Answers0