Bug #17092 allowing TRUNCATE TABLE while LOCKing done.
Submitted: 3 Feb 2006 7:34 Modified: 17 Dec 2010 13:17
Reporter: vijay patel Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: DDL Severity:S4 (Feature request)
Version: OS:Any
Assigned to: CPU Architecture:Any

[3 Feb 2006 7:34] vijay patel
Description:
I required to use same type of usage described in "7.3.1. Locking Methods" --

LOCK TABLES real_table WRITE, tmp_insert WRITE;
INSERT INTO tmp_insert VALUES (.....);
SELECT COUNT(DISTINCT(col1)) AS cnt_tmp_insert FROM tmp_insert;
....c code here....
if (cnt_tmp_insert > 1,000,000,000) {
INSERT INTO real_table SELECT * FROM tmp_insert;
TRUNCATE TABLE tmp_insert;
}
UNLOCK TABLES;

In future version, I request to facilitate use TRUNCATE TABLE query while LOCK TABLES is done on same table.

How to repeat:
LOCK TABLES real_table WRITE, tmp_insert WRITE;
INSERT INTO tmp_insert VALUES (.....);
SELECT COUNT(DISTINCT(col1)) AS cnt_tmp_insert FROM tmp_insert;
....c code here....
if (cnt_tmp_insert > 1,000,000,000) {
INSERT INTO real_table SELECT * FROM tmp_insert;
TRUNCATE TABLE tmp_insert;
}
UNLOCK TABLES;