MDEV-31416 ASAN errors in dict_v_col_t::detach upon adding key to virtual column

- InnoDB throws ASAN error while adding the index on virtual column
of system versioned table. InnoDB wrongly assumes that virtual
column collation type changes, creates new column with different
character set. This leads to failure while detaching the column
from indexes.
parent 80585c9d
......@@ -134,3 +134,12 @@ t CREATE TABLE `t` (
FULLTEXT KEY `a` (`a`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_520_ci
DROP TABLE t;
#
# MDEV-31416 ASAN errors in dict_v_col_t::detach upon
# adding key to virtual column
#
CREATE TABLE t (a INT) ENGINE=InnoDB WITH SYSTEM VERSIONING;
SET SYSTEM_VERSIONING_ALTER_HISTORY= KEEP;
ALTER TABLE t ADD COLUMN v VARCHAR(128) GENERATED ALWAYS AS (CRC32('MariaDB'));
ALTER TABLE t ADD INDEX (v);
DROP TABLE t;
......@@ -144,4 +144,13 @@ ALTER TABLE t MODIFY COLUMN a VARCHAR(512);
SHOW CREATE TABLE t;
DROP TABLE t;
--echo #
--echo # MDEV-31416 ASAN errors in dict_v_col_t::detach upon
--echo # adding key to virtual column
--echo #
CREATE TABLE t (a INT) ENGINE=InnoDB WITH SYSTEM VERSIONING;
SET SYSTEM_VERSIONING_ALTER_HISTORY= KEEP;
ALTER TABLE t ADD COLUMN v VARCHAR(128) GENERATED ALWAYS AS (CRC32('MariaDB'));
ALTER TABLE t ADD INDEX (v);
DROP TABLE t;
--source include/wait_until_count_sessions.inc
......@@ -1387,7 +1387,8 @@ struct ha_innobase_inplace_ctx : public inplace_alter_handler_ctx
for (unsigned i= 0; i < index->n_fields; i++)
{
const char *field_name= index->fields[i].name();
if (!field_name || !dtype_is_string_type(index->fields[i].col->mtype))
if (!field_name || !dtype_is_string_type(index->fields[i].col->mtype) ||
index->fields[i].col->is_virtual())
continue;
for (uint j= 0; j < altered_table.s->fields; j++)
{
......
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