Bug #5719 impossible to lock VIEW
Submitted: 23 Sep 2004 13:52 Modified: 9 Aug 2007 13:26
Reporter: Oleksandr Byelkin Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Locking Severity:S3 (Non-critical)
Version:5.0 OS:Any (all)
Assigned to: Konstantin Osipov

[23 Sep 2004 13:52] Oleksandr Byelkin
Description:
impossible to use VIEW after locking it with LOCK TABLES query. 

How to repeat:
mysql> create table t1 (a int); 
Query OK, 0 rows affected (0.02 sec) 
 
mysql> create view v1 as select * from t1; 
Query OK, 0 rows affected (0.00 sec) 
 
mysql> lock tables t1 read, v1 read; 
Query OK, 0 rows affected (0.00 sec) 
 
mysql> select * from v1; 
ERROR 1100 (HY000): Table 'v1' was not locked with LOCK TABLES
[24 Sep 2004 7:10] Oleksandr Byelkin
We made workaround which allow to use views during LOCK TABLES, real fix will be 
easy to make after table/view descripror cache will be made. 
 
ChangeSet 
  1.1686 04/09/24 12:50:10 bell@sanja.is.com.ua +6 -0 
  new show create view output 
  mysqldump view support (BUG#4972) 
  workaround to allow view work after LOCK TABLES
[28 Jul 2006 8:37] Konstantin Osipov
Tomash, please fix it by emitting the following error message:
LOCK TABLE v1;
ERROR: v1 is not a base table and can not be locked with LOCK TABLES.

I'm not sure if we should ever allow LOCK TABLE statement for views: LOCK is an operation with a physical data object, VIEW does not seem to match this definition.

Trudy, PeterG: please let me know if you disagree with my decision.
[7 Mar 2007 22:19] Konstantin Osipov
Fixed in 5.1. Needs a test case. Might be broken.
[2 Aug 2007 9:58] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/32004

ChangeSet@1.2573, 2007-08-02 13:58:06+04:00, kostja@bodhi.(none) +2 -0
  Add a test case for Bug#5719 "impossible to lock VIEW".
  It has been possible to lock a view in 5.1 for some time.
[2 Aug 2007 9:59] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/32005

ChangeSet@1.2573, 2007-08-02 13:59:02+04:00, kostja@bodhi.(none) +2 -0
  Add a test case for Bug#5719 "impossible to lock VIEW".
  It has been possible to lock a view in 5.1 for some time.
[2 Aug 2007 10:00] Konstantin Osipov
Queued the test in 5.1-runtime
[9 Aug 2007 13:18] Bugs System
Pushed into 5.1.22-beta
[9 Aug 2007 13:26] Konstantin Osipov
No code change, only added the test case.