Skip to content

Commit 723488b

Browse files
committed
MDEV-10424 - Assertion `ticket == __null' failed in MDL_request::set_type
Reexecution of prepared "ANALYZE TABLE merge_table, table" may miss to reinitialize "table" for subsequent execution and trigger assertion failure. This happens because MERGE engine may adjust table->next_global chain, which gets cleared by close_thread_tables()/ha_myisammrg::detach_children() later. Since reinitilization iterates next_global chain, it won't see tables following merge table. Fixed by appending saved next_global chain after merge children.
1 parent 09cb646 commit 723488b

File tree

3 files changed

+43
-1
lines changed

3 files changed

+43
-1
lines changed

mysql-test/r/merge.result

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3832,4 +3832,21 @@ test.m1 repair error Corrupt
38323832
# Clean-up.
38333833
drop tables m1, t1, t4;
38343834
drop view t3;
3835+
#
3836+
# MDEV-10424 - Assertion `ticket == __null' failed in
3837+
# MDL_request::set_type
3838+
#
3839+
CREATE TABLE t1 (f1 INT) ENGINE=MyISAM;
3840+
CREATE TABLE tmerge (f1 INT) ENGINE=MERGE UNION=(t1);
3841+
PREPARE stmt FROM "ANALYZE TABLE tmerge, t1";
3842+
EXECUTE stmt;
3843+
Table Op Msg_type Msg_text
3844+
test.tmerge analyze note The storage engine for the table doesn't support analyze
3845+
test.t1 analyze status Table is already up to date
3846+
EXECUTE stmt;
3847+
Table Op Msg_type Msg_text
3848+
test.tmerge analyze note The storage engine for the table doesn't support analyze
3849+
test.t1 analyze status Table is already up to date
3850+
DEALLOCATE PREPARE stmt;
3851+
DROP TABLE t1, tmerge;
38353852
End of 5.5 tests

mysql-test/t/merge.test

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2880,6 +2880,19 @@ drop tables m1, t1, t4;
28802880
drop view t3;
28812881

28822882

2883+
--echo #
2884+
--echo # MDEV-10424 - Assertion `ticket == __null' failed in
2885+
--echo # MDL_request::set_type
2886+
--echo #
2887+
CREATE TABLE t1 (f1 INT) ENGINE=MyISAM;
2888+
CREATE TABLE tmerge (f1 INT) ENGINE=MERGE UNION=(t1);
2889+
PREPARE stmt FROM "ANALYZE TABLE tmerge, t1";
2890+
EXECUTE stmt;
2891+
EXECUTE stmt;
2892+
DEALLOCATE PREPARE stmt;
2893+
DROP TABLE t1, tmerge;
2894+
2895+
28832896
--echo End of 5.5 tests
28842897

28852898
--disable_result_log

sql/sql_admin.cc

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,19 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
441441
}
442442
thd->prepare_derived_at_open= FALSE;
443443

444-
table->next_global= save_next_global;
444+
/*
445+
MERGE engine may adjust table->next_global chain, thus we have to
446+
append save_next_global after merge children.
447+
*/
448+
if (save_next_global)
449+
{
450+
TABLE_LIST *table_list_iterator= table;
451+
while (table_list_iterator->next_global)
452+
table_list_iterator= table_list_iterator->next_global;
453+
table_list_iterator->next_global= save_next_global;
454+
save_next_global->prev_global= &table_list_iterator->next_global;
455+
}
456+
445457
table->next_local= save_next_local;
446458
thd->open_options&= ~extra_open_options;
447459

0 commit comments

Comments
 (0)