diff options
author | Monty <monty@mariadb.org> | 2020-06-08 23:51:57 +0300 |
---|---|---|
committer | Monty <monty@mariadb.org> | 2020-06-14 19:39:43 +0300 |
commit | 654b5931498b662177b31d48760e68212a3cafe9 (patch) | |
tree | 4ba4ab29df9b85eefbb7cd53b18b800c5358e1af | |
parent | 6a3b581b9051e5832d43e841b73c88df9fe90755 (diff) | |
download | mariadb-git-654b5931498b662177b31d48760e68212a3cafe9.tar.gz |
BINLOG with LOCK TABLES and SAVEPOINT could cause a crash in debug bin
MDEV-22048 Assertion `binlog_table_maps == 0 ||
locked_tables_mode == LTM_LOCK_TABLES' failed in
THD::reset_for_next_command
-rw-r--r-- | mysql-test/suite/binlog/r/binlog_mixed.result | 11 | ||||
-rw-r--r-- | mysql-test/suite/binlog/t/binlog_mixed.test | 23 | ||||
-rw-r--r-- | sql/sql_parse.cc | 1 |
3 files changed, 35 insertions, 0 deletions
diff --git a/mysql-test/suite/binlog/r/binlog_mixed.result b/mysql-test/suite/binlog/r/binlog_mixed.result new file mode 100644 index 00000000000..1f30f21a9b4 --- /dev/null +++ b/mysql-test/suite/binlog/r/binlog_mixed.result @@ -0,0 +1,11 @@ +CREATE TABLE t1 (a INT) ENGINE=InnoDB; +INSERT INTO t1 (a) VALUES (1),(2); +CREATE TABLE t2 (b INT) ENGINE=InnoDB; +CREATE TRIGGER tr1 BEFORE UPDATE ON t1 FOR EACH ROW SET @a = 0; +CREATE TRIGGER tr2 BEFORE INSERT ON t2 FOR EACH ROW DELETE FROM t1 LIMIT 1; +SET AUTOCOMMIT= OFF; +LOCK TABLES t2 WRITE; +DELETE FROM t1 LIMIT 1; +SAVEPOINT A; +UNLOCK TABLES; +DROP TABLE t1, t2; diff --git a/mysql-test/suite/binlog/t/binlog_mixed.test b/mysql-test/suite/binlog/t/binlog_mixed.test new file mode 100644 index 00000000000..fa1b2ca3a85 --- /dev/null +++ b/mysql-test/suite/binlog/t/binlog_mixed.test @@ -0,0 +1,23 @@ +--source include/have_innodb.inc +--source include/have_binlog_format_mixed_or_row.inc + +# +# MDEV-22048 Assertion `binlog_table_maps == 0 || +# locked_tables_mode == LTM_LOCK_TABLES' failed in +# THD::reset_for_next_command +# + +CREATE TABLE t1 (a INT) ENGINE=InnoDB; +INSERT INTO t1 (a) VALUES (1),(2); + +CREATE TABLE t2 (b INT) ENGINE=InnoDB; + +CREATE TRIGGER tr1 BEFORE UPDATE ON t1 FOR EACH ROW SET @a = 0; +CREATE TRIGGER tr2 BEFORE INSERT ON t2 FOR EACH ROW DELETE FROM t1 LIMIT 1; + +SET AUTOCOMMIT= OFF; +LOCK TABLES t2 WRITE; +DELETE FROM t1 LIMIT 1; +SAVEPOINT A; +UNLOCK TABLES; +DROP TABLE t1, t2; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 86f81dd001a..7a133d84f89 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -5045,6 +5045,7 @@ mysql_execute_command(THD *thd) res= 1; thd->mdl_context.release_transactional_locks(); thd->variables.option_bits&= ~(OPTION_TABLE_LOCK); + thd->reset_binlog_for_next_statement(); } if (thd->global_read_lock.is_acquired() && thd->current_backup_stage == BACKUP_FINISHED) |