Commit 619afb15 authored by Sergei Golubchik's avatar Sergei Golubchik

MDEV-15456 Server crashes upon adding or dropping a partition in ALTER under...

MDEV-15456 Server crashes upon adding or dropping a partition in ALTER under LOCK TABLE after ER_SAME_NAME_PARTITION

followup for bcb36ee2

move reopening before trans_commit_stmt(thd);
parent 03da1253
...@@ -39,7 +39,7 @@ DROP TABLE t1; ...@@ -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 # 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; lock table t1 write;
--error ER_SAME_NAME_PARTITION --error ER_SAME_NAME_PARTITION
alter table t1 add partition (partition p0 values less than (20)); alter table t1 add partition (partition p0 values less than (20));
......
...@@ -47,7 +47,7 @@ PARTITION p3 VALUES IN (4,5,6) ...@@ -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 ERROR HY000: Syntax error: LIST PARTITIONING requires definition of VALUES IN for each partition
DROP TABLE t1; 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; lock table t1 write;
alter table t1 add partition (partition p0 values less than (20)); alter table t1 add partition (partition p0 values less than (20));
ERROR HY000: Duplicate partition name p0 ERROR HY000: Duplicate partition name p0
......
...@@ -69,7 +69,7 @@ PARTITION p3 VALUES IN (4,5,6) ...@@ -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 ERROR HY000: Syntax error: LIST PARTITIONING requires definition of VALUES IN for each partition
DROP TABLE t1; 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; lock table t1 write;
alter table t1 add partition (partition p0 values less than (20)); alter table t1 add partition (partition p0 values less than (20));
ERROR HY000: Duplicate partition name p0 ERROR HY000: Duplicate partition name p0
......
...@@ -42,7 +42,7 @@ PARTITION p3 VALUES IN (4,5,6) ...@@ -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 ERROR HY000: Syntax error: LIST PARTITIONING requires definition of VALUES IN for each partition
DROP TABLE t1; 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; lock table t1 write;
alter table t1 add partition (partition p0 values less than (20)); alter table t1 add partition (partition p0 values less than (20));
ERROR HY000: Duplicate partition name p0 ERROR HY000: Duplicate partition name p0
......
...@@ -952,10 +952,7 @@ void close_thread_tables(THD *thd) ...@@ -952,10 +952,7 @@ void close_thread_tables(THD *thd)
we will exit this function a few lines below. we will exit this function a few lines below.
*/ */
if (! thd->lex->requires_prelocking()) if (! thd->lex->requires_prelocking())
{
thd->locked_tables_list.reopen_tables(thd, true);
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
}
/* /*
We are in the top-level statement of a prelocked statement, We are in the top-level statement of a prelocked statement,
......
...@@ -5136,6 +5136,10 @@ case SQLCOM_PREPARE: ...@@ -5136,6 +5136,10 @@ case SQLCOM_PREPARE:
lex->unit.cleanup(); 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->in_sub_stmt)
{ {
if (thd->killed != NOT_KILLED) if (thd->killed != NOT_KILLED)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment