MDEV-31869 Server aborts when table does drop column

- InnoDB aborts when table is dropping the column. This is
caused by 5f09b53b (MDEV-31086).
While iterating the altered table fields, we fail to consider
the dropped columns.
parent ab10a675
......@@ -75,3 +75,10 @@ ALTER TABLE t1 MODIFY msg VARCHAR(200) CHARSET utf8mb4, ALGORITHM=COPY;
ALTER TABLE t2 ADD CONSTRAINT FOREIGN KEY (msg) REFERENCES t1(msg), aLGORITHM=INPLACE;
SET FOREIGN_KEY_CHECKS=1;
DROP TABLE t2, t1;
#
# MDEV-31869 Server aborts when table does drop column
#
CREATE TABLE t (a VARCHAR(40), b INT, C INT) ENGINE=InnoDB;
ALTER TABLE t MODIFY a VARCHAR(50), DROP b;
DROP TABLE t;
# End of 10.4 tests
......@@ -104,3 +104,11 @@ ALTER TABLE t2 ADD CONSTRAINT FOREIGN KEY (msg) REFERENCES t1(msg), aLGORITHM=IN
SET FOREIGN_KEY_CHECKS=1;
DROP TABLE t2, t1;
--echo #
--echo # MDEV-31869 Server aborts when table does drop column
--echo #
CREATE TABLE t (a VARCHAR(40), b INT, C INT) ENGINE=InnoDB;
ALTER TABLE t MODIFY a VARCHAR(50), DROP b;
DROP TABLE t;
--echo # End of 10.4 tests
......@@ -8330,14 +8330,21 @@ ha_innobase::prepare_inplace_alter_table(
index columns are modified */
if (ha_alter_info->handler_flags
& ALTER_COLUMN_TYPE_CHANGE_BY_ENGINE) {
List_iterator<Create_field> it(
ha_alter_info->alter_info->create_list);
for (uint i = 0; i < table->s->fields; i++) {
for (uint i= 0; i < table->s->fields; i++) {
Field* field = table->field[i];
Create_field *f= it++;
if (!f->field || field->is_equal(*f))
continue;
for (const Create_field& new_field :
ha_alter_info->alter_info->create_list) {
if (new_field.field == field) {
if (!field->is_equal(new_field)) {
goto field_changed;
}
break;
}
}
continue;
field_changed:
const char* col_name= field->field_name.str;
dict_col_t *col= dict_table_get_nth_col(
m_prebuilt->table, i);
......
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