f4 char(200) not null,primary key(f1))engine=innodb;
insert into t1 select NULL,'aaa','bbb','ccc' from t480;
insert into t1 select NULL,'aaaa','bbbb','cccc' from t480;
insert into t1 select NULL,'aaaaa','bbbbb','ccccc' from t480;
insert into t1 select NULL,'aaaaaa','bbbbbb','cccccc' from t480;
insert into t1 select NULL,'aaaaaaa','bbbbbbb','ccccccc' from t480;
insert into t1 select NULL,'aaaaaaaa','bbbbbbbb','cccccccc' from t480;
select count(*) from t1;
count(*)
2880
SET DEBUG_DBUG = '+d,innobase_tmpfile_creation_failure';
alter table t1 force, algorithm=inplace;
ERROR HY000: Out of memory; check if mysqld or some other process uses all available memory; if not, you may have to use 'ulimit' to allow mysqld to use more memory or you can add more swap space
ALTER TABLE child ADD FOREIGN KEY(a2) REFERENCES parent(b),
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 child ADD CONSTRAINT fk_1 FOREIGN KEY (a2)
REFERENCES parent(b) ON DELETE SET NULL ON UPDATE CASCADE,
ALGORITHM = INPLACE;
SELECT * FROM information_schema.INNODB_SYS_FOREIGN;
ID FOR_NAME REF_NAME N_COLS TYPE
test/fk_1 test/child test/parent 1 6
SELECT * FROM information_schema.INNODB_SYS_FOREIGN_COLS;
ID FOR_COL_NAME REF_COL_NAME POS
test/fk_1 a2 b 0
ALTER TABLE child ADD CONSTRAINT fk_1 FOREIGN KEY (a2)
REFERENCES parent(b) ON DELETE SET NULL ON UPDATE CASCADE,
ALGORITHM = INPLACE;
ERROR HY000: Duplicate foreign key constraint name 'test/fk_1'
SET foreign_key_checks = 1;
INSERT INTO child VALUES(1,2),(2,3);
INSERT INTO child VALUES(4,4);
ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`child`, CONSTRAINT `fk_1` FOREIGN KEY (`a2`) REFERENCES `parent` (`b`) ON DELETE SET NULL ON UPDATE CASCADE)
SELECT * FROM parent;
a b
1 2
2 3
10 20
20 30
SET foreign_key_checks = 0;
ALTER TABLE child ADD CONSTRAINT fk_20 FOREIGN KEY (a1, a2)
REFERENCES parent(a, b) ON DELETE CASCADE ON UPDATE CASCADE,
ALGORITHM = INPLACE;
ERROR HY000: Failed to add the foreign key constaint. Missing index for constraint 'fk_20' in the referenced table 'parent'
SHOW WARNINGS;
Level Code Message
Error 1822 Failed to add the foreign key constaint. Missing index for constraint 'fk_20' in the referenced table 'parent'
SHOW ERRORS;
Level Code Message
Error 1822 Failed to add the foreign key constaint. Missing index for constraint 'fk_20' in the referenced table 'parent'
CREATE INDEX idx1 on parent(a, b);
ALTER TABLE child ADD CONSTRAINT fk_10 FOREIGN KEY (a1, a2)
REFERENCES parent(a, b) ON DELETE CASCADE ON UPDATE CASCADE,
ALGORITHM = INPLACE;
ALTER TABLE child ADD CONSTRAINT fk_2 FOREIGN KEY (a1, a2)
REFERENCES parent(a, b) ON DELETE CASCADE ON UPDATE CASCADE, ADD INDEX idx1(a1,a2),
ALGORITHM = INPLACE;
ALTER TABLE child ADD CONSTRAINT fk_3 FOREIGN KEY (a1, a2)
REFERENCES parent(a, b) ON DELETE CASCADE ON UPDATE CASCADE;
SELECT * FROM information_schema.INNODB_SYS_FOREIGN;
ID FOR_NAME REF_NAME N_COLS TYPE
test/fk_1 test/child test/parent 1 6
test/fk_10 test/child test/parent 2 5
test/fk_2 test/child test/parent 2 5
test/fk_3 test/child test/parent 2 5
SELECT * FROM information_schema.INNODB_SYS_FOREIGN_COLS;
ID FOR_COL_NAME REF_COL_NAME POS
test/fk_1 a2 b 0
test/fk_10 a1 a 0
test/fk_10 a2 b 1
test/fk_2 a1 a 0
test/fk_2 a2 b 1
test/fk_3 a1 a 0
test/fk_3 a2 b 1
SET foreign_key_checks = 1;
INSERT INTO child VALUES(5,4);
ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`child`, CONSTRAINT `fk_1` FOREIGN KEY (`a2`) REFERENCES `parent` (`b`) ON DELETE SET NULL ON UPDATE CASCADE)
SHOW CREATE TABLE child;
Table Create Table
child CREATE TABLE `child` (
`a1` int(11) NOT NULL,
`a2` int(11) DEFAULT NULL,
PRIMARY KEY (`a1`),
KEY `tb` (`a2`),
KEY `idx1` (`a1`,`a2`),
CONSTRAINT `fk_1` FOREIGN KEY (`a2`) REFERENCES `parent` (`b`) ON DELETE SET NULL ON UPDATE CASCADE,
CONSTRAINT `fk_10` FOREIGN KEY (`a1`, `a2`) REFERENCES `parent` (`a`, `b`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `fk_2` FOREIGN KEY (`a1`, `a2`) REFERENCES `parent` (`a`, `b`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `fk_3` FOREIGN KEY (`a1`, `a2`) REFERENCES `parent` (`a`, `b`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1
DELETE FROM parent where a = 1;
SELECT * FROM child;
a1 a2
1 NULL
2 3
10 20
SET foreign_key_checks = 0;
SET @saved_debug_dbug = @@SESSION.debug_dbug;
SET DEBUG_DBUG = '+d,innodb_test_open_ref_fail';
ALTER TABLE child ADD CONSTRAINT fk_4 FOREIGN KEY (a1, a2)
REFERENCES parent(a, b) ON DELETE CASCADE ON UPDATE CASCADE,
ALGORITHM = INPLACE;
SET DEBUG_DBUG = @saved_debug_dbug;
SELECT * FROM information_schema.INNODB_SYS_FOREIGN;
ID FOR_NAME REF_NAME N_COLS TYPE
test/fk_1 test/child test/parent 1 6
test/fk_10 test/child test/parent 2 5
test/fk_2 test/child test/parent 2 5
test/fk_3 test/child test/parent 2 5
test/fk_4 test/child test/parent 2 5
SELECT * FROM information_schema.INNODB_SYS_FOREIGN_COLS;
ID FOR_COL_NAME REF_COL_NAME POS
test/fk_1 a2 b 0
test/fk_10 a1 a 0
test/fk_10 a2 b 1
test/fk_2 a1 a 0
test/fk_2 a2 b 1
test/fk_3 a1 a 0
test/fk_3 a2 b 1
test/fk_4 a1 a 0
test/fk_4 a2 b 1
SELECT t2.name, t1.name FROM information_schema.innodb_sys_columns t1, information_schema.innodb_sys_tables t2 WHERE t1.table_id = t2.table_id AND t2.name LIKE "%child" ORDER BY t1.name;
name name
test/child a1
test/child a2
SELECT NAME FROM information_schema.INNODB_SYS_TABLES;
NAME
SYS_DATAFILES
SYS_FOREIGN
SYS_FOREIGN_COLS
SYS_TABLESPACES
mysql/innodb_index_stats
mysql/innodb_table_stats
test/child
test/parent
INSERT INTO child VALUES(5,4);
SET foreign_key_checks = 1;
INSERT INTO child VALUES(6,5);
ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`child`, CONSTRAINT `fk_1` FOREIGN KEY (`a2`) REFERENCES `parent` (`b`) ON DELETE SET NULL ON UPDATE CASCADE)
SET foreign_key_checks = 0;
CREATE TABLE `#parent` (a INT PRIMARY KEY, b INT NOT NULL) ENGINE = InnoDB;
ERROR HY000: Failed to add the foreign key constraint 'test/fk_1' to system tables
SET DEBUG_DBUG = @saved_debug_dbug;
SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN;
ID FOR_NAME REF_NAME N_COLS TYPE
SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS;
ID FOR_COL_NAME REF_COL_NAME POS
SELECT t2.name, t1.name FROM information_schema.innodb_sys_columns t1, information_schema.innodb_sys_tables t2 WHERE t1.table_id = t2.table_id AND t2.name LIKE "%child" ORDER BY t1.name;
name name
test/child a1
test/child a2
SELECT NAME FROM information_schema.INNODB_SYS_TABLES;
SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN;
ID FOR_NAME REF_NAME N_COLS TYPE
test/fk_1 test/child test/parent 1 6
SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS;
ID FOR_COL_NAME REF_COL_NAME POS
test/fk_1 a2 b 0
SELECT t2.name, t1.name FROM information_schema.innodb_sys_columns t1, information_schema.innodb_sys_tables t2 WHERE t1.table_id = t2.table_id AND t2.name LIKE "%child" ORDER BY t1.name;
name name
test/child a2
test/child a3
SELECT NAME FROM information_schema.INNODB_SYS_TABLES;
NAME
SYS_DATAFILES
SYS_FOREIGN
SYS_FOREIGN_COLS
SYS_TABLESPACES
mysql/innodb_index_stats
mysql/innodb_table_stats
test/child
test/parent
SHOW CREATE TABLE child;
Table Create Table
child CREATE TABLE `child` (
`a3` int(11) NOT NULL DEFAULT '0',
`a2` int(11) DEFAULT NULL,
PRIMARY KEY (`a3`),
KEY `tb` (`a2`),
CONSTRAINT `fk_1` FOREIGN KEY (`a2`) REFERENCES `parent` (`b`) ON DELETE SET NULL ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1
DROP TABLE child;
CREATE TABLE child (a1 INT NOT NULL, a2 INT) ENGINE = InnoDB;
SELECT * from information_schema.INNODB_SYS_FOREIGN;
ID FOR_NAME REF_NAME N_COLS TYPE
test/fk_1 test/child test/parent 1 6
SELECT * from information_schema.INNODB_SYS_FOREIGN_COLS;
ID FOR_COL_NAME REF_COL_NAME POS
test/fk_1 a2 b 0
SELECT t2.name, t1.name FROM information_schema.innodb_sys_columns t1, information_schema.innodb_sys_tables t2 WHERE t1.table_id = t2.table_id AND t2.name LIKE "%child" ORDER BY t1.name;
name name
test/child a1
test/child a2
SELECT NAME FROM information_schema.INNODB_SYS_TABLES;
NAME
SYS_DATAFILES
SYS_FOREIGN
SYS_FOREIGN_COLS
SYS_TABLESPACES
mysql/innodb_index_stats
mysql/innodb_table_stats
test/child
test/parent
SHOW CREATE TABLE child;
Table Create Table
child CREATE TABLE `child` (
`a1` int(11) NOT NULL,
`a2` int(11) DEFAULT NULL,
PRIMARY KEY (`a1`),
KEY `fk_1` (`a2`),
CONSTRAINT `fk_1` FOREIGN KEY (`a2`) REFERENCES `parent` (`b`) ON DELETE SET NULL ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1
DROP TABLE child;
CREATE TABLE child (a1 INT NOT NULL, a2 INT) ENGINE = InnoDB;
SELECT * from information_schema.INNODB_SYS_FOREIGN;
ID FOR_NAME REF_NAME N_COLS TYPE
test/fk_1 test/child test/parent 1 6
SELECT * from information_schema.INNODB_SYS_FOREIGN_COLS;
ID FOR_COL_NAME REF_COL_NAME POS
test/fk_1 a3 b 0
SELECT t2.name, t1.name FROM information_schema.innodb_sys_columns t1, information_schema.innodb_sys_tables t2 WHERE t1.table_id = t2.table_id AND t2.name LIKE "%child" ORDER BY t1.name;
name name
test/child a2
test/child a3
SELECT NAME FROM information_schema.INNODB_SYS_TABLES;
NAME
SYS_DATAFILES
SYS_FOREIGN
SYS_FOREIGN_COLS
SYS_TABLESPACES
mysql/innodb_index_stats
mysql/innodb_table_stats
test/child
test/parent
SHOW CREATE TABLE child;
Table Create Table
child CREATE TABLE `child` (
`a3` int(11) DEFAULT NULL,
`a2` int(11) DEFAULT NULL,
KEY `fk_1` (`a3`),
CONSTRAINT `fk_1` FOREIGN KEY (`a3`) REFERENCES `parent` (`b`) ON DELETE SET NULL ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1
DROP TABLE child;
CREATE TABLE child (a1 INT NOT NULL, a2 INT) ENGINE = InnoDB;
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl';
name count
ddl_background_drop_indexes 0
ddl_background_drop_tables 0
ddl_online_create_index 0
ddl_pending_alter_table 0
SET @saved_debug_dbug = @@SESSION.debug_dbug;
SET DEBUG_DBUG = '+d,innodb_OOM_prepare_inplace_alter';
ALTER TABLE t1 ADD UNIQUE INDEX(c2);
ERROR HY000: Out of memory; check if mysqld or some other process uses all available memory; if not, you may have to use 'ulimit' to allow mysqld to use more memory or you can add more swap space
SET DEBUG_DBUG = @saved_debug_dbug;
SET DEBUG_DBUG = '+d,innodb_OOM_inplace_alter';
CREATE UNIQUE INDEX c2 ON t1(c2);
ERROR HY000: Out of memory; check if mysqld or some other process uses all available memory; if not, you may have to use 'ulimit' to allow mysqld to use more memory or you can add more swap space
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl';
name count
ddl_background_drop_indexes 0
ddl_background_drop_tables 0
ddl_online_create_index 0
ddl_pending_alter_table 0
# session con1
SET @saved_debug_dbug = @@SESSION.debug_dbug;
SET DEBUG_DBUG = '+d,innodb_OOM_prepare_inplace_alter';
ALTER TABLE t1 ROW_FORMAT=REDUNDANT, ALGORITHM=INPLACE, LOCK=NONE;
ERROR HY000: Out of memory; check if mysqld or some other process uses all available memory; if not, you may have to use 'ulimit' to allow mysqld to use more memory or you can add more swap space
SET SESSION DEBUG = @saved_debug_dbug;
Warnings:
Warning 1287 '@@debug' is deprecated and will be removed in a future release. Please use '@@debug_dbug' instead
SET SESSION DEBUG = '+d,innodb_OOM_inplace_alter';
Warnings:
Warning 1287 '@@debug' is deprecated and will be removed in a future release. Please use '@@debug_dbug' instead
ALTER TABLE t1 ROW_FORMAT=REDUNDANT, ALGORITHM=INPLACE, LOCK=NONE;
ERROR HY000: Out of memory; check if mysqld or some other process uses all available memory; if not, you may have to use 'ulimit' to allow mysqld to use more memory or you can add more swap space
SET SESSION DEBUG = @saved_debug_dbug;
Warnings:
Warning 1287 '@@debug' is deprecated and will be removed in a future release. Please use '@@debug_dbug' instead
ALTER TABLE t1 ROW_FORMAT=REDUNDANT, ALGORITHM=INPLACE, LOCK=NONE;
ALTER TABLE t1 DROP INDEX c2, ALGORITHM = INPLACE;
ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: Dropping a primary key is not allowed without also adding a new primary key. Try ALGORITHM=COPY.
callmtr.add_suppression("\\[ERROR\\] InnoDB: Cannot rename '.*' to '.*' for space ID .* because the target file exists. Remove the target file and try again");