Skip to content

Commit 8852afe

Browse files
committed
Merge branch '10.4' into 10.5
2 parents 8adb610 + 0ede90d commit 8852afe

File tree

3 files changed

+28
-6
lines changed

3 files changed

+28
-6
lines changed

mysql-test/suite/innodb/r/fk_col_alter.result

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,10 @@ ALTER TABLE t1 MODIFY msg VARCHAR(200) CHARSET utf8mb4, ALGORITHM=COPY;
7575
ALTER TABLE t2 ADD CONSTRAINT FOREIGN KEY (msg) REFERENCES t1(msg), aLGORITHM=INPLACE;
7676
SET FOREIGN_KEY_CHECKS=1;
7777
DROP TABLE t2, t1;
78+
#
79+
# MDEV-31869 Server aborts when table does drop column
80+
#
81+
CREATE TABLE t (a VARCHAR(40), b INT, C INT) ENGINE=InnoDB;
82+
ALTER TABLE t MODIFY a VARCHAR(50), DROP b;
83+
DROP TABLE t;
84+
# End of 10.4 tests

mysql-test/suite/innodb/t/fk_col_alter.test

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,11 @@ ALTER TABLE t2 ADD CONSTRAINT FOREIGN KEY (msg) REFERENCES t1(msg), aLGORITHM=IN
104104
SET FOREIGN_KEY_CHECKS=1;
105105

106106
DROP TABLE t2, t1;
107+
108+
--echo #
109+
--echo # MDEV-31869 Server aborts when table does drop column
110+
--echo #
111+
CREATE TABLE t (a VARCHAR(40), b INT, C INT) ENGINE=InnoDB;
112+
ALTER TABLE t MODIFY a VARCHAR(50), DROP b;
113+
DROP TABLE t;
114+
--echo # End of 10.4 tests

storage/innobase/handler/handler0alter.cc

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8248,14 +8248,21 @@ ha_innobase::prepare_inplace_alter_table(
82488248
index columns are modified */
82498249
if (ha_alter_info->handler_flags
82508250
& ALTER_COLUMN_TYPE_CHANGE_BY_ENGINE) {
8251-
List_iterator<Create_field> it(
8252-
ha_alter_info->alter_info->create_list);
8253-
for (uint i = 0; i < table->s->fields; i++) {
8251+
8252+
for (uint i= 0; i < table->s->fields; i++) {
82548253
Field* field = table->field[i];
8255-
Create_field *f= it++;
8256-
if (!f->field || field->is_equal(*f))
8257-
continue;
8254+
for (const Create_field& new_field :
8255+
ha_alter_info->alter_info->create_list) {
8256+
if (new_field.field == field) {
8257+
if (!field->is_equal(new_field)) {
8258+
goto field_changed;
8259+
}
8260+
break;
8261+
}
8262+
}
82588263

8264+
continue;
8265+
field_changed:
82598266
const char* col_name= field->field_name.str;
82608267
dict_col_t *col= dict_table_get_nth_col(
82618268
m_prebuilt->table, i);

0 commit comments

Comments
 (0)