summaryrefslogtreecommitdiffstats
path: root/mysql-test/suite/innodb/r/fk_col_alter.result
diff options
context:
space:
mode:
Diffstat (limited to 'mysql-test/suite/innodb/r/fk_col_alter.result')
-rw-r--r--mysql-test/suite/innodb/r/fk_col_alter.result118
1 files changed, 118 insertions, 0 deletions
diff --git a/mysql-test/suite/innodb/r/fk_col_alter.result b/mysql-test/suite/innodb/r/fk_col_alter.result
new file mode 100644
index 00000000..403bef6a
--- /dev/null
+++ b/mysql-test/suite/innodb/r/fk_col_alter.result
@@ -0,0 +1,118 @@
+#
+# MDEV-31086 MODIFY COLUMN can break FK constraints, and
+# lead to unrestorable dumps
+#
+CREATE TABLE t1(
+id SERIAL,
+msg VARCHAR(100) CHARACTER SET utf8mb3,
+KEY(msg))ENGINE=InnoDB;
+CREATE TABLE t2(
+id SERIAL,
+msg varchar(100) CHARACTER SET utf8mb4,
+CONSTRAINT fk_t1 FOREIGN KEY (msg) REFERENCES t1 (msg))ENGINE=InnoDB;
+ERROR HY000: Can't create table `test`.`t2` (errno: 150 "Foreign key constraint is incorrectly formed")
+CREATE TABLE t2(
+id SERIAL,
+msg varchar(100) CHARACTER SET utf8mb3,
+msg_1 varchar(100) CHARACTER SET utf8mb3,
+INDEX (msg_1),
+INDEX (msg),
+CONSTRAINT fk_t1 FOREIGN KEY (msg) REFERENCES t1 (msg)
+ON DELETE CASCADE)ENGINE=InnoDB;
+SET FOREIGN_KEY_CHECKS=1;
+ALTER TABLE t2 MODIFY COLUMN msg VARCHAR(200) character set utf8mb3, ALGORITHM=COPY;
+ERROR HY000: Cannot change column 'msg': used in a foreign key constraint 'fk_t1'
+ALTER TABLE t2 MODIFY COLUMN msg VARCHAR(200) character set utf8mb3, ALGORITHM=INPLACE;
+ERROR HY000: Cannot change column 'msg': used in a foreign key constraint 'test/fk_t1'
+SET FOREIGN_KEY_CHECKS=0;
+ALTER TABLE t2 MODIFY COLUMN msg VARCHAR(200) character set utf8mb3, ALGORITHM=COPY;
+ERROR HY000: Cannot change column 'msg': used in a foreign key constraint 'fk_t1'
+ALTER TABLE t2 MODIFY COLUMN msg VARCHAR(400) character set utf8mb3, ALGORITHM=INPLACE;
+ERROR HY000: Cannot change column 'msg': used in a foreign key constraint 'test/fk_t1'
+SET FOREIGN_KEY_CHECKS=1;
+ALTER TABLE t2 MODIFY COLUMN msg VARCHAR(100) CHARACTER SET utf8mb4, ALGORITHM=COPY;
+ERROR HY000: Cannot change column 'msg': used in a foreign key constraint 'fk_t1'
+ALTER TABLE t2 MODIFY COLUMN msg VARCHAR(100) CHARACTER SET utf8mb4, ALGORITHM=INPLACE;
+ERROR HY000: Cannot change column 'msg': used in a foreign key constraint 'test/fk_t1'
+SET FOREIGN_KEY_CHECKS=0;
+ALTER TABLE t2 MODIFY COLUMN msg VARCHAR(100) CHARACTER SET utf8mb4,ALGORITHM=COPY;
+ERROR HY000: Cannot change column 'msg': used in a foreign key constraint 'fk_t1'
+ALTER TABLE t2 MODIFY COLUMN msg VARCHAR(100) CHARACTER SET utf8mb4,ALGORITHM=INPLACE;
+ERROR HY000: Cannot change column 'msg': used in a foreign key constraint 'test/fk_t1'
+SET FOREIGN_KEY_CHECKS=1;
+ALTER TABLE t2 ADD CONSTRAINT FOREIGN KEY(msg_1) REFERENCES t1(msg),MODIFY COLUMN msg_1 VARCHAR(100) CHARACTER SET utf8mb4, ALGORITHM=COPY;
+ERROR HY000: Can't create table `test`.`t2` (errno: 150 "Foreign key constraint is incorrectly formed")
+ALTER TABLE t2 ADD CONSTRAINT FOREIGN KEY(msg_1) REFERENCES t1(msg),MODIFY COLUMN msg_1 VARCHAR(100) CHARACTER SET utf8mb4, ALGORITHM=INPLACE;
+ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: Adding foreign keys needs foreign_key_checks=OFF. Try ALGORITHM=COPY
+SET FOREIGN_KEY_CHECKS=0;
+ALTER TABLE t2 ADD CONSTRAINT FOREIGN KEY(msg_1) REFERENCES t1(msg),MODIFY COLUMN msg_1 VARCHAR(100) CHARACTER SET utf8mb4, ALGORITHM=COPY;
+ERROR HY000: Can't create table `test`.`t2` (errno: 150 "Foreign key constraint is incorrectly formed")
+ALTER TABLE t2 ADD CONSTRAINT FOREIGN KEY(msg_1) REFERENCES t1(msg),MODIFY COLUMN msg_1 VARCHAR(100) CHARACTER SET utf8mb4, ALGORITHM=INPLACE;
+ERROR HY000: Cannot change column 'msg_1': used in a foreign key constraint 'test/t2_ibfk_0'
+ALTER TABLE t2 ADD CONSTRAINT FOREIGN KEY(msg_1) REFERENCES t1(msg),MODIFY COLUMN msg_1 VARCHAR(200) CHARACTER SET utf8mb3, ALGORITHM=INPLACE;
+ERROR HY000: Cannot change column 'msg_1': used in a foreign key constraint 'test/t2_ibfk_0'
+SET FOREIGN_KEY_CHECKS=1;
+ALTER TABLE t1 MODIFY msg VARCHAR(200) CHARSET utf8mb3, ALGORITHM=COPY;
+ERROR HY000: Cannot change column 'msg': used in a foreign key constraint 'fk_t1' of table 'test.t2'
+ALTER TABLE t1 MODIFY msg VARCHAR(200) CHARSET utf8mb3, ALGORITHM=INPLACE;
+ERROR HY000: Cannot change column 'msg': used in a foreign key constraint 'test/fk_t1' of table 'test/t2'
+ALTER TABLE t1 MODIFY msg VARCHAR(200) CHARSET utf8mb4, ALGORITHM=COPY;
+ERROR HY000: Cannot change column 'msg': used in a foreign key constraint 'fk_t1' of table 'test.t2'
+ALTER TABLE t1 MODIFY msg VARCHAR(200) CHARSET utf8mb4, ALGORITHM=INPLACE;
+ERROR HY000: Cannot change column 'msg': used in a foreign key constraint 'test/fk_t1' of table 'test/t2'
+SET FOREIGN_KEY_CHECKS=0;
+ALTER TABLE t1 MODIFY msg VARCHAR(200) CHARSET utf8mb3, ALGORITHM=COPY;
+ERROR HY000: Cannot change column 'msg': used in a foreign key constraint 'fk_t1' of table 'test.t2'
+ALTER TABLE t1 MODIFY msg VARCHAR(400) CHARSET utf8mb3, ALGORITHM=INPLACE;
+ERROR HY000: Cannot change column 'msg': used in a foreign key constraint 'test/fk_t1' of table 'test/t2'
+ALTER TABLE t1 MODIFY msg VARCHAR(200) CHARSET utf8mb4, ALGORITHM=COPY;
+ERROR HY000: Cannot change column 'msg': used in a foreign key constraint 'fk_t1' of table 'test.t2'
+ALTER TABLE t1 MODIFY msg VARCHAR(200) CHARSET utf8mb4, ALGORITHM=INPLACE;
+ERROR HY000: Cannot change column 'msg': used in a foreign key constraint 'test/fk_t1' of table 'test/t2'
+SET FOREIGN_KEY_CHECKS=0;
+ALTER TABLE t2 DROP FOREIGN KEY fk_t1, MODIFY msg VARCHAR(200) CHARSET utf8mb4, ALGORITHM=COPY;
+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;
+#
+# MDEV-32060 Server aborts when table doesn't
+# have referenced index
+#
+SET SESSION FOREIGN_KEY_CHECKS = OFF;
+CREATE TABLE t1 (a VARCHAR(16) KEY, FOREIGN KEY(a) REFERENCES t2(b)) ENGINE=InnoDB;
+CREATE TABLE t2 (b VARCHAR(8)) ENGINE=InnoDB;
+SET SESSION FOREIGN_KEY_CHECKS = ON;
+ALTER TABLE t2 MODIFY b VARCHAR(16), ADD KEY(b);
+DROP TABLE t1, 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;
+#
+# MDEV-32527 Server aborts during alter operation
+# when table doesn't have foreign index
+#
+CREATE TABLE t1 (f1 INT NOT NULL, INDEX(f1)) ENGINE=InnoDB;
+CREATE TABLE t2(f1 INT NOT NULL, f2 VARCHAR(100) DEFAULT NULL,
+INDEX idx(f1, f2),
+FOREIGN KEY(f1) REFERENCES t1(f1))ENGINE=INNODB;
+SET SESSION FOREIGN_KEY_CHECKS = OFF;
+ALTER TABLE t2 DROP INDEX idx;
+ALTER TABLE t2 MODIFY f2 VARCHAR(1023);
+SET SESSION FOREIGN_KEY_CHECKS = ON;
+DROP TABLE t2, t1;
+# End of 10.4 tests