Skip to content

Commit

Permalink
Fix for crash in Aria LOCK TABLES + CREATE TRIGGER
Browse files Browse the repository at this point in the history
MDEV-22829 SIGSEGV in _ma_reset_history on LOCK
  • Loading branch information
montywi committed Jun 14, 2020
1 parent ab7eedc commit 56045ef
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
11 changes: 11 additions & 0 deletions mysql-test/suite/maria/lock.result
Original file line number Diff line number Diff line change
Expand Up @@ -166,3 +166,14 @@ test.t1 optimize status Table is already up to date
disconnect con1;
connection default;
DROP TABLE t1, t2;
#
# MDEV-22829 SIGSEGV in _ma_reset_history on LOCK
#
CREATE TABLE t1 (f1 INT) ENGINE=Aria;
CREATE TABLE t2 (f2 INT) ENGINE=Aria;
LOCK TABLES t2 WRITE, t1 WRITE;
INSERT INTO t1 VALUES (1);
CREATE TRIGGER ai AFTER INSERT ON t1 FOR EACH ROW UPDATE t1 SET v=1 WHERE b=new.a;
ERROR 42S22: Unknown column 'a' in 'NEW'
UNLOCK TABLES;
DROP TABLE t1, t2;
13 changes: 13 additions & 0 deletions mysql-test/suite/maria/lock.test
Original file line number Diff line number Diff line change
Expand Up @@ -185,3 +185,16 @@ OPTIMIZE TABLE t1;
--disconnect con1
--connection default
DROP TABLE t1, t2;

--echo #
--echo # MDEV-22829 SIGSEGV in _ma_reset_history on LOCK
--echo #

CREATE TABLE t1 (f1 INT) ENGINE=Aria;
CREATE TABLE t2 (f2 INT) ENGINE=Aria;
LOCK TABLES t2 WRITE, t1 WRITE;
INSERT INTO t1 VALUES (1);
--error ER_BAD_FIELD_ERROR
CREATE TRIGGER ai AFTER INSERT ON t1 FOR EACH ROW UPDATE t1 SET v=1 WHERE b=new.a;
UNLOCK TABLES;
DROP TABLE t1, t2;
6 changes: 5 additions & 1 deletion sql/sql_trigger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,11 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create)
/* Later on we will need it to downgrade the lock */
mdl_ticket= table->mdl_ticket;

if (wait_while_table_is_used(thd, table, HA_EXTRA_FORCE_REOPEN))
/*
RENAME ensures that table is flushed properly and locked tables will
be removed from the active transaction
*/
if (wait_while_table_is_used(thd, table, HA_EXTRA_PREPARE_FOR_RENAME))
goto end;

lock_upgrade_done= TRUE;
Expand Down

0 comments on commit 56045ef

Please sign in to comment.