MDEV-32337 Assertion `pos < table->n_def' failed in dict_table_get_nth_col

While checking for altered column in foreign key constraints,
InnoDB fails to ignore virtual columns. This issue caused
by commit 5f09b53b(MDEV-31086).
parent a2312b6f
......@@ -94,4 +94,15 @@ ALTER TABLE t2 MODIFY b VARCHAR(16), ADD KEY(b);
ERROR 42S02: Table 'test.t2' doesn't exist
DROP TABLE t2, t1;
ERROR 42S02: Unknown table 'test.t2'
#
# MDEV-32337 Assertion `pos < table->n_def' failed
# in dict_table_get_nth_col
#
CREATE TABLE t (a INT, va INT AS (a), b INT, vb INT AS (b),
c INT, vc INT AS (c), vf VARCHAR(16) AS (f),
f VARCHAR(4)) ENGINE=InnoDB;
ALTER TABLE t MODIFY f VARCHAR(8);
ALTER TABLE t MODIFY vf VARCHAR(18);
ERROR HY000: This is not yet supported for generated columns
DROP TABLE t;
# End of 10.4 tests
......@@ -126,4 +126,17 @@ SET SESSION FOREIGN_KEY_CHECKS = ON;
ALTER TABLE t2 MODIFY b VARCHAR(16), ADD KEY(b);
--error ER_BAD_TABLE_ERROR
DROP TABLE t2, t1;
--echo #
--echo # MDEV-32337 Assertion `pos < table->n_def' failed
--echo # in dict_table_get_nth_col
--echo #
CREATE TABLE t (a INT, va INT AS (a), b INT, vb INT AS (b),
c INT, vc INT AS (c), vf VARCHAR(16) AS (f),
f VARCHAR(4)) ENGINE=InnoDB;
ALTER TABLE t MODIFY f VARCHAR(8);
# Altering the virtual column is not supported
--error ER_UNSUPPORTED_ACTION_ON_GENERATED_COLUMN
ALTER TABLE t MODIFY vf VARCHAR(18);
DROP TABLE t;
--echo # End of 10.4 tests
......@@ -8333,8 +8333,17 @@ ha_innobase::prepare_inplace_alter_table(
if (ha_alter_info->handler_flags
& ALTER_COLUMN_TYPE_CHANGE_BY_ENGINE) {
for (uint i= 0; i < table->s->fields; i++) {
for (uint i= 0, n_v_col= 0; i < table->s->fields;
i++) {
Field* field = table->field[i];
/* Altering the virtual column is not
supported for inplace alter algorithm */
if (field->vcol_info) {
n_v_col++;
continue;
}
for (const Create_field& new_field :
ha_alter_info->alter_info->create_list) {
if (new_field.field == field) {
......@@ -8349,7 +8358,7 @@ ha_innobase::prepare_inplace_alter_table(
field_changed:
const char* col_name= field->field_name.str;
dict_col_t *col= dict_table_get_nth_col(
m_prebuilt->table, i);
m_prebuilt->table, i - n_v_col);
if (check_col_is_in_fk_indexes(
m_prebuilt->table, col, col_name,
span<const dict_foreign_t*>(
......
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