Commit a56f7824 authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-21645 SIGSEGV in innobase_get_computed_value

ha_innobase::commit_inplace_alter_table(): After
ALTER_STORED_COLUMN_ORDER, ensure that the virtual column metadata
will be reloaded also when the table is not being rebuilt.
parent 46386661
......@@ -358,4 +358,13 @@ t1 CREATE TABLE `t1` (
`a` char(1) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin2 ROW_FORMAT=REDUNDANT
DROP TABLE t1;
#
# MDEV-21645 SIGSEGV in innobase_get_computed_value
#
CREATE TABLE t1 (a INT PRIMARY KEY, b INT, va INTEGER GENERATED ALWAYS AS (a))
ENGINE=InnoDB;
INSERT INTO t1 SET a=1, b=NULL;
ALTER TABLE t1 MODIFY COLUMN b INT FIRST;
ALTER TABLE t1 ADD UNIQUE INDEX (va);
DROP TABLE t1;
SET GLOBAL innodb_purge_rseg_truncate_frequency=@save_frequency;
......@@ -374,4 +374,14 @@ ALTER TABLE t1 MODIFY a CHAR, ALGORITHM=INSTANT;
SHOW CREATE TABLE t1;
DROP TABLE t1;
--echo #
--echo # MDEV-21645 SIGSEGV in innobase_get_computed_value
--echo #
CREATE TABLE t1 (a INT PRIMARY KEY, b INT, va INTEGER GENERATED ALWAYS AS (a))
ENGINE=InnoDB;
INSERT INTO t1 SET a=1, b=NULL;
ALTER TABLE t1 MODIFY COLUMN b INT FIRST;
ALTER TABLE t1 ADD UNIQUE INDEX (va);
DROP TABLE t1;
SET GLOBAL innodb_purge_rseg_truncate_frequency=@save_frequency;
......@@ -11172,7 +11172,10 @@ ha_innobase::commit_inplace_alter_table(
/* MDEV-17468: Avoid this at least when ctx->is_instant().
Currently dict_load_column_low() is the only place where
num_base for virtual columns is assigned to nonzero. */
if (ctx0->num_to_drop_vcol || ctx0->num_to_add_vcol) {
if (ctx0->num_to_drop_vcol || ctx0->num_to_add_vcol
|| (ctx0->is_instant()
&& m_prebuilt->table->n_v_cols
&& ha_alter_info->handler_flags & ALTER_STORED_COLUMN_ORDER)) {
DBUG_ASSERT(ctx0->old_table->get_ref_count() == 1);
trx_commit_for_mysql(m_prebuilt->trx);
......
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