Skip to content

Commit 0df51e6

Browse files
committed
MDEV-25651 Server crash or assertion failure in THD::update_stats upon concurrent DROP TRIGGER
The problem was that in a timeout event, thd->lex->restore_backup_query_tables_list() was called when it should not have been. Patch tested with the script in MDEV-25651 (not suitable for mtr)
1 parent 621501f commit 0df51e6

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

sql/sql_trigger.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,7 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create)
396396
bool result= TRUE;
397397
String stmt_query;
398398
bool lock_upgrade_done= FALSE;
399+
bool backup_of_table_list_done= 0;;
399400
MDL_ticket *mdl_ticket= NULL;
400401
MDL_request mdl_request_for_trn;
401402
Query_tables_list backup;
@@ -465,6 +466,7 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create)
465466
Protect the query table list from the temporary and potentially
466467
destructive changes necessary to open the trigger's table.
467468
*/
469+
backup_of_table_list_done= 1;
468470
thd->lex->reset_n_backup_query_tables_list(&backup);
469471
/*
470472
Restore Query_tables_list::sql_command, which was
@@ -634,7 +636,7 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create)
634636
mdl_ticket->downgrade_lock(MDL_SHARED_NO_READ_WRITE);
635637

636638
/* Restore the query table list. Used only for drop trigger. */
637-
if (!create)
639+
if (backup_of_table_list_done)
638640
thd->lex->restore_backup_query_tables_list(&backup);
639641

640642
if (!result)

0 commit comments

Comments
 (0)