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;