Bug #16018 Error if locked table used more than once in the union statement.
Submitted: 27 Dec 2005 15:18 Modified: 30 Dec 2005 11:28
Reporter: Sergey Gondrya Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.0.19-BK, 4.1.17-BK OS:Linux (Linux, Windows)
Assigned to: CPU Architecture:Any

[27 Dec 2005 15:18] Sergey Gondrya
Description:
Mysql reports about error if locked table used more than once in the union statement.

This problem was not found in mysql 4.0.

How to repeat:
mysql> CREATE TABLE t1 (id INT);
Query OK, 0 rows affected (0.00 sec)

mysql> LOCK TABLES t1 READ;
Query OK, 0 rows affected (0.00 sec)

mysql> SELECT * FROM t1 UNION SELECT * FROM t1;
ERROR 1100 (HY000): Table 't1' was not locked with LOCK TABLES

Suggested fix:
I do not think that it is a documentation problem, but if it is so please describe this in MySQL manual. This error breaks backward compatibility.
[27 Dec 2005 15:41] Valeriy Kravchuk
Thank you for a bug report. Verified just as described on 4.1.17-BK (ChangeSet@1.2466, 2005-12-23 12:38:22+01:00) and 5.0.19-BK (ChangeSet@1.2003, 2005-12-24 14:32:50+01:00) on Linux:

mysql> CREATE TABLE t1 (id INT);
Query OK, 0 rows affected (0.00 sec)

mysql> LOCK TABLES t1 READ;
Query OK, 0 rows affected (0.00 sec)

mysql> SELECT * FROM t1 UNION SELECT * FROM t1;
ERROR 1100 (HY000): Table 't1' was not locked with LOCK TABLES
mysql> select version();
+-----------+
| version() |
+-----------+
| 5.0.19    |
+-----------+
1 row in set (0.00 sec)

mysql> SELECT * FROM t1;
Empty set (0.00 sec)
[30 Dec 2005 11:28] Sergei Golubchik
Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same. Because of this, we hope you add your comments
to the original bug instead.

Thank you for your interest in MySQL.

Additional info:

a duplicate of bug#6588