diff --git a/mysql-test/suite/parts/inc/part_alter_values.inc b/mysql-test/suite/parts/inc/part_alter_values.inc index 1b0605ff57b..ac69169a9ca 100644 --- a/mysql-test/suite/parts/inc/part_alter_values.inc +++ b/mysql-test/suite/parts/inc/part_alter_values.inc @@ -39,7 +39,7 @@ DROP TABLE t1; # # MDEV-15456 Server crashes upon adding or dropping a partition in ALTER under LOCK TABLE after ER_SAME_NAME_PARTITION # -create table t1 (i int) partition by range(i) (partition p0 values less than (10)); +--eval create table t1 (i int) engine=$engine partition by range(i) (partition p0 values less than (10)) lock table t1 write; --error ER_SAME_NAME_PARTITION alter table t1 add partition (partition p0 values less than (20)); diff --git a/mysql-test/suite/parts/r/partition_alter_innodb.result b/mysql-test/suite/parts/r/partition_alter_innodb.result index 08f0c321119..87c113a2720 100644 --- a/mysql-test/suite/parts/r/partition_alter_innodb.result +++ b/mysql-test/suite/parts/r/partition_alter_innodb.result @@ -47,7 +47,7 @@ PARTITION p3 VALUES IN (4,5,6) ); ERROR HY000: Syntax error: LIST PARTITIONING requires definition of VALUES IN for each partition DROP TABLE t1; -create table t1 (i int) partition by range(i) (partition p0 values less than (10)); +create table t1 (i int) engine=InnoDB partition by range(i) (partition p0 values less than (10)); lock table t1 write; alter table t1 add partition (partition p0 values less than (20)); ERROR HY000: Duplicate partition name p0 diff --git a/mysql-test/suite/parts/r/partition_alter_maria.result b/mysql-test/suite/parts/r/partition_alter_maria.result index 5e53dc99db8..5f1f882d2ea 100644 --- a/mysql-test/suite/parts/r/partition_alter_maria.result +++ b/mysql-test/suite/parts/r/partition_alter_maria.result @@ -69,7 +69,7 @@ PARTITION p3 VALUES IN (4,5,6) ); ERROR HY000: Syntax error: LIST PARTITIONING requires definition of VALUES IN for each partition DROP TABLE t1; -create table t1 (i int) partition by range(i) (partition p0 values less than (10)); +create table t1 (i int) engine=Aria partition by range(i) (partition p0 values less than (10)); lock table t1 write; alter table t1 add partition (partition p0 values less than (20)); ERROR HY000: Duplicate partition name p0 diff --git a/mysql-test/suite/parts/r/partition_alter_myisam.result b/mysql-test/suite/parts/r/partition_alter_myisam.result index 0d3094418ff..248c8627b2f 100644 --- a/mysql-test/suite/parts/r/partition_alter_myisam.result +++ b/mysql-test/suite/parts/r/partition_alter_myisam.result @@ -42,7 +42,7 @@ PARTITION p3 VALUES IN (4,5,6) ); ERROR HY000: Syntax error: LIST PARTITIONING requires definition of VALUES IN for each partition DROP TABLE t1; -create table t1 (i int) partition by range(i) (partition p0 values less than (10)); +create table t1 (i int) engine=MyISAM partition by range(i) (partition p0 values less than (10)); lock table t1 write; alter table t1 add partition (partition p0 values less than (20)); ERROR HY000: Duplicate partition name p0 diff --git a/sql/sql_base.cc b/sql/sql_base.cc index f7de4e4f3c2..554c8cffeaf 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -952,10 +952,7 @@ void close_thread_tables(THD *thd) we will exit this function a few lines below. */ if (! thd->lex->requires_prelocking()) - { - thd->locked_tables_list.reopen_tables(thd, true); DBUG_VOID_RETURN; - } /* We are in the top-level statement of a prelocked statement, diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index fa95c852f53..4c0be4ebc8b 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -5136,6 +5136,10 @@ finish: lex->unit.cleanup(); + /* close/reopen tables that were marked to need reopen under LOCK TABLES */ + if (! thd->lex->requires_prelocking()) + thd->locked_tables_list.reopen_tables(thd, true); + if (! thd->in_sub_stmt) { if (thd->killed != NOT_KILLED)