From 324e5f02a98be3f3acaf8fd6ee7f55d8d439afd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 1 Feb 2021 18:43:07 +0200 Subject: [PATCH] MDEV-24754 Crash in ha_partition_inplace_ctx::~ha_partition_inplace_ctx() ha_innobase::commit_inplace_alter_table(): Fix a regression that was introduced in 6d1f1b61b59310027698a92ccf533a3093f1ce04 (MDEV-24564). --- mysql-test/suite/innodb/r/alter_partitioned.result | 8 ++++++++ mysql-test/suite/innodb/t/alter_partitioned.test | 9 +++++++++ storage/innobase/handler/handler0alter.cc | 2 +- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/mysql-test/suite/innodb/r/alter_partitioned.result b/mysql-test/suite/innodb/r/alter_partitioned.result index 1e7ac1dadae..cbdfab36499 100644 --- a/mysql-test/suite/innodb/r/alter_partitioned.result +++ b/mysql-test/suite/innodb/r/alter_partitioned.result @@ -8,3 +8,11 @@ PARTITION BY RANGE(a) PARTITION pb VALUES LESS THAN (4)); ERROR HY000: Partitioned tables do not support FOREIGN KEY DROP TABLE t1; +# +# MDEV-24754 Server crash in +# ha_partition_inplace_ctx::~ha_partition_inplace_ctx +# +CREATE TABLE t1 (id INT PRIMARY KEY, a INT, va INT AS (a) VIRTUAL) +ENGINE=InnoDB PARTITION BY HASH(id) PARTITIONS 2; +ALTER TABLE t1 ADD b INT, ALGORITHM=INSTANT; +DROP TABLE t1; diff --git a/mysql-test/suite/innodb/t/alter_partitioned.test b/mysql-test/suite/innodb/t/alter_partitioned.test index 19b712c2657..e443f92bc8c 100644 --- a/mysql-test/suite/innodb/t/alter_partitioned.test +++ b/mysql-test/suite/innodb/t/alter_partitioned.test @@ -13,3 +13,12 @@ PARTITION BY RANGE(a) PARTITION pb VALUES LESS THAN (4)); DROP TABLE t1; + +--echo # +--echo # MDEV-24754 Server crash in +--echo # ha_partition_inplace_ctx::~ha_partition_inplace_ctx +--echo # +CREATE TABLE t1 (id INT PRIMARY KEY, a INT, va INT AS (a) VIRTUAL) +ENGINE=InnoDB PARTITION BY HASH(id) PARTITIONS 2; +ALTER TABLE t1 ADD b INT, ALGORITHM=INSTANT; +DROP TABLE t1; diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc index 4248442f3da..54a20a95a31 100644 --- a/storage/innobase/handler/handler0alter.cc +++ b/storage/innobase/handler/handler0alter.cc @@ -11271,7 +11271,7 @@ foreign_fail: auto ctx= static_cast(*pctx); ctx->prebuilt->table = innobase_reload_table( m_user_thd, ctx->prebuilt->table, - table->s->table_name, *ctx0); + table->s->table_name, *ctx); innobase_copy_frm_flags_from_table_share( ctx->prebuilt->table, altered_table->s); }