Skip to content

Commit

Permalink
MDEV-21645 SIGSEGV in innobase_get_computed_value
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dr-m committed Feb 4, 2020
1 parent 4638666 commit a56f782
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
9 changes: 9 additions & 0 deletions mysql-test/suite/innodb/r/instant_alter_bugs.result
Original file line number Diff line number Diff line change
Expand Up @@ -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;
10 changes: 10 additions & 0 deletions mysql-test/suite/innodb/t/instant_alter_bugs.test
Original file line number Diff line number Diff line change
Expand Up @@ -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;
5 changes: 4 additions & 1 deletion storage/innobase/handler/handler0alter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit a56f782

Please sign in to comment.