Browse Source

Fix for crash in Aria LOCK TABLES + CREATE TRIGGER

MDEV-22829 SIGSEGV in _ma_reset_history on LOCK
bb-10.5-MDEV-22726-aria-non-trans-log
Monty 5 years ago
parent
commit
56045ef94a
  1. 11
      mysql-test/suite/maria/lock.result
  2. 13
      mysql-test/suite/maria/lock.test
  3. 6
      sql/sql_trigger.cc

11
mysql-test/suite/maria/lock.result

@ -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
mysql-test/suite/maria/lock.test

@ -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
sql/sql_trigger.cc

@ -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;

Loading…
Cancel
Save