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 5f09b53bdb4e973e7c7ec2c53a24c98321223f98(MDEV-31086).
This commit is contained in:
Thirunarayanan Balathandayuthapani 2023-10-12 14:49:27 +05:30
parent a2312b6fb2
commit 4045ead9db
3 changed files with 35 additions and 2 deletions

View File

@ -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

View File

@ -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

View File

@ -8333,8 +8333,17 @@ err_exit:
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 @@ err_exit:
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*>(