1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-01 03:47:19 +03:00

MDEV-10216: Assertion `strcmp(share->unique_file_name,filename) ||

.. share->last_version' failed in myisam/mi_open.c:67: test_if_reopen

During the RENAME operation since the renamed temporary table is also
opened and added to myisam_open_list/maria_open_list, resetting the
last_version at the end of operation (HA_EXTRA_PREPARE_FOR_RENAME)
will cause an assertion failure when a subsequent query tries to open
an additional temporary table instance and thus attempts to reuse it
from the open table list.

This commit fixes the issue by skipping flush/close operations executed
toward the end of ALTER for temporary tables. It also enables a shortcut
for simple ALTERs (like rename, disable/enable keys) on temporary
tables.

As safety checks, added some assertions at code points that should not
be hit for temporary tables.
This commit is contained in:
Nirbhay Choubey
2016-08-08 17:26:06 -04:00
parent 45ffbda79e
commit df9b4554b7
11 changed files with 330 additions and 14 deletions

View File

@ -490,5 +490,50 @@ SELECT * FROM temp_t1;
i
1
DROP TABLE temp_t1, t1;
#
# ALTER TABLE RENAME & ENABLE/DISABLE KEYS (shortcuts)
#
CREATE TEMPORARY TABLE t1(i INT PRIMARY KEY) ENGINE=MYISAM;
INSERT INTO t1 VALUES(1);
SELECT COUNT(*)=1 FROM t1;
COUNT(*)=1
1
ALTER TABLE t1 RENAME t2;
SELECT COUNT(*)=1 FROM t2;
COUNT(*)=1
1
ALTER TABLE t2 RENAME t1;
ALTER TABLE t1 DISABLE KEYS;
ALTER TABLE t1 ENABLE KEYS;
LOCK TABLES t1 WRITE;
ALTER TABLE t1 RENAME t2;
SELECT COUNT(*)=1 FROM t2;
COUNT(*)=1
1
ALTER TABLE t2 RENAME t1;
ALTER TABLE t1 DISABLE KEYS;
ALTER TABLE t1 ENABLE KEYS;
UNLOCK TABLES;
LOCK TABLES t1 READ;
ALTER TABLE t1 RENAME t2;
SELECT COUNT(*)=1 FROM t2;
COUNT(*)=1
1
ALTER TABLE t2 RENAME t1;
ALTER TABLE t1 DISABLE KEYS;
ALTER TABLE t1 ENABLE KEYS;
UNLOCK TABLES;
FLUSH TABLES WITH READ LOCK;
ALTER TABLE t1 RENAME t2;
SELECT COUNT(*)=1 FROM t2;
COUNT(*)=1
1
ALTER TABLE t2 RENAME t1;
ALTER TABLE t1 DISABLE KEYS;
ALTER TABLE t1 ENABLE KEYS;
UNLOCK TABLES;
ALTER TABLE t1 RENAME t2, LOCK SHARED;
ALTER TABLE t2 RENAME t1, LOCK EXCLUSIVE;
DROP TABLE t1;
# Cleanup
DROP DATABASE temp_db;