Commit fdbdd3b1 authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-13625 Merge InnoDB test cases from MySQL 5.6 (part 1)

parents 888a8b69 9e9a3b8e
# Export Table and Import from saved files .cfg and .ibd
# Caller should create t1 table definition and populate table
let $MYSQLD_DATADIR = `SELECT @@datadir`;
if(!$source_db) {
let $source_db = test;
}
if(!$dest_db) {
let $dest_db = test;
}
eval FLUSH TABLES $source_db.t1 FOR EXPORT;
--copy_file $MYSQLD_DATADIR/$source_db/t1.cfg $MYSQLD_DATADIR/t1.cfg_back
--copy_file $MYSQLD_DATADIR/$source_db/t1.ibd $MYSQLD_DATADIR/t1.ibd_back
UNLOCK TABLES;
if($source_db != $dest_db) {
eval USE $dest_db;
let $create1 = query_get_value(SHOW CREATE TABLE $source_db.t1, Create Table, 1);
eval $create1;
}
eval ALTER TABLE $dest_db.t1 DISCARD TABLESPACE;
--move_file $MYSQLD_DATADIR/t1.cfg_back $MYSQLD_DATADIR/$dest_db/t1.cfg
--move_file $MYSQLD_DATADIR/t1.ibd_back $MYSQLD_DATADIR/$dest_db/t1.ibd
eval ALTER TABLE $dest_db.t1 IMPORT TABLESPACE;
eval CHECK TABLE $dest_db.t1;
eval SHOW CREATE TABLE $dest_db.t1;
eval SELECT * FROM $dest_db.t1;
if($source_db != $dest_db) {
eval DROP TABLE $dest_db.t1;
}
SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN
FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i
INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID;
SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i
INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID;
SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i
INNER JOIN sys_foreign sf ON i.ID = sf.ID;
#
# Show what happens during ALTER TABLE when an existing file
# exists in the target location.
#
# Bug #19218794: IF TABLESPACE EXISTS, CAN'T CREATE TABLE,
# BUT CAN ALTER ENGINE=INNODB
#
CREATE TABLE t1 (a SERIAL, b CHAR(10)) ENGINE=Memory;
INSERT INTO t1(b) VALUES('one'), ('two'), ('three');
#
# Create a file called MYSQLD_DATADIR/test/t1.ibd
# Directory listing of test/*.ibd
#
t1.ibd
ALTER TABLE t1 ENGINE = InnoDB;
ERROR HY000: Error on rename of 'OLD_FILE_NAME' to 'NEW_FILE_NAME' (errno: 184 "Tablespace already exists")
#
# Move the file to InnoDB as t2
#
ALTER TABLE t1 RENAME TO t2, ENGINE = INNODB;
SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`a` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`b` char(10) DEFAULT NULL,
UNIQUE KEY `a` (`a`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1
SELECT * from t2;
a b
1 one
2 two
3 three
ALTER TABLE t2 RENAME TO t1;
ERROR HY000: Error on rename of 'OLD_FILE_NAME' to 'NEW_FILE_NAME' (errno: 184 "Tablespace already exists")
#
# Create another t1, but in the system tablespace.
#
SET GLOBAL innodb_file_per_table=OFF;
CREATE TABLE t1 (a SERIAL, b CHAR(20)) ENGINE=InnoDB;
INSERT INTO t1(b) VALUES('one'), ('two'), ('three');
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`b` char(20) DEFAULT NULL,
UNIQUE KEY `a` (`a`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1
SELECT name, space=0 FROM information_schema.innodb_sys_tables WHERE name = 'test/t1';
name space=0
test/t1 1
#
# ALTER TABLE from system tablespace to system tablespace
#
ALTER TABLE t1 ADD COLUMN c INT, ALGORITHM=INPLACE;
ALTER TABLE t1 ADD COLUMN d INT, ALGORITHM=COPY;
#
# Try to move t1 from the system tablespace to a file-per-table
# while a blocking t1.ibd file exists.
#
SET GLOBAL innodb_file_per_table=ON;
ALTER TABLE t1 ADD COLUMN e1 INT, ALGORITHM=INPLACE;
ERROR HY000: Tablespace for table 'test/t1' exists. Please DISCARD the tablespace before IMPORT.
ALTER TABLE t1 ADD COLUMN e2 INT, ALGORITHM=COPY;
ERROR HY000: Error on rename of 'OLD_FILE_NAME' to 'NEW_FILE_NAME' (errno: 184 "Tablespace already exists")
#
# Delete the blocking file called MYSQLD_DATADIR/test/t1.ibd
# Move t1 to file-per-table using ALGORITHM=INPLACE with no blocking t1.ibd.
#
ALTER TABLE t1 ADD COLUMN e INT, ALGORITHM=INPLACE;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`b` char(20) DEFAULT NULL,
`c` int(11) DEFAULT NULL,
`d` int(11) DEFAULT NULL,
`e` int(11) DEFAULT NULL,
UNIQUE KEY `a` (`a`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1
SELECT name, space=0 FROM information_schema.innodb_sys_tables WHERE name = 'test/t1';
name space=0
test/t1 0
DROP TABLE t1;
#
# Rename t2.ibd to t1.ibd.
#
ALTER TABLE t2 RENAME TO t1;
SELECT name, space=0 FROM information_schema.innodb_sys_tables WHERE name = 'test/t1';
name space=0
test/t1 0
SELECT * from t1;
a b
1 one
2 two
3 three
DROP TABLE t1;
SET @saved_debug_dbug = @@SESSION.debug_dbug;
#
#BUG#21326304 INNODB ONLINE ALTER TABLE ENDS IN CRASH ON DISK FULL
#
CREATE TABLE t1(f1 CHAR(255) NOT NULL, f2 CHAR(255) NOT NULL, f3
CHAR(255) NOT NULL, f4 CHAR(255) NOT NULL, f5 CHAR(255) NOT NULL,f6
CHAR(255) NOT NULL, f7 CHAR(255) NOT NULL, f8 CHAR(255) NOT NULL,f9
CHAR(255) NOT NULL, f10 CHAR(255) NOT NULL, f11 CHAR(255) NOT NULL,f12
CHAR(255) NOT NULL, f13 CHAR(255) NOT NULL, f14 CHAR(255) NOT NULL,f15
CHAR(255) NOT NULL, f16 CHAR(255) NOT NULL, f17 CHAR(255) NOT NULL,f18
CHAR(255) NOT NULL)
ENGINE=INNODB ROW_FORMAT=DYNAMIC;
Warnings:
Warning 1478 InnoDB: ROW_FORMAT=DYNAMIC requires innodb_file_format > Antelope.
Warning 1478 InnoDB: assuming ROW_FORMAT=COMPACT.
INSERT INTO t1
VALUES('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r');
INSERT INTO t1 SELECT * FROM t1;
INSERT INTO t1 SELECT * FROM t1;
INSERT INTO t1 SELECT * FROM t1;
INSERT INTO t1 SELECT * FROM t1;
SET debug_dbug = '+d,disk_is_full';
ALTER TABLE t1 FORCE, ALGORITHM=INPLACE;
ERROR HY000: The table 't1' is full
SET debug_dbug= @saved_debug_dbug;
DROP TABLE t1;
#
# Bug#15923864 (Bug#67718):
# INNODB DRASTICALLY UNDER-FILLS PAGES IN CERTAIN CONDITIONS
#
SET GLOBAL innodb_file_per_table=ON;
CREATE TABLE t1 (a BIGINT PRIMARY KEY, b VARCHAR(4096)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (0, REPEAT('a', 4096));
INSERT INTO t1 VALUES (1000, REPEAT('a', 4096));
INSERT INTO t1 VALUES (1001, REPEAT('a', 4096));
INSERT INTO t1 VALUES (1002, REPEAT('a', 4096));
INSERT INTO t1 VALUES (1, REPEAT('a', 4096));
INSERT INTO t1 VALUES (2, REPEAT('a', 4096));
SELECT page_number, number_records
FROM information_schema.innodb_sys_tablespaces s1,
information_schema.innodb_buffer_page s2
WHERE s1.space = s2.space AND name = 'test/t1'
AND page_type = "INDEX" ORDER BY page_number;
page_number number_records
3 2
4 3
5 3
INSERT INTO t1 VALUES (999, REPEAT('a', 4096));
SELECT page_number, number_records
FROM information_schema.innodb_sys_tablespaces s1,
information_schema.innodb_buffer_page s2
WHERE s1.space = s2.space AND name = 'test/t1'
AND page_type = "INDEX" ORDER BY page_number;
page_number number_records
3 3
4 3
5 3
6 1
INSERT INTO t1 VALUES (998, REPEAT('a', 4096));
SELECT page_number, number_records
FROM information_schema.innodb_sys_tablespaces s1,
information_schema.innodb_buffer_page s2
WHERE s1.space = s2.space AND name = 'test/t1'
AND page_type = "INDEX" ORDER BY page_number;
page_number number_records
3 3
4 3
5 3
6 2
INSERT INTO t1 VALUES (997, REPEAT('a', 4096));
SELECT page_number, number_records
FROM information_schema.innodb_sys_tablespaces s1,
information_schema.innodb_buffer_page s2
WHERE s1.space = s2.space AND name = 'test/t1'
AND page_type = "INDEX" ORDER BY page_number;
page_number number_records
3 3
4 3
5 3
6 3
DROP TABLE t1;
CREATE TABLE t1 (a INT) ENGINE=InnoDB;
INSERT INTO t1 VALUES(347),(33101),(123),(45),(6);
SET @old_sql_mode = @@sql_mode;
SET @@sql_mode = 'STRICT_TRANS_TABLES';
ALTER TABLE t1 ADD PRIMARY KEY(a);
SET @@sql_mode = @old_sql_mode;
ALTER TABLE t1 DROP PRIMARY KEY, ADD id INT AUTO_INCREMENT PRIMARY KEY,
LOCK=NONE;
ERROR 0A000: LOCK=NONE is not supported. Reason: Adding an auto-increment column requires a lock. Try LOCK=SHARED.
ALTER TABLE t1 ADD id INT AUTO_INCREMENT;
ERROR 42000: Incorrect table definition; there can be only one auto column and it must be defined as a key
ALTER TABLE t1 ADD id INT AUTO_INCREMENT, ADD INDEX(a, id);
ERROR 42000: Incorrect table definition; there can be only one auto column and it must be defined as a key
ALTER TABLE t1 ADD id INT NOT NULL, ADD INDEX(id, a);
SELECT * FROM t1;
a id
6 0
45 0
123 0
347 0
33101 0
SET AUTO_INCREMENT_INCREMENT = 5, AUTO_INCREMENT_OFFSET = 30;
ALTER TABLE t1 DROP PRIMARY KEY, ADD id INT AUTO_INCREMENT PRIMARY KEY,
DROP COLUMN id, AUTO_INCREMENT = 42, ALGORITHM=COPY;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL DEFAULT '0',
`id` int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`),
KEY `id` (`id`,`a`)
) ENGINE=InnoDB AUTO_INCREMENT=70 DEFAULT CHARSET=latin1
BEGIN;
INSERT INTO t1 VALUES(7,0);
SELECT * FROM t1;
a id
6 45
45 50
123 55
347 60
33101 65
7 70
ROLLBACK;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL DEFAULT '0',
`id` int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`),
KEY `id` (`id`,`a`)
) ENGINE=InnoDB AUTO_INCREMENT=75 DEFAULT CHARSET=latin1
ALTER TABLE t1 DROP PRIMARY KEY, ADD id INT AUTO_INCREMENT PRIMARY KEY,
DROP COLUMN id, AUTO_INCREMENT = 42, LOCK=NONE;
ERROR 0A000: LOCK=NONE is not supported. Reason: Adding an auto-increment column requires a lock. Try LOCK=SHARED.
ALTER TABLE t1 DROP PRIMARY KEY, ADD id INT AUTO_INCREMENT PRIMARY KEY,
DROP COLUMN id, AUTO_INCREMENT = 42, ALGORITHM=INPLACE;
SELECT * FROM t1;
a id
6 45
45 50
123 55
347 60
33101 65
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL DEFAULT '0',
`id` int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`),
KEY `id` (`id`,`a`)
) ENGINE=InnoDB AUTO_INCREMENT=70 DEFAULT CHARSET=latin1
INSERT INTO t1 SET a=123;
INSERT INTO t1 VALUES(-123,-45);
ALTER TABLE t1 AUTO_INCREMENT = 75;
INSERT INTO t1 SET a=123;
SELECT * FROM t1;
a id
-123 -45
6 45
45 50
123 55
347 60
33101 65
123 70
123 75
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL DEFAULT '0',
`id` int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`),
KEY `id` (`id`,`a`)
) ENGINE=InnoDB AUTO_INCREMENT=80 DEFAULT CHARSET=latin1
DROP TABLE t1;
CREATE TABLE t1 (a INT) ENGINE=InnoDB;
INSERT INTO t1 VALUES(347),(33101),(123),(45),(6);
ALTER TABLE t1 ADD PRIMARY KEY(a);
ALTER TABLE t1 ADD id INT NOT NULL, ADD INDEX(id, a);
SELECT * FROM t1;
a id
6 0
45 0
123 0
347 0
33101 0
ALTER TABLE t1 DROP PRIMARY KEY, ADD id INT AUTO_INCREMENT PRIMARY KEY,
DROP COLUMN id, AUTO_INCREMENT = 42, ALGORITHM=INPLACE;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL DEFAULT '0',
`id` int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`),
KEY `id` (`id`,`a`)
) ENGINE=InnoDB AUTO_INCREMENT=70 DEFAULT CHARSET=latin1
BEGIN;
INSERT INTO t1 VALUES(7,0);
SELECT * FROM t1;
a id
6 45
45 50
123 55
347 60
33101 65
7 70
ROLLBACK;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL DEFAULT '0',
`id` int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`),
KEY `id` (`id`,`a`)
) ENGINE=InnoDB AUTO_INCREMENT=75 DEFAULT CHARSET=latin1
ALTER TABLE t1 DROP PRIMARY KEY, ADD id INT AUTO_INCREMENT PRIMARY KEY,
DROP COLUMN id, AUTO_INCREMENT = 42, ALGORITHM=COPY;
SELECT * FROM t1;
a id
6 45
45 50
123 55
347 60
33101 65
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL DEFAULT '0',
`id` int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`),
KEY `id` (`id`,`a`)
) ENGINE=InnoDB AUTO_INCREMENT=75 DEFAULT CHARSET=latin1
INSERT INTO t1 SET a=123;
INSERT INTO t1 VALUES(-123,-45);
ALTER TABLE t1 AUTO_INCREMENT = 75;
INSERT INTO t1 SET a=123;
SELECT * FROM t1;
a id
-123 -45
6 45
45 50
123 55
347 60
33101 65
123 75
123 80
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL DEFAULT '0',
`id` int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`),
KEY `id` (`id`,`a`)
) ENGINE=InnoDB AUTO_INCREMENT=85 DEFAULT CHARSET=latin1
DROP TABLE t1;
SET NAMES utf8;
CREATE TABLE t1 (
c1 INT PRIMARY KEY, c2 INT DEFAULT 1, ct TEXT,
INDEX(c2))
ENGINE=InnoDB;
INSERT INTO t1 SET c1=1;
CREATE TABLE sys_tables SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES
WHERE NAME LIKE 'test/t%';
CREATE TABLE sys_indexes SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES i
INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID;
CREATE TABLE t1p LIKE t1;
CREATE TABLE t1c (c1 INT PRIMARY KEY, c2 INT, c3 INT, INDEX(c2), INDEX(c3),
CONSTRAINT t1c2 FOREIGN KEY (c2) REFERENCES t1(c2),
CONSTRAINT t1c3 FOREIGN KEY (c3) REFERENCES t1p(c2))
ENGINE=InnoDB;
CREATE TABLE sys_foreign SELECT i.*
FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN i
WHERE FOR_NAME LIKE 'test/t%';
SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i
INNER JOIN sys_foreign sf ON i.ID = sf.ID;
ID FOR_COL_NAME REF_COL_NAME POS
test/t1c2 c2 c2 0
test/t1c3 c3 c2 0
SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN
FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i
INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID;
NAME POS MTYPE PRTYPE LEN
c1 0 6 1283 4
c2 1 6 1027 4
ct 2 5 524540 10
SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i
INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID;
NAME POS NAME
PRIMARY 0 c1
c2 0 c2
SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i
INNER JOIN sys_foreign sf ON i.ID = sf.ID;
ID FOR_COL_NAME REF_COL_NAME POS
test/t1c2 c2 c2 0
test/t1c3 c3 c2 0
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` int(11) NOT NULL,
`c2` int(11) DEFAULT '1',
`ct` text,
PRIMARY KEY (`c1`),
KEY `c2` (`c2`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
ALTER TABLE t1 ALTER c2 DROP DEFAULT;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` int(11) NOT NULL,
`c2` int(11),
`ct` text,
PRIMARY KEY (`c1`),
KEY `c2` (`c2`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN
FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i
INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID;
NAME POS MTYPE PRTYPE LEN
c1 0 6 1283 4
c2 1 6 1027 4
ct 2 5 524540 10
SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i
INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID;
NAME POS NAME
PRIMARY 0 c1
c2 0 c2
SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i
INNER JOIN sys_foreign sf ON i.ID = sf.ID;
ID FOR_COL_NAME REF_COL_NAME POS
test/t1c2 c2 c2 0
test/t1c3 c3 c2 0
ALTER TABLE t1 CHANGE c2 c2 INT AFTER c1;
ALTER TABLE t1 CHANGE c1 c1 INT FIRST;
SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN
FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i
INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID;
NAME POS MTYPE PRTYPE LEN
c1 0 6 1283 4
c2 1 6 1027 4
ct 2 5 524540 10
SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i
INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID;
NAME POS NAME
PRIMARY 0 c1
c2 0 c2
SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i
INNER JOIN sys_foreign sf ON i.ID = sf.ID;
ID FOR_COL_NAME REF_COL_NAME POS
test/t1c2 c2 c2 0
test/t1c3 c3 c2 0
ALTER TABLE t1 CHANGE C2 c3 INT;
SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN
FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i
INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID;
NAME POS MTYPE PRTYPE LEN
c1 0 6 1283 4
c3 1 6 1027 4
ct 2 5 524540 10
SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i
INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID;
NAME POS NAME
PRIMARY 0 c1
c2 0 c3
SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i
INNER JOIN sys_foreign sf ON i.ID = sf.ID;
ID FOR_COL_NAME REF_COL_NAME POS
test/t1c2 c2 c3 0
test/t1c3 c3 c2 0
ALTER TABLE t1 CHANGE c3 C INT;
SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN
FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i
INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID;
NAME POS MTYPE PRTYPE LEN
c1 0 6 1283 4
C 1 6 1027 4
ct 2 5 524540 10
SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i
INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID;
NAME POS NAME
PRIMARY 0 c1
c2 0 C
SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i
INNER JOIN sys_foreign sf ON i.ID = sf.ID;
ID FOR_COL_NAME REF_COL_NAME POS
test/t1c2 c2 C 0
test/t1c3 c3 c2 0
ALTER TABLE t1 CHANGE C Cöŀumň_TWO INT;
SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i
INNER JOIN sys_foreign sf ON i.ID = sf.ID;
ID FOR_COL_NAME REF_COL_NAME POS
test/t1c2 c2 Cöŀumň_TWO 0
test/t1c3 c3 c2 0
SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN
FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i
INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID;
NAME POS MTYPE PRTYPE LEN
c1 0 6 1283 4
Cöŀumň_TWO 1 6 1027 4
ct 2 5 524540 10
SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i
INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID;
NAME POS NAME
PRIMARY 0 c1
c2 0 Cöŀumň_TWO
SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i
INNER JOIN sys_foreign sf ON i.ID = sf.ID;
ID FOR_COL_NAME REF_COL_NAME POS
test/t1c2 c2 Cöŀumň_TWO 0
test/t1c3 c3 c2 0
ALTER TABLE t1 CHANGE cöĿǖmň_two c3 INT;
ERROR 42S22: Unknown column 'cöĿǖmň_two' in 't1'
ALTER TABLE t1 CHANGE cÖĿUMŇ_two c3 INT, RENAME TO t3;
SELECT st.NAME, i.NAME
FROM sys_tables st INNER JOIN INFORMATION_SCHEMA.INNODB_SYS_TABLES i
ON i.TABLE_ID=st.TABLE_ID;
NAME NAME
test/t1 test/t3
SHOW CREATE TABLE t3;
Table Create Table
t3 CREATE TABLE `t3` (
`c1` int(11) NOT NULL DEFAULT '0',
`c3` int(11) DEFAULT NULL,
`ct` text,
PRIMARY KEY (`c1`),
KEY `c2` (`c3`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
SHOW CREATE TABLE t1c;
Table Create Table
t1c CREATE TABLE `t1c` (
`c1` int(11) NOT NULL,
`c2` int(11) DEFAULT NULL,
`c3` int(11) DEFAULT NULL,
PRIMARY KEY (`c1`),
KEY `c2` (`c2`),
KEY `c3` (`c3`),
CONSTRAINT `t1c2` FOREIGN KEY (`c2`) REFERENCES `t3` (`c3`),
CONSTRAINT `t1c3` FOREIGN KEY (`c3`) REFERENCES `t1p` (`c2`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
ALTER TABLE t3 CHANGE c3
`12345678901234567890123456789012345678901234567890123456789012345` INT;
ERROR 42000: Identifier name '12345678901234567890123456789012345678901234567890123456789012345' is too long
ALTER TABLE t3 CHANGE c3
`1234567890123456789012345678901234567890123456789012345678901234` INT;
SHOW CREATE TABLE t3;
Table Create Table
t3 CREATE TABLE `t3` (
`c1` int(11) NOT NULL DEFAULT '0',
`1234567890123456789012345678901234567890123456789012345678901234` int(11) DEFAULT NULL,
`ct` text,
PRIMARY KEY (`c1`),
KEY `c2` (`1234567890123456789012345678901234567890123456789012345678901234`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
ALTER TABLE t3 CHANGE
`1234567890123456789012345678901234567890123456789012345678901234`
`倀倁倂倃倄倅倆倇倈倉倊個倌倍倎倏倐們倒倓倔倕倖倗倘候倚倛倜倝倞借倠倡倢倣値倥倦倧倨倩倪倫倬倭倮倯倰倱倲倳倴倵倶倷倸倹债倻值倽倾倿偀` INT;
ERROR 42000: Identifier name '倀倁倂倃倄倅倆倇倈倉倊個倌倍倎倏倐們倒倓倔倕倖倗倘候倚倛倜倝倞借倠' is too long
ALTER TABLE t3 CHANGE
`1234567890123456789012345678901234567890123456789012345678901234`
`倀倁倂倃倄倅倆倇倈倉倊個倌倍倎倏倐們倒倓倔倕倖倗倘候倚倛倜倝倞借倠倡倢倣値倥倦倧倨倩倪倫倬倭倮倯倰倱倲倳倴倵倶倷倸倹债倻值倽倾倿ä` INT;
ERROR 42000: Identifier name '倀倁倂倃倄倅倆倇倈倉倊個倌倍倎倏倐們倒倓倔倕倖倗倘候倚倛倜倝倞借倠' is too long
ALTER TABLE t3 CHANGE
`1234567890123456789012345678901234567890123456789012345678901234`
`倀倁倂倃倄倅倆倇倈倉倊個倌倍倎倏倐們倒倓倔倕倖倗倘候倚倛倜倝倞借倠倡倢倣値倥倦倧倨倩倪倫倬倭倮倯倰倱倲倳倴倵倶倷倸倹债倻值倽倾ä` INT;
ALTER TABLE t3 CHANGE
`倀倁倂倃倄倅倆倇倈倉倊個倌倍倎倏倐們倒倓倔倕倖倗倘候倚倛倜倝倞借倠倡倢倣値倥倦倧倨倩倪倫倬倭倮倯倰倱倲倳倴倵倶倷倸倹债倻值倽倾Ä`
c3 INT;
ALTER TABLE t3 CHANGE c3 𐌀𐌁𐌂𐌃𐌄𐌅𐌆𐌇𐌈𐌉𐌊𐌋𐌌𐌍𐌎𐌏𐌐𐌑𐌒𐌓𐌔𐌕𐌖𐌗𐌘𐌙𐌚𐌛𐌜 INT;
ERROR HY000: Invalid utf8 character string: '\xF0\x90\x8C\x80\xF0\x90\x8C\x81\xF0\x90\x8C\x82\xF0\x90\x8C\x83'
ALTER TABLE t3 CHANGE c3 😲 INT;
ERROR HY000: Invalid utf8 character string: '\xF0\x9F\x98\xB2'
ALTER TABLE t3 RENAME TO t2;
SELECT st.NAME, i.NAME
FROM sys_tables st INNER JOIN INFORMATION_SCHEMA.INNODB_SYS_TABLES i
ON i.TABLE_ID=st.TABLE_ID;
NAME NAME
test/t1 test/t2
SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`c1` int(11) NOT NULL DEFAULT '0',
`c3` int(11) DEFAULT NULL,
`ct` text,
PRIMARY KEY (`c1`),
KEY `c2` (`c3`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
RENAME TABLE t2 TO t1;
SELECT st.NAME, i.NAME
FROM sys_tables st INNER JOIN INFORMATION_SCHEMA.INNODB_SYS_TABLES i
ON i.TABLE_ID=st.TABLE_ID;
NAME NAME
test/t1 test/t1
SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN
FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i
INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID;
NAME POS MTYPE PRTYPE LEN
c1 0 6 1283 4
c3 1 6 1027 4
ct 2 5 524540 10
SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i
INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID;
NAME POS NAME
PRIMARY 0 c1
c2 0 c3
SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i
INNER JOIN sys_foreign sf ON i.ID = sf.ID;
ID FOR_COL_NAME REF_COL_NAME POS
test/t1c2 c2 c3 0
test/t1c3 c3 c2 0
ALTER TABLE t1 DROP INDEX c2;
ERROR HY000: Cannot drop index 'c2': needed in a foreign key constraint
ALTER TABLE t1 DROP INDEX c4;
ERROR 42000: Can't DROP 'c4'; check that column/key exists
ALTER TABLE t1c DROP FOREIGN KEY c2;
ERROR 42000: Can't DROP 'c2'; check that column/key exists
ALTER TABLE t1c DROP FOREIGN KEY t1c2, DROP FOREIGN KEY c2;
ERROR 42000: Can't DROP 'c2'; check that column/key exists
ALTER TABLE t1c DROP FOREIGN KEY t1c2, DROP FOREIGN KEY c2, DROP INDEX c2;
ERROR 42000: Can't DROP 'c2'; check that column/key exists
ALTER TABLE t1c DROP INDEX c2;
ERROR HY000: Cannot drop index 'c2': needed in a foreign key constraint
ALTER TABLE t1c DROP FOREIGN KEY ẗ1C2;
ERROR 42000: Can't DROP 'ẗ1C2'; check that column/key exists
SHOW CREATE TABLE t1c;
Table Create Table
t1c CREATE TABLE `t1c` (
`c1` int(11) NOT NULL,
`c2` int(11) DEFAULT NULL,
`c3` int(11) DEFAULT NULL,
PRIMARY KEY (`c1`),
KEY `c2` (`c2`),
KEY `c3` (`c3`),
CONSTRAINT `t1c2` FOREIGN KEY (`c2`) REFERENCES `t1` (`c3`),
CONSTRAINT `t1c3` FOREIGN KEY (`c3`) REFERENCES `t1p` (`c2`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
SET foreign_key_checks=0;
DROP TABLE t1p;
SET foreign_key_checks=1;
SHOW CREATE TABLE t1c;
Table Create Table
t1c CREATE TABLE `t1c` (
`c1` int(11) NOT NULL,
`c2` int(11) DEFAULT NULL,
`c3` int(11) DEFAULT NULL,
PRIMARY KEY (`c1`),
KEY `c2` (`c2`),
KEY `c3` (`c3`),
CONSTRAINT `t1c2` FOREIGN KEY (`c2`) REFERENCES `t1` (`c3`),
CONSTRAINT `t1c3` FOREIGN KEY (`c3`) REFERENCES `t1p` (`c2`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN
FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i
INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID;
NAME POS MTYPE PRTYPE LEN
c1 0 6 1283 4
c3 1 6 1027 4
ct 2 5 524540 10
SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i
INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID;
NAME POS NAME
PRIMARY 0 c1
c2 0 c3
SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i
INNER JOIN sys_foreign sf ON i.ID = sf.ID;
ID FOR_COL_NAME REF_COL_NAME POS
test/t1c2 c2 c3 0
test/t1c3 c3 c2 0
CREATE TABLE t1p (c1 INT PRIMARY KEY, c2 INT, INDEX(c2)) ENGINE=InnoDB;
ALTER TABLE t1c DROP INDEX C2, DROP INDEX C3;
ERROR HY000: Cannot drop index 'c2': needed in a foreign key constraint
ALTER TABLE t1c DROP INDEX C3;
ERROR HY000: Cannot drop index 'c3': needed in a foreign key constraint
SET foreign_key_checks=0;
ALTER TABLE t1c DROP INDEX C3;
SET foreign_key_checks=1;
SHOW CREATE TABLE t1c;
Table Create Table
t1c CREATE TABLE `t1c` (
`c1` int(11) NOT NULL,
`c2` int(11) DEFAULT NULL,
`c3` int(11) DEFAULT NULL,
PRIMARY KEY (`c1`),
KEY `c2` (`c2`),
CONSTRAINT `t1c2` FOREIGN KEY (`c2`) REFERENCES `t1` (`c3`),
CONSTRAINT `t1c3` FOREIGN KEY (`c3`) REFERENCES `t1p` (`c2`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN
FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i
INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID;
NAME POS MTYPE PRTYPE LEN
c1 0 6 1283 4
c3 1 6 1027 4
ct 2 5 524540 10
SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i
INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID;
NAME POS NAME
PRIMARY 0 c1
c2 0 c3
SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i
INNER JOIN sys_foreign sf ON i.ID = sf.ID;
ID FOR_COL_NAME REF_COL_NAME POS
test/t1c2 c2 c3 0
test/t1c3 c3 c2 0
ALTER TABLE t1c DROP FOREIGN KEY t1C3;
SHOW CREATE TABLE t1c;
Table Create Table
t1c CREATE TABLE `t1c` (
`c1` int(11) NOT NULL,
`c2` int(11) DEFAULT NULL,
`c3` int(11) DEFAULT NULL,
PRIMARY KEY (`c1`),
KEY `c2` (`c2`),
CONSTRAINT `t1c2` FOREIGN KEY (`c2`) REFERENCES `t1` (`c3`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN
FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i
INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID;
NAME POS MTYPE PRTYPE LEN
c1 0 6 1283 4
c3 1 6 1027 4
ct 2 5 524540 10
SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i
INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID;
NAME POS NAME
PRIMARY 0 c1
c2 0 c3
SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i
INNER JOIN sys_foreign sf ON i.ID = sf.ID;
ID FOR_COL_NAME REF_COL_NAME POS
test/t1c2 c2 c3 0
ALTER TABLE t1c DROP INDEX c2, DROP FOREIGN KEY t1C2;
SHOW CREATE TABLE t1c;
Table Create Table
t1c CREATE TABLE `t1c` (
`c1` int(11) NOT NULL,
`c2` int(11) DEFAULT NULL,
`c3` int(11) DEFAULT NULL,
PRIMARY KEY (`c1`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN
FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i
INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID;
NAME POS MTYPE PRTYPE LEN
c1 0 6 1283 4
c3 1 6 1027 4
ct 2 5 524540 10
SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i
INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID;
NAME POS NAME
PRIMARY 0 c1
c2 0 c3
SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i
INNER JOIN sys_foreign sf ON i.ID = sf.ID;
ID FOR_COL_NAME REF_COL_NAME POS
ALTER TABLE t1 DROP INDEX c2, CHANGE c3 c2 INT;
SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN
FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i
INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID;
NAME POS MTYPE PRTYPE LEN
c1 0 6 1283 4
c2 1 6 1027 4
ct 2 5 524540 10
SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i
INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID;
NAME POS NAME
PRIMARY 0 c1
SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i
INNER JOIN sys_foreign sf ON i.ID = sf.ID;
ID FOR_COL_NAME REF_COL_NAME POS
CREATE TABLE t1o LIKE t1;
ALTER TABLE t1 ADD FULLTEXT INDEX (ct),
CHANGE c1 pk INT, ALTER c2 SET DEFAULT 42, RENAME TO tt,
ALGORITHM=INPLACE, LOCK=NONE;
ERROR 0A000: LOCK=NONE is not supported. Reason: Fulltext index creation requires a lock. Try LOCK=SHARED.
ALTER TABLE t1 ADD FULLTEXT INDEX (ct),
CHANGE c1 pk INT, ALTER c2 SET DEFAULT 42, RENAME TO tt,
ALGORITHM=INPLACE, LOCK=SHARED;
Warnings:
Warning 124 InnoDB rebuilding table to add column FTS_DOC_ID
SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN
FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i
INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID;
NAME POS MTYPE PRTYPE LEN
SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i
INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID;
NAME POS NAME
SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i
INNER JOIN sys_foreign sf ON i.ID = sf.ID;
ID FOR_COL_NAME REF_COL_NAME POS
SHOW CREATE TABLE tt;
Table Create Table
tt CREATE TABLE `tt` (
`pk` int(11) NOT NULL DEFAULT '0',
`c2` int(11) DEFAULT '42',
`ct` text,
PRIMARY KEY (`pk`),
FULLTEXT KEY `ct` (`ct`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
ALTER TABLE t1o CHANGE c1 dB_row_Id INT, ALGORITHM=COPY;
ERROR 42000: Incorrect column name 'dB_row_Id'
ALTER TABLE t1o CHANGE c1 dB_row_Id INT, ALGORITHM=INPLACE;
ERROR 42000: Incorrect column name 'DB_ROW_ID'
ALTER TABLE t1o CHANGE c1 DB_TRX_ID INT;
ERROR 42000: Incorrect column name 'DB_TRX_ID'
ALTER TABLE t1o CHANGE c1 db_roll_ptr INT;
ERROR 42000: Incorrect column name 'DB_ROLL_PTR'
ALTER TABLE t1o ADD COLUMN DB_TRX_ID INT;
ERROR 42000: Incorrect column name 'DB_TRX_ID'
ALTER TABLE t1o ADD COLUMN db_roll_ptr INT;
ERROR 42000: Incorrect column name 'db_roll_ptr'
ALTER TABLE t1o ADD FULLTEXT INDEX(ct), ADD COLUMN FTS_DOC_ID BIGINT;
ERROR HY000: Column 'FTS_DOC_ID' is of wrong type for an InnoDB FULLTEXT index
ALTER TABLE t1o ADD FULLTEXT INDEX(ct), ADD COLUMN FTS_DOC_ID BIGINT UNSIGNED;
ERROR HY000: Column 'FTS_DOC_ID' is of wrong type for an InnoDB FULLTEXT index
ALTER TABLE t1o ADD FULLTEXT INDEX(ct),
ADD COLUMN FTS_DOC_ID BIGINT UNSIGNED NOT NULL;
ALTER TABLE t1o ADD FULLTEXT INDEX(ct), ADD COLUMN FTS_DOC_ID INT;
ERROR 42S21: Duplicate column name 'FTS_DOC_ID'
ALTER TABLE t1o DROP COLUMN FTS_DOC_ID, ALGORITHM=INPLACE;
ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: Cannot drop or rename FTS_DOC_ID. Try ALGORITHM=COPY.
ALTER TABLE t1o DROP COLUMN FTS_DOC_ID, DROP INDEX ct, ALGORITHM=INPLACE;
ALTER TABLE t1o ADD FULLTEXT INDEX(ct), ADD COLUMN cu TEXT;
Warnings:
Warning 124 InnoDB rebuilding table to add column FTS_DOC_ID
ALTER TABLE t1o ADD FULLTEXT INDEX(cu), ADD COLUMN FTS_DOC_ID BIGINT,
ALGORITHM=INPLACE;
ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: InnoDB presently supports one FULLTEXT index creation at a time. Try ALGORITHM=COPY.
ALTER TABLE t1o ADD FULLTEXT INDEX(cu), ADD COLUMN FTS_DOC_ID BIGINT;
ERROR 42000: Incorrect column name 'FTS_DOC_ID'
ALTER TABLE t1o ADD FULLTEXT INDEX(cu), ADD COLUMN FTS_DOC_ID BIGINT UNSIGNED,
ALGORITHM=INPLACE;
ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: InnoDB presently supports one FULLTEXT index creation at a time. Try ALGORITHM=COPY.
ALTER TABLE t1o ADD FULLTEXT INDEX(cu), ADD COLUMN FTS_DOC_ID BIGINT UNSIGNED;
ERROR 42000: Incorrect column name 'FTS_DOC_ID'
ALTER TABLE t1o ADD FULLTEXT INDEX(cu),
ADD COLUMN FTS_DOC_ID BIGINT UNSIGNED NOT NULL, ALGORITHM=INPLACE;
ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: InnoDB presently supports one FULLTEXT index creation at a time. Try ALGORITHM=COPY.
ALTER TABLE t1o ADD COLUMN FTS_DOC_ID BIGINT UNSIGNED NOT NULL,
ALGORITHM=INPLACE;
ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: InnoDB presently supports one FULLTEXT index creation at a time. Try ALGORITHM=COPY.
ALTER TABLE t1o ADD COLUMN FTS_DOC_ID BIGINT UNSIGNED NOT NULL;
ALTER TABLE t1o DROP COLUMN FTS_DOC_ID, ALGORITHM=INPLACE;
ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: Cannot drop or rename FTS_DOC_ID. Try ALGORITHM=COPY.
ALTER TABLE t1o DROP COLUMN FTS_DOC_ID;
ALTER TABLE t1o ADD FULLTEXT INDEX(ct), CHANGE c1 FTS_DOC_ID INT,
ALGORITHM=COPY;
ERROR 42000: Incorrect column name 'FTS_DOC_ID'
ALTER TABLE t1o ADD FULLTEXT INDEX(ct), CHANGE c1 FTS_DOC_ID INT,
ALGORITHM=INPLACE;
ERROR 42000: Incorrect column name 'FTS_DOC_ID'
ALTER TABLE t1o ADD FULLTEXT INDEX(ct), CHANGE c1 FTS_Doc_ID INT,
ALGORITHM=INPLACE;
ERROR 42000: Incorrect column name 'FTS_DOC_ID'
ALTER TABLE t1o ADD FULLTEXT INDEX(ct),
CHANGE c1 FTS_DOC_ID BIGINT UNSIGNED NOT NULL,
ALGORITHM=INPLACE;
ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: Cannot change column type INPLACE. Try ALGORITHM=COPY.
CREATE TABLE t1n LIKE t1o;
ALTER TABLE t1n ADD FULLTEXT INDEX(ct);
ALTER TABLE t1n CHANGE c1 Fts_DOC_ID INT, ALGORITHM=INPLACE;
ERROR 42000: Incorrect column name 'FTS_DOC_ID'
ALTER TABLE t1n CHANGE c1 Fts_DOC_ID INT, ALGORITHM=COPY;
ERROR 42000: Incorrect column name 'Fts_DOC_ID'
ALTER TABLE t1n CHANGE FTS_DOC_ID c11 INT, ALGORITHM=INPLACE;
ERROR 42S22: Unknown column 'FTS_DOC_ID' in 't1n'
ALTER TABLE t1n CHANGE c1 FTS_DOC_ïD INT, ALGORITHM=INPLACE;
ALTER TABLE t1n CHANGE FTS_DOC_ÏD c1 INT, ALGORITHM=INPLACE;
ALTER TABLE t1n CHANGE c1 c2 INT, CHANGE c2 ct INT, CHANGE ct c1 TEXT,
ALGORITHM=INPLACE;
SHOW CREATE TABLE t1n;
Table Create Table
t1n CREATE TABLE `t1n` (
`c2` int(11) NOT NULL DEFAULT '0',
`ct` int(11) DEFAULT NULL,
`c1` text,
`cu` text,
PRIMARY KEY (`c2`),
FULLTEXT KEY `ct` (`c1`),
FULLTEXT KEY `ct_2` (`c1`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
ALTER TABLE t1n CHANGE c2 c1 INT, CHANGE ct c2 INT, CHANGE c1 ct TEXT,
ALGORITHM=COPY;
SHOW CREATE TABLE t1n;
Table Create Table
t1n CREATE TABLE `t1n` (
`c1` int(11) NOT NULL DEFAULT '0',
`c2` int(11) DEFAULT NULL,
`ct` text,
`cu` text,
PRIMARY KEY (`c1`),
FULLTEXT KEY `ct` (`ct`),
FULLTEXT KEY `ct_2` (`ct`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
ALTER TABLE t1n ADD INDEX(c2), CHANGE c2 c4 INT, ALGORITHM=INPLACE;
ERROR 42000: Key column 'c2' doesn't exist in table
ALTER TABLE t1n ADD INDEX(c2), CHANGE c2 c4 INT, ALGORITHM=COPY;
ERROR 42000: Key column 'c2' doesn't exist in table
ALTER TABLE t1n ADD INDEX(c4), CHANGE c2 c4 INT, ALGORITHM=INPLACE;
ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: InnoDB presently supports one FULLTEXT index creation at a time. Try ALGORITHM=COPY.
ALTER TABLE t1n CHANGE c2 c4 INT, LOCK=NONE;
ALTER TABLE t1n ADD INDEX(c4), LOCK=NONE;
SHOW CREATE TABLE t1n;
Table Create Table
t1n CREATE TABLE `t1n` (
`c1` int(11) NOT NULL DEFAULT '0',
`c4` int(11) DEFAULT NULL,
`ct` text,
`cu` text,
PRIMARY KEY (`c1`),
KEY `c4` (`c4`),
FULLTEXT KEY `ct` (`ct`),
FULLTEXT KEY `ct_2` (`ct`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
ALTER TABLE t1n DROP INDEX c4;
ALTER TABLE t1n CHANGE c4 c1 INT, ADD INDEX(c1), ALGORITHM=INPLACE;
ERROR 42S21: Duplicate column name 'c1'
ALTER TABLE t1n CHANGE c4 c11 INT, ADD INDEX(c11), ALGORITHM=INPLACE;
ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: InnoDB presently supports one FULLTEXT index creation at a time. Try ALGORITHM=COPY.
ALTER TABLE t1n CHANGE c4 c11 INT, LOCK=NONE;
ALTER TABLE t1n ADD INDEX(c11), LOCK=NONE;
SHOW CREATE TABLE t1n;
Table Create Table
t1n CREATE TABLE `t1n` (
`c1` int(11) NOT NULL DEFAULT '0',
`c11` int(11) DEFAULT NULL,
`ct` text,
`cu` text,
PRIMARY KEY (`c1`),
KEY `c11` (`c11`),
FULLTEXT KEY `ct` (`ct`),
FULLTEXT KEY `ct_2` (`ct`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
DROP TABLE t1n;
ALTER TABLE t1o MODIFY c1 BIGINT UNSIGNED NOT NULL, DROP INDEX ct,
ALGORITHM=INPLACE;
ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: Cannot change column type INPLACE. Try ALGORITHM=COPY.
ALTER TABLE t1o MODIFY c1 BIGINT UNSIGNED NOT NULL, DROP INDEX ct;
ALTER TABLE t1o CHANGE c1 FTS_DOC_ID BIGINT UNSIGNED NOT NULL,
ALGORITHM=INPLACE;
ALTER TABLE t1o ADD FULLTEXT INDEX(ct), ALGORITHM=INPLACE;
ALTER TABLE t1o CHANGE FTS_DOC_ID foo_id BIGINT UNSIGNED NOT NULL,
ALGORITHM=INPLACE;
ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: Cannot drop or rename FTS_DOC_ID. Try ALGORITHM=COPY.
SELECT sc.pos FROM information_schema.innodb_sys_columns sc
INNER JOIN information_schema.innodb_sys_tables st
ON sc.TABLE_ID=st.TABLE_ID
WHERE st.NAME='test/t1o' AND sc.NAME='FTS_DOC_ID';
pos
0
SHOW CREATE TABLE t1o;
Table Create Table
t1o CREATE TABLE `t1o` (
`FTS_DOC_ID` bigint(20) unsigned NOT NULL,
`c2` int(11) DEFAULT NULL,
`ct` text,
`cu` text,
PRIMARY KEY (`FTS_DOC_ID`),
FULLTEXT KEY `ct` (`ct`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
ALTER TABLE t1o CHANGE FTS_DOC_ID foo_id BIGINT UNSIGNED NOT NULL,
DROP INDEX ct, ALGORITHM=INPLACE;
SHOW CREATE TABLE t1o;
Table Create Table
t1o CREATE TABLE `t1o` (
`foo_id` bigint(20) unsigned NOT NULL,
`c2` int(11) DEFAULT NULL,
`ct` text,
`cu` text,
PRIMARY KEY (`foo_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
DROP TABLE t1c, t1p, sys_tables, sys_indexes, sys_foreign;
CREATE TABLE sys_tables SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES
WHERE NAME='test/t1o';
CREATE TABLE sys_indexes SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES i
INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID;
CREATE TABLE sys_foreign SELECT i.*
FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN i WHERE FOR_NAME='test/t1o';
SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN
FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i
INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID;
NAME POS MTYPE PRTYPE LEN
foo_id 0 6 1800 8
c2 1 6 1027 4
ct 2 5 524540 10
cu 3 5 524540 10
SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i
INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID;
NAME POS NAME
PRIMARY 0 foo_id
SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i
INNER JOIN sys_foreign sf ON i.ID = sf.ID;
ID FOR_COL_NAME REF_COL_NAME POS
ALTER TABLE t1o ADD UNIQUE INDEX FTS_DOC_ID_INDEX(FTS_DOC_ID),
ADD FULLTEXT INDEX(ct),
CHANGE foo_id FTS_DOC_ID BIGINT UNSIGNED NOT NULL;
ALTER TABLE t1o DROP INDEX ct, DROP INDEX FTS_DOC_ID_INDEX,
CHANGE FTS_DOC_ID foo_id BIGINT UNSIGNED NOT NULL;
ALTER TABLE t1o ADD UNIQUE INDEX FTS_DOC_ID_INDEX(foo_id);
call mtr.add_suppression("Error: no matching column for .FTS_DOC_ID. in index .ct.--temporary-- of table .test...t1o");
ALTER TABLE t1o CHANGE foo_id FTS_DOC_ID BIGINT UNSIGNED NOT NULL,
ADD FULLTEXT INDEX(ct);
ERROR HY000: Incorrect key file for table 't1o'; try to repair it
DROP TABLE sys_indexes;
CREATE TABLE sys_indexes SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES i
INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID;
SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN
FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i
INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID;
NAME POS MTYPE PRTYPE LEN
SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i
INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID;
NAME POS NAME
SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i
INNER JOIN sys_foreign sf ON i.ID = sf.ID;
ID FOR_COL_NAME REF_COL_NAME POS
DROP TABLE tt, t1o, sys_tables, sys_indexes, sys_foreign;
CREATE TABLE t (t TEXT, FULLTEXT(t)) ENGINE=InnoDB;
DROP INDEX t ON t;
SELECT SUBSTRING(name, LOCATE('_', name) - 3, 5) AS prefix, name
FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES
WHERE name LIKE '%FTS_%' ORDER BY 1, 2;
prefix name
FTS_0 test/FTS_AUX_BEING_DELETED
FTS_0 test/FTS_AUX_BEING_DELETED_CACHE
FTS_0 test/FTS_AUX_CONFIG
FTS_0 test/FTS_AUX_DELETED
FTS_0 test/FTS_AUX_DELETED_CACHE
SELECT sc.pos, sc.NAME FROM information_schema.innodb_sys_columns sc
INNER JOIN information_schema.innodb_sys_tables st
ON sc.TABLE_ID=st.TABLE_ID
WHERE st.NAME='test/t';
pos NAME
0 t
1 FTS_DOC_ID
ALTER TABLE t ROW_FORMAT=REDUNDANT, ALGORITHM=INPLACE;
SELECT SUBSTRING(name, LOCATE('_', name) - 3, 5) AS prefix, name
FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES
WHERE name LIKE '%FTS_%' ORDER BY 1, 2;
prefix name
ALTER TABLE t ADD FULLTEXT INDEX(t);
Warnings:
Warning 124 InnoDB rebuilding table to add column FTS_DOC_ID
SELECT sc.pos, sc.NAME FROM information_schema.innodb_sys_columns sc
INNER JOIN information_schema.innodb_sys_tables st
ON sc.TABLE_ID=st.TABLE_ID
WHERE st.NAME='test/t';
pos NAME
0 t
1 FTS_DOC_ID
DROP TABLE t;
#
# Bug #19465984 INNODB DATA DICTIONARY IS NOT UPDATED WHILE
# RENAMING THE COLUMN
#
CREATE TABLE t1(c1 INT NOT NULL, PRIMARY KEY(c1))ENGINE=INNODB;
CREATE TABLE t2(c2 INT NOT NULL, FOREIGN KEY(c2) REFERENCES t1(c1))ENGINE=INNODB;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` int(11) NOT NULL,
PRIMARY KEY (`c1`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`c2` int(11) NOT NULL,
KEY `c2` (`c2`),
CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`c2`) REFERENCES `t1` (`c1`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
ALTER TABLE t1 CHANGE COLUMN c1 C1 INT;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`C1` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`C1`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`c2` int(11) NOT NULL,
KEY `c2` (`c2`),
CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`c2`) REFERENCES `t1` (`c1`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`C1` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`C1`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`c2` int(11) NOT NULL,
KEY `c2` (`c2`),
CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`c2`) REFERENCES `t1` (`c1`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
DROP TABLE t2, t1;
#
# BUG 20029625 - HANDLE_FATAL_SIGNAL (SIG=11) IN
# DICT_MEM_TABLE_COL_RENAME_LOW
#
CREATE TABLE parent(a INT, b INT, KEY(a, b)) ENGINE = InnoDB;
CREATE TABLE t1(a1 INT, a2 INT) ENGINE = InnoDB;
set foreign_key_checks=0;
ALTER TABLE t1 ADD CONSTRAINT fk_a FOREIGN KEY(a1, a2) REFERENCES parent(a, b) ON DELETE SET NULL ON UPDATE CASCADE;
ALTER TABLE t1 CHANGE a2 a3 INT,ADD CONSTRAINT fk_1 FOREIGN KEY(a1, a3) REFERENCES parent(a, b) ON DELETE SET NULL ON UPDATE CASCADE;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a1` int(11) DEFAULT NULL,
`a3` int(11) DEFAULT NULL,
KEY `fk_1` (`a1`,`a3`),
CONSTRAINT `fk_1` FOREIGN KEY (`a1`, `a3`) REFERENCES `parent` (`a`, `b`) ON DELETE SET NULL ON UPDATE CASCADE,
CONSTRAINT `fk_a` FOREIGN KEY (`a1`, `a3`) REFERENCES `parent` (`a`, `b`) ON DELETE SET NULL ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
ALTER TABLE t1 CHANGE a3 a4 INT;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a1` int(11) DEFAULT NULL,
`a4` int(11) DEFAULT NULL,
KEY `fk_1` (`a1`,`a4`),
CONSTRAINT `fk_1` FOREIGN KEY (`a1`, `a4`) REFERENCES `parent` (`a`, `b`) ON DELETE SET NULL ON UPDATE CASCADE,
CONSTRAINT `fk_a` FOREIGN KEY (`a1`, `a4`) REFERENCES `parent` (`a`, `b`) ON DELETE SET NULL ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
ALTER TABLE parent CHANGE b c INT;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a1` int(11) DEFAULT NULL,
`a4` int(11) DEFAULT NULL,
KEY `fk_1` (`a1`,`a4`),
CONSTRAINT `fk_1` FOREIGN KEY (`a1`, `a4`) REFERENCES `parent` (`a`, `c`) ON DELETE SET NULL ON UPDATE CASCADE,
CONSTRAINT `fk_a` FOREIGN KEY (`a1`, `a4`) REFERENCES `parent` (`a`, `c`) ON DELETE SET NULL ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
DROP TABLE t1, parent;
#
#BUG#21514135 SCHEMA MISMATCH ERROR WHEN IMPORTING TABLESPACE AFTER
#DROPPING AN INDEX
#
CREATE DATABASE source_db;
CREATE DATABASE dest_db;
CREATE TABLE source_db.t1 (
id int(11) NOT NULL,
age int(11) DEFAULT NULL,
name varchar(20),
PRIMARY KEY (id),
KEY index1 (age)
) ENGINE=InnoDB;
ALTER TABLE source_db.t1 DROP INDEX index1, ADD INDEX index2(name, age), algorithm=inplace;
FLUSH TABLES source_db.t1 FOR EXPORT;
UNLOCK TABLES;
USE dest_db;
CREATE TABLE `t1` (
`id` int(11) NOT NULL,
`age` int(11) DEFAULT NULL,
`name` varchar(20) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `index2` (`name`,`age`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
ALTER TABLE dest_db.t1 DISCARD TABLESPACE;
ALTER TABLE dest_db.t1 IMPORT TABLESPACE;
CHECK TABLE dest_db.t1;
Table Op Msg_type Msg_text
dest_db.t1 check status OK
SHOW CREATE TABLE dest_db.t1;
Table Create Table
t1 CREATE TABLE `t1` (
`id` int(11) NOT NULL,
`age` int(11) DEFAULT NULL,
`name` varchar(20) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `index2` (`name`,`age`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
SELECT * FROM dest_db.t1;
id age name
DROP TABLE dest_db.t1;
ALTER TABLE source_db.t1 DROP INDEX index2, algorithm=inplace;
FLUSH TABLES source_db.t1 FOR EXPORT;
UNLOCK TABLES;
USE dest_db;
CREATE TABLE `t1` (
`id` int(11) NOT NULL,
`age` int(11) DEFAULT NULL,
`name` varchar(20) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
ALTER TABLE dest_db.t1 DISCARD TABLESPACE;
ALTER TABLE dest_db.t1 IMPORT TABLESPACE;
CHECK TABLE dest_db.t1;
Table Op Msg_type Msg_text
dest_db.t1 check status OK
SHOW CREATE TABLE dest_db.t1;
Table Create Table
t1 CREATE TABLE `t1` (
`id` int(11) NOT NULL,
`age` int(11) DEFAULT NULL,
`name` varchar(20) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
SELECT * FROM dest_db.t1;
id age name
DROP TABLE dest_db.t1;
DROP TABLE source_db.t1;
DROP DATABASE source_db;
DROP DATABASE dest_db;
set global innodb_file_per_table=on;
set global innodb_file_format='Barracuda';
CREATE TABLE t1(c1 INT NOT NULL, c2 INT, PRIMARY KEY(c1)) Engine=InnoDB;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` int(11) NOT NULL,
`c2` int(11) DEFAULT NULL,
PRIMARY KEY (`c1`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
INSERT INTO t1 VALUES (1,1),(2,2),(3,3),(4,4),(5,5);
SET @saved_debug_dbug = @@SESSION.debug_dbug;
SET DEBUG_DBUG='+d,ib_build_indexes_too_many_concurrent_trxs, ib_rename_indexes_too_many_concurrent_trxs, ib_drop_index_too_many_concurrent_trxs';
ALTER TABLE t1 ADD UNIQUE INDEX(c2);
ERROR HY000: Too many active concurrent transactions
SET DEBUG_DBUG = @saved_debug_dbug;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` int(11) NOT NULL,
`c2` int(11) DEFAULT NULL,
PRIMARY KEY (`c1`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
DROP TABLE t1;
CREATE TABLE bug13861218 (c1 INT NOT NULL, c2 INT NOT NULL, INDEX(c2))
ENGINE=InnoDB;
INSERT INTO bug13861218 VALUES (8, 0), (4, 0), (0, 0);
SET DEBUG_DBUG = '+d,ib_row_merge_buf_add_two';
CREATE UNIQUE INDEX ui ON bug13861218(c1);
SET DEBUG_DBUG = @saved_debug_dbug;
DROP TABLE bug13861218;
CREATE TABLE bug13861218 (c1 INT NOT NULL, c2 INT UNIQUE) ENGINE=InnoDB;
INSERT INTO bug13861218 VALUES (8, NULL), (4, NULL), (0, NULL);
SET DEBUG_DBUG = '+d,ib_row_merge_buf_add_two';
CREATE UNIQUE INDEX ui ON bug13861218(c1);
SET DEBUG_DBUG = @saved_debug_dbug;
DROP TABLE bug13861218;
set global innodb_file_per_table=1;
set global innodb_file_format=Antelope;
set global innodb_file_format_max=Antelope;
#
# Bug #21762319 ADDING INDEXES ON EMPTY TABLE IS SLOW
# WITH LARGE INNODB_SORT_BUFFER_SIZE.
call mtr.add_suppression("InnoDB: Cannot create temporary merge file");
create table t480(a serial)engine=innodb;
insert into t480
values(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),
(),(),(),(),(),(),(),();
insert into t480 select 0 from t480;
insert into t480 select 0 from t480;
insert into t480 select 0 from t480;
insert into t480 select 0 from t480;
create table t1(f1 int auto_increment not null,
f2 char(200) not null, f3 char(200) not null,
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
SET DEBUG_DBUG = @saved_debug_dbug;
drop table t1, t480;
CREATE TABLE t (a INT PRIMARY KEY, b INT NOT NULL) ENGINE=InnoDB;
INSERT INTO t VALUES(1,2),(2,3);
SET DEBUG_SYNC='alter_table_inplace_after_lock_downgrade SIGNAL do WAIT_FOR m';
SET DEBUG_SYNC='innodb_after_inplace_alter_table SIGNAL scanned WAIT_FOR done';
CREATE INDEX tb ON t(b);
SET DEBUG_SYNC='now WAIT_FOR do';
SET DEBUG_SYNC='row_update_for_mysql_error SIGNAL m WAIT_FOR scanned';
UPDATE t SET a=2 WHERE a=1;
ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
call mtr.add_suppression('InnoDB: record in index .*tb was not found on rollback, trying to insert');
SET DEBUG_SYNC='now SIGNAL done';
SET DEBUG_SYNC='RESET';
DROP TABLE t;
CREATE TABLE parent (a INT PRIMARY KEY, b INT NOT NULL) ENGINE = InnoDB;
INSERT INTO parent VALUES(1,2),(2,3);
CREATE INDEX tb ON parent(b);
INSERT INTO parent VALUES(10,20),(20,30);
CREATE TABLE child (a1 INT PRIMARY KEY, a2 INT) ENGINE = InnoDB;
CREATE INDEX tb ON child(a2);
INSERT INTO child VALUES(10,20);
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;
CREATE INDEX tb ON `#parent`(a, b);
CREATE TABLE `#child` (a1 INT PRIMARY KEY, a2 INT) ENGINE = InnoDB;
CREATE INDEX tb ON `#child`(a1, a2);
SET DEBUG_DBUG = '+d,innodb_test_no_foreign_idx';
ALTER TABLE `#child` ADD CONSTRAINT fk_40 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_40' in the foreign table '#child'
SET DEBUG_DBUG = @saved_debug_dbug;
SHOW ERRORS;
Level Code Message
Error 1821 Failed to add the foreign key constaint. Missing index for constraint 'fk_40' in the foreign table '#child'
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
SET DEBUG_DBUG = '+d,innodb_test_no_reference_idx';
ALTER TABLE child ADD CONSTRAINT fk_42 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_42' in the referenced table 'parent'
SET DEBUG_DBUG = @saved_debug_dbug;
SHOW ERRORS;
Level Code Message
Error 1822 Failed to add the foreign key constaint. Missing index for constraint 'fk_42' in the referenced table 'parent'
SET DEBUG_DBUG = '+d,innodb_test_wrong_fk_option';
ALTER TABLE child ADD CONSTRAINT fk_42 FOREIGN KEY (a1, a2)
REFERENCES parent(a, b) ON DELETE CASCADE ON UPDATE CASCADE,
ALGORITHM = INPLACE;
ERROR HY000: Failed to add the foreign key constraint on table 'child'. Incorrect options in FOREIGN KEY constraint 'test/fk_42'
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
SET DEBUG_DBUG = '+d,innodb_test_cannot_add_fk_system';
ALTER TABLE `#child` ADD CONSTRAINT fk_43 FOREIGN KEY (a1, a2)
REFERENCES `#parent`(a, b) ON DELETE CASCADE ON UPDATE CASCADE,
ALGORITHM = INPLACE;
ERROR HY000: Failed to add the foreign key constraint 'test/fk_43' to system tables
SET DEBUG_DBUG = @saved_debug_dbug;
SHOW ERRORS;
Level Code Message
Error 1823 Failed to add the foreign key constraint 'test/fk_43' to system tables
DROP TABLE `#child`;
DROP TABLE `#parent`;
SET foreign_key_checks = 0;
ALTER TABLE child ADD CONSTRAINT fk_5 FOREIGN KEY (a2) REFERENCES parent(b)
ON DELETE SET NULL ON UPDATE CASCADE,
ADD CONSTRAINT fk_6 FOREIGN KEY (a1, a2)
REFERENCES parent(a, b) ON DELETE CASCADE 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
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
test/fk_5 test/child test/parent 1 6
test/fk_6 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
test/fk_5 a2 b 0
test/fk_6 a1 a 0
test/fk_6 a2 b 1
DROP TABLE child;
DROP TABLE parent;
CREATE TABLE parent (a INT PRIMARY KEY, b INT NOT NULL) ENGINE = InnoDB;
INSERT INTO parent VALUES(1,2),(2,3);
CREATE INDEX tb ON parent(b);
INSERT INTO parent VALUES(10,20),(20,30);
CREATE TABLE child (a1 INT PRIMARY KEY, a2 INT) ENGINE = InnoDB;
CREATE INDEX tb ON child(a2);
INSERT INTO child VALUES(10,20);
SET foreign_key_checks = 0;
ALTER TABLE child DROP INDEX tb, ADD CONSTRAINT fk_4 FOREIGN KEY (a2)
REFERENCES parent(b) ON DELETE CASCADE ON UPDATE CASCADE,
ALGORITHM = INPLACE;
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_4` (`a2`),
CONSTRAINT `fk_4` FOREIGN KEY (`a2`) REFERENCES `parent` (`b`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1
SELECT * FROM information_schema.INNODB_SYS_FOREIGN;
ID FOR_NAME REF_NAME N_COLS TYPE
test/fk_4 test/child test/parent 1 5
SELECT * FROM information_schema.INNODB_SYS_FOREIGN_COLS;
ID FOR_COL_NAME REF_COL_NAME POS
test/fk_4 a2 b 0
SET foreign_key_checks = 1;
DROP TABLE child;
DROP TABLE parent;
CREATE TABLE parent (a INT PRIMARY KEY, b INT NOT NULL) ENGINE = InnoDB;
INSERT INTO parent VALUES(1,2),(2,3);
CREATE INDEX tb ON parent(b);
INSERT INTO parent VALUES(10,20),(20,30);
CREATE TABLE child (a1 INT PRIMARY KEY, a2 INT) ENGINE = InnoDB;
CREATE INDEX tb ON child(a2);
SET foreign_key_checks = 0;
ALTER TABLE child CHANGE a2 a3 INT,
ADD CONSTRAINT fk_1 FOREIGN KEY (a2) REFERENCES parent(b)
ON DELETE SET NULL ON UPDATE CASCADE,
ALGORITHM = INPLACE;
ERROR 42000: Key column 'a2' doesn't exist in table
ALTER TABLE child CHANGE a2 a3 INT,
ADD CONSTRAINT fk_1 FOREIGN KEY (a3) REFERENCES parent(b)
ON DELETE SET NULL ON UPDATE CASCADE,
ALGORITHM = INPLACE;
DROP TABLE child;
DROP TABLE parent;
CREATE TABLE parent (a INT PRIMARY KEY, b INT NOT NULL) ENGINE = InnoDB;
INSERT INTO parent VALUES(1,2),(2,3);
CREATE INDEX tb ON parent(b);
INSERT INTO parent VALUES(10,20),(20,30);
CREATE TABLE child (a1 INT NOT NULL, a2 INT) ENGINE = InnoDB;
CREATE INDEX tb ON child(a2);
SET foreign_key_checks = 0;
SET DEBUG_DBUG = '+d,innodb_test_cannot_add_fk_system';
ALTER TABLE child ADD PRIMARY KEY idx (a3), CHANGE a1 a3 INT,
ADD CONSTRAINT fk_1 FOREIGN KEY (a2) REFERENCES parent(b)
ON DELETE SET NULL ON UPDATE CASCADE,
ALGORITHM = INPLACE;
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;
NAME
SYS_DATAFILES
SYS_FOREIGN
SYS_FOREIGN_COLS
SYS_TABLESPACES
mysql/innodb_index_stats
mysql/innodb_table_stats
test/child
test/parent
ALTER TABLE child ADD PRIMARY KEY idx (a3), CHANGE a1 a3 INT,
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
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;
ALTER TABLE child ADD PRIMARY KEY idx (a1),
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
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;
ALTER TABLE child CHANGE a1 a3 INT,
ADD CONSTRAINT fk_1 FOREIGN KEY (a3) 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 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;
ALTER TABLE child ADD PRIMARY KEY idx (a3), CHANGE a1 a3 INT,
ADD CONSTRAINT fk_1 FOREIGN KEY (a3) REFERENCES parent(b)
ON DELETE SET NULL ON UPDATE CASCADE,
ALGORITHM = INPLACE;
ERROR HY000: Failed to add the foreign key constraint on table 'child'. Incorrect options in FOREIGN KEY constraint 'test/fk_1'
DROP TABLE parent;
DROP TABLE child;
CREATE TABLE parent (a INT PRIMARY KEY, b INT NOT NULL, c INT) ENGINE = InnoDB;
INSERT INTO parent VALUES(1,2,3),(2,3,4);
CREATE INDEX tb ON parent(b);
CREATE TABLE child (a1 INT NOT NULL, a2 INT, a3 INT) ENGINE = InnoDB;
CREATE INDEX tb ON child(a2);
ALTER TABLE child
ADD CONSTRAINT fk_a FOREIGN KEY (a2) REFERENCES parent(b)
ON DELETE SET NULL ON UPDATE CASCADE,
ALGORITHM = INPLACE;
ALTER TABLE child
ADD CONSTRAINT fk_b FOREIGN KEY (a1) REFERENCES parent(a),
ALGORITHM = INPLACE;
ALTER TABLE child CHANGE a2 a2_new INT, CHANGE a1 a1_new INT;
SHOW CREATE TABLE child;
Table Create Table
child CREATE TABLE `child` (
`a1_new` int(11) DEFAULT NULL,
`a2_new` int(11) DEFAULT NULL,
`a3` int(11) DEFAULT NULL,
KEY `tb` (`a2_new`),
KEY `fk_b` (`a1_new`),
CONSTRAINT `fk_a` FOREIGN KEY (`a2_new`) REFERENCES `parent` (`b`) ON DELETE SET NULL ON UPDATE CASCADE,
CONSTRAINT `fk_b` FOREIGN KEY (`a1_new`) REFERENCES `parent` (`a`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
SELECT * from information_schema.INNODB_SYS_FOREIGN;
ID FOR_NAME REF_NAME N_COLS TYPE
test/fk_a test/child test/parent 1 6
test/fk_b test/child test/parent 1 0
SELECT * from information_schema.INNODB_SYS_FOREIGN_COLS;
ID FOR_COL_NAME REF_COL_NAME POS
test/fk_a a2_new b 0
test/fk_b a1_new a 0
ALTER TABLE child
ADD CONSTRAINT fk_new_1 FOREIGN KEY (a1_new) REFERENCES parent(b),
ADD CONSTRAINT fk_new_2 FOREIGN KEY (a2_new) REFERENCES parent(a),
ADD CONSTRAINT fk_new_3 FOREIGN KEY (a3) REFERENCES parent(c),
ALGORITHM = INPLACE;
ERROR HY000: Failed to add the foreign key constaint. Missing index for constraint 'fk_new_3' in the referenced table 'parent'
SHOW CREATE TABLE child;
Table Create Table
child CREATE TABLE `child` (
`a1_new` int(11) DEFAULT NULL,
`a2_new` int(11) DEFAULT NULL,
`a3` int(11) DEFAULT NULL,
KEY `tb` (`a2_new`),
KEY `fk_b` (`a1_new`),
CONSTRAINT `fk_a` FOREIGN KEY (`a2_new`) REFERENCES `parent` (`b`) ON DELETE SET NULL ON UPDATE CASCADE,
CONSTRAINT `fk_b` FOREIGN KEY (`a1_new`) REFERENCES `parent` (`a`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
SELECT * from information_schema.INNODB_SYS_FOREIGN;
ID FOR_NAME REF_NAME N_COLS TYPE
test/fk_a test/child test/parent 1 6
test/fk_b test/child test/parent 1 0
SELECT * from information_schema.INNODB_SYS_FOREIGN_COLS;
ID FOR_COL_NAME REF_COL_NAME POS
test/fk_a a2_new b 0
test/fk_b a1_new a 0
ALTER TABLE child
ADD CONSTRAINT fk_new_1 FOREIGN KEY (a1_new) REFERENCES parent(b),
ADD CONSTRAINT fk_new_2 FOREIGN KEY (a2_new) REFERENCES parent(a),
ADD CONSTRAINT fk_new_3 FOREIGN KEY (a3) REFERENCES parent(a),
ALGORITHM = INPLACE;
SHOW CREATE TABLE child;
Table Create Table
child CREATE TABLE `child` (
`a1_new` int(11) DEFAULT NULL,
`a2_new` int(11) DEFAULT NULL,
`a3` int(11) DEFAULT NULL,
KEY `tb` (`a2_new`),
KEY `fk_new_1` (`a1_new`),
KEY `fk_new_3` (`a3`),
CONSTRAINT `fk_a` FOREIGN KEY (`a2_new`) REFERENCES `parent` (`b`) ON DELETE SET NULL ON UPDATE CASCADE,
CONSTRAINT `fk_b` FOREIGN KEY (`a1_new`) REFERENCES `parent` (`a`),
CONSTRAINT `fk_new_1` FOREIGN KEY (`a1_new`) REFERENCES `parent` (`b`),
CONSTRAINT `fk_new_2` FOREIGN KEY (`a2_new`) REFERENCES `parent` (`a`),
CONSTRAINT `fk_new_3` FOREIGN KEY (`a3`) REFERENCES `parent` (`a`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
SELECT * from information_schema.INNODB_SYS_FOREIGN;
ID FOR_NAME REF_NAME N_COLS TYPE
test/fk_a test/child test/parent 1 6
test/fk_b test/child test/parent 1 0
test/fk_new_1 test/child test/parent 1 0
test/fk_new_2 test/child test/parent 1 0
test/fk_new_3 test/child test/parent 1 0
SELECT * from information_schema.INNODB_SYS_FOREIGN_COLS;
ID FOR_COL_NAME REF_COL_NAME POS
test/fk_a a2_new b 0
test/fk_b a1_new a 0
test/fk_new_1 a1_new b 0
test/fk_new_2 a2_new a 0
test/fk_new_3 a3 a 0
DROP TABLE child;
CREATE TABLE child (a1 INT NOT NULL, a2 INT, a3 INT) ENGINE = InnoDB;
CREATE INDEX tb ON child(a2);
ALTER TABLE child ADD PRIMARY KEY idx (a1),
ADD CONSTRAINT fk_new_1 FOREIGN KEY (a1) REFERENCES parent(b),
ADD CONSTRAINT fk_new_2 FOREIGN KEY (a2) REFERENCES parent(a),
ADD CONSTRAINT fk_new_3 FOREIGN KEY (a3) REFERENCES parent(c),
ALGORITHM = INPLACE;
ERROR HY000: Failed to add the foreign key constaint. Missing index for constraint 'fk_new_3' in the referenced table 'parent'
SHOW CREATE TABLE child;
Table Create Table
child CREATE TABLE `child` (
`a1` int(11) NOT NULL,
`a2` int(11) DEFAULT NULL,
`a3` int(11) DEFAULT NULL,
KEY `tb` (`a2`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
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
ALTER TABLE child ADD PRIMARY KEY idx (a1),
ADD CONSTRAINT fk_new_1 FOREIGN KEY (a1) REFERENCES parent(b),
ADD CONSTRAINT fk_new_2 FOREIGN KEY (a2) REFERENCES parent(a),
ADD CONSTRAINT fk_new_3 FOREIGN KEY (a3) REFERENCES parent(a),
ALGORITHM = INPLACE;
SHOW CREATE TABLE child;
Table Create Table
child CREATE TABLE `child` (
`a1` int(11) NOT NULL,
`a2` int(11) DEFAULT NULL,
`a3` int(11) DEFAULT NULL,
PRIMARY KEY (`a1`),
KEY `tb` (`a2`),
KEY `fk_new_3` (`a3`),
CONSTRAINT `fk_new_1` FOREIGN KEY (`a1`) REFERENCES `parent` (`b`),
CONSTRAINT `fk_new_2` FOREIGN KEY (`a2`) REFERENCES `parent` (`a`),
CONSTRAINT `fk_new_3` FOREIGN KEY (`a3`) REFERENCES `parent` (`a`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
SELECT * from information_schema.INNODB_SYS_FOREIGN;
ID FOR_NAME REF_NAME N_COLS TYPE
test/fk_new_1 test/child test/parent 1 0
test/fk_new_2 test/child test/parent 1 0
test/fk_new_3 test/child test/parent 1 0
SELECT * from information_schema.INNODB_SYS_FOREIGN_COLS;
ID FOR_COL_NAME REF_COL_NAME POS
test/fk_new_1 a1 b 0
test/fk_new_2 a2 a 0
test/fk_new_3 a3 a 0
SET foreign_key_checks = 1;
DROP TABLE child;
DROP TABLE parent;
CREATE TABLE Parent (a INT PRIMARY KEY, b INT NOT NULL) ENGINE = InnoDB;
INSERT INTO Parent VALUES(1,2),(2,3);
CREATE INDEX tb ON Parent(b);
INSERT INTO Parent VALUES(10,20),(20,30);
CREATE TABLE Child (a1 INT PRIMARY KEY, a2 INT) ENGINE = InnoDB;
CREATE INDEX tb ON Child(a2);
INSERT INTO Child VALUES(10,20);
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;
DROP TABLE Child;
DROP TABLE Parent;
CREATE TABLE `t2`(a int,c int,d int) ENGINE=INNODB;
CREATE TABLE `t3`(a int,c int,d int) ENGINE=INNODB;
CREATE INDEX idx ON t3(a);
ALTER TABLE `t2` ADD CONSTRAINT `fw` FOREIGN KEY (`c`) REFERENCES t3 (a);
ALTER TABLE `t2` ADD CONSTRAINT `e` foreign key (`d`) REFERENCES t3(a);
ALTER TABLE `t3` ADD CONSTRAINT `e` foreign key (`c`) REFERENCES `t2`(`c`) ON UPDATE SET NULL;
ERROR HY000: Failed to add the foreign key constraint 'test/e' to system tables
SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN;
ID FOR_NAME REF_NAME N_COLS TYPE
test/e test/t2 test/t3 1 0
test/fw test/t2 test/t3 1 0
SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS;
ID FOR_COL_NAME REF_COL_NAME POS
test/e d a 0
test/fw c a 0
DROP TABLE t2;
DROP TABLE t3;
CREATE TABLE t (a INT PRIMARY KEY, c TEXT) ENGINE=InnoDB;
CREATE TABLE u (a INT PRIMARY KEY, b INT, c INT NOT NULL) ENGINE=InnoDB;
INSERT INTO t VALUES (1,'aa');
BEGIN;
INSERT INTO u SET a=1, c=1;
INSERT INTO u SELECT a+1,NULL,a+1 FROM u;
INSERT INTO u SELECT a+2,NULL,a+2 FROM u;
INSERT INTO u SELECT a+4,NULL,a+4 FROM u;
INSERT INTO u SELECT a+8,NULL,a+8 FROM u;
INSERT INTO u SELECT a+16,NULL,a+16 FROM u;
INSERT INTO u SELECT a+32,NULL,a+32 FROM u;
INSERT INTO u SELECT a+64,NULL,a+64 FROM u;
INSERT INTO u SELECT a+128,NULL,a+64 FROM u;
INSERT INTO u SELECT a+256,NULL,a+64 FROM u;
COMMIT;
BEGIN;
DELETE FROM u;
SET DEBUG_SYNC='row_log_apply_before SIGNAL created_u WAIT_FOR dml_done_u';
ALTER TABLE u ADD INDEX (c);
COMMIT;
SET DEBUG_SYNC='now WAIT_FOR created_u';
SELECT state FROM information_schema.processlist
WHERE info='ALTER TABLE u ADD INDEX (c)';
state
debug sync point: row_log_apply_before
SET DEBUG_SYNC='row_log_apply_before SIGNAL created_t WAIT_FOR dml_done_t';
CREATE INDEX c1 ON t (c(1));
SET DEBUG_SYNC='now WAIT_FOR created_t';
UPDATE t SET c='ab';
SELECT SLEEP(10);
SLEEP(10)
0
SET DEBUG_SYNC='now SIGNAL dml_done_u';
SET DEBUG_SYNC='now SIGNAL dml_done_t';
SET DEBUG_SYNC='RESET';
DROP TABLE t,u;
call mtr.add_suppression("InnoDB: Warning: Small buffer pool size");
SET @global_innodb_file_per_table_orig = @@global.innodb_file_per_table;
SET GLOBAL innodb_file_per_table = on;
CREATE TABLE t1 (c1 INT PRIMARY KEY, c2 INT, c3 TEXT)
ENGINE=InnoDB STATS_PERSISTENT=0;
INSERT INTO t1 VALUES (1,1,''), (2,2,''), (3,3,''), (4,4,''), (5,5,'');
SET GLOBAL innodb_monitor_enable = module_ddl;
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 DEBUG_SYNC = 'RESET';
SET DEBUG_SYNC = 'write_row_noreplace SIGNAL have_handle WAIT_FOR go_ahead';
INSERT INTO t1 VALUES(1,2,3);
SET DEBUG_SYNC = 'now WAIT_FOR have_handle';
SET lock_wait_timeout = 1;
ALTER TABLE t1 ADD UNIQUE INDEX(c2);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
SET DEBUG_SYNC = 'now SIGNAL go_ahead';
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
SET DEBUG_DBUG = @saved_debug_dbug;
CREATE UNIQUE INDEX c2 ON t1(c2);
DROP INDEX c2 ON t1;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` int(11) NOT NULL,
`c2` int(11) DEFAULT NULL,
`c3` text,
PRIMARY KEY (`c1`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 STATS_PERSISTENT=0
BEGIN;
INSERT INTO t1 VALUES(7,4,2);
SET DEBUG_SYNC = 'row_log_apply_before SIGNAL scanned WAIT_FOR rollback_done';
ALTER TABLE t1 ADD UNIQUE INDEX(c2);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
COMMIT;
ALTER TABLE t1 ADD UNIQUE INDEX(c2);
ERROR 23000: Duplicate entry '4' for key 'c2'
DELETE FROM t1 WHERE c1 = 7;
ALTER TABLE t1 ADD FOREIGN KEY(c2) REFERENCES t1(c2), ALGORITHM = INPLACE;
ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: Adding foreign keys needs foreign_key_checks=OFF. Try ALGORITHM=COPY.
ALTER TABLE t1 ADD UNIQUE INDEX(c2), LOCK = EXCLUSIVE, ALGORITHM = INPLACE;
DROP INDEX c2 ON t1;
ALTER TABLE t1 ADD UNIQUE INDEX(c2);
SET DEBUG_SYNC = 'now WAIT_FOR scanned';
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 1
ddl_pending_alter_table 1
BEGIN;
INSERT INTO t1 VALUES(7,4,2);
ROLLBACK;
SET DEBUG_SYNC = 'now SIGNAL rollback_done';
ERROR 23000: Duplicate entry '4' for key 'c2'
SET DEBUG_SYNC = 'row_log_apply_after SIGNAL created WAIT_FOR dml_done';
ALTER TABLE t1 ADD UNIQUE INDEX(c2);
SET DEBUG_SYNC = 'now WAIT_FOR created';
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 1
INSERT INTO t1 VALUES(6,3,1);
SET DEBUG_SYNC = 'now SIGNAL dml_done';
ERROR 23000: Duplicate entry for key 'c2'
DELETE FROM t1 WHERE c1=6;
ALTER TABLE t1 ADD UNIQUE INDEX(c2);
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
INSERT INTO t1 VALUES(6,3,1);
ERROR 23000: Duplicate entry '3' for key 'c2'
INSERT INTO t1 VALUES(7,4,2);
ERROR 23000: Duplicate entry '4' for key 'c2'
ALTER TABLE t1 STATS_PERSISTENT=1;
ANALYZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 analyze status OK
UPDATE mysql.innodb_index_stats SET stat_value = 5
WHERE database_name = 'test' AND table_name= 't1' AND index_name = 'PRIMARY'
AND stat_value = 6;
SELECT * FROM mysql.innodb_index_stats WHERE table_name IN ('t1');
database_name table_name index_name last_update stat_name stat_value sample_size stat_description
test t1 PRIMARY LAST_UPDATE n_diff_pfx01 5 1 c1
test t1 PRIMARY LAST_UPDATE n_leaf_pages 1 NULL Number of leaf pages in the index
test t1 PRIMARY LAST_UPDATE size 1 NULL Number of pages in the index
test t1 c2 LAST_UPDATE n_diff_pfx01 5 1 c2
test t1 c2 LAST_UPDATE n_leaf_pages 1 NULL Number of leaf pages in the index
test t1 c2 LAST_UPDATE size 1 NULL Number of pages in the index
CREATE TABLE t1_c2_stats SELECT * FROM mysql.innodb_index_stats
WHERE database_name = 'test' AND table_name = 't1' and index_name = 'c2';
ALTER TABLE t1_c2_stats ENGINE=INNODB;
DROP INDEX c2 ON t1;
ANALYZE TABLE t1_c2_stats;
Table Op Msg_type Msg_text
test.t1_c2_stats analyze status OK
SELECT * FROM mysql.innodb_index_stats WHERE table_name IN ('t1', 't1_c2_stats');
database_name table_name index_name last_update stat_name stat_value sample_size stat_description
test t1 PRIMARY LAST_UPDATE n_diff_pfx01 5 1 c1
test t1 PRIMARY LAST_UPDATE n_leaf_pages 1 NULL Number of leaf pages in the index
test t1 PRIMARY LAST_UPDATE size 1 NULL Number of pages in the index
KILL QUERY @id;
ERROR 70100: Query execution was interrupted
SET DEBUG_SYNC = 'row_log_apply_before SIGNAL c2d_created WAIT_FOR kill_done';
CREATE INDEX c2d ON t1(c2);
SET DEBUG_SYNC = 'now WAIT_FOR c2d_created';
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 1
ddl_pending_alter_table 1
KILL QUERY @id;
SET DEBUG_SYNC = 'now SIGNAL kill_done';
ERROR 70100: Query execution was interrupted
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
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
INSERT INTO t1 SELECT 5 + c1, c2, c3 FROM t1;
INSERT INTO t1 SELECT 10 + c1, c2, c3 FROM t1;
INSERT INTO t1 SELECT 20 + c1, c2, c3 FROM t1;
INSERT INTO t1 SELECT 40 + c1, c2, c3 FROM t1;
EXPLAIN SELECT COUNT(*) FROM t1 WHERE c2 > 3;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 80 Using where
ANALYZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 analyze status OK
UPDATE t1_c2_stats SET index_name = 'c2d';
UPDATE t1_c2_stats SET stat_value = 2 WHERE stat_name = 'n_diff_pfx01';
INSERT INTO t1_c2_stats
SELECT database_name, table_name, index_name, last_update, 'n_diff_pfx02', 80,
sample_size, 'c2,c1' FROM t1_c2_stats
WHERE stat_name = 'n_diff_pfx01' AND stat_description = 'c2';
INSERT INTO mysql.innodb_index_stats SELECT * FROM t1_c2_stats;
DROP TABLE t1_c2_stats;
CREATE INDEX c2d ON t1(c2);
SHOW INDEX FROM t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t1 0 PRIMARY 1 c1 A 80 NULL NULL BTREE
t1 1 c2d 1 c2 A 10 NULL NULL YES BTREE
EXPLAIN SELECT COUNT(*) FROM t1 WHERE c2 > 3;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c2d c2d 5 NULL 32 Using where; Using index
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` int(11) NOT NULL,
`c2` int(11) DEFAULT NULL,
`c3` text,
PRIMARY KEY (`c1`),
KEY `c2d` (`c2`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 STATS_PERSISTENT=1
SET DEBUG_SYNC = 'row_log_apply_before SIGNAL c2e_created WAIT_FOR dml2_done';
SET lock_wait_timeout = 10;
ALTER TABLE t1 DROP INDEX c2d, ADD INDEX c2e(c2),
ALGORITHM = INPLACE;
INSERT INTO t1 SELECT 80 + c1, c2, c3 FROM t1;
INSERT INTO t1 SELECT 160 + c1, c2, c3 FROM t1;
SET DEBUG_SYNC = 'now WAIT_FOR c2e_created';
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 1
ddl_pending_alter_table 1
BEGIN;
DELETE FROM t1;
ROLLBACK;
UPDATE t1 SET c2 = c2 + 1;
BEGIN;
UPDATE t1 SET c2 = c2 + 1;
DELETE FROM t1;
ROLLBACK;
BEGIN;
DELETE FROM t1;
ROLLBACK;
UPDATE t1 SET c2 = c2 + 1;
BEGIN;
UPDATE t1 SET c2 = c2 + 1;
DELETE FROM t1;
ROLLBACK;
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 1
ddl_pending_alter_table 1
SELECT sf.name, sf.pos FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES si
INNER JOIN INFORMATION_SCHEMA.INNODB_SYS_FIELDS sf
ON si.index_id = sf.index_id WHERE si.name = '?c2e';
name pos
c2 0
SET DEBUG_SYNC = 'now SIGNAL dml2_done';
ERROR HY000: Creating index 'c2e' required more than 'innodb_online_alter_log_max_size' bytes of modification log. Please try again.
SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl';
name count
ddl_background_drop_indexes 1
ddl_background_drop_tables 0
ddl_online_create_index 0
ddl_pending_alter_table 0
SELECT sf.name, sf.pos FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES si
INNER JOIN INFORMATION_SCHEMA.INNODB_SYS_FIELDS sf
ON si.index_id = sf.index_id WHERE si.name = 'c2e';
name pos
SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl';
name count
ddl_background_drop_indexes 1
ddl_background_drop_tables 0
ddl_online_create_index 0
ddl_pending_alter_table 0
ALTER TABLE t1 COMMENT 'testing if c2e will be dropped';
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 DEBUG_SYNC = 'row_log_apply_before SIGNAL c2f_created WAIT_FOR dml3_done';
ALTER TABLE t1 ADD INDEX c2f(c2);
SET DEBUG_SYNC = 'now WAIT_FOR c2f_created';
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 1
ddl_pending_alter_table 1
BEGIN;
INSERT INTO t1 SELECT 320 + c1, c2, c3 FROM t1 WHERE c1 > 160;
DELETE FROM t1 WHERE c1 > 320;
ROLLBACK;
BEGIN;
UPDATE t1 SET c2 = c2 + 1;
DELETE FROM t1;
ROLLBACK;
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 1
ddl_pending_alter_table 1
SET DEBUG_SYNC = 'now SIGNAL dml3_done';
Warnings:
Note 1831 Duplicate index `c2f`. This is deprecated and will be disallowed in a future release.
ALTER TABLE t1 CHANGE c2 c22f INT;
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
SELECT COUNT(c22f) FROM t1;
COUNT(c22f)
320
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
ALTER TABLE t1 ADD UNIQUE INDEX c3p5(c3(5));
ERROR 23000: Duplicate entry 'NULL' for key 'c3p5'
UPDATE t1 SET c3 = NULL WHERE c3 = '';
SET lock_wait_timeout = 1;
SET DEBUG_SYNC = 'row_log_apply_before SIGNAL c3p5_created WAIT_FOR ins_done';
ALTER TABLE t1 ADD UNIQUE INDEX c3p5(c3(5));
SET DEBUG_SYNC = 'now WAIT_FOR c3p5_created';
SELECT sf.name, sf.pos FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES si
INNER JOIN INFORMATION_SCHEMA.INNODB_SYS_FIELDS sf
ON si.index_id = sf.index_id WHERE si.name = '?c3p5';
name pos
c3 0
SET DEBUG_SYNC = 'ib_after_row_insert SIGNAL ins_done WAIT_FOR ddl_timed_out';
INSERT INTO t1 VALUES(347,33101,NULL);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
SET DEBUG_SYNC = 'now SIGNAL ddl_timed_out';
SELECT sf.name, sf.pos FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES si
INNER JOIN INFORMATION_SCHEMA.INNODB_SYS_FIELDS sf
ON si.index_id = sf.index_id WHERE si.name = 'c3p5';
name pos
SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl';
name count
ddl_background_drop_indexes 1
ddl_background_drop_tables 0
ddl_online_create_index 0
ddl_pending_alter_table 0
SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl';
name count
ddl_background_drop_indexes 1
ddl_background_drop_tables 0
ddl_online_create_index 0
ddl_pending_alter_table 0
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` int(11) NOT NULL,
`c22f` int(11) DEFAULT NULL,
`c3` text,
PRIMARY KEY (`c1`),
KEY `c2d` (`c22f`),
KEY `c2f` (`c22f`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 STATS_PERSISTENT=1 COMMENT='testing if c2e will be dropped'
ALTER TABLE t1 DROP INDEX c2d, DROP INDEX c2f;
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
ALTER TABLE t1 ADD INDEX c2h(c22f), ALGORITHM = INPLACE;
ALTER TABLE t1 ADD INDEX c2h(c22f), ALGORITHM = COPY;
ERROR 42000: Duplicate key name 'c2h'
SET DEBUG_SYNC = 'RESET';
SET GLOBAL innodb_monitor_disable = module_ddl;
DROP TABLE t1;
SET GLOBAL innodb_file_per_table = @global_innodb_file_per_table_orig;
SET GLOBAL innodb_monitor_enable = default;
SET GLOBAL innodb_monitor_disable = default;
call mtr.add_suppression("InnoDB: Warning: Small buffer pool size");
call mtr.add_suppression("InnoDB: Error: table 'test/t1'");
call mtr.add_suppression("MySQL is trying to open a table handle but the .ibd file for");
SET @global_innodb_file_per_table_orig = @@global.innodb_file_per_table;
SET GLOBAL innodb_file_per_table = on;
CREATE TABLE t1 (c1 INT PRIMARY KEY, c2 INT NOT NULL, c3 TEXT NOT NULL)
ENGINE = InnoDB;
INSERT INTO t1 VALUES (1,1,''), (2,2,''), (3,3,''), (4,4,''), (5,5,'');
SET GLOBAL innodb_monitor_enable = module_ddl;
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 DEBUG_SYNC = 'RESET';
SET DEBUG_SYNC = 'write_row_noreplace SIGNAL have_handle WAIT_FOR go_ahead';
INSERT INTO t1 VALUES(1,2,3);
# Establish session con1 (user=root)
SET DEBUG_SYNC = 'now WAIT_FOR have_handle';
SET lock_wait_timeout = 1;
ALTER TABLE t1 ROW_FORMAT=REDUNDANT;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
SET DEBUG_SYNC = 'now SIGNAL go_ahead';
# session default
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;
# session default
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` int(11) NOT NULL,
`c2` int(11) NOT NULL,
`c3` text NOT NULL,
PRIMARY KEY (`c1`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=REDUNDANT
BEGIN;
INSERT INTO t1 VALUES(7,4,2);
# session con1
SET DEBUG_SYNC = 'row_log_table_apply1_before SIGNAL scanned WAIT_FOR insert_done';
ALTER TABLE t1 DROP PRIMARY KEY, ADD UNIQUE INDEX(c2);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
# session default
COMMIT;
# session con1
ALTER TABLE t1 DROP PRIMARY KEY, ADD UNIQUE INDEX(c2);
ERROR 23000: Duplicate entry '4' for key 'c2'
# session default
DELETE FROM t1 WHERE c1 = 7;
# session con1
ALTER TABLE t1 DROP PRIMARY KEY, ADD UNIQUE INDEX(c2), ROW_FORMAT=COMPACT,
LOCK = SHARED, ALGORITHM = INPLACE;
ALTER TABLE t1 ADD UNIQUE INDEX(c2),
LOCK = EXCLUSIVE, ALGORITHM = INPLACE;
Warnings:
Note 1831 Duplicate index `c2_2`. This is deprecated and will be disallowed in a future release.
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` int(11) NOT NULL,
`c2` int(11) NOT NULL,
`c3` text NOT NULL,
UNIQUE KEY `c2` (`c2`),
UNIQUE KEY `c2_2` (`c2`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=COMPACT
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.
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` int(11) NOT NULL,
`c2` int(11) NOT NULL,
`c3` text NOT NULL,
UNIQUE KEY `c2` (`c2`),
UNIQUE KEY `c2_2` (`c2`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=COMPACT
ALTER TABLE t1 DROP INDEX c2, ADD PRIMARY KEY(c1);
# session default
SET DEBUG_SYNC = 'now WAIT_FOR scanned';
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 1
ddl_pending_alter_table 1
BEGIN;
INSERT INTO t1 VALUES(4,7,2);
SET DEBUG_SYNC = 'now SIGNAL insert_done';
# session con1
ERROR 23000: Duplicate entry '4' for key 'PRIMARY'
# session default
ROLLBACK;
# session con1
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` int(11) NOT NULL,
`c2` int(11) NOT NULL,
`c3` text NOT NULL,
UNIQUE KEY `c2` (`c2`),
UNIQUE KEY `c2_2` (`c2`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=COMPACT
ALTER TABLE t1 DROP PRIMARY KEY, ADD UNIQUE INDEX(c2), ALGORITHM = INPLACE;
ERROR 42000: Can't DROP 'PRIMARY'; check that column/key exists
ALTER TABLE t1 DROP INDEX c2, ADD PRIMARY KEY(c1), ALGORITHM = INPLACE;
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 default
INSERT INTO t1 VALUES(6,3,1);
ERROR 23000: Duplicate entry '3' for key 'c2_2'
INSERT INTO t1 VALUES(7,4,2);
ERROR 23000: Duplicate entry '4' for key 'c2_2'
DROP INDEX c2_2 ON t1;
BEGIN;
INSERT INTO t1 VALUES(7,4,2);
ROLLBACK;
# session con1
KILL QUERY @id;
ERROR 70100: Query execution was interrupted
SET DEBUG_SYNC = 'row_log_table_apply1_before SIGNAL rebuilt WAIT_FOR kill_done';
ALTER TABLE t1 ROW_FORMAT=REDUNDANT;
# session default
SET DEBUG_SYNC = 'now WAIT_FOR rebuilt';
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 1
ddl_pending_alter_table 1
KILL QUERY @id;
SET DEBUG_SYNC = 'now SIGNAL kill_done';
# session con1
ERROR 70100: Query execution was interrupted
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 default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
INSERT INTO t1 SELECT 5 + c1, c2, c3 FROM t1;
INSERT INTO t1 SELECT 10 + c1, c2, c3 FROM t1;
INSERT INTO t1 SELECT 20 + c1, c2, c3 FROM t1;
INSERT INTO t1 SELECT 40 + c1, c2, c3 FROM t1;
EXPLAIN SELECT COUNT(*) FROM t1 WHERE c2 > 3;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 80 Using where
ANALYZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 analyze status OK
# session con1
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` int(11) NOT NULL,
`c2` int(11) NOT NULL,
`c3` text NOT NULL,
PRIMARY KEY (`c1`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=COMPACT
SET DEBUG_SYNC = 'row_log_table_apply1_before SIGNAL rebuilt2 WAIT_FOR dml2_done';
SET lock_wait_timeout = 10;
ALTER TABLE t1 ROW_FORMAT=COMPACT, ALGORITHM = INPLACE;
# session default
INSERT INTO t1 SELECT 80 + c1, c2, c3 FROM t1;
INSERT INTO t1 SELECT 160 + c1, c2, c3 FROM t1;
UPDATE t1 SET c2 = c2 + 1;
SET DEBUG_SYNC = 'now WAIT_FOR rebuilt2';
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 1
ddl_pending_alter_table 1
BEGIN;
DELETE FROM t1;
ROLLBACK;
UPDATE t1 SET c2 = c2 + 1;
BEGIN;
UPDATE t1 SET c2 = c2 + 1;
DELETE FROM t1;
ROLLBACK;
BEGIN;
DELETE FROM t1;
ROLLBACK;
UPDATE t1 SET c2 = c2 + 1;
BEGIN;
UPDATE t1 SET c2 = c2 + 1;
DELETE FROM t1;
ROLLBACK;
BEGIN;
DELETE FROM t1;
ROLLBACK;
UPDATE t1 SET c2 = c2 + 1;
BEGIN;
UPDATE t1 SET c2 = c2 + 1;
DELETE FROM t1;
ROLLBACK;
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 1
ddl_pending_alter_table 1
SET DEBUG_SYNC = 'now SIGNAL dml2_done';
# session con1
ERROR HY000: Creating index 'PRIMARY' required more than 'innodb_online_alter_log_max_size' bytes of modification log. Please try again.
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 DEBUG_SYNC = 'row_log_table_apply1_before SIGNAL rebuilt3 WAIT_FOR dml3_done';
ALTER TABLE t1 ADD PRIMARY KEY(c22f), CHANGE c2 c22f INT;
ERROR 42000: Multiple primary key defined
ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY(c22f), CHANGE c2 c22f INT;
ERROR 23000: Duplicate entry '5' for key 'PRIMARY'
ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY(c1,c22f,c4(5)),
CHANGE c2 c22f INT, CHANGE c3 c3 TEXT NULL, CHANGE c1 c1 INT AFTER c22f,
ADD COLUMN c4 VARCHAR(6) DEFAULT 'Online';
# session default
SET DEBUG_SYNC = 'now WAIT_FOR rebuilt3';
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 1
ddl_pending_alter_table 1
BEGIN;
INSERT INTO t1 SELECT 320 + c1, c2, c3 FROM t1 WHERE c1 > 240;
DELETE FROM t1 WHERE c1 > 320;
ROLLBACK;
BEGIN;
UPDATE t1 SET c2 = c2 + 1;
DELETE FROM t1;
ROLLBACK;
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 1
ddl_pending_alter_table 1
SET DEBUG_SYNC = 'now SIGNAL dml3_done';
# session con1
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
SELECT COUNT(c22f) FROM t1;
COUNT(c22f)
320
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY c3p5(c3(5));
ERROR 23000: Duplicate entry '' for key 'PRIMARY'
UPDATE t1 SET c3 = NULL WHERE c3 = '';
SET lock_wait_timeout = 1;
ALTER TABLE t1 DROP COLUMN c22f, ADD PRIMARY KEY c3p5(c3(5));
ERROR 42000: Multiple primary key defined
SET @old_sql_mode = @@sql_mode;
SET @@sql_mode = 'STRICT_TRANS_TABLES';
ALTER TABLE t1 DROP COLUMN c22f, DROP PRIMARY KEY, ADD PRIMARY KEY c3p5(c3(5)),
ALGORITHM = INPLACE;
ERROR 22004: Invalid use of NULL value
ALTER TABLE t1 MODIFY c3 TEXT NOT NULL;
ERROR 22004: Invalid use of NULL value
SET @@sql_mode = @old_sql_mode;
UPDATE t1 SET c3=CONCAT(c1,REPEAT('foo',c1)) WHERE c3 IS NULL;
SET DEBUG_SYNC = 'row_log_table_apply1_before SIGNAL c3p5_created0 WAIT_FOR ins_done0';
SET @@sql_mode = 'STRICT_TRANS_TABLES';
ALTER TABLE t1 MODIFY c3 TEXT NOT NULL, DROP COLUMN c22f,
ADD COLUMN c5 CHAR(5) DEFAULT 'tired' FIRST;
# session default
SET DEBUG_SYNC = 'now WAIT_FOR c3p5_created0';
BEGIN;
INSERT INTO t1 VALUES(347,33101,'Pikku kakkosen posti','YLETV2');
INSERT INTO t1 VALUES(33101,347,NULL,'');
SET DEBUG_SYNC = 'now SIGNAL ins_done0';
# session con1
ERROR 22004: Invalid use of NULL value
SET @@sql_mode = @old_sql_mode;
# session default
ROLLBACK;
# session con1
ALTER TABLE t1 MODIFY c3 TEXT NOT NULL;
SET DEBUG_SYNC = 'row_log_table_apply1_before SIGNAL c3p5_created WAIT_FOR ins_done';
ALTER TABLE t1 DROP PRIMARY KEY, DROP COLUMN c22f,
ADD COLUMN c6 VARCHAR(1000) DEFAULT
'I love tracking down hard-to-reproduce bugs.',
ADD PRIMARY KEY c3p5(c3(5), c6(2));
# session default
SET DEBUG_SYNC = 'now WAIT_FOR c3p5_created';
SET DEBUG_SYNC = 'ib_after_row_insert SIGNAL ins_done WAIT_FOR ddl_timed_out';
INSERT INTO t1 VALUES(347,33101,NULL,'');
ERROR 23000: Column 'c3' cannot be null
INSERT INTO t1 VALUES(347,33101,'Pikku kakkosen posti','');
# session con1
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
SET DEBUG_SYNC = 'now SIGNAL ddl_timed_out';
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 default
SELECT COUNT(*) FROM t1;
COUNT(*)
321
ALTER TABLE t1 ROW_FORMAT=REDUNDANT;
SELECT * FROM t1 LIMIT 10;
c22f c1 c3 c4
5 1 1foo Online
6 2 2foofoo Online
7 3 3foofoofoo Online
8 4 4foofoofoofoo Online
9 5 5foofoofoofoofoo Online
5 6 6foofoofoofoofoofoo Online
6 7 7foofoofoofoofoofoofoo Online
7 8 8foofoofoofoofoofoofoofoo Online
8 9 9foofoofoofoofoofoofoofoofoo Online
9 10 10foofoofoofoofoofoofoofoofoofoo Online
# session con1
ALTER TABLE t1 DISCARD TABLESPACE;
# Disconnect session con1
# session default
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c22f` int(11) NOT NULL DEFAULT '0',
`c1` int(11) NOT NULL DEFAULT '0',
`c3` text NOT NULL,
`c4` varchar(6) NOT NULL DEFAULT 'Online',
PRIMARY KEY (`c1`,`c22f`,`c4`(5))
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=REDUNDANT
SET DEBUG_SYNC = 'RESET';
SET GLOBAL innodb_monitor_disable = module_ddl;
DROP TABLE t1;
SET GLOBAL innodb_file_per_table = @global_innodb_file_per_table_orig;
SET GLOBAL innodb_monitor_enable = default;
SET GLOBAL innodb_monitor_disable = default;
#
# This is a copy of innodb-alter.test except using remote tablespaces
# and showing those files.
#
SET default_storage_engine=InnoDB;
SET GLOBAL innodb_file_per_table=ON;
SET NAMES utf8;
CREATE TABLE t1 (
c1 INT PRIMARY KEY, c2 INT DEFAULT 1, ct TEXT,
INDEX(c2))
ENGINE=InnoDB DATA DIRECTORY='MYSQL_TMP_DIR/alt_dir';
INSERT INTO t1 SET c1=1;
CREATE TABLE sys_tables SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES
WHERE NAME LIKE 'test/t%';
CREATE TABLE sys_indexes SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES i
INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID;
CREATE TABLE t1p LIKE t1;
CREATE TABLE t1c (c1 INT PRIMARY KEY, c2 INT, c3 INT, INDEX(c2), INDEX(c3),
CONSTRAINT t1c2 FOREIGN KEY (c2) REFERENCES t1(c2),
CONSTRAINT t1c3 FOREIGN KEY (c3) REFERENCES t1p(c2))
ENGINE=InnoDB DATA DIRECTORY='MYSQL_TMP_DIR/alt_dir';
CREATE TABLE sys_foreign SELECT i.*
FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN i
WHERE FOR_NAME LIKE 'test/t%';
SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i
INNER JOIN sys_foreign sf ON i.ID = sf.ID;
ID FOR_COL_NAME REF_COL_NAME POS
test/t1c2 c2 c2 0
test/t1c3 c3 c2 0
SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN
FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i
INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID;
NAME POS MTYPE PRTYPE LEN
c1 0 6 1283 4
c2 1 6 1027 4
ct 2 5 524540 10
SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i
INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID;
NAME POS NAME
PRIMARY 0 c1
c2 0 c2
SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i
INNER JOIN sys_foreign sf ON i.ID = sf.ID;
ID FOR_COL_NAME REF_COL_NAME POS
test/t1c2 c2 c2 0
test/t1c3 c3 c2 0
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` int(11) NOT NULL,
`c2` int(11) DEFAULT '1',
`ct` text,
PRIMARY KEY (`c1`),
KEY `c2` (`c2`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQL_TMP_DIR/alt_dir/'
ALTER TABLE t1 ALTER c2 DROP DEFAULT;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` int(11) NOT NULL,
`c2` int(11),
`ct` text,
PRIMARY KEY (`c1`),
KEY `c2` (`c2`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQL_TMP_DIR/alt_dir/'
### files in MYSQL_DATA_DIR/test
sys_foreign.frm
sys_foreign.ibd
sys_indexes.frm
sys_indexes.ibd
sys_tables.frm
sys_tables.ibd
t1.frm
t1.isl
t1c.frm
t1c.isl
t1p.frm
t1p.ibd
### files in MYSQL_TMP_DIR/alt_dir/test
t1.ibd
t1c.ibd
SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN
FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i
INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID;
NAME POS MTYPE PRTYPE LEN
c1 0 6 1283 4
c2 1 6 1027 4
ct 2 5 524540 10
SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i
INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID;
NAME POS NAME
PRIMARY 0 c1
c2 0 c2
SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i
INNER JOIN sys_foreign sf ON i.ID = sf.ID;
ID FOR_COL_NAME REF_COL_NAME POS
test/t1c2 c2 c2 0
test/t1c3 c3 c2 0
ALTER TABLE t1 CHANGE c2 c2 INT AFTER c1;
ALTER TABLE t1 CHANGE c1 c1 INT FIRST;
### files in MYSQL_DATA_DIR/test
sys_foreign.frm
sys_foreign.ibd
sys_indexes.frm
sys_indexes.ibd
sys_tables.frm
sys_tables.ibd
t1.frm
t1.isl
t1c.frm
t1c.isl
t1p.frm
t1p.ibd
### files in MYSQL_TMP_DIR/alt_dir/test
t1.ibd
t1c.ibd
SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN
FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i
INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID;
NAME POS MTYPE PRTYPE LEN
c1 0 6 1283 4
c2 1 6 1027 4
ct 2 5 524540 10
SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i
INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID;
NAME POS NAME
PRIMARY 0 c1
c2 0 c2
SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i
INNER JOIN sys_foreign sf ON i.ID = sf.ID;
ID FOR_COL_NAME REF_COL_NAME POS
test/t1c2 c2 c2 0
test/t1c3 c3 c2 0
ALTER TABLE t1 CHANGE C2 c3 INT;
### files in MYSQL_DATA_DIR/test
sys_foreign.frm
sys_foreign.ibd
sys_indexes.frm
sys_indexes.ibd
sys_tables.frm
sys_tables.ibd
t1.frm
t1.isl
t1c.frm
t1c.isl
t1p.frm
t1p.ibd
### files in MYSQL_TMP_DIR/alt_dir/test
t1.ibd
t1c.ibd
SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN
FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i
INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID;
NAME POS MTYPE PRTYPE LEN
c1 0 6 1283 4
c3 1 6 1027 4
ct 2 5 524540 10
SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i
INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID;
NAME POS NAME
PRIMARY 0 c1
c2 0 c3
SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i
INNER JOIN sys_foreign sf ON i.ID = sf.ID;
ID FOR_COL_NAME REF_COL_NAME POS
test/t1c2 c2 c3 0
test/t1c3 c3 c2 0
ALTER TABLE t1 CHANGE c3 C INT;
### files in MYSQL_DATA_DIR/test
sys_foreign.frm
sys_foreign.ibd
sys_indexes.frm
sys_indexes.ibd
sys_tables.frm
sys_tables.ibd
t1.frm
t1.isl
t1c.frm
t1c.isl
t1p.frm
t1p.ibd
### files in MYSQL_TMP_DIR/alt_dir/test
t1.ibd
t1c.ibd
SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN
FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i
INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID;
NAME POS MTYPE PRTYPE LEN
c1 0 6 1283 4
C 1 6 1027 4
ct 2 5 524540 10
SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i
INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID;
NAME POS NAME
PRIMARY 0 c1
c2 0 C
SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i
INNER JOIN sys_foreign sf ON i.ID = sf.ID;
ID FOR_COL_NAME REF_COL_NAME POS
test/t1c2 c2 C 0
test/t1c3 c3 c2 0
ALTER TABLE t1 CHANGE C Cöŀumň_TWO INT;
### files in MYSQL_DATA_DIR/test
sys_foreign.frm
sys_foreign.ibd
sys_indexes.frm
sys_indexes.ibd
sys_tables.frm
sys_tables.ibd
t1.frm
t1.isl
t1c.frm
t1c.isl
t1p.frm
t1p.ibd
### files in MYSQL_TMP_DIR/alt_dir/test
t1.ibd
t1c.ibd
SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i
INNER JOIN sys_foreign sf ON i.ID = sf.ID;
ID FOR_COL_NAME REF_COL_NAME POS
test/t1c2 c2 Cöŀumň_TWO 0
test/t1c3 c3 c2 0
SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN
FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i
INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID;
NAME POS MTYPE PRTYPE LEN
c1 0 6 1283 4
Cöŀumň_TWO 1 6 1027 4
ct 2 5 524540 10
SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i
INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID;
NAME POS NAME
PRIMARY 0 c1
c2 0 Cöŀumň_TWO
SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i
INNER JOIN sys_foreign sf ON i.ID = sf.ID;
ID FOR_COL_NAME REF_COL_NAME POS
test/t1c2 c2 Cöŀumň_TWO 0
test/t1c3 c3 c2 0
ALTER TABLE t1 CHANGE cöĿǖmň_two c3 INT;
ERROR 42S22: Unknown column 'cöĿǖmň_two' in 't1'
ALTER TABLE t1 CHANGE cÖĿUMŇ_two c3 INT, RENAME TO t3;
### files in MYSQL_DATA_DIR/test
sys_foreign.frm
sys_foreign.ibd
sys_indexes.frm
sys_indexes.ibd
sys_tables.frm
sys_tables.ibd
t1c.frm
t1c.isl
t1p.frm
t1p.ibd
t3.frm
t3.isl
### files in MYSQL_TMP_DIR/alt_dir/test
t1c.ibd
t3.ibd
SELECT st.NAME, i.NAME
FROM sys_tables st INNER JOIN INFORMATION_SCHEMA.INNODB_SYS_TABLES i
ON i.TABLE_ID=st.TABLE_ID;
NAME NAME
test/t1 test/t3
SHOW CREATE TABLE t3;
Table Create Table
t3 CREATE TABLE `t3` (
`c1` int(11) NOT NULL DEFAULT '0',
`c3` int(11) DEFAULT NULL,
`ct` text,
PRIMARY KEY (`c1`),
KEY `c2` (`c3`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQL_TMP_DIR/alt_dir/'
SHOW CREATE TABLE t1c;
Table Create Table
t1c CREATE TABLE `t1c` (
`c1` int(11) NOT NULL,
`c2` int(11) DEFAULT NULL,
`c3` int(11) DEFAULT NULL,
PRIMARY KEY (`c1`),
KEY `c2` (`c2`),
KEY `c3` (`c3`),
CONSTRAINT `t1c2` FOREIGN KEY (`c2`) REFERENCES `t3` (`c3`),
CONSTRAINT `t1c3` FOREIGN KEY (`c3`) REFERENCES `t1p` (`c2`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQL_TMP_DIR/alt_dir/'
ALTER TABLE t3 CHANGE c3
`12345678901234567890123456789012345678901234567890123456789012345` INT;
ERROR 42000: Identifier name '12345678901234567890123456789012345678901234567890123456789012345' is too long
ALTER TABLE t3 CHANGE c3
`1234567890123456789012345678901234567890123456789012345678901234` INT;
### files in MYSQL_DATA_DIR/test
sys_foreign.frm
sys_foreign.ibd
sys_indexes.frm
sys_indexes.ibd
sys_tables.frm
sys_tables.ibd
t1c.frm
t1c.isl
t1p.frm
t1p.ibd
t3.frm
t3.isl
### files in MYSQL_TMP_DIR/alt_dir/test
t1c.ibd
t3.ibd
SHOW CREATE TABLE t3;
Table Create Table
t3 CREATE TABLE `t3` (
`c1` int(11) NOT NULL DEFAULT '0',
`1234567890123456789012345678901234567890123456789012345678901234` int(11) DEFAULT NULL,
`ct` text,
PRIMARY KEY (`c1`),
KEY `c2` (`1234567890123456789012345678901234567890123456789012345678901234`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQL_TMP_DIR/alt_dir/'
ALTER TABLE t3 CHANGE
`1234567890123456789012345678901234567890123456789012345678901234`
`倀倁倂倃倄倅倆倇倈倉倊個倌倍倎倏倐們倒倓倔倕倖倗倘候倚倛倜倝倞借倠倡倢倣値倥倦倧倨倩倪倫倬倭倮倯倰倱倲倳倴倵倶倷倸倹债倻值倽倾倿偀` INT;
ERROR 42000: Identifier name '倀倁倂倃倄倅倆倇倈倉倊個倌倍倎倏倐們倒倓倔倕倖倗倘候倚倛倜倝倞借倠' is too long
ALTER TABLE t3 CHANGE
`1234567890123456789012345678901234567890123456789012345678901234`
`倀倁倂倃倄倅倆倇倈倉倊個倌倍倎倏倐們倒倓倔倕倖倗倘候倚倛倜倝倞借倠倡倢倣値倥倦倧倨倩倪倫倬倭倮倯倰倱倲倳倴倵倶倷倸倹债倻值倽倾倿ä` INT;
ERROR 42000: Identifier name '倀倁倂倃倄倅倆倇倈倉倊個倌倍倎倏倐們倒倓倔倕倖倗倘候倚倛倜倝倞借倠' is too long
ALTER TABLE t3 CHANGE
`1234567890123456789012345678901234567890123456789012345678901234`
`倀倁倂倃倄倅倆倇倈倉倊個倌倍倎倏倐們倒倓倔倕倖倗倘候倚倛倜倝倞借倠倡倢倣値倥倦倧倨倩倪倫倬倭倮倯倰倱倲倳倴倵倶倷倸倹债倻值倽倾ä` INT;
### files in MYSQL_DATA_DIR/test
sys_foreign.frm
sys_foreign.ibd
sys_indexes.frm
sys_indexes.ibd
sys_tables.frm
sys_tables.ibd
t1c.frm
t1c.isl
t1p.frm
t1p.ibd
t3.frm
t3.isl
### files in MYSQL_TMP_DIR/alt_dir/test
t1c.ibd
t3.ibd
ALTER TABLE t3 CHANGE
`倀倁倂倃倄倅倆倇倈倉倊個倌倍倎倏倐們倒倓倔倕倖倗倘候倚倛倜倝倞借倠倡倢倣値倥倦倧倨倩倪倫倬倭倮倯倰倱倲倳倴倵倶倷倸倹债倻值倽倾Ä`
c3 INT;
### files in MYSQL_DATA_DIR/test
sys_foreign.frm
sys_foreign.ibd
sys_indexes.frm
sys_indexes.ibd
sys_tables.frm
sys_tables.ibd
t1c.frm
t1c.isl
t1p.frm
t1p.ibd
t3.frm
t3.isl
### files in MYSQL_TMP_DIR/alt_dir/test
t1c.ibd
t3.ibd
ALTER TABLE t3 CHANGE c3 𐌀𐌁𐌂𐌃𐌄𐌅𐌆𐌇𐌈𐌉𐌊𐌋𐌌𐌍𐌎𐌏𐌐𐌑𐌒𐌓𐌔𐌕𐌖𐌗𐌘𐌙𐌚𐌛𐌜 INT;
ERROR HY000: Invalid utf8 character string: '\xF0\x90\x8C\x80\xF0\x90\x8C\x81\xF0\x90\x8C\x82\xF0\x90\x8C\x83'
ALTER TABLE t3 CHANGE c3 😲 INT;
ERROR HY000: Invalid utf8 character string: '\xF0\x9F\x98\xB2'
ALTER TABLE t3 RENAME TO t2;
### files in MYSQL_DATA_DIR/test
sys_foreign.frm
sys_foreign.ibd
sys_indexes.frm
sys_indexes.ibd
sys_tables.frm
sys_tables.ibd
t1c.frm
t1c.isl
t1p.frm
t1p.ibd
t2.frm
t2.isl
### files in MYSQL_TMP_DIR/alt_dir/test
t1c.ibd
t2.ibd
SELECT st.NAME, i.NAME
FROM sys_tables st INNER JOIN INFORMATION_SCHEMA.INNODB_SYS_TABLES i
ON i.TABLE_ID=st.TABLE_ID;
NAME NAME
test/t1 test/t2
SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`c1` int(11) NOT NULL DEFAULT '0',
`c3` int(11) DEFAULT NULL,
`ct` text,
PRIMARY KEY (`c1`),
KEY `c2` (`c3`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQL_TMP_DIR/alt_dir/'
RENAME TABLE t2 TO t1;
SELECT st.NAME, i.NAME
FROM sys_tables st INNER JOIN INFORMATION_SCHEMA.INNODB_SYS_TABLES i
ON i.TABLE_ID=st.TABLE_ID;
NAME NAME
test/t1 test/t1
### files in MYSQL_DATA_DIR/test
sys_foreign.frm
sys_foreign.ibd
sys_indexes.frm
sys_indexes.ibd
sys_tables.frm
sys_tables.ibd
t1.frm
t1.isl
t1c.frm
t1c.isl
t1p.frm
t1p.ibd
### files in MYSQL_TMP_DIR/alt_dir/test
t1.ibd
t1c.ibd
SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN
FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i
INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID;
NAME POS MTYPE PRTYPE LEN
c1 0 6 1283 4
c3 1 6 1027 4
ct 2 5 524540 10
SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i
INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID;
NAME POS NAME
PRIMARY 0 c1
c2 0 c3
SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i
INNER JOIN sys_foreign sf ON i.ID = sf.ID;
ID FOR_COL_NAME REF_COL_NAME POS
test/t1c2 c2 c3 0
test/t1c3 c3 c2 0
ALTER TABLE t1 DROP INDEX c2;
ERROR HY000: Cannot drop index 'c2': needed in a foreign key constraint
ALTER TABLE t1 DROP INDEX c4;
ERROR 42000: Can't DROP 'c4'; check that column/key exists
ALTER TABLE t1c DROP FOREIGN KEY c2;
ERROR 42000: Can't DROP 'c2'; check that column/key exists
ALTER TABLE t1c DROP FOREIGN KEY t1c2, DROP FOREIGN KEY c2;
ERROR 42000: Can't DROP 'c2'; check that column/key exists
ALTER TABLE t1c DROP FOREIGN KEY t1c2, DROP FOREIGN KEY c2, DROP INDEX c2;
ERROR 42000: Can't DROP 'c2'; check that column/key exists
ALTER TABLE t1c DROP INDEX c2;
ERROR HY000: Cannot drop index 'c2': needed in a foreign key constraint
ALTER TABLE t1c DROP FOREIGN KEY ẗ1C2;
ERROR 42000: Can't DROP 'ẗ1C2'; check that column/key exists
SHOW CREATE TABLE t1c;
Table Create Table
t1c CREATE TABLE `t1c` (
`c1` int(11) NOT NULL,
`c2` int(11) DEFAULT NULL,
`c3` int(11) DEFAULT NULL,
PRIMARY KEY (`c1`),
KEY `c2` (`c2`),
KEY `c3` (`c3`),
CONSTRAINT `t1c2` FOREIGN KEY (`c2`) REFERENCES `t1` (`c3`),
CONSTRAINT `t1c3` FOREIGN KEY (`c3`) REFERENCES `t1p` (`c2`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQL_TMP_DIR/alt_dir/'
SET foreign_key_checks=0;
DROP TABLE t1p;
SET foreign_key_checks=1;
SHOW CREATE TABLE t1c;
Table Create Table
t1c CREATE TABLE `t1c` (
`c1` int(11) NOT NULL,
`c2` int(11) DEFAULT NULL,
`c3` int(11) DEFAULT NULL,
PRIMARY KEY (`c1`),
KEY `c2` (`c2`),
KEY `c3` (`c3`),
CONSTRAINT `t1c2` FOREIGN KEY (`c2`) REFERENCES `t1` (`c3`),
CONSTRAINT `t1c3` FOREIGN KEY (`c3`) REFERENCES `t1p` (`c2`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQL_TMP_DIR/alt_dir/'
### files in MYSQL_DATA_DIR/test
sys_foreign.frm
sys_foreign.ibd
sys_indexes.frm
sys_indexes.ibd
sys_tables.frm
sys_tables.ibd
t1.frm
t1.isl
t1c.frm
t1c.isl
### files in MYSQL_TMP_DIR/alt_dir/test
t1.ibd
t1c.ibd
SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN
FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i
INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID;
NAME POS MTYPE PRTYPE LEN
c1 0 6 1283 4
c3 1 6 1027 4
ct 2 5 524540 10
SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i
INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID;
NAME POS NAME
PRIMARY 0 c1
c2 0 c3
SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i
INNER JOIN sys_foreign sf ON i.ID = sf.ID;
ID FOR_COL_NAME REF_COL_NAME POS
test/t1c2 c2 c3 0
test/t1c3 c3 c2 0
CREATE TABLE t1p (c1 INT PRIMARY KEY, c2 INT, INDEX(c2))
ENGINE=InnoDB DATA DIRECTORY='MYSQL_TMP_DIR/alt_dir';
ALTER TABLE t1c DROP INDEX C2, DROP INDEX C3;
ERROR HY000: Cannot drop index 'c2': needed in a foreign key constraint
ALTER TABLE t1c DROP INDEX C3;
ERROR HY000: Cannot drop index 'c3': needed in a foreign key constraint
SET foreign_key_checks=0;
ALTER TABLE t1c DROP INDEX C3;
### files in MYSQL_DATA_DIR/test
sys_foreign.frm
sys_foreign.ibd
sys_indexes.frm
sys_indexes.ibd
sys_tables.frm
sys_tables.ibd
t1.frm
t1.isl
t1c.frm
t1c.isl
t1p.frm
t1p.isl
### files in MYSQL_TMP_DIR/alt_dir/test
t1.ibd
t1c.ibd
t1p.ibd
SET foreign_key_checks=1;
SHOW CREATE TABLE t1c;
Table Create Table
t1c CREATE TABLE `t1c` (
`c1` int(11) NOT NULL,
`c2` int(11) DEFAULT NULL,
`c3` int(11) DEFAULT NULL,
PRIMARY KEY (`c1`),
KEY `c2` (`c2`),
CONSTRAINT `t1c2` FOREIGN KEY (`c2`) REFERENCES `t1` (`c3`),
CONSTRAINT `t1c3` FOREIGN KEY (`c3`) REFERENCES `t1p` (`c2`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQL_TMP_DIR/alt_dir/'
SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN
FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i
INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID;
NAME POS MTYPE PRTYPE LEN
c1 0 6 1283 4
c3 1 6 1027 4
ct 2 5 524540 10
SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i
INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID;
NAME POS NAME
PRIMARY 0 c1
c2 0 c3
SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i
INNER JOIN sys_foreign sf ON i.ID = sf.ID;
ID FOR_COL_NAME REF_COL_NAME POS
test/t1c2 c2 c3 0
test/t1c3 c3 c2 0
ALTER TABLE t1c DROP FOREIGN KEY t1C3;
### files in MYSQL_DATA_DIR/test
sys_foreign.frm
sys_foreign.ibd
sys_indexes.frm
sys_indexes.ibd
sys_tables.frm
sys_tables.ibd
t1.frm
t1.isl
t1c.frm
t1c.isl
t1p.frm
t1p.isl
### files in MYSQL_TMP_DIR/alt_dir/test
t1.ibd
t1c.ibd
t1p.ibd
SHOW CREATE TABLE t1c;
Table Create Table
t1c CREATE TABLE `t1c` (
`c1` int(11) NOT NULL,
`c2` int(11) DEFAULT NULL,
`c3` int(11) DEFAULT NULL,
PRIMARY KEY (`c1`),
KEY `c2` (`c2`),
CONSTRAINT `t1c2` FOREIGN KEY (`c2`) REFERENCES `t1` (`c3`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQL_TMP_DIR/alt_dir/'
SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN
FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i
INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID;
NAME POS MTYPE PRTYPE LEN
c1 0 6 1283 4
c3 1 6 1027 4
ct 2 5 524540 10
SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i
INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID;
NAME POS NAME
PRIMARY 0 c1
c2 0 c3
SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i
INNER JOIN sys_foreign sf ON i.ID = sf.ID;
ID FOR_COL_NAME REF_COL_NAME POS
test/t1c2 c2 c3 0
ALTER TABLE t1c DROP INDEX c2, DROP FOREIGN KEY t1C2;
### files in MYSQL_DATA_DIR/test
sys_foreign.frm
sys_foreign.ibd
sys_indexes.frm
sys_indexes.ibd
sys_tables.frm
sys_tables.ibd
t1.frm
t1.isl
t1c.frm
t1c.isl
t1p.frm
t1p.isl
### files in MYSQL_TMP_DIR/alt_dir/test
t1.ibd
t1c.ibd
t1p.ibd
SHOW CREATE TABLE t1c;
Table Create Table
t1c CREATE TABLE `t1c` (
`c1` int(11) NOT NULL,
`c2` int(11) DEFAULT NULL,
`c3` int(11) DEFAULT NULL,
PRIMARY KEY (`c1`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQL_TMP_DIR/alt_dir/'
SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN
FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i
INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID;
NAME POS MTYPE PRTYPE LEN
c1 0 6 1283 4
c3 1 6 1027 4
ct 2 5 524540 10
SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i
INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID;
NAME POS NAME
PRIMARY 0 c1
c2 0 c3
SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i
INNER JOIN sys_foreign sf ON i.ID = sf.ID;
ID FOR_COL_NAME REF_COL_NAME POS
ALTER TABLE t1 DROP INDEX c2, CHANGE c3 c2 INT;
### files in MYSQL_DATA_DIR/test
sys_foreign.frm
sys_foreign.ibd
sys_indexes.frm
sys_indexes.ibd
sys_tables.frm
sys_tables.ibd
t1.frm
t1.isl
t1c.frm
t1c.isl
t1p.frm
t1p.isl
### files in MYSQL_TMP_DIR/alt_dir/test
t1.ibd
t1c.ibd
t1p.ibd
SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN
FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i
INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID;
NAME POS MTYPE PRTYPE LEN
c1 0 6 1283 4
c2 1 6 1027 4
ct 2 5 524540 10
SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i
INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID;
NAME POS NAME
PRIMARY 0 c1
SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i
INNER JOIN sys_foreign sf ON i.ID = sf.ID;
ID FOR_COL_NAME REF_COL_NAME POS
CREATE TABLE t1o LIKE t1;
ALTER TABLE t1 ADD FULLTEXT INDEX (ct),
CHANGE c1 pk INT, ALTER c2 SET DEFAULT 42, RENAME TO tt,
ALGORITHM=INPLACE, LOCK=NONE;
ERROR 0A000: LOCK=NONE is not supported. Reason: Fulltext index creation requires a lock. Try LOCK=SHARED.
ALTER TABLE t1 ADD FULLTEXT INDEX (ct),
CHANGE c1 pk INT, ALTER c2 SET DEFAULT 42, RENAME TO tt,
ALGORITHM=INPLACE, LOCK=SHARED;
Warnings:
Warning 124 InnoDB rebuilding table to add column FTS_DOC_ID
### files in MYSQL_DATA_DIR/test
FTS_AUX_INDEX_1.ibd
FTS_AUX_INDEX_2.ibd
FTS_AUX_INDEX_3.ibd
FTS_AUX_INDEX_4.ibd
FTS_AUX_INDEX_5.ibd
FTS_AUX_INDEX_6.ibd
FTS_AUX_BEING_DELETED.ibd
FTS_AUX_BEING_DELETED_CACHE.ibd
FTS_AUX_CONFIG.ibd
FTS_AUX_DELETED.ibd
FTS_AUX_DELETED_CACHE.ibd
sys_foreign.frm
sys_foreign.ibd
sys_indexes.frm
sys_indexes.ibd
sys_tables.frm
sys_tables.ibd
t1c.frm
t1c.isl
t1o.frm
t1o.ibd
t1p.frm
t1p.isl
tt.frm
tt.isl
### files in MYSQL_TMP_DIR/alt_dir/test
t1c.ibd
t1p.ibd
tt.ibd
SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN
FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i
INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID;
NAME POS MTYPE PRTYPE LEN
SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i
INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID;
NAME POS NAME
SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i
INNER JOIN sys_foreign sf ON i.ID = sf.ID;
ID FOR_COL_NAME REF_COL_NAME POS
SHOW CREATE TABLE tt;
Table Create Table
tt CREATE TABLE `tt` (
`pk` int(11) NOT NULL DEFAULT '0',
`c2` int(11) DEFAULT '42',
`ct` text,
PRIMARY KEY (`pk`),
FULLTEXT KEY `ct` (`ct`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQL_TMP_DIR/alt_dir/'
ALTER TABLE t1o CHANGE c1 dB_row_Id INT, ALGORITHM=COPY;
ERROR 42000: Incorrect column name 'dB_row_Id'
ALTER TABLE t1o CHANGE c1 dB_row_Id INT, ALGORITHM=INPLACE;
ERROR 42000: Incorrect column name 'DB_ROW_ID'
ALTER TABLE t1o CHANGE c1 DB_TRX_ID INT;
ERROR 42000: Incorrect column name 'DB_TRX_ID'
ALTER TABLE t1o CHANGE c1 db_roll_ptr INT;
ERROR 42000: Incorrect column name 'DB_ROLL_PTR'
ALTER TABLE t1o ADD FULLTEXT INDEX(ct), CHANGE c1 FTS_DOC_ID INT,
ALGORITHM=COPY;
ERROR 42000: Incorrect column name 'FTS_DOC_ID'
ALTER TABLE t1o ADD FULLTEXT INDEX(ct), CHANGE c1 FTS_DOC_ID INT,
ALGORITHM=INPLACE;
ERROR HY000: Column 'FTS_DOC_ID' is of wrong type for an InnoDB FULLTEXT index
ALTER TABLE t1o ADD FULLTEXT INDEX(ct), CHANGE c1 FTS_Doc_ID INT,
ALGORITHM=INPLACE;
ERROR 42000: Incorrect column name 'FTS_Doc_ID'
ALTER TABLE t1o ADD FULLTEXT INDEX(ct),
CHANGE c1 FTS_DOC_ID BIGINT UNSIGNED NOT NULL,
ALGORITHM=INPLACE;
ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: Cannot change column type INPLACE. Try ALGORITHM=COPY.
CREATE TABLE t1n LIKE t1o;
ALTER TABLE t1n ADD FULLTEXT INDEX(ct);
Warnings:
Warning 124 InnoDB rebuilding table to add column FTS_DOC_ID
### files in MYSQL_DATA_DIR/test
FTS_AUX_INDEX_1.ibd
FTS_AUX_INDEX_2.ibd
FTS_AUX_INDEX_3.ibd
FTS_AUX_INDEX_4.ibd
FTS_AUX_INDEX_5.ibd
FTS_AUX_INDEX_6.ibd
FTS_AUX_BEING_DELETED.ibd
FTS_AUX_BEING_DELETED_CACHE.ibd
FTS_AUX_CONFIG.ibd
FTS_AUX_DELETED.ibd
FTS_AUX_DELETED_CACHE.ibd
FTS_AUX_INDEX_1.ibd
FTS_AUX_INDEX_2.ibd
FTS_AUX_INDEX_3.ibd
FTS_AUX_INDEX_4.ibd
FTS_AUX_INDEX_5.ibd
FTS_AUX_INDEX_6.ibd
FTS_AUX_BEING_DELETED.ibd
FTS_AUX_BEING_DELETED_CACHE.ibd
FTS_AUX_CONFIG.ibd
FTS_AUX_DELETED.ibd
FTS_AUX_DELETED_CACHE.ibd
sys_foreign.frm
sys_foreign.ibd
sys_indexes.frm
sys_indexes.ibd
sys_tables.frm
sys_tables.ibd
t1c.frm
t1c.isl
t1n.frm
t1n.ibd
t1o.frm
t1o.ibd
t1p.frm
t1p.isl
tt.frm
tt.isl
### files in MYSQL_TMP_DIR/alt_dir/test
t1c.ibd
t1p.ibd
tt.ibd
ALTER TABLE t1n CHANGE c1 Fts_DOC_ID INT, ALGORITHM=INPLACE;
ERROR 42000: Incorrect column name 'FTS_DOC_ID'
ALTER TABLE t1n CHANGE c1 Fts_DOC_ID INT, ALGORITHM=COPY;
ERROR 42000: Incorrect column name 'Fts_DOC_ID'
ALTER TABLE t1n CHANGE FTS_DOC_ID c11 INT, ALGORITHM=INPLACE;
ERROR 42S22: Unknown column 'FTS_DOC_ID' in 't1n'
ALTER TABLE t1n CHANGE c1 FTS_DOC_ïD INT, ALGORITHM=INPLACE;
### files in MYSQL_DATA_DIR/test
FTS_AUX_INDEX_1.ibd
FTS_AUX_INDEX_2.ibd
FTS_AUX_INDEX_3.ibd
FTS_AUX_INDEX_4.ibd
FTS_AUX_INDEX_5.ibd
FTS_AUX_INDEX_6.ibd
FTS_AUX_BEING_DELETED.ibd
FTS_AUX_BEING_DELETED_CACHE.ibd
FTS_AUX_CONFIG.ibd
FTS_AUX_DELETED.ibd
FTS_AUX_DELETED_CACHE.ibd
FTS_AUX_INDEX_1.ibd
FTS_AUX_INDEX_2.ibd
FTS_AUX_INDEX_3.ibd
FTS_AUX_INDEX_4.ibd
FTS_AUX_INDEX_5.ibd
FTS_AUX_INDEX_6.ibd
FTS_AUX_BEING_DELETED.ibd
FTS_AUX_BEING_DELETED_CACHE.ibd
FTS_AUX_CONFIG.ibd
FTS_AUX_DELETED.ibd
FTS_AUX_DELETED_CACHE.ibd
sys_foreign.frm
sys_foreign.ibd
sys_indexes.frm
sys_indexes.ibd
sys_tables.frm
sys_tables.ibd
t1c.frm
t1c.isl
t1n.frm
t1n.ibd
t1o.frm
t1o.ibd
t1p.frm
t1p.isl
tt.frm
tt.isl
### files in MYSQL_TMP_DIR/alt_dir/test
t1c.ibd
t1p.ibd
tt.ibd
ALTER TABLE t1n CHANGE FTS_DOC_ÏD c1 INT, ALGORITHM=INPLACE;
### files in MYSQL_DATA_DIR/test
FTS_AUX_INDEX_1.ibd
FTS_AUX_INDEX_2.ibd
FTS_AUX_INDEX_3.ibd
FTS_AUX_INDEX_4.ibd
FTS_AUX_INDEX_5.ibd
FTS_AUX_INDEX_6.ibd
FTS_AUX_BEING_DELETED.ibd
FTS_AUX_BEING_DELETED_CACHE.ibd
FTS_AUX_CONFIG.ibd
FTS_AUX_DELETED.ibd
FTS_AUX_DELETED_CACHE.ibd
FTS_AUX_INDEX_1.ibd
FTS_AUX_INDEX_2.ibd
FTS_AUX_INDEX_3.ibd
FTS_AUX_INDEX_4.ibd
FTS_AUX_INDEX_5.ibd
FTS_AUX_INDEX_6.ibd
FTS_AUX_BEING_DELETED.ibd
FTS_AUX_BEING_DELETED_CACHE.ibd
FTS_AUX_CONFIG.ibd
FTS_AUX_DELETED.ibd
FTS_AUX_DELETED_CACHE.ibd
sys_foreign.frm
sys_foreign.ibd
sys_indexes.frm
sys_indexes.ibd
sys_tables.frm
sys_tables.ibd
t1c.frm
t1c.isl
t1n.frm
t1n.ibd
t1o.frm
t1o.ibd
t1p.frm
t1p.isl
tt.frm
tt.isl
### files in MYSQL_TMP_DIR/alt_dir/test
t1c.ibd
t1p.ibd
tt.ibd
ALTER TABLE t1n CHANGE c1 c2 INT, CHANGE c2 ct INT, CHANGE ct c1 TEXT,
ALGORITHM=INPLACE;
### files in MYSQL_DATA_DIR/test
FTS_AUX_INDEX_1.ibd
FTS_AUX_INDEX_2.ibd
FTS_AUX_INDEX_3.ibd
FTS_AUX_INDEX_4.ibd
FTS_AUX_INDEX_5.ibd
FTS_AUX_INDEX_6.ibd
FTS_AUX_BEING_DELETED.ibd
FTS_AUX_BEING_DELETED_CACHE.ibd
FTS_AUX_CONFIG.ibd
FTS_AUX_DELETED.ibd
FTS_AUX_DELETED_CACHE.ibd
FTS_AUX_INDEX_1.ibd
FTS_AUX_INDEX_2.ibd
FTS_AUX_INDEX_3.ibd
FTS_AUX_INDEX_4.ibd
FTS_AUX_INDEX_5.ibd
FTS_AUX_INDEX_6.ibd
FTS_AUX_BEING_DELETED.ibd
FTS_AUX_BEING_DELETED_CACHE.ibd
FTS_AUX_CONFIG.ibd
FTS_AUX_DELETED.ibd
FTS_AUX_DELETED_CACHE.ibd
sys_foreign.frm
sys_foreign.ibd
sys_indexes.frm
sys_indexes.ibd
sys_tables.frm
sys_tables.ibd
t1c.frm
t1c.isl
t1n.frm
t1n.ibd
t1o.frm
t1o.ibd
t1p.frm
t1p.isl
tt.frm
tt.isl
### files in MYSQL_TMP_DIR/alt_dir/test
t1c.ibd
t1p.ibd
tt.ibd
SHOW CREATE TABLE t1n;
Table Create Table
t1n CREATE TABLE `t1n` (
`c2` int(11) NOT NULL DEFAULT '0',
`ct` int(11) DEFAULT NULL,
`c1` text,
PRIMARY KEY (`c2`),
FULLTEXT KEY `ct` (`c1`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
ALTER TABLE t1n CHANGE c2 c1 INT, CHANGE ct c2 INT, CHANGE c1 ct TEXT,
ALGORITHM=COPY;
### files in MYSQL_DATA_DIR/test
FTS_AUX_INDEX_1.ibd
FTS_AUX_INDEX_2.ibd
FTS_AUX_INDEX_3.ibd
FTS_AUX_INDEX_4.ibd
FTS_AUX_INDEX_5.ibd
FTS_AUX_INDEX_6.ibd
FTS_AUX_BEING_DELETED.ibd
FTS_AUX_BEING_DELETED_CACHE.ibd
FTS_AUX_CONFIG.ibd
FTS_AUX_DELETED.ibd
FTS_AUX_DELETED_CACHE.ibd
FTS_AUX_INDEX_1.ibd
FTS_AUX_INDEX_2.ibd
FTS_AUX_INDEX_3.ibd
FTS_AUX_INDEX_4.ibd
FTS_AUX_INDEX_5.ibd
FTS_AUX_INDEX_6.ibd
FTS_AUX_BEING_DELETED.ibd
FTS_AUX_BEING_DELETED_CACHE.ibd
FTS_AUX_CONFIG.ibd
FTS_AUX_DELETED.ibd
FTS_AUX_DELETED_CACHE.ibd
sys_foreign.frm
sys_foreign.ibd
sys_indexes.frm
sys_indexes.ibd
sys_tables.frm
sys_tables.ibd
t1c.frm
t1c.isl
t1n.frm
t1n.ibd
t1o.frm
t1o.ibd
t1p.frm
t1p.isl
tt.frm
tt.isl
### files in MYSQL_TMP_DIR/alt_dir/test
t1c.ibd
t1p.ibd
tt.ibd
SHOW CREATE TABLE t1n;
Table Create Table
t1n CREATE TABLE `t1n` (
`c1` int(11) NOT NULL DEFAULT '0',
`c2` int(11) DEFAULT NULL,
`ct` text,
PRIMARY KEY (`c1`),
FULLTEXT KEY `ct` (`ct`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
ALTER TABLE t1n ADD INDEX(c2), CHANGE c2 c4 INT, ALGORITHM=INPLACE;
ERROR 42000: Key column 'c2' doesn't exist in table
ALTER TABLE t1n ADD INDEX(c2), CHANGE c2 c4 INT, ALGORITHM=COPY;
ERROR 42000: Key column 'c2' doesn't exist in table
ALTER TABLE t1n ADD INDEX(c4), CHANGE c2 c4 INT, ALGORITHM=INPLACE;
ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: InnoDB presently supports one FULLTEXT index creation at a time. Try ALGORITHM=COPY.
ALTER TABLE t1n CHANGE c2 c4 INT, LOCK=NONE;
ALTER TABLE t1n ADD INDEX(c4), LOCK=NONE;
### files in MYSQL_DATA_DIR/test
FTS_AUX_INDEX_1.ibd
FTS_AUX_INDEX_2.ibd
FTS_AUX_INDEX_3.ibd
FTS_AUX_INDEX_4.ibd
FTS_AUX_INDEX_5.ibd
FTS_AUX_INDEX_6.ibd
FTS_AUX_BEING_DELETED.ibd
FTS_AUX_BEING_DELETED_CACHE.ibd
FTS_AUX_CONFIG.ibd
FTS_AUX_DELETED.ibd
FTS_AUX_DELETED_CACHE.ibd
FTS_AUX_INDEX_1.ibd
FTS_AUX_INDEX_2.ibd
FTS_AUX_INDEX_3.ibd
FTS_AUX_INDEX_4.ibd
FTS_AUX_INDEX_5.ibd
FTS_AUX_INDEX_6.ibd
FTS_AUX_BEING_DELETED.ibd
FTS_AUX_BEING_DELETED_CACHE.ibd
FTS_AUX_CONFIG.ibd
FTS_AUX_DELETED.ibd
FTS_AUX_DELETED_CACHE.ibd
sys_foreign.frm
sys_foreign.ibd
sys_indexes.frm
sys_indexes.ibd
sys_tables.frm
sys_tables.ibd
t1c.frm
t1c.isl
t1n.frm
t1n.ibd
t1o.frm
t1o.ibd
t1p.frm
t1p.isl
tt.frm
tt.isl
### files in MYSQL_TMP_DIR/alt_dir/test
t1c.ibd
t1p.ibd
tt.ibd
SHOW CREATE TABLE t1n;
Table Create Table
t1n CREATE TABLE `t1n` (
`c1` int(11) NOT NULL DEFAULT '0',
`c4` int(11) DEFAULT NULL,
`ct` text,
PRIMARY KEY (`c1`),
KEY `c4` (`c4`),
FULLTEXT KEY `ct` (`ct`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
ALTER TABLE t1n DROP INDEX c4;
### files in MYSQL_DATA_DIR/test
FTS_AUX_INDEX_1.ibd
FTS_AUX_INDEX_2.ibd
FTS_AUX_INDEX_3.ibd
FTS_AUX_INDEX_4.ibd
FTS_AUX_INDEX_5.ibd
FTS_AUX_INDEX_6.ibd
FTS_AUX_BEING_DELETED.ibd
FTS_AUX_BEING_DELETED_CACHE.ibd
FTS_AUX_CONFIG.ibd
FTS_AUX_DELETED.ibd
FTS_AUX_DELETED_CACHE.ibd
FTS_AUX_INDEX_1.ibd
FTS_AUX_INDEX_2.ibd
FTS_AUX_INDEX_3.ibd
FTS_AUX_INDEX_4.ibd
FTS_AUX_INDEX_5.ibd
FTS_AUX_INDEX_6.ibd
FTS_AUX_BEING_DELETED.ibd
FTS_AUX_BEING_DELETED_CACHE.ibd
FTS_AUX_CONFIG.ibd
FTS_AUX_DELETED.ibd
FTS_AUX_DELETED_CACHE.ibd
sys_foreign.frm
sys_foreign.ibd
sys_indexes.frm
sys_indexes.ibd
sys_tables.frm
sys_tables.ibd
t1c.frm
t1c.isl
t1n.frm
t1n.ibd
t1o.frm
t1o.ibd
t1p.frm
t1p.isl
tt.frm
tt.isl
### files in MYSQL_TMP_DIR/alt_dir/test
t1c.ibd
t1p.ibd
tt.ibd
ALTER TABLE t1n CHANGE c4 c1 INT, ADD INDEX(c1), ALGORITHM=INPLACE;
ERROR 42S21: Duplicate column name 'c1'
ALTER TABLE t1n CHANGE c4 c11 INT, ADD INDEX(c11), ALGORITHM=INPLACE;
ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: InnoDB presently supports one FULLTEXT index creation at a time. Try ALGORITHM=COPY.
ALTER TABLE t1n CHANGE c4 c11 INT, LOCK=NONE;
ALTER TABLE t1n ADD INDEX(c11), LOCK=NONE;
### files in MYSQL_DATA_DIR/test
FTS_AUX_INDEX_1.ibd
FTS_AUX_INDEX_2.ibd
FTS_AUX_INDEX_3.ibd
FTS_AUX_INDEX_4.ibd
FTS_AUX_INDEX_5.ibd
FTS_AUX_INDEX_6.ibd
FTS_AUX_BEING_DELETED.ibd
FTS_AUX_BEING_DELETED_CACHE.ibd
FTS_AUX_CONFIG.ibd
FTS_AUX_DELETED.ibd
FTS_AUX_DELETED_CACHE.ibd
FTS_AUX_INDEX_1.ibd
FTS_AUX_INDEX_2.ibd
FTS_AUX_INDEX_3.ibd
FTS_AUX_INDEX_4.ibd
FTS_AUX_INDEX_5.ibd
FTS_AUX_INDEX_6.ibd
FTS_AUX_BEING_DELETED.ibd
FTS_AUX_BEING_DELETED_CACHE.ibd
FTS_AUX_CONFIG.ibd
FTS_AUX_DELETED.ibd
FTS_AUX_DELETED_CACHE.ibd
sys_foreign.frm
sys_foreign.ibd
sys_indexes.frm
sys_indexes.ibd
sys_tables.frm
sys_tables.ibd
t1c.frm
t1c.isl
t1n.frm
t1n.ibd
t1o.frm
t1o.ibd
t1p.frm
t1p.isl
tt.frm
tt.isl
### files in MYSQL_TMP_DIR/alt_dir/test
t1c.ibd
t1p.ibd
tt.ibd
SHOW CREATE TABLE t1n;
Table Create Table
t1n CREATE TABLE `t1n` (
`c1` int(11) NOT NULL DEFAULT '0',
`c11` int(11) DEFAULT NULL,
`ct` text,
PRIMARY KEY (`c1`),
KEY `c11` (`c11`),
FULLTEXT KEY `ct` (`ct`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
DROP TABLE t1n;
ALTER TABLE t1o MODIFY c1 BIGINT UNSIGNED NOT NULL;
### files in MYSQL_DATA_DIR/test
FTS_AUX_INDEX_1.ibd
FTS_AUX_INDEX_2.ibd
FTS_AUX_INDEX_3.ibd
FTS_AUX_INDEX_4.ibd
FTS_AUX_INDEX_5.ibd
FTS_AUX_INDEX_6.ibd
FTS_AUX_BEING_DELETED.ibd
FTS_AUX_BEING_DELETED_CACHE.ibd
FTS_AUX_CONFIG.ibd
FTS_AUX_DELETED.ibd
FTS_AUX_DELETED_CACHE.ibd
sys_foreign.frm
sys_foreign.ibd
sys_indexes.frm
sys_indexes.ibd
sys_tables.frm
sys_tables.ibd
t1c.frm
t1c.isl
t1o.frm
t1o.ibd
t1p.frm
t1p.isl
tt.frm
tt.isl
### files in MYSQL_TMP_DIR/alt_dir/test
t1c.ibd
t1p.ibd
tt.ibd
call mtr.add_suppression("Error: no matching column for .FTS_DOC_ID. in index .ct.--temporary-- of table .test...t1o");
ALTER TABLE t1o ADD FULLTEXT INDEX(ct),
CHANGE c1 FTS_DOC_ID BIGINT UNSIGNED NOT NULL,
ALGORITHM=INPLACE;
ERROR HY000: Incorrect key file for table 't1o'; try to repair it
ALTER TABLE t1o CHANGE c1 FTS_DOC_ID BIGINT UNSIGNED NOT NULL, LOCK=NONE;
ALTER TABLE t1o ADD FULLTEXT INDEX(ct), ALGORITHM=INPLACE;
### files in MYSQL_DATA_DIR/test
FTS_AUX_INDEX_1.ibd
FTS_AUX_INDEX_2.ibd
FTS_AUX_INDEX_3.ibd
FTS_AUX_INDEX_4.ibd
FTS_AUX_INDEX_5.ibd
FTS_AUX_INDEX_6.ibd
FTS_AUX_BEING_DELETED.ibd
FTS_AUX_BEING_DELETED_CACHE.ibd
FTS_AUX_CONFIG.ibd
FTS_AUX_DELETED.ibd
FTS_AUX_DELETED_CACHE.ibd
FTS_AUX_INDEX_1.ibd
FTS_AUX_INDEX_2.ibd
FTS_AUX_INDEX_3.ibd
FTS_AUX_INDEX_4.ibd
FTS_AUX_INDEX_5.ibd
FTS_AUX_INDEX_6.ibd
FTS_AUX_BEING_DELETED.ibd
FTS_AUX_BEING_DELETED_CACHE.ibd
FTS_AUX_CONFIG.ibd
FTS_AUX_DELETED.ibd
FTS_AUX_DELETED_CACHE.ibd
sys_foreign.frm
sys_foreign.ibd
sys_indexes.frm
sys_indexes.ibd
sys_tables.frm
sys_tables.ibd
t1c.frm
t1c.isl
t1o.frm
t1o.ibd
t1p.frm
t1p.isl
tt.frm
tt.isl
### files in MYSQL_TMP_DIR/alt_dir/test
t1c.ibd
t1p.ibd
tt.ibd
SELECT sc.pos FROM information_schema.innodb_sys_columns sc
INNER JOIN information_schema.innodb_sys_tables st
ON sc.TABLE_ID=st.TABLE_ID
WHERE st.NAME='test/t1o' AND sc.NAME='FTS_DOC_ID';
pos
0
SHOW CREATE TABLE t1o;
Table Create Table
t1o CREATE TABLE `t1o` (
`FTS_DOC_ID` bigint(20) unsigned NOT NULL,
`c2` int(11) DEFAULT NULL,
`ct` text,
PRIMARY KEY (`FTS_DOC_ID`),
FULLTEXT KEY `ct` (`ct`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
ALTER TABLE t1o CHANGE FTS_DOC_ID foo_id BIGINT UNSIGNED NOT NULL,
DROP INDEX ct, LOCK=NONE;
### files in MYSQL_DATA_DIR/test
FTS_AUX_INDEX_1.ibd
FTS_AUX_INDEX_2.ibd
FTS_AUX_INDEX_3.ibd
FTS_AUX_INDEX_4.ibd
FTS_AUX_INDEX_5.ibd
FTS_AUX_INDEX_6.ibd
FTS_AUX_BEING_DELETED.ibd
FTS_AUX_BEING_DELETED_CACHE.ibd
FTS_AUX_CONFIG.ibd
FTS_AUX_DELETED.ibd
FTS_AUX_DELETED_CACHE.ibd
sys_foreign.frm
sys_foreign.ibd
sys_indexes.frm
sys_indexes.ibd
sys_tables.frm
sys_tables.ibd
t1c.frm
t1c.isl
t1o.frm
t1o.ibd
t1p.frm
t1p.isl
tt.frm
tt.isl
### files in MYSQL_TMP_DIR/alt_dir/test
t1c.ibd
t1p.ibd
tt.ibd
SHOW CREATE TABLE t1o;
Table Create Table
t1o CREATE TABLE `t1o` (
`foo_id` bigint(20) unsigned NOT NULL,
`c2` int(11) DEFAULT NULL,
`ct` text,
PRIMARY KEY (`foo_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
DROP TABLE t1c, t1p, sys_tables, sys_indexes, sys_foreign;
CREATE TABLE sys_tables SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES
WHERE NAME='test/t1o';
CREATE TABLE sys_indexes SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES i
INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID;
CREATE TABLE sys_foreign SELECT i.*
FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN i WHERE FOR_NAME='test/t1o';
SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN
FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i
INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID;
NAME POS MTYPE PRTYPE LEN
foo_id 0 6 1800 8
c2 1 6 1027 4
ct 2 5 524540 10
SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i
INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID;
NAME POS NAME
PRIMARY 0 foo_id
SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i
INNER JOIN sys_foreign sf ON i.ID = sf.ID;
ID FOR_COL_NAME REF_COL_NAME POS
ALTER TABLE t1o ADD UNIQUE INDEX FTS_DOC_ID_INDEX(foo_id);
### files in MYSQL_DATA_DIR/test
FTS_AUX_INDEX_1.ibd
FTS_AUX_INDEX_2.ibd
FTS_AUX_INDEX_3.ibd
FTS_AUX_INDEX_4.ibd
FTS_AUX_INDEX_5.ibd
FTS_AUX_INDEX_6.ibd
FTS_AUX_BEING_DELETED.ibd
FTS_AUX_BEING_DELETED_CACHE.ibd
FTS_AUX_CONFIG.ibd
FTS_AUX_DELETED.ibd
FTS_AUX_DELETED_CACHE.ibd
sys_foreign.frm
sys_foreign.ibd
sys_indexes.frm
sys_indexes.ibd
sys_tables.frm
sys_tables.ibd
t1o.frm
t1o.ibd
tt.frm
tt.isl
### files in MYSQL_TMP_DIR/alt_dir/test
tt.ibd
ALTER TABLE t1o CHANGE foo_id FTS_DOC_ID BIGINT UNSIGNED NOT NULL,
ADD FULLTEXT INDEX(ct);
ERROR HY000: Incorrect key file for table 't1o'; try to repair it
ALTER TABLE t1o CHANGE foo_id FTS_DOC_ID BIGINT UNSIGNED NOT NULL, LOCK=NONE;
ALTER TABLE t1o ADD FULLTEXT INDEX(ct), ALGORITHM=INPLACE;
### files in MYSQL_DATA_DIR/test
FTS_AUX_INDEX_1.ibd
FTS_AUX_INDEX_2.ibd
FTS_AUX_INDEX_3.ibd
FTS_AUX_INDEX_4.ibd
FTS_AUX_INDEX_5.ibd
FTS_AUX_INDEX_6.ibd
FTS_AUX_BEING_DELETED.ibd
FTS_AUX_BEING_DELETED_CACHE.ibd
FTS_AUX_CONFIG.ibd
FTS_AUX_DELETED.ibd
FTS_AUX_DELETED_CACHE.ibd
FTS_AUX_INDEX_1.ibd
FTS_AUX_INDEX_2.ibd
FTS_AUX_INDEX_3.ibd
FTS_AUX_INDEX_4.ibd
FTS_AUX_INDEX_5.ibd
FTS_AUX_INDEX_6.ibd
FTS_AUX_BEING_DELETED.ibd
FTS_AUX_BEING_DELETED_CACHE.ibd
FTS_AUX_CONFIG.ibd
FTS_AUX_DELETED.ibd
FTS_AUX_DELETED_CACHE.ibd
sys_foreign.frm
sys_foreign.ibd
sys_indexes.frm
sys_indexes.ibd
sys_tables.frm
sys_tables.ibd
t1o.frm
t1o.ibd
tt.frm
tt.isl
### files in MYSQL_TMP_DIR/alt_dir/test
tt.ibd
ALTER TABLE t1o CHANGE FTS_DOC_ID foo_id BIGINT UNSIGNED NOT NULL;
ERROR HY000: Index 'FTS_DOC_ID_INDEX' is of wrong type for an InnoDB FULLTEXT index
DROP TABLE sys_indexes;
CREATE TABLE sys_indexes SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES i
INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID;
SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN
FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i
INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID;
NAME POS MTYPE PRTYPE LEN
FTS_DOC_ID 0 6 1800 8
c2 1 6 1027 4
ct 2 5 524540 10
SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i
INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID;
NAME POS NAME
PRIMARY 0 FTS_DOC_ID
FTS_DOC_ID_INDEX 0 FTS_DOC_ID
ct 0 ct
SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i
INNER JOIN sys_foreign sf ON i.ID = sf.ID;
ID FOR_COL_NAME REF_COL_NAME POS
#
# Cleanup
#
DROP TABLE tt, t1o, sys_tables, sys_indexes, sys_foreign;
### files in MYSQL_DATA_DIR/test
### files in MYSQL_TMP_DIR/alt_dir/test
--echo #
--echo # Show what happens during ALTER TABLE when an existing file
--echo # exists in the target location.
--echo #
--echo # Bug #19218794: IF TABLESPACE EXISTS, CAN'T CREATE TABLE,
--echo # BUT CAN ALTER ENGINE=INNODB
--echo #
--source include/have_innodb.inc
--disable_query_log
LET $MYSQLD_DATADIR = `select @@datadir`;
SET @old_innodb_file_per_table = @@innodb_file_per_table;
--enable_query_log
CREATE TABLE t1 (a SERIAL, b CHAR(10)) ENGINE=Memory;
INSERT INTO t1(b) VALUES('one'), ('two'), ('three');
--echo #
--echo # Create a file called MYSQLD_DATADIR/test/t1.ibd
--exec echo "This is not t1.ibd" > $MYSQLD_DATADIR/test/t1.ibd
--echo # Directory listing of test/*.ibd
--echo #
--list_files $MYSQLD_DATADIR/test/ *.ibd
--replace_regex /Error on rename of '.*' to '.*'/Error on rename of 'OLD_FILE_NAME' to 'NEW_FILE_NAME'/
--error ER_ERROR_ON_RENAME
ALTER TABLE t1 ENGINE = InnoDB;
--echo #
--echo # Move the file to InnoDB as t2
--echo #
ALTER TABLE t1 RENAME TO t2, ENGINE = INNODB;
SHOW CREATE TABLE t2;
SELECT * from t2;
--replace_regex /Error on rename of '.*' to '.*'/Error on rename of 'OLD_FILE_NAME' to 'NEW_FILE_NAME'/
--error ER_ERROR_ON_RENAME
ALTER TABLE t2 RENAME TO t1;
--echo #
--echo # Create another t1, but in the system tablespace.
--echo #
SET GLOBAL innodb_file_per_table=OFF;
CREATE TABLE t1 (a SERIAL, b CHAR(20)) ENGINE=InnoDB;
INSERT INTO t1(b) VALUES('one'), ('two'), ('three');
SHOW CREATE TABLE t1;
SELECT name, space=0 FROM information_schema.innodb_sys_tables WHERE name = 'test/t1';
--echo #
--echo # ALTER TABLE from system tablespace to system tablespace
--echo #
ALTER TABLE t1 ADD COLUMN c INT, ALGORITHM=INPLACE;
ALTER TABLE t1 ADD COLUMN d INT, ALGORITHM=COPY;
--echo #
--echo # Try to move t1 from the system tablespace to a file-per-table
--echo # while a blocking t1.ibd file exists.
--echo #
SET GLOBAL innodb_file_per_table=ON;
--replace_regex /$MYSQLD_DATADIR/MYSQLD_DATADIR/
--error ER_TABLESPACE_EXISTS
ALTER TABLE t1 ADD COLUMN e1 INT, ALGORITHM=INPLACE;
--replace_regex /Error on rename of '.*' to '.*'/Error on rename of 'OLD_FILE_NAME' to 'NEW_FILE_NAME'/
--error ER_ERROR_ON_RENAME
ALTER TABLE t1 ADD COLUMN e2 INT, ALGORITHM=COPY;
--echo #
--echo # Delete the blocking file called MYSQLD_DATADIR/test/t1.ibd
--remove_file $MYSQLD_DATADIR/test/t1.ibd
--echo # Move t1 to file-per-table using ALGORITHM=INPLACE with no blocking t1.ibd.
--echo #
ALTER TABLE t1 ADD COLUMN e INT, ALGORITHM=INPLACE;
SHOW CREATE TABLE t1;
SELECT name, space=0 FROM information_schema.innodb_sys_tables WHERE name = 'test/t1';
DROP TABLE t1;
--echo #
--echo # Rename t2.ibd to t1.ibd.
--echo #
ALTER TABLE t2 RENAME TO t1;
SELECT name, space=0 FROM information_schema.innodb_sys_tables WHERE name = 'test/t1';
SELECT * from t1;
DROP TABLE t1;
--disable_query_log
call mtr.add_suppression("\\[ERROR\\] InnoDB: Cannot rename '.*' to '.*' for space ID .* because the target file exists. Remove the target file and try again");
SET GLOBAL innodb_file_per_table = @old_innodb_file_per_table;
--enable_query_log
--source include/have_innodb.inc
--source include/have_innodb_16k.inc
--source include/have_debug.inc
SET @saved_debug_dbug = @@SESSION.debug_dbug;
--echo #
--echo #BUG#21326304 INNODB ONLINE ALTER TABLE ENDS IN CRASH ON DISK FULL
--echo #
CREATE TABLE t1(f1 CHAR(255) NOT NULL, f2 CHAR(255) NOT NULL, f3
CHAR(255) NOT NULL, f4 CHAR(255) NOT NULL, f5 CHAR(255) NOT NULL,f6
CHAR(255) NOT NULL, f7 CHAR(255) NOT NULL, f8 CHAR(255) NOT NULL,f9
CHAR(255) NOT NULL, f10 CHAR(255) NOT NULL, f11 CHAR(255) NOT NULL,f12
CHAR(255) NOT NULL, f13 CHAR(255) NOT NULL, f14 CHAR(255) NOT NULL,f15
CHAR(255) NOT NULL, f16 CHAR(255) NOT NULL, f17 CHAR(255) NOT NULL,f18
CHAR(255) NOT NULL)
ENGINE=INNODB ROW_FORMAT=DYNAMIC;
INSERT INTO t1
VALUES('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r');
INSERT INTO t1 SELECT * FROM t1;
INSERT INTO t1 SELECT * FROM t1;
INSERT INTO t1 SELECT * FROM t1;
INSERT INTO t1 SELECT * FROM t1;
SET debug_dbug = '+d,disk_is_full';
--error ER_RECORD_FILE_FULL
ALTER TABLE t1 FORCE, ALGORITHM=INPLACE;
SET debug_dbug= @saved_debug_dbug;
DROP TABLE t1;
-- source include/have_innodb.inc
-- source include/have_innodb_16k.inc
--echo #
--echo # Bug#15923864 (Bug#67718):
--echo # INNODB DRASTICALLY UNDER-FILLS PAGES IN CERTAIN CONDITIONS
--echo #
# InnoDB should try to insert to the next page before split,
# if the insert record for split_and_insert is last of the page.
# Otherwise, the follwing records 999,998,997 cause each page per record.
#
--disable_query_log
SET @old_innodb_file_per_table = @@innodb_file_per_table;
--enable_query_log
SET GLOBAL innodb_file_per_table=ON;
CREATE TABLE t1 (a BIGINT PRIMARY KEY, b VARCHAR(4096)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (0, REPEAT('a', 4096));
INSERT INTO t1 VALUES (1000, REPEAT('a', 4096));
INSERT INTO t1 VALUES (1001, REPEAT('a', 4096));
INSERT INTO t1 VALUES (1002, REPEAT('a', 4096));
INSERT INTO t1 VALUES (1, REPEAT('a', 4096));
INSERT INTO t1 VALUES (2, REPEAT('a', 4096));
# | 0, 1, 2 | 1000, 1001, 1002|
SELECT page_number, number_records
FROM information_schema.innodb_sys_tablespaces s1,
information_schema.innodb_buffer_page s2
WHERE s1.space = s2.space AND name = 'test/t1'
AND page_type = "INDEX" ORDER BY page_number;
INSERT INTO t1 VALUES (999, REPEAT('a', 4096));
# try to insert '999' to the end of '0,1,2' page, but no space
# the next '1000,1001,1002' page has also no space.
# | 0, 1, 2 | 999 | 1000, 1001, 1002|
SELECT page_number, number_records
FROM information_schema.innodb_sys_tablespaces s1,
information_schema.innodb_buffer_page s2
WHERE s1.space = s2.space AND name = 'test/t1'
AND page_type = "INDEX" ORDER BY page_number;
INSERT INTO t1 VALUES (998, REPEAT('a', 4096));
# try to insert to the end of '0,1,2' page, but no space
# the next '998' page has space.
# | 0, 1, 2 | 998, 999 | 1000, 1001, 1002|
SELECT page_number, number_records
FROM information_schema.innodb_sys_tablespaces s1,
information_schema.innodb_buffer_page s2
WHERE s1.space = s2.space AND name = 'test/t1'
AND page_type = "INDEX" ORDER BY page_number;
INSERT INTO t1 VALUES (997, REPEAT('a', 4096));
# same
# | 0, 1, 2 | 997, 998, 999 | 1000, 1001, 1002|
SELECT page_number, number_records
FROM information_schema.innodb_sys_tablespaces s1,
information_schema.innodb_buffer_page s2
WHERE s1.space = s2.space AND name = 'test/t1'
AND page_type = "INDEX" ORDER BY page_number;
DROP TABLE t1;
--disable_query_log
SET GLOBAL innodb_file_per_table = @old_innodb_file_per_table;
--enable_query_log
--source include/have_innodb.inc
CREATE TABLE t1 (a INT) ENGINE=InnoDB;
INSERT INTO t1 VALUES(347),(33101),(123),(45),(6);
# NULL -> NOT NULL only allowed INPLACE if strict sql_mode is on.
SET @old_sql_mode = @@sql_mode;
SET @@sql_mode = 'STRICT_TRANS_TABLES';
ALTER TABLE t1 ADD PRIMARY KEY(a);
SET @@sql_mode = @old_sql_mode;
# We cannot assign AUTO_INCREMENT values during online index creation.
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
ALTER TABLE t1 DROP PRIMARY KEY, ADD id INT AUTO_INCREMENT PRIMARY KEY,
LOCK=NONE;
--error ER_WRONG_AUTO_KEY
ALTER TABLE t1 ADD id INT AUTO_INCREMENT;
--error ER_WRONG_AUTO_KEY
ALTER TABLE t1 ADD id INT AUTO_INCREMENT, ADD INDEX(a, id);
ALTER TABLE t1 ADD id INT NOT NULL, ADD INDEX(id, a);
SELECT * FROM t1;
# Test with a non-default increment and offset
SET AUTO_INCREMENT_INCREMENT = 5, AUTO_INCREMENT_OFFSET = 30;
ALTER TABLE t1 DROP PRIMARY KEY, ADD id INT AUTO_INCREMENT PRIMARY KEY,
DROP COLUMN id, AUTO_INCREMENT = 42, ALGORITHM=COPY;
SHOW CREATE TABLE t1;
# The autoinc next value should increase. It is not rolled back.
BEGIN;
INSERT INTO t1 VALUES(7,0);
SELECT * FROM t1;
ROLLBACK;
SHOW CREATE TABLE t1;
# We cannot assign AUTO_INCREMENT values during online index creation.
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
ALTER TABLE t1 DROP PRIMARY KEY, ADD id INT AUTO_INCREMENT PRIMARY KEY,
DROP COLUMN id, AUTO_INCREMENT = 42, LOCK=NONE;
ALTER TABLE t1 DROP PRIMARY KEY, ADD id INT AUTO_INCREMENT PRIMARY KEY,
DROP COLUMN id, AUTO_INCREMENT = 42, ALGORITHM=INPLACE;
SELECT * FROM t1;
SHOW CREATE TABLE t1;
INSERT INTO t1 SET a=123;
INSERT INTO t1 VALUES(-123,-45);
ALTER TABLE t1 AUTO_INCREMENT = 75;
INSERT INTO t1 SET a=123;
SELECT * FROM t1;
SHOW CREATE TABLE t1;
DROP TABLE t1;
# ALGORITHM=INPLACE should deliver identical results to ALGORITHM=COPY.
CREATE TABLE t1 (a INT) ENGINE=InnoDB;
INSERT INTO t1 VALUES(347),(33101),(123),(45),(6);
ALTER TABLE t1 ADD PRIMARY KEY(a);
ALTER TABLE t1 ADD id INT NOT NULL, ADD INDEX(id, a);
SELECT * FROM t1;
ALTER TABLE t1 DROP PRIMARY KEY, ADD id INT AUTO_INCREMENT PRIMARY KEY,
DROP COLUMN id, AUTO_INCREMENT = 42, ALGORITHM=INPLACE;
SHOW CREATE TABLE t1;
# The autoinc next value should increase. It is not rolled back.
BEGIN;
INSERT INTO t1 VALUES(7,0);
SELECT * FROM t1;
ROLLBACK;
SHOW CREATE TABLE t1;
ALTER TABLE t1 DROP PRIMARY KEY, ADD id INT AUTO_INCREMENT PRIMARY KEY,
DROP COLUMN id, AUTO_INCREMENT = 42, ALGORITHM=COPY;
SELECT * FROM t1;
SHOW CREATE TABLE t1;
INSERT INTO t1 SET a=123;
INSERT INTO t1 VALUES(-123,-45);
ALTER TABLE t1 AUTO_INCREMENT = 75;
INSERT INTO t1 SET a=123;
SELECT * FROM t1;
SHOW CREATE TABLE t1;
DROP TABLE t1;
--loose-innodb-sys-indexes
--loose-innodb-sys-columns
--loose-innodb-sys-fields
--source include/have_innodb.inc
SET NAMES utf8;
CREATE TABLE t1 (
c1 INT PRIMARY KEY, c2 INT DEFAULT 1, ct TEXT,
INDEX(c2))
ENGINE=InnoDB;
INSERT INTO t1 SET c1=1;
CREATE TABLE sys_tables SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES
WHERE NAME LIKE 'test/t%';
CREATE TABLE sys_indexes SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES i
INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID;
CREATE TABLE t1p LIKE t1;
CREATE TABLE t1c (c1 INT PRIMARY KEY, c2 INT, c3 INT, INDEX(c2), INDEX(c3),
CONSTRAINT t1c2 FOREIGN KEY (c2) REFERENCES t1(c2),
CONSTRAINT t1c3 FOREIGN KEY (c3) REFERENCES t1p(c2))
ENGINE=InnoDB;
CREATE TABLE sys_foreign SELECT i.*
FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN i
WHERE FOR_NAME LIKE 'test/t%';
SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i
INNER JOIN sys_foreign sf ON i.ID = sf.ID;
-- source suite/innodb/include/innodb_dict.inc
SHOW CREATE TABLE t1;
ALTER TABLE t1 ALTER c2 DROP DEFAULT;
SHOW CREATE TABLE t1;
-- source suite/innodb/include/innodb_dict.inc
# These should be no-op.
ALTER TABLE t1 CHANGE c2 c2 INT AFTER c1;
ALTER TABLE t1 CHANGE c1 c1 INT FIRST;
-- source suite/innodb/include/innodb_dict.inc
ALTER TABLE t1 CHANGE C2 c3 INT;
-- source suite/innodb/include/innodb_dict.inc
ALTER TABLE t1 CHANGE c3 C INT;
-- source suite/innodb/include/innodb_dict.inc
ALTER TABLE t1 CHANGE C Cöŀumň_TWO INT;
SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i
INNER JOIN sys_foreign sf ON i.ID = sf.ID;
-- source suite/innodb/include/innodb_dict.inc
-- error ER_BAD_FIELD_ERROR
ALTER TABLE t1 CHANGE cöĿǖmň_two c3 INT;
ALTER TABLE t1 CHANGE cÖĿUMŇ_two c3 INT, RENAME TO t3;
SELECT st.NAME, i.NAME
FROM sys_tables st INNER JOIN INFORMATION_SCHEMA.INNODB_SYS_TABLES i
ON i.TABLE_ID=st.TABLE_ID;
SHOW CREATE TABLE t3;
SHOW CREATE TABLE t1c;
# The maximum column name length should be 64 characters.
--error ER_TOO_LONG_IDENT
ALTER TABLE t3 CHANGE c3
`12345678901234567890123456789012345678901234567890123456789012345` INT;
ALTER TABLE t3 CHANGE c3
`1234567890123456789012345678901234567890123456789012345678901234` INT;
SHOW CREATE TABLE t3;
# Test the length limit with non-ASCII utf-8 characters.
--error ER_TOO_LONG_IDENT
ALTER TABLE t3 CHANGE
`1234567890123456789012345678901234567890123456789012345678901234`
`倀倁倂倃倄倅倆倇倈倉倊個倌倍倎倏倐們倒倓倔倕倖倗倘候倚倛倜倝倞借倠倡倢倣値倥倦倧倨倩倪倫倬倭倮倯倰倱倲倳倴倵倶倷倸倹债倻值倽倾倿偀` INT;
--error ER_TOO_LONG_IDENT
ALTER TABLE t3 CHANGE
`1234567890123456789012345678901234567890123456789012345678901234`
`倀倁倂倃倄倅倆倇倈倉倊個倌倍倎倏倐們倒倓倔倕倖倗倘候倚倛倜倝倞借倠倡倢倣値倥倦倧倨倩倪倫倬倭倮倯倰倱倲倳倴倵倶倷倸倹债倻值倽倾倿ä` INT;
ALTER TABLE t3 CHANGE
`1234567890123456789012345678901234567890123456789012345678901234`
`倀倁倂倃倄倅倆倇倈倉倊個倌倍倎倏倐們倒倓倔倕倖倗倘候倚倛倜倝倞借倠倡倢倣値倥倦倧倨倩倪倫倬倭倮倯倰倱倲倳倴倵倶倷倸倹债倻值倽倾ä` INT;
# check that the rename is case-insensitive (note the upper-case ä at end)
ALTER TABLE t3 CHANGE
`倀倁倂倃倄倅倆倇倈倉倊個倌倍倎倏倐們倒倓倔倕倖倗倘候倚倛倜倝倞借倠倡倢倣値倥倦倧倨倩倪倫倬倭倮倯倰倱倲倳倴倵倶倷倸倹债倻值倽倾Ä`
c3 INT;
# test with 4-byte UTF-8 (should be disallowed)
--error ER_INVALID_CHARACTER_STRING
ALTER TABLE t3 CHANGE c3 𐌀𐌁𐌂𐌃𐌄𐌅𐌆𐌇𐌈𐌉𐌊𐌋𐌌𐌍𐌎𐌏𐌐𐌑𐌒𐌓𐌔𐌕𐌖𐌗𐌘𐌙𐌚𐌛𐌜 INT;
--error ER_INVALID_CHARACTER_STRING
ALTER TABLE t3 CHANGE c3 😲 INT;
ALTER TABLE t3 RENAME TO t2;
SELECT st.NAME, i.NAME
FROM sys_tables st INNER JOIN INFORMATION_SCHEMA.INNODB_SYS_TABLES i
ON i.TABLE_ID=st.TABLE_ID;
SHOW CREATE TABLE t2;
RENAME TABLE t2 TO t1;
SELECT st.NAME, i.NAME
FROM sys_tables st INNER JOIN INFORMATION_SCHEMA.INNODB_SYS_TABLES i
ON i.TABLE_ID=st.TABLE_ID;
-- source suite/innodb/include/innodb_dict.inc
--error ER_DROP_INDEX_FK
ALTER TABLE t1 DROP INDEX c2;
--error ER_CANT_DROP_FIELD_OR_KEY
ALTER TABLE t1 DROP INDEX c4;
--error ER_CANT_DROP_FIELD_OR_KEY
ALTER TABLE t1c DROP FOREIGN KEY c2;
--error ER_CANT_DROP_FIELD_OR_KEY
ALTER TABLE t1c DROP FOREIGN KEY t1c2, DROP FOREIGN KEY c2;
--error ER_CANT_DROP_FIELD_OR_KEY
ALTER TABLE t1c DROP FOREIGN KEY t1c2, DROP FOREIGN KEY c2, DROP INDEX c2;
--error ER_DROP_INDEX_FK
ALTER TABLE t1c DROP INDEX c2;
--error ER_CANT_DROP_FIELD_OR_KEY
ALTER TABLE t1c DROP FOREIGN KEY ẗ1C2;
SHOW CREATE TABLE t1c;
SET foreign_key_checks=0;
DROP TABLE t1p;
SET foreign_key_checks=1;
SHOW CREATE TABLE t1c;
-- source suite/innodb/include/innodb_dict.inc
CREATE TABLE t1p (c1 INT PRIMARY KEY, c2 INT, INDEX(c2)) ENGINE=InnoDB;
--error ER_DROP_INDEX_FK
ALTER TABLE t1c DROP INDEX C2, DROP INDEX C3;
--error ER_DROP_INDEX_FK
ALTER TABLE t1c DROP INDEX C3;
SET foreign_key_checks=0;
ALTER TABLE t1c DROP INDEX C3;
SET foreign_key_checks=1;
SHOW CREATE TABLE t1c;
-- source suite/innodb/include/innodb_dict.inc
ALTER TABLE t1c DROP FOREIGN KEY t1C3;
SHOW CREATE TABLE t1c;
-- source suite/innodb/include/innodb_dict.inc
ALTER TABLE t1c DROP INDEX c2, DROP FOREIGN KEY t1C2;
SHOW CREATE TABLE t1c;
-- source suite/innodb/include/innodb_dict.inc
ALTER TABLE t1 DROP INDEX c2, CHANGE c3 c2 INT;
-- source suite/innodb/include/innodb_dict.inc
CREATE TABLE t1o LIKE t1;
# This will implicitly add a FTS_DOC_ID column, which cannot be done online.
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
ALTER TABLE t1 ADD FULLTEXT INDEX (ct),
CHANGE c1 pk INT, ALTER c2 SET DEFAULT 42, RENAME TO tt,
ALGORITHM=INPLACE, LOCK=NONE;
ALTER TABLE t1 ADD FULLTEXT INDEX (ct),
CHANGE c1 pk INT, ALTER c2 SET DEFAULT 42, RENAME TO tt,
ALGORITHM=INPLACE, LOCK=SHARED;
# The output should be empty, because index->id was reassigned.
-- source suite/innodb/include/innodb_dict.inc
SHOW CREATE TABLE tt;
# DB_ROW_ID, DB_TRX_ID, DB_ROLL_PTR are reserved InnoDB system column names.
--error ER_WRONG_COLUMN_NAME
ALTER TABLE t1o CHANGE c1 dB_row_Id INT, ALGORITHM=COPY;
--error ER_WRONG_COLUMN_NAME
ALTER TABLE t1o CHANGE c1 dB_row_Id INT, ALGORITHM=INPLACE;
--error ER_WRONG_COLUMN_NAME
ALTER TABLE t1o CHANGE c1 DB_TRX_ID INT;
--error ER_WRONG_COLUMN_NAME
ALTER TABLE t1o CHANGE c1 db_roll_ptr INT;
--error ER_WRONG_COLUMN_NAME
ALTER TABLE t1o ADD COLUMN DB_TRX_ID INT;
--error ER_WRONG_COLUMN_NAME
ALTER TABLE t1o ADD COLUMN db_roll_ptr INT;
--error ER_INNODB_FT_WRONG_DOCID_COLUMN
ALTER TABLE t1o ADD FULLTEXT INDEX(ct), ADD COLUMN FTS_DOC_ID BIGINT;
--error ER_INNODB_FT_WRONG_DOCID_COLUMN
ALTER TABLE t1o ADD FULLTEXT INDEX(ct), ADD COLUMN FTS_DOC_ID BIGINT UNSIGNED;
ALTER TABLE t1o ADD FULLTEXT INDEX(ct),
ADD COLUMN FTS_DOC_ID BIGINT UNSIGNED NOT NULL;
--error ER_DUP_FIELDNAME
ALTER TABLE t1o ADD FULLTEXT INDEX(ct), ADD COLUMN FTS_DOC_ID INT;
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
ALTER TABLE t1o DROP COLUMN FTS_DOC_ID, ALGORITHM=INPLACE;
ALTER TABLE t1o DROP COLUMN FTS_DOC_ID, DROP INDEX ct, ALGORITHM=INPLACE;
# This creates a hidden FTS_DOC_ID column.
ALTER TABLE t1o ADD FULLTEXT INDEX(ct), ADD COLUMN cu TEXT;
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
ALTER TABLE t1o ADD FULLTEXT INDEX(cu), ADD COLUMN FTS_DOC_ID BIGINT,
ALGORITHM=INPLACE;
--error ER_WRONG_COLUMN_NAME
ALTER TABLE t1o ADD FULLTEXT INDEX(cu), ADD COLUMN FTS_DOC_ID BIGINT;
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
ALTER TABLE t1o ADD FULLTEXT INDEX(cu), ADD COLUMN FTS_DOC_ID BIGINT UNSIGNED,
ALGORITHM=INPLACE;
--error ER_WRONG_COLUMN_NAME
ALTER TABLE t1o ADD FULLTEXT INDEX(cu), ADD COLUMN FTS_DOC_ID BIGINT UNSIGNED;
# This would drop the hidden FTS_DOC_ID column and create
# a fulltext index on ct and another fulltext index on cu.
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
ALTER TABLE t1o ADD FULLTEXT INDEX(cu),
ADD COLUMN FTS_DOC_ID BIGINT UNSIGNED NOT NULL, ALGORITHM=INPLACE;
# Replace the hidden FTS_DOC_ID column with a user-visible one.
# This used to work if there is at most one fulltext index.
# Currently, we disallow native ALTER TABLE if the table
# contains any FULLTEXT indexes.
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
ALTER TABLE t1o ADD COLUMN FTS_DOC_ID BIGINT UNSIGNED NOT NULL,
ALGORITHM=INPLACE;
ALTER TABLE t1o ADD COLUMN FTS_DOC_ID BIGINT UNSIGNED NOT NULL;
# Replace the user-visible FTS_DOC_ID column with a hidden one.
# We do not support this in-place.
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
ALTER TABLE t1o DROP COLUMN FTS_DOC_ID, ALGORITHM=INPLACE;
ALTER TABLE t1o DROP COLUMN FTS_DOC_ID;
# FTS_DOC_ID is the internal row identifier for full-text search.
# It should be of type BIGINT UNSIGNED NOT NULL.
--error ER_WRONG_COLUMN_NAME
ALTER TABLE t1o ADD FULLTEXT INDEX(ct), CHANGE c1 FTS_DOC_ID INT,
ALGORITHM=COPY;
--error ER_WRONG_COLUMN_NAME
ALTER TABLE t1o ADD FULLTEXT INDEX(ct), CHANGE c1 FTS_DOC_ID INT,
ALGORITHM=INPLACE;
--error ER_WRONG_COLUMN_NAME
ALTER TABLE t1o ADD FULLTEXT INDEX(ct), CHANGE c1 FTS_Doc_ID INT,
ALGORITHM=INPLACE;
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
ALTER TABLE t1o ADD FULLTEXT INDEX(ct),
CHANGE c1 FTS_DOC_ID BIGINT UNSIGNED NOT NULL,
ALGORITHM=INPLACE;
CREATE TABLE t1n LIKE t1o;
ALTER TABLE t1n ADD FULLTEXT INDEX(ct);
--error ER_WRONG_COLUMN_NAME
ALTER TABLE t1n CHANGE c1 Fts_DOC_ID INT, ALGORITHM=INPLACE;
--error ER_WRONG_COLUMN_NAME
ALTER TABLE t1n CHANGE c1 Fts_DOC_ID INT, ALGORITHM=COPY;
--error ER_BAD_FIELD_ERROR
ALTER TABLE t1n CHANGE FTS_DOC_ID c11 INT, ALGORITHM=INPLACE;
ALTER TABLE t1n CHANGE c1 FTS_DOC_ïD INT, ALGORITHM=INPLACE;
ALTER TABLE t1n CHANGE FTS_DOC_ÏD c1 INT, ALGORITHM=INPLACE;
ALTER TABLE t1n CHANGE c1 c2 INT, CHANGE c2 ct INT, CHANGE ct c1 TEXT,
ALGORITHM=INPLACE;
SHOW CREATE TABLE t1n;
ALTER TABLE t1n CHANGE c2 c1 INT, CHANGE ct c2 INT, CHANGE c1 ct TEXT,
ALGORITHM=COPY;
SHOW CREATE TABLE t1n;
--error ER_KEY_COLUMN_DOES_NOT_EXITS
ALTER TABLE t1n ADD INDEX(c2), CHANGE c2 c4 INT, ALGORITHM=INPLACE;
--error ER_KEY_COLUMN_DOES_NOT_EXITS
ALTER TABLE t1n ADD INDEX(c2), CHANGE c2 c4 INT, ALGORITHM=COPY;
# FIXME: MDEV-13668 InnoDB unnecessarily rebuilds table
# when renaming a column and adding index
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
ALTER TABLE t1n ADD INDEX(c4), CHANGE c2 c4 INT, ALGORITHM=INPLACE;
ALTER TABLE t1n CHANGE c2 c4 INT, LOCK=NONE;
ALTER TABLE t1n ADD INDEX(c4), LOCK=NONE;
SHOW CREATE TABLE t1n;
ALTER TABLE t1n DROP INDEX c4;
--error ER_DUP_FIELDNAME
ALTER TABLE t1n CHANGE c4 c1 INT, ADD INDEX(c1), ALGORITHM=INPLACE;
# FIXME: MDEV-13668
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
ALTER TABLE t1n CHANGE c4 c11 INT, ADD INDEX(c11), ALGORITHM=INPLACE;
ALTER TABLE t1n CHANGE c4 c11 INT, LOCK=NONE;
ALTER TABLE t1n ADD INDEX(c11), LOCK=NONE;
SHOW CREATE TABLE t1n;
DROP TABLE t1n;
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
ALTER TABLE t1o MODIFY c1 BIGINT UNSIGNED NOT NULL, DROP INDEX ct,
ALGORITHM=INPLACE;
# This will copy the table, removing the hidden FTS_DOC_ID column.
ALTER TABLE t1o MODIFY c1 BIGINT UNSIGNED NOT NULL, DROP INDEX ct;
ALTER TABLE t1o CHANGE c1 FTS_DOC_ID BIGINT UNSIGNED NOT NULL,
ALGORITHM=INPLACE;
ALTER TABLE t1o ADD FULLTEXT INDEX(ct), ALGORITHM=INPLACE;
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
ALTER TABLE t1o CHANGE FTS_DOC_ID foo_id BIGINT UNSIGNED NOT NULL,
ALGORITHM=INPLACE;
# This should not show duplicates.
SELECT sc.pos FROM information_schema.innodb_sys_columns sc
INNER JOIN information_schema.innodb_sys_tables st
ON sc.TABLE_ID=st.TABLE_ID
WHERE st.NAME='test/t1o' AND sc.NAME='FTS_DOC_ID';
SHOW CREATE TABLE t1o;
ALTER TABLE t1o CHANGE FTS_DOC_ID foo_id BIGINT UNSIGNED NOT NULL,
DROP INDEX ct, ALGORITHM=INPLACE;
SHOW CREATE TABLE t1o;
DROP TABLE t1c, t1p, sys_tables, sys_indexes, sys_foreign;
# Check the internal schemata of tt, t1o.
CREATE TABLE sys_tables SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES
WHERE NAME='test/t1o';
CREATE TABLE sys_indexes SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES i
INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID;
CREATE TABLE sys_foreign SELECT i.*
FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN i WHERE FOR_NAME='test/t1o';
-- source suite/innodb/include/innodb_dict.inc
# Ensure that there exists no hidden FTS_DOC_ID_INDEX on foo_id.
ALTER TABLE t1o ADD UNIQUE INDEX FTS_DOC_ID_INDEX(FTS_DOC_ID),
ADD FULLTEXT INDEX(ct),
CHANGE foo_id FTS_DOC_ID BIGINT UNSIGNED NOT NULL;
ALTER TABLE t1o DROP INDEX ct, DROP INDEX FTS_DOC_ID_INDEX,
CHANGE FTS_DOC_ID foo_id BIGINT UNSIGNED NOT NULL;
ALTER TABLE t1o ADD UNIQUE INDEX FTS_DOC_ID_INDEX(foo_id);
# FIXME: MDEV-9469 'Incorrect key file' on ALTER TABLE
call mtr.add_suppression("Error: no matching column for .FTS_DOC_ID. in index .ct.--temporary-- of table .test...t1o");
--error ER_NOT_KEYFILE
ALTER TABLE t1o CHANGE foo_id FTS_DOC_ID BIGINT UNSIGNED NOT NULL,
ADD FULLTEXT INDEX(ct);
# FIXME: MDEV-9469 (enable this)
#--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
#ALTER TABLE t1o CHANGE FTS_DOC_ID foo_id BIGINT UNSIGNED NOT NULL,
#ALGORITHM=INPLACE;
#end of MDEV-9469 FIXME
DROP TABLE sys_indexes;
CREATE TABLE sys_indexes SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES i
INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID;
-- source suite/innodb/include/innodb_dict.inc
DROP TABLE tt, t1o, sys_tables, sys_indexes, sys_foreign;
CREATE TABLE t (t TEXT, FULLTEXT(t)) ENGINE=InnoDB;
DROP INDEX t ON t;
LET $regexp=/FTS_([0-9a-f_]+)([A-Z_]+)/FTS_AUX_\2/;
--replace_regex $regexp
SELECT SUBSTRING(name, LOCATE('_', name) - 3, 5) AS prefix, name
FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES
WHERE name LIKE '%FTS_%' ORDER BY 1, 2;
SELECT sc.pos, sc.NAME FROM information_schema.innodb_sys_columns sc
INNER JOIN information_schema.innodb_sys_tables st
ON sc.TABLE_ID=st.TABLE_ID
WHERE st.NAME='test/t';
ALTER TABLE t ROW_FORMAT=REDUNDANT, ALGORITHM=INPLACE;
--replace_regex $regexp
SELECT SUBSTRING(name, LOCATE('_', name) - 3, 5) AS prefix, name
FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES
WHERE name LIKE '%FTS_%' ORDER BY 1, 2;
ALTER TABLE t ADD FULLTEXT INDEX(t);
SELECT sc.pos, sc.NAME FROM information_schema.innodb_sys_columns sc
INNER JOIN information_schema.innodb_sys_tables st
ON sc.TABLE_ID=st.TABLE_ID
WHERE st.NAME='test/t';
DROP TABLE t;
--disable_query_log
call mtr.add_suppression("deleting orphaned .ibd file");
--enable_query_log
--echo #
--echo # Bug #19465984 INNODB DATA DICTIONARY IS NOT UPDATED WHILE
--echo # RENAMING THE COLUMN
--echo #
CREATE TABLE t1(c1 INT NOT NULL, PRIMARY KEY(c1))ENGINE=INNODB;
CREATE TABLE t2(c2 INT NOT NULL, FOREIGN KEY(c2) REFERENCES t1(c1))ENGINE=INNODB;
SHOW CREATE TABLE t1;
SHOW CREATE TABLE t2;
ALTER TABLE t1 CHANGE COLUMN c1 C1 INT;
SHOW CREATE TABLE t1;
SHOW CREATE TABLE t2;
# FIXME: MDEV-13671 InnoDB should use case-insensitive column name comparisons
# like the rest of the server
#ALTER TABLE t1 CHANGE COLUMN C1 c5 INT;
SHOW CREATE TABLE t1;
SHOW CREATE TABLE t2;
DROP TABLE t2, t1;
--echo #
--echo # BUG 20029625 - HANDLE_FATAL_SIGNAL (SIG=11) IN
--echo # DICT_MEM_TABLE_COL_RENAME_LOW
--echo #
CREATE TABLE parent(a INT, b INT, KEY(a, b)) ENGINE = InnoDB;
CREATE TABLE t1(a1 INT, a2 INT) ENGINE = InnoDB;
set foreign_key_checks=0;
ALTER TABLE t1 ADD CONSTRAINT fk_a FOREIGN KEY(a1, a2) REFERENCES parent(a, b) ON DELETE SET NULL ON UPDATE CASCADE;
ALTER TABLE t1 CHANGE a2 a3 INT,ADD CONSTRAINT fk_1 FOREIGN KEY(a1, a3) REFERENCES parent(a, b) ON DELETE SET NULL ON UPDATE CASCADE;
SHOW CREATE TABLE t1;
CHECK TABLE t1;
ALTER TABLE t1 CHANGE a3 a4 INT;
SHOW CREATE TABLE t1;
CHECK TABLE t1;
ALTER TABLE parent CHANGE b c INT;
SHOW CREATE TABLE t1;
CHECK TABLE t1;
DROP TABLE t1, parent;
--echo #
--echo #BUG#21514135 SCHEMA MISMATCH ERROR WHEN IMPORTING TABLESPACE AFTER
--echo #DROPPING AN INDEX
--echo #
let $source_db = source_db;
let $dest_db = dest_db;
eval CREATE DATABASE $source_db;
eval CREATE DATABASE $dest_db;
eval CREATE TABLE $source_db.t1 (
id int(11) NOT NULL,
age int(11) DEFAULT NULL,
name varchar(20),
PRIMARY KEY (id),
KEY index1 (age)
) ENGINE=InnoDB;
eval ALTER TABLE $source_db.t1 DROP INDEX index1, ADD INDEX index2(name, age), algorithm=inplace;
--source suite/innodb/include/import.inc
eval ALTER TABLE $source_db.t1 DROP INDEX index2, algorithm=inplace;
--source suite/innodb/include/import.inc
eval DROP TABLE $source_db.t1;
eval DROP DATABASE $source_db;
eval DROP DATABASE $dest_db;
-- source include/have_debug.inc
-- source include/have_innodb.inc
let $MYSQLD_DATADIR= `select @@datadir`;
let $per_table=`select @@innodb_file_per_table`;
let $format=`select @@innodb_file_format`;
set global innodb_file_per_table=on;
set global innodb_file_format='Barracuda';
#
# Test for BUG# 12739098, check whether trx->error_status is reset on error.
#
CREATE TABLE t1(c1 INT NOT NULL, c2 INT, PRIMARY KEY(c1)) Engine=InnoDB;
SHOW CREATE TABLE t1;
INSERT INTO t1 VALUES (1,1),(2,2),(3,3),(4,4),(5,5);
SET @saved_debug_dbug = @@SESSION.debug_dbug;
SET DEBUG_DBUG='+d,ib_build_indexes_too_many_concurrent_trxs, ib_rename_indexes_too_many_concurrent_trxs, ib_drop_index_too_many_concurrent_trxs';
--error ER_TOO_MANY_CONCURRENT_TRXS
ALTER TABLE t1 ADD UNIQUE INDEX(c2);
SET DEBUG_DBUG = @saved_debug_dbug;
SHOW CREATE TABLE t1;
DROP TABLE t1;
#
# Test for Bug#13861218 Records are not fully sorted during index creation
#
CREATE TABLE bug13861218 (c1 INT NOT NULL, c2 INT NOT NULL, INDEX(c2))
ENGINE=InnoDB;
INSERT INTO bug13861218 VALUES (8, 0), (4, 0), (0, 0);
SET DEBUG_DBUG = '+d,ib_row_merge_buf_add_two';
# Force creation of a PRIMARY KEY on c1 to see what happens on the index(c2).
# No crash here, because n_uniq for c2 includes the clustered index fields
CREATE UNIQUE INDEX ui ON bug13861218(c1);
SET DEBUG_DBUG = @saved_debug_dbug;
DROP TABLE bug13861218;
CREATE TABLE bug13861218 (c1 INT NOT NULL, c2 INT UNIQUE) ENGINE=InnoDB;
INSERT INTO bug13861218 VALUES (8, NULL), (4, NULL), (0, NULL);
SET DEBUG_DBUG = '+d,ib_row_merge_buf_add_two';
# Force creation of a PRIMARY KEY on c1 to see what happens on the index(c2).
# assertion failure: ut_ad(cmp_dtuple_rec(dtuple, rec, rec_offsets) > 0)
CREATE UNIQUE INDEX ui ON bug13861218(c1);
SET DEBUG_DBUG = @saved_debug_dbug;
DROP TABLE bug13861218;
eval set global innodb_file_per_table=$per_table;
eval set global innodb_file_format=$format;
eval set global innodb_file_format_max=$format;
--echo #
--echo # Bug #21762319 ADDING INDEXES ON EMPTY TABLE IS SLOW
--echo # WITH LARGE INNODB_SORT_BUFFER_SIZE.
call mtr.add_suppression("InnoDB: Cannot create temporary merge file");
# Table with large data which is greater than sort buffer
create table t480(a serial)engine=innodb;
insert into t480
values(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),
(),(),(),(),(),(),(),();
insert into t480 select 0 from t480;
insert into t480 select 0 from t480;
insert into t480 select 0 from t480;
insert into t480 select 0 from t480;
create table t1(f1 int auto_increment not null,
f2 char(200) not null, f3 char(200) not null,
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;
SET DEBUG_DBUG = '+d,innobase_tmpfile_creation_failure';
--error ER_OUT_OF_RESOURCES
alter table t1 force, algorithm=inplace;
SET DEBUG_DBUG = @saved_debug_dbug;
drop table t1, t480;
--source include/have_innodb.inc
--source include/have_debug_sync.inc
# Save the initial number of concurrent sessions.
--source include/count_sessions.inc
connect (con1,localhost,root,,);
connection default;
CREATE TABLE t (a INT PRIMARY KEY, b INT NOT NULL) ENGINE=InnoDB;
INSERT INTO t VALUES(1,2),(2,3);
SET DEBUG_SYNC='alter_table_inplace_after_lock_downgrade SIGNAL do WAIT_FOR m';
SET DEBUG_SYNC='innodb_after_inplace_alter_table SIGNAL scanned WAIT_FOR done';
--send
CREATE INDEX tb ON t(b);
connection con1;
SET DEBUG_SYNC='now WAIT_FOR do';
SET DEBUG_SYNC='row_update_for_mysql_error SIGNAL m WAIT_FOR scanned';
--error ER_DUP_ENTRY
UPDATE t SET a=2 WHERE a=1;
call mtr.add_suppression('InnoDB: record in index .*tb was not found on rollback, trying to insert');
SET DEBUG_SYNC='now SIGNAL done';
disconnect con1;
connection default;
reap;
SET DEBUG_SYNC='RESET';
DROP TABLE t;
# Check that all connections opened by test cases in this file are really
# gone so execution of other tests won't be affected by their presence.
--source include/wait_until_count_sessions.inc
--loose-innodb-sys-tables
--loose-innodb-sys-columns
--loose-innodb-sys-foreign
--loose-innodb-sys-foreign-cols
--source include/have_innodb.inc
--source include/have_debug.inc
CREATE TABLE parent (a INT PRIMARY KEY, b INT NOT NULL) ENGINE = InnoDB;
INSERT INTO parent VALUES(1,2),(2,3);
CREATE INDEX tb ON parent(b);
INSERT INTO parent VALUES(10,20),(20,30);
CREATE TABLE child (a1 INT PRIMARY KEY, a2 INT) ENGINE = InnoDB;
CREATE INDEX tb ON child(a2);
INSERT INTO child VALUES(10,20);
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
ALTER TABLE child ADD FOREIGN KEY(a2) REFERENCES parent(b),
ALGORITHM = INPLACE;
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;
SELECT * FROM information_schema.INNODB_SYS_FOREIGN_COLS;
# duplicated foreign key name
--error ER_FK_DUP_NAME
ALTER TABLE child ADD CONSTRAINT fk_1 FOREIGN KEY (a2)
REFERENCES parent(b) ON DELETE SET NULL ON UPDATE CASCADE,
ALGORITHM = INPLACE;
SET foreign_key_checks = 1;
INSERT INTO child VALUES(1,2),(2,3);
--error ER_NO_REFERENCED_ROW_2
INSERT INTO child VALUES(4,4);
SELECT * FROM parent;
SET foreign_key_checks = 0;
# This would fail. No corresponding index
--error ER_FK_NO_INDEX_PARENT
ALTER TABLE child ADD CONSTRAINT fk_20 FOREIGN KEY (a1, a2)
REFERENCES parent(a, b) ON DELETE CASCADE ON UPDATE CASCADE,
ALGORITHM = INPLACE;
SHOW WARNINGS;
SHOW ERRORS;
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;
# This should be successful, as we added the index
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;
SELECT * FROM information_schema.INNODB_SYS_FOREIGN_COLS;
SET foreign_key_checks = 1;
--error ER_NO_REFERENCED_ROW_2
INSERT INTO child VALUES(5,4);
SHOW CREATE TABLE child;
DELETE FROM parent where a = 1;
SELECT * FROM child;
# Now test referenced table cannot be opened. This should work fine
# when foreign_key_checks is set to 0
SET foreign_key_checks = 0;
# This is to test the scenario we cannot open the referenced table.
# Since foreign_key_checks is set to 0, the foreign key should still
# be added.
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;
SELECT * FROM information_schema.INNODB_SYS_FOREIGN_COLS;
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;
SELECT NAME FROM information_schema.INNODB_SYS_TABLES;
# this should succeed, since we disabled the foreign key check
INSERT INTO child VALUES(5,4);
SET foreign_key_checks = 1;
--error ER_NO_REFERENCED_ROW_2
INSERT INTO child VALUES(6,5);
SET foreign_key_checks = 0;
# Create some table with 'funny' characters, for testing the
# error message
CREATE TABLE `#parent` (a INT PRIMARY KEY, b INT NOT NULL) ENGINE = InnoDB;
CREATE INDEX tb ON `#parent`(a, b);
CREATE TABLE `#child` (a1 INT PRIMARY KEY, a2 INT) ENGINE = InnoDB;
CREATE INDEX tb ON `#child`(a1, a2);
# This is to test the scenario no foreign index, alter table should fail
SET DEBUG_DBUG = '+d,innodb_test_no_foreign_idx';
--error ER_FK_NO_INDEX_CHILD,
ALTER TABLE `#child` ADD CONSTRAINT fk_40 FOREIGN KEY (a1, a2)
REFERENCES `#parent`(a, b) ON DELETE CASCADE ON UPDATE CASCADE,
ALGORITHM = INPLACE;
SET DEBUG_DBUG = @saved_debug_dbug;
SHOW ERRORS;
SELECT * FROM information_schema.INNODB_SYS_FOREIGN;
SELECT * FROM information_schema.INNODB_SYS_FOREIGN_COLS;
# This is to test the scenario no index on referenced table,
# alter table should fail
SET DEBUG_DBUG = '+d,innodb_test_no_reference_idx';
--error ER_FK_NO_INDEX_PARENT,
ALTER TABLE child ADD CONSTRAINT fk_42 FOREIGN KEY (a1, a2)
REFERENCES parent(a, b) ON DELETE CASCADE ON UPDATE CASCADE,
ALGORITHM = INPLACE;
SET DEBUG_DBUG = @saved_debug_dbug;
SHOW ERRORS;
# This is to test the scenario no index on referenced table,
# alter table should fail
SET DEBUG_DBUG = '+d,innodb_test_wrong_fk_option';
--error ER_FK_INCORRECT_OPTION
ALTER TABLE child ADD CONSTRAINT fk_42 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;
SELECT * FROM information_schema.INNODB_SYS_FOREIGN_COLS;
# This is to test the scenario cannot add fk to the system table,
# alter table should fail
SET DEBUG_DBUG = '+d,innodb_test_cannot_add_fk_system';
--error ER_FK_FAIL_ADD_SYSTEM
ALTER TABLE `#child` ADD CONSTRAINT fk_43 FOREIGN KEY (a1, a2)
REFERENCES `#parent`(a, b) ON DELETE CASCADE ON UPDATE CASCADE,
ALGORITHM = INPLACE;
SET DEBUG_DBUG = @saved_debug_dbug;
SHOW ERRORS;
DROP TABLE `#child`;
DROP TABLE `#parent`;
# Now test add multiple foreign key constrain in a single clause
SET foreign_key_checks = 0;
ALTER TABLE child ADD CONSTRAINT fk_5 FOREIGN KEY (a2) REFERENCES parent(b)
ON DELETE SET NULL ON UPDATE CASCADE,
ADD CONSTRAINT fk_6 FOREIGN KEY (a1, a2)
REFERENCES parent(a, b) ON DELETE CASCADE ON UPDATE CASCADE,
ALGORITHM = INPLACE;
SELECT * FROM information_schema.INNODB_SYS_FOREIGN;
SELECT * FROM information_schema.INNODB_SYS_FOREIGN_COLS;
DROP TABLE child;
DROP TABLE parent;
# Test a case where child's foreign key index is being dropped in the
# same clause of adding the foreign key. In theory, MySQL will
# automatically create a new index to meet the index requirement
CREATE TABLE parent (a INT PRIMARY KEY, b INT NOT NULL) ENGINE = InnoDB;
INSERT INTO parent VALUES(1,2),(2,3);
CREATE INDEX tb ON parent(b);
INSERT INTO parent VALUES(10,20),(20,30);
CREATE TABLE child (a1 INT PRIMARY KEY, a2 INT) ENGINE = InnoDB;
CREATE INDEX tb ON child(a2);
INSERT INTO child VALUES(10,20);
SET foreign_key_checks = 0;
ALTER TABLE child DROP INDEX tb, ADD CONSTRAINT fk_4 FOREIGN KEY (a2)
REFERENCES parent(b) ON DELETE CASCADE ON UPDATE CASCADE,
ALGORITHM = INPLACE;
SHOW CREATE TABLE child;
SELECT * FROM information_schema.INNODB_SYS_FOREIGN;
SELECT * FROM information_schema.INNODB_SYS_FOREIGN_COLS;
SET foreign_key_checks = 1;
DROP TABLE child;
DROP TABLE parent;
# Test ADD FOREIGN KEY together with renaming columns.
CREATE TABLE parent (a INT PRIMARY KEY, b INT NOT NULL) ENGINE = InnoDB;
INSERT INTO parent VALUES(1,2),(2,3);
CREATE INDEX tb ON parent(b);
INSERT INTO parent VALUES(10,20),(20,30);
CREATE TABLE child (a1 INT PRIMARY KEY, a2 INT) ENGINE = InnoDB;
CREATE INDEX tb ON child(a2);
SET foreign_key_checks = 0;
--error ER_KEY_COLUMN_DOES_NOT_EXITS
ALTER TABLE child CHANGE a2 a3 INT,
ADD CONSTRAINT fk_1 FOREIGN KEY (a2) REFERENCES parent(b)
ON DELETE SET NULL ON UPDATE CASCADE,
ALGORITHM = INPLACE;
ALTER TABLE child CHANGE a2 a3 INT,
ADD CONSTRAINT fk_1 FOREIGN KEY (a3) REFERENCES parent(b)
ON DELETE SET NULL ON UPDATE CASCADE,
ALGORITHM = INPLACE;
DROP TABLE child;
DROP TABLE parent;
# Add test for add Primary key and FK on changing columns
CREATE TABLE parent (a INT PRIMARY KEY, b INT NOT NULL) ENGINE = InnoDB;
INSERT INTO parent VALUES(1,2),(2,3);
CREATE INDEX tb ON parent(b);
INSERT INTO parent VALUES(10,20),(20,30);
CREATE TABLE child (a1 INT NOT NULL, a2 INT) ENGINE = InnoDB;
CREATE INDEX tb ON child(a2);
SET foreign_key_checks = 0;
# Let's rebuild the table and add the FK, make the add FK failed.
SET DEBUG_DBUG = '+d,innodb_test_cannot_add_fk_system';
--error ER_FK_FAIL_ADD_SYSTEM
ALTER TABLE child ADD PRIMARY KEY idx (a3), CHANGE a1 a3 INT,
ADD CONSTRAINT fk_1 FOREIGN KEY (a2) REFERENCES parent(b)
ON DELETE SET NULL ON UPDATE CASCADE,
ALGORITHM = INPLACE;
SET DEBUG_DBUG = @saved_debug_dbug;
SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN;
SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS;
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;
SELECT NAME FROM information_schema.INNODB_SYS_TABLES;
# This should be successful. It will also check any left over
# from previous failed operation (if dictionary entries not cleaned,
# it will have dup key error.
ALTER TABLE child ADD PRIMARY KEY idx (a3), CHANGE a1 a3 INT,
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;
SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS;
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;
SELECT NAME FROM information_schema.INNODB_SYS_TABLES;
SHOW CREATE TABLE child;
DROP TABLE child;
CREATE TABLE child (a1 INT NOT NULL, a2 INT) ENGINE = InnoDB;
# Now try primary index and FK
ALTER TABLE child ADD PRIMARY KEY idx (a1),
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;
SELECT * from information_schema.INNODB_SYS_FOREIGN_COLS;
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;
SELECT NAME FROM information_schema.INNODB_SYS_TABLES;
SHOW CREATE TABLE child;
DROP TABLE child;
CREATE TABLE child (a1 INT NOT NULL, a2 INT) ENGINE = InnoDB;
ALTER TABLE child CHANGE a1 a3 INT,
ADD CONSTRAINT fk_1 FOREIGN KEY (a3) REFERENCES parent(b)
ON DELETE SET NULL ON UPDATE CASCADE,
ALGORITHM = INPLACE;
SELECT * from information_schema.INNODB_SYS_FOREIGN;
SELECT * from information_schema.INNODB_SYS_FOREIGN_COLS;
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;
SELECT NAME FROM information_schema.INNODB_SYS_TABLES;
SHOW CREATE TABLE child;
DROP TABLE child;
CREATE TABLE child (a1 INT NOT NULL, a2 INT) ENGINE = InnoDB;
# Now try all three
--error ER_FK_INCORRECT_OPTION
ALTER TABLE child ADD PRIMARY KEY idx (a3), CHANGE a1 a3 INT,
ADD CONSTRAINT fk_1 FOREIGN KEY (a3) REFERENCES parent(b)
ON DELETE SET NULL ON UPDATE CASCADE,
ALGORITHM = INPLACE;
DROP TABLE parent;
DROP TABLE child;
CREATE TABLE parent (a INT PRIMARY KEY, b INT NOT NULL, c INT) ENGINE = InnoDB;
INSERT INTO parent VALUES(1,2,3),(2,3,4);
CREATE INDEX tb ON parent(b);
CREATE TABLE child (a1 INT NOT NULL, a2 INT, a3 INT) ENGINE = InnoDB;
CREATE INDEX tb ON child(a2);
ALTER TABLE child
ADD CONSTRAINT fk_a FOREIGN KEY (a2) REFERENCES parent(b)
ON DELETE SET NULL ON UPDATE CASCADE,
ALGORITHM = INPLACE;
ALTER TABLE child
ADD CONSTRAINT fk_b FOREIGN KEY (a1) REFERENCES parent(a),
ALGORITHM = INPLACE;
ALTER TABLE child CHANGE a2 a2_new INT, CHANGE a1 a1_new INT;
SHOW CREATE TABLE child;
SELECT * from information_schema.INNODB_SYS_FOREIGN;
SELECT * from information_schema.INNODB_SYS_FOREIGN_COLS;
# The third add FK will fail
--error ER_FK_NO_INDEX_PARENT
ALTER TABLE child
ADD CONSTRAINT fk_new_1 FOREIGN KEY (a1_new) REFERENCES parent(b),
ADD CONSTRAINT fk_new_2 FOREIGN KEY (a2_new) REFERENCES parent(a),
ADD CONSTRAINT fk_new_3 FOREIGN KEY (a3) REFERENCES parent(c),
ALGORITHM = INPLACE;
# It should still have only 2 FKs
SHOW CREATE TABLE child;
SELECT * from information_schema.INNODB_SYS_FOREIGN;
SELECT * from information_schema.INNODB_SYS_FOREIGN_COLS;
#Now let's make it successful
ALTER TABLE child
ADD CONSTRAINT fk_new_1 FOREIGN KEY (a1_new) REFERENCES parent(b),
ADD CONSTRAINT fk_new_2 FOREIGN KEY (a2_new) REFERENCES parent(a),
ADD CONSTRAINT fk_new_3 FOREIGN KEY (a3) REFERENCES parent(a),
ALGORITHM = INPLACE;
# It should still have 5 FKs
SHOW CREATE TABLE child;
SELECT * from information_schema.INNODB_SYS_FOREIGN;
SELECT * from information_schema.INNODB_SYS_FOREIGN_COLS;
DROP TABLE child;
CREATE TABLE child (a1 INT NOT NULL, a2 INT, a3 INT) ENGINE = InnoDB;
CREATE INDEX tb ON child(a2);
# Let's try this 3rd fk failure with add primary index
--error ER_FK_NO_INDEX_PARENT
ALTER TABLE child ADD PRIMARY KEY idx (a1),
ADD CONSTRAINT fk_new_1 FOREIGN KEY (a1) REFERENCES parent(b),
ADD CONSTRAINT fk_new_2 FOREIGN KEY (a2) REFERENCES parent(a),
ADD CONSTRAINT fk_new_3 FOREIGN KEY (a3) REFERENCES parent(c),
ALGORITHM = INPLACE;
# It should still have no FKs, no PRIMARY
SHOW CREATE TABLE child;
SELECT * from information_schema.INNODB_SYS_FOREIGN;
SELECT * from information_schema.INNODB_SYS_FOREIGN_COLS;
# make it successful
ALTER TABLE child ADD PRIMARY KEY idx (a1),
ADD CONSTRAINT fk_new_1 FOREIGN KEY (a1) REFERENCES parent(b),
ADD CONSTRAINT fk_new_2 FOREIGN KEY (a2) REFERENCES parent(a),
ADD CONSTRAINT fk_new_3 FOREIGN KEY (a3) REFERENCES parent(a),
ALGORITHM = INPLACE;
# It should have 3 FKs, a new PRIMARY
SHOW CREATE TABLE child;
SELECT * from information_schema.INNODB_SYS_FOREIGN;
SELECT * from information_schema.INNODB_SYS_FOREIGN_COLS;
SET foreign_key_checks = 1;
DROP TABLE child;
DROP TABLE parent;
CREATE TABLE Parent (a INT PRIMARY KEY, b INT NOT NULL) ENGINE = InnoDB;
INSERT INTO Parent VALUES(1,2),(2,3);
CREATE INDEX tb ON Parent(b);
INSERT INTO Parent VALUES(10,20),(20,30);
CREATE TABLE Child (a1 INT PRIMARY KEY, a2 INT) ENGINE = InnoDB;
CREATE INDEX tb ON Child(a2);
INSERT INTO Child VALUES(10,20);
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;
DROP TABLE Child;
DROP TABLE Parent;
# This is the test for bug 14594526 - FK: ASSERTION IN
# DICT_TABLE_CHECK_FOR_DUP_INDEXES
CREATE TABLE `t2`(a int,c int,d int) ENGINE=INNODB;
CREATE TABLE `t3`(a int,c int,d int) ENGINE=INNODB;
CREATE INDEX idx ON t3(a);
ALTER TABLE `t2` ADD CONSTRAINT `fw` FOREIGN KEY (`c`) REFERENCES t3 (a);
ALTER TABLE `t2` ADD CONSTRAINT `e` foreign key (`d`) REFERENCES t3(a);
--error ER_FK_FAIL_ADD_SYSTEM
ALTER TABLE `t3` ADD CONSTRAINT `e` foreign key (`c`) REFERENCES `t2`(`c`) ON UPDATE SET NULL;
SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN;
SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS;
DROP TABLE t2;
DROP TABLE t3;
--source include/have_innodb.inc
--source include/have_debug_sync.inc
# Save the initial number of concurrent sessions.
--source include/count_sessions.inc
connect (con1,localhost,root,,);
connect (con2,localhost,root,,);
connection default;
CREATE TABLE t (a INT PRIMARY KEY, c TEXT) ENGINE=InnoDB;
CREATE TABLE u (a INT PRIMARY KEY, b INT, c INT NOT NULL) ENGINE=InnoDB;
INSERT INTO t VALUES (1,'aa');
BEGIN;
INSERT INTO u SET a=1, c=1;
INSERT INTO u SELECT a+1,NULL,a+1 FROM u;
INSERT INTO u SELECT a+2,NULL,a+2 FROM u;
INSERT INTO u SELECT a+4,NULL,a+4 FROM u;
INSERT INTO u SELECT a+8,NULL,a+8 FROM u;
INSERT INTO u SELECT a+16,NULL,a+16 FROM u;
INSERT INTO u SELECT a+32,NULL,a+32 FROM u;
INSERT INTO u SELECT a+64,NULL,a+64 FROM u;
INSERT INTO u SELECT a+128,NULL,a+64 FROM u;
INSERT INTO u SELECT a+256,NULL,a+64 FROM u;
COMMIT;
BEGIN;
DELETE FROM u;
connection con2;
SET DEBUG_SYNC='row_log_apply_before SIGNAL created_u WAIT_FOR dml_done_u';
--send
ALTER TABLE u ADD INDEX (c);
connection default;
# Check that the above SELECT is blocked
let $wait_condition=
SELECT COUNT(*) = 1 from information_schema.processlist
WHERE state = 'Waiting for table metadata lock' AND
info = 'ALTER TABLE u ADD INDEX (c)';
--source include/wait_condition.inc
COMMIT;
SET DEBUG_SYNC='now WAIT_FOR created_u';
SELECT state FROM information_schema.processlist
WHERE info='ALTER TABLE u ADD INDEX (c)';
connection con1;
SET DEBUG_SYNC='row_log_apply_before SIGNAL created_t WAIT_FOR dml_done_t';
--send
CREATE INDEX c1 ON t (c(1));
connection default;
SET DEBUG_SYNC='now WAIT_FOR created_t';
UPDATE t SET c='ab';
# Allow purge to kick in. TODO: Trigger this faster, somehow.
SELECT SLEEP(10);
SET DEBUG_SYNC='now SIGNAL dml_done_u';
connection con2;
reap;
SET DEBUG_SYNC='now SIGNAL dml_done_t';
disconnect con2;
connection con1;
reap;
disconnect con1;
connection default;
SET DEBUG_SYNC='RESET';
DROP TABLE t,u;
# Check that all connections opened by test cases in this file are really
# gone so execution of other tests won't be affected by their presence.
--source include/wait_until_count_sessions.inc
--innodb-sort-buffer-size=64k
--innodb-online-alter-log-max-size=64k
--innodb-buffer-pool-size=5M
--innodb-log-buffer-size=256k
--innodb-sys-indexes
--innodb-sys-fields
--source include/innodb_page_size_small.inc
--source include/have_debug_sync.inc
let $innodb_metrics_select=
SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl';
call mtr.add_suppression("InnoDB: Warning: Small buffer pool size");
# DISCARD TABLESPACE needs file-per-table
SET @global_innodb_file_per_table_orig = @@global.innodb_file_per_table;
SET GLOBAL innodb_file_per_table = on;
# Save the initial number of concurrent sessions.
--source include/count_sessions.inc
CREATE TABLE t1 (c1 INT PRIMARY KEY, c2 INT, c3 TEXT)
ENGINE=InnoDB STATS_PERSISTENT=0;
INSERT INTO t1 VALUES (1,1,''), (2,2,''), (3,3,''), (4,4,''), (5,5,'');
SET GLOBAL innodb_monitor_enable = module_ddl;
eval $innodb_metrics_select;
SET DEBUG_SYNC = 'RESET';
SET DEBUG_SYNC = 'write_row_noreplace SIGNAL have_handle WAIT_FOR go_ahead';
--send
INSERT INTO t1 VALUES(1,2,3);
connect (con1,localhost,root,,);
connection con1;
# This should block at the end because of the INSERT in connection default
# is holding a metadata lock.
SET DEBUG_SYNC = 'now WAIT_FOR have_handle';
SET lock_wait_timeout = 1;
--error ER_LOCK_WAIT_TIMEOUT
ALTER TABLE t1 ADD UNIQUE INDEX(c2);
SET DEBUG_SYNC = 'now SIGNAL go_ahead';
connection default;
--error ER_DUP_ENTRY
reap;
eval $innodb_metrics_select;
connection con1;
SET @saved_debug_dbug = @@SESSION.debug_dbug;
SET DEBUG_DBUG = '+d,innodb_OOM_prepare_inplace_alter';
--error ER_OUT_OF_RESOURCES
ALTER TABLE t1 ADD UNIQUE INDEX(c2);
SET DEBUG_DBUG = @saved_debug_dbug;
SET DEBUG_DBUG = '+d,innodb_OOM_inplace_alter';
--error ER_OUT_OF_RESOURCES
CREATE UNIQUE INDEX c2 ON t1(c2);
SET DEBUG_DBUG = @saved_debug_dbug;
CREATE UNIQUE INDEX c2 ON t1(c2);
DROP INDEX c2 ON t1;
connection default;
SHOW CREATE TABLE t1;
# Insert a duplicate entry (4) for the upcoming UNIQUE INDEX(c2).
BEGIN;
INSERT INTO t1 VALUES(7,4,2);
connection con1;
# This DEBUG_SYNC should not kick in yet, because the duplicate key will be
# detected before we get a chance to apply the online log.
SET DEBUG_SYNC = 'row_log_apply_before SIGNAL scanned WAIT_FOR rollback_done';
# This will be a lock wait timeout on the meta-data lock,
# because the transaction inserting (7,4,2) is still active.
--error ER_LOCK_WAIT_TIMEOUT
ALTER TABLE t1 ADD UNIQUE INDEX(c2);
connection default;
COMMIT;
connection con1;
--error ER_DUP_ENTRY
ALTER TABLE t1 ADD UNIQUE INDEX(c2);
connection default;
DELETE FROM t1 WHERE c1 = 7;
connection con1;
# ADD FOREIGN KEY is not supported in-place
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
ALTER TABLE t1 ADD FOREIGN KEY(c2) REFERENCES t1(c2), ALGORITHM = INPLACE;
# The previous DEBUG_SYNC should be ignored, because an exclusive lock
# has been requested and the online log is not being allocated.
ALTER TABLE t1 ADD UNIQUE INDEX(c2), LOCK = EXCLUSIVE, ALGORITHM = INPLACE;
DROP INDEX c2 ON t1;
# Now the previous DEBUG_SYNC should kick in.
--send
ALTER TABLE t1 ADD UNIQUE INDEX(c2);
connection default;
SET DEBUG_SYNC = 'now WAIT_FOR scanned';
eval $innodb_metrics_select;
# Insert a duplicate entry (4) for the already started UNIQUE INDEX(c2).
BEGIN;
INSERT INTO t1 VALUES(7,4,2);
ROLLBACK;
SET DEBUG_SYNC = 'now SIGNAL rollback_done';
connection con1;
# Because the modification log will be applied in order, there will be
# a duplicate key error on the (7,4,2) even though we roll it back.
--error ER_DUP_ENTRY
reap;
# Now, create the index without any concurrent DML, while no duplicate exists.
SET DEBUG_SYNC = 'row_log_apply_after SIGNAL created WAIT_FOR dml_done';
--send
ALTER TABLE t1 ADD UNIQUE INDEX(c2);
connection default;
SET DEBUG_SYNC = 'now WAIT_FOR created';
# At this point, the index has been created inside InnoDB but not yet
# in the MySQL data dictionary.
eval $innodb_metrics_select;
# A duplicate key error should now be triggered by InnoDB, but reported
# by the ALTER TABLE because the index does not 'officially' exist yet.
INSERT INTO t1 VALUES(6,3,1);
SET DEBUG_SYNC = 'now SIGNAL dml_done';
connection con1;
# This is due to the duplicate entry (6,3,1).
--error ER_DUP_UNKNOWN_IN_INDEX
reap;
DELETE FROM t1 WHERE c1=6;
ALTER TABLE t1 ADD UNIQUE INDEX(c2);
eval $innodb_metrics_select;
connection default;
--error ER_DUP_ENTRY
INSERT INTO t1 VALUES(6,3,1);
--error ER_DUP_ENTRY
INSERT INTO t1 VALUES(7,4,2);
ALTER TABLE t1 STATS_PERSISTENT=1;
ANALYZE TABLE t1;
# Purge may or may not have cleaned up the DELETE FROM t1 WHERE c1 = 7;
UPDATE mysql.innodb_index_stats SET stat_value = 5
WHERE database_name = 'test' AND table_name= 't1' AND index_name = 'PRIMARY'
AND stat_value = 6;
--replace_column 4 LAST_UPDATE
SELECT * FROM mysql.innodb_index_stats WHERE table_name IN ('t1');
CREATE TABLE t1_c2_stats SELECT * FROM mysql.innodb_index_stats
WHERE database_name = 'test' AND table_name = 't1' and index_name = 'c2';
# in Embedded mode (./mtr --embedded-server) the t1_c2_stats table gets
# created in MyISAM format by default even if we set
# default_storage_engine='innodb'
ALTER TABLE t1_c2_stats ENGINE=INNODB;
DROP INDEX c2 ON t1;
ANALYZE TABLE t1_c2_stats;
--replace_column 4 LAST_UPDATE
SELECT * FROM mysql.innodb_index_stats WHERE table_name IN ('t1', 't1_c2_stats');
connection con1;
let $ID= `SELECT @id := CONNECTION_ID()`;
--error ER_QUERY_INTERRUPTED
KILL QUERY @id;
SET DEBUG_SYNC = 'row_log_apply_before SIGNAL c2d_created WAIT_FOR kill_done';
--send
CREATE INDEX c2d ON t1(c2);
connection default;
SET DEBUG_SYNC = 'now WAIT_FOR c2d_created';
eval $innodb_metrics_select;
let $ignore= `SELECT @id := $ID`;
KILL QUERY @id;
SET DEBUG_SYNC = 'now SIGNAL kill_done';
connection con1;
--error ER_QUERY_INTERRUPTED
reap;
eval $innodb_metrics_select;
connection default;
CHECK TABLE t1;
INSERT INTO t1 SELECT 5 + c1, c2, c3 FROM t1;
INSERT INTO t1 SELECT 10 + c1, c2, c3 FROM t1;
INSERT INTO t1 SELECT 20 + c1, c2, c3 FROM t1;
INSERT INTO t1 SELECT 40 + c1, c2, c3 FROM t1;
# Purge may or may not have cleaned up the DELETE FROM t1 WHERE c1 = 7;
--replace_result 81 80
EXPLAIN SELECT COUNT(*) FROM t1 WHERE c2 > 3;
ANALYZE TABLE t1;
connection con1;
# Forge some statistics for c2d, and see that they will be used
UPDATE t1_c2_stats SET index_name = 'c2d';
# Fake the statistics. The cardinality should be 5,80.
UPDATE t1_c2_stats SET stat_value = 2 WHERE stat_name = 'n_diff_pfx01';
INSERT INTO t1_c2_stats
SELECT database_name, table_name, index_name, last_update, 'n_diff_pfx02', 80,
sample_size, 'c2,c1' FROM t1_c2_stats
WHERE stat_name = 'n_diff_pfx01' AND stat_description = 'c2';
INSERT INTO mysql.innodb_index_stats SELECT * FROM t1_c2_stats;
DROP TABLE t1_c2_stats;
CREATE INDEX c2d ON t1(c2);
# This should show the newly calculated stats by CREATE INDEX above,
# not the faked cardinality=4 for c2d(c2).
# Purge may or may not have cleaned up the DELETE FROM t1 WHERE c1 = 7;
--replace_result 81 80
SHOW INDEX FROM t1;
EXPLAIN SELECT COUNT(*) FROM t1 WHERE c2 > 3;
SHOW CREATE TABLE t1;
# Exceed the configured innodb_online_alter_log_max_size.
# The actual limit is a multiple of innodb_sort_buf_size,
# because that is the size of the in-memory log buffers.
SET DEBUG_SYNC = 'row_log_apply_before SIGNAL c2e_created WAIT_FOR dml2_done';
# Ensure that the ALTER TABLE will be executed even with some concurrent DML.
SET lock_wait_timeout = 10;
--send
# FIXME: MDEV-13668
#ALTER TABLE t1 CHANGE c2 c22 INT, DROP INDEX c2d, ADD INDEX c2e(c22),
ALTER TABLE t1 DROP INDEX c2d, ADD INDEX c2e(c2),
ALGORITHM = INPLACE;
# Generate some log (delete-mark, delete-unmark, insert etc.)
# while the index creation is blocked. Some of this may run
# in parallel with the clustered index scan.
connection default;
INSERT INTO t1 SELECT 80 + c1, c2, c3 FROM t1;
INSERT INTO t1 SELECT 160 + c1, c2, c3 FROM t1;
#UPDATE t1 SET c2 = c2 + 1;
SET DEBUG_SYNC = 'now WAIT_FOR c2e_created';
# At this point, the clustered index scan must have completed,
# but the modification log keeps accumulating due to the DEBUG_SYNC.
eval $innodb_metrics_select;
let $c= 2;
while ($c)
{
BEGIN;
DELETE FROM t1;
ROLLBACK;
UPDATE t1 SET c2 = c2 + 1;
BEGIN;
UPDATE t1 SET c2 = c2 + 1;
DELETE FROM t1;
ROLLBACK;
dec $c;
}
# Incomplete index c2e should exist until the DDL thread notices the overflow.
# (The output below strips TEMP_INDEX_PREFIX from the name.)
eval $innodb_metrics_select;
SELECT sf.name, sf.pos FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES si
INNER JOIN INFORMATION_SCHEMA.INNODB_SYS_FIELDS sf
ON si.index_id = sf.index_id WHERE si.name = '?c2e';
# Release con1.
SET DEBUG_SYNC = 'now SIGNAL dml2_done';
connection con1;
# If the following fails with the wrong error, it probably means that
# you should rerun with a larger mtr --debug-sync-timeout.
--error ER_INNODB_ONLINE_LOG_TOO_BIG
reap;
# The index c2e should have been dropped from the data dictionary
# when the above error was noticed. It should still exist in the
# cache with index->online_status = ONLINE_INDEX_ABORTED_DROPPED.
eval $innodb_metrics_select;
SELECT sf.name, sf.pos FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES si
INNER JOIN INFORMATION_SCHEMA.INNODB_SYS_FIELDS sf
ON si.index_id = sf.index_id WHERE si.name = 'c2e';
# ddl_background_drop_indexes = 1 here, because the incomplete index c2e still
# exists in the InnoDB data dictionary cache.
eval $innodb_metrics_select;
connection default;
ALTER TABLE t1 COMMENT 'testing if c2e will be dropped';
# Check that the 'zombie' index c2e was dropped.
eval $innodb_metrics_select;
connection con1;
# Accumulate and apply some modification log.
SET DEBUG_SYNC = 'row_log_apply_before SIGNAL c2f_created WAIT_FOR dml3_done';
--send
# FIXME: MDEV-13668
#ALTER TABLE t1 ADD INDEX c2f(c22f), CHANGE c2 c22f INT;
ALTER TABLE t1 ADD INDEX c2f(c2);
connection default;
SET DEBUG_SYNC = 'now WAIT_FOR c2f_created';
# Generate some log (delete-mark, delete-unmark, insert etc.)
eval $innodb_metrics_select;
BEGIN;
INSERT INTO t1 SELECT 320 + c1, c2, c3 FROM t1 WHERE c1 > 160;
DELETE FROM t1 WHERE c1 > 320;
ROLLBACK;
BEGIN;
UPDATE t1 SET c2 = c2 + 1;
DELETE FROM t1;
ROLLBACK;
eval $innodb_metrics_select;
# Release con1.
SET DEBUG_SYNC = 'now SIGNAL dml3_done';
connection con1;
reap;
# FIXME: MDEV-13668
ALTER TABLE t1 CHANGE c2 c22f INT;
eval $innodb_metrics_select;
SELECT COUNT(c22f) FROM t1;
CHECK TABLE t1;
# Create a column prefix index.
--error ER_DUP_ENTRY
ALTER TABLE t1 ADD UNIQUE INDEX c3p5(c3(5));
UPDATE t1 SET c3 = NULL WHERE c3 = '';
SET lock_wait_timeout = 1;
SET DEBUG_SYNC = 'row_log_apply_before SIGNAL c3p5_created WAIT_FOR ins_done';
--send
ALTER TABLE t1 ADD UNIQUE INDEX c3p5(c3(5));
connection default;
SET DEBUG_SYNC = 'now WAIT_FOR c3p5_created';
# Check that the index was created.
SELECT sf.name, sf.pos FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES si
INNER JOIN INFORMATION_SCHEMA.INNODB_SYS_FIELDS sf
ON si.index_id = sf.index_id WHERE si.name = '?c3p5';
SET DEBUG_SYNC = 'ib_after_row_insert SIGNAL ins_done WAIT_FOR ddl_timed_out';
--send
INSERT INTO t1 VALUES(347,33101,NULL);
connection con1;
--error ER_LOCK_WAIT_TIMEOUT
reap;
SET DEBUG_SYNC = 'now SIGNAL ddl_timed_out';
# InnoDB should have cleaned up the index c3p5 from the data dictionary,
# but not yet from the dictionary cache.
SELECT sf.name, sf.pos FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES si
INNER JOIN INFORMATION_SCHEMA.INNODB_SYS_FIELDS sf
ON si.index_id = sf.index_id WHERE si.name = 'c3p5';
eval $innodb_metrics_select;
connection default;
reap;
# Index c3p5 should still exist in the data dictionary cache.
eval $innodb_metrics_select;
--disable_parsing
# Temporarily disabled by fix for bug#14213236. Should be either
# removed or updated to take into account that locking for IMPORT/
# DISCARD TABLESPACE happens on MDL layer. New test case is added
# to validate this at MDL layer(i_main.alter_table.test)
SET DEBUG_SYNC = 'row_log_apply_before SIGNAL c2g_created WAIT_FOR dml4_done';
# The lock upgrade at the end of the ALTER will conflict with the DISCARD.
SET lock_wait_timeout = 1;
--send
ALTER TABLE t1 DROP INDEX c2f, ADD INDEX c2g(c22f);
connection con1;
SET DEBUG_SYNC = 'now WAIT_FOR c2g_created';
connect (con2,localhost,root,,);
connection con2;
# This will conflict with the ALTER in connection default, above.
SET lock_wait_timeout = 10;
--send
ALTER TABLE t1 DISCARD TABLESPACE;
connection con1;
let $wait_condition=
SELECT COUNT(*) = 1 FROM information_schema.processlist
WHERE state = 'Waiting for table level lock' and
info = 'ALTER TABLE t1 DISCARD TABLESPACE';
--source include/wait_condition.inc
SET DEBUG_SYNC = 'now SIGNAL dml4_done';
disconnect con1;
connection con2;
reap;
disconnect con2;
connection default;
--error ER_LOCK_WAIT_TIMEOUT
reap;
--enable_parsing
#remove below con1 disconnect if above test case is enabled
connection con1;
disconnect con1;
connection default;
SHOW CREATE TABLE t1;
ALTER TABLE t1 DROP INDEX c2d, DROP INDEX c2f;
# The ALTER TABLE should have cleaned up c3p5 from the cache.
eval $innodb_metrics_select;
ALTER TABLE t1 ADD INDEX c2h(c22f), ALGORITHM = INPLACE;
--error ER_DUP_KEYNAME
ALTER TABLE t1 ADD INDEX c2h(c22f), ALGORITHM = COPY;
SET DEBUG_SYNC = 'RESET';
SET GLOBAL innodb_monitor_disable = module_ddl;
DROP TABLE t1;
# Check that all connections opened by test cases in this file are really
# gone so execution of other tests won't be affected by their presence.
--source include/wait_until_count_sessions.inc
SET GLOBAL innodb_file_per_table = @global_innodb_file_per_table_orig;
--disable_warnings
SET GLOBAL innodb_monitor_enable = default;
SET GLOBAL innodb_monitor_disable = default;
--enable_warnings
--innodb-sort-buffer-size=64k --innodb-online-alter-log-max-size=64k --innodb-buffer-pool-size=5M --innodb-log-buffer-size=256k
--source include/innodb_page_size.inc
--source include/have_debug.inc
--source include/have_debug_sync.inc
let $innodb_metrics_select=
SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl';
call mtr.add_suppression("InnoDB: Warning: Small buffer pool size");
# these will be triggered by DISCARD TABLESPACE
call mtr.add_suppression("InnoDB: Error: table 'test/t1'");
call mtr.add_suppression("MySQL is trying to open a table handle but the .ibd file for");
# DISCARD TABLESPACE needs file-per-table
SET @global_innodb_file_per_table_orig = @@global.innodb_file_per_table;
SET GLOBAL innodb_file_per_table = on;
# Save the initial number of concurrent sessions.
--source include/count_sessions.inc
CREATE TABLE t1 (c1 INT PRIMARY KEY, c2 INT NOT NULL, c3 TEXT NOT NULL)
ENGINE = InnoDB;
INSERT INTO t1 VALUES (1,1,''), (2,2,''), (3,3,''), (4,4,''), (5,5,'');
SET GLOBAL innodb_monitor_enable = module_ddl;
eval $innodb_metrics_select;
SET DEBUG_SYNC = 'RESET';
SET DEBUG_SYNC = 'write_row_noreplace SIGNAL have_handle WAIT_FOR go_ahead';
--send
INSERT INTO t1 VALUES(1,2,3);
--echo # Establish session con1 (user=root)
connect (con1,localhost,root,,);
connection con1;
# This should block at the end because of the INSERT in connection default
# is holding a metadata lock.
SET DEBUG_SYNC = 'now WAIT_FOR have_handle';
SET lock_wait_timeout = 1;
--error ER_LOCK_WAIT_TIMEOUT
ALTER TABLE t1 ROW_FORMAT=REDUNDANT;
SET DEBUG_SYNC = 'now SIGNAL go_ahead';
--echo # session default
connection default;
--error ER_DUP_ENTRY
reap;
eval $innodb_metrics_select;
--echo # session con1
connection con1;
SET @saved_debug_dbug = @@SESSION.debug_dbug;
SET DEBUG_DBUG = '+d,innodb_OOM_prepare_inplace_alter';
--error ER_OUT_OF_RESOURCES
ALTER TABLE t1 ROW_FORMAT=REDUNDANT, ALGORITHM=INPLACE, LOCK=NONE;
SET SESSION DEBUG = @saved_debug_dbug;
SET SESSION DEBUG = '+d,innodb_OOM_inplace_alter';
--error ER_OUT_OF_RESOURCES
ALTER TABLE t1 ROW_FORMAT=REDUNDANT, ALGORITHM=INPLACE, LOCK=NONE;
SET SESSION DEBUG = @saved_debug_dbug;
ALTER TABLE t1 ROW_FORMAT=REDUNDANT, ALGORITHM=INPLACE, LOCK=NONE;
--echo # session default
connection default;
SHOW CREATE TABLE t1;
# Insert a duplicate entry (4) for the upcoming UNIQUE INDEX(c2).
BEGIN;
INSERT INTO t1 VALUES(7,4,2);
--echo # session con1
connection con1;
# This DEBUG_SYNC should not kick in yet, because the duplicate key will be
# detected before we get a chance to apply the online log.
SET DEBUG_SYNC = 'row_log_table_apply1_before SIGNAL scanned WAIT_FOR insert_done';
# This will be a lock wait timeout on the meta-data lock,
# because the transaction inserting (7,4,2) is still active.
--error ER_LOCK_WAIT_TIMEOUT
ALTER TABLE t1 DROP PRIMARY KEY, ADD UNIQUE INDEX(c2);
--echo # session default
connection default;
COMMIT;
--echo # session con1
connection con1;
--error ER_DUP_ENTRY
ALTER TABLE t1 DROP PRIMARY KEY, ADD UNIQUE INDEX(c2);
--echo # session default
connection default;
DELETE FROM t1 WHERE c1 = 7;
--echo # session con1
connection con1;
ALTER TABLE t1 DROP PRIMARY KEY, ADD UNIQUE INDEX(c2), ROW_FORMAT=COMPACT,
LOCK = SHARED, ALGORITHM = INPLACE;
# The previous DEBUG_SYNC should be ignored, because an exclusive lock
# has been requested and the online log is not being allocated.
ALTER TABLE t1 ADD UNIQUE INDEX(c2),
LOCK = EXCLUSIVE, ALGORITHM = INPLACE;
SHOW CREATE TABLE t1;
# We do not support plain DROP_PK_INDEX without ADD_PK_INDEX.
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
ALTER TABLE t1 DROP INDEX c2, ALGORITHM = INPLACE;
SHOW CREATE TABLE t1;
# Now the previous DEBUG_SYNC should kick in.
--send
ALTER TABLE t1 DROP INDEX c2, ADD PRIMARY KEY(c1);
--echo # session default
connection default;
SET DEBUG_SYNC = 'now WAIT_FOR scanned';
eval $innodb_metrics_select;
# Insert a duplicate entry (4) for the already started UNIQUE INDEX(c1).
BEGIN;
INSERT INTO t1 VALUES(4,7,2);
SET DEBUG_SYNC = 'now SIGNAL insert_done';
--echo # session con1
connection con1;
# Because the modification log will be applied in order and we did
# not roll back before the log apply, there will be a duplicate key
# error on the (4,7,2).
--error ER_DUP_ENTRY
reap;
--echo # session default
connection default;
ROLLBACK;
--echo # session con1
connection con1;
SHOW CREATE TABLE t1;
# Now, rebuild the table without any concurrent DML, while no duplicate exists.
--error ER_CANT_DROP_FIELD_OR_KEY
ALTER TABLE t1 DROP PRIMARY KEY, ADD UNIQUE INDEX(c2), ALGORITHM = INPLACE;
ALTER TABLE t1 DROP INDEX c2, ADD PRIMARY KEY(c1), ALGORITHM = INPLACE;
eval $innodb_metrics_select;
--echo # session default
connection default;
--error ER_DUP_ENTRY
INSERT INTO t1 VALUES(6,3,1);
--error ER_DUP_ENTRY
INSERT INTO t1 VALUES(7,4,2);
DROP INDEX c2_2 ON t1;
BEGIN;
INSERT INTO t1 VALUES(7,4,2);
ROLLBACK;
--echo # session con1
connection con1;
let $ID= `SELECT @id := CONNECTION_ID()`;
--error ER_QUERY_INTERRUPTED
KILL QUERY @id;
SET DEBUG_SYNC = 'row_log_table_apply1_before SIGNAL rebuilt WAIT_FOR kill_done';
--send
ALTER TABLE t1 ROW_FORMAT=REDUNDANT;
--echo # session default
connection default;
SET DEBUG_SYNC = 'now WAIT_FOR rebuilt';
eval $innodb_metrics_select;
let $ignore= `SELECT @id := $ID`;
KILL QUERY @id;
SET DEBUG_SYNC = 'now SIGNAL kill_done';
--echo # session con1
connection con1;
--error ER_QUERY_INTERRUPTED
reap;
eval $innodb_metrics_select;
--echo # session default
connection default;
CHECK TABLE t1;
INSERT INTO t1 SELECT 5 + c1, c2, c3 FROM t1;
INSERT INTO t1 SELECT 10 + c1, c2, c3 FROM t1;
INSERT INTO t1 SELECT 20 + c1, c2, c3 FROM t1;
INSERT INTO t1 SELECT 40 + c1, c2, c3 FROM t1;
# Purge may or may not have cleaned up the DELETE FROM t1 WHERE c1 = 7;
--replace_result 81 80
EXPLAIN SELECT COUNT(*) FROM t1 WHERE c2 > 3;
ANALYZE TABLE t1;
--echo # session con1
connection con1;
SHOW CREATE TABLE t1;
# Exceed the configured innodb_online_alter_log_max_size.
# The actual limit is a multiple of innodb_sort_buf_size,
# because that is the size of the in-memory log buffers.
SET DEBUG_SYNC = 'row_log_table_apply1_before SIGNAL rebuilt2 WAIT_FOR dml2_done';
# Ensure that the ALTER TABLE will be executed even with some concurrent DML.
SET lock_wait_timeout = 10;
--send
ALTER TABLE t1 ROW_FORMAT=COMPACT, ALGORITHM = INPLACE;
# Generate some log (delete-mark, delete-unmark, insert etc.)
# while the index creation is blocked. Some of this may run
# in parallel with the clustered index scan.
--echo # session default
connection default;
INSERT INTO t1 SELECT 80 + c1, c2, c3 FROM t1;
INSERT INTO t1 SELECT 160 + c1, c2, c3 FROM t1;
UPDATE t1 SET c2 = c2 + 1;
SET DEBUG_SYNC = 'now WAIT_FOR rebuilt2';
# At this point, the clustered index scan must have completed,
# but the modification log keeps accumulating due to the DEBUG_SYNC.
eval $innodb_metrics_select;
let $c= 3;
while ($c)
{
BEGIN;
DELETE FROM t1;
ROLLBACK;
UPDATE t1 SET c2 = c2 + 1;
BEGIN;
UPDATE t1 SET c2 = c2 + 1;
DELETE FROM t1;
ROLLBACK;
dec $c;
}
# Temporary table should exist until the DDL thread notices the overflow.
eval $innodb_metrics_select;
# Release con1.
SET DEBUG_SYNC = 'now SIGNAL dml2_done';
--echo # session con1
connection con1;
# If the following fails with the wrong error, it probably means that
# you should rerun with a larger mtr --debug-sync-timeout.
--error ER_INNODB_ONLINE_LOG_TOO_BIG
reap;
# The table should have been dropped from the data dictionary
# when the above error was noticed.
eval $innodb_metrics_select;
# Accumulate and apply some modification log.
SET DEBUG_SYNC = 'row_log_table_apply1_before SIGNAL rebuilt3 WAIT_FOR dml3_done';
--error ER_MULTIPLE_PRI_KEY
ALTER TABLE t1 ADD PRIMARY KEY(c22f), CHANGE c2 c22f INT;
--error ER_DUP_ENTRY
ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY(c22f), CHANGE c2 c22f INT;
--send
ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY(c1,c22f,c4(5)),
CHANGE c2 c22f INT, CHANGE c3 c3 TEXT NULL, CHANGE c1 c1 INT AFTER c22f,
ADD COLUMN c4 VARCHAR(6) DEFAULT 'Online';
--echo # session default
connection default;
SET DEBUG_SYNC = 'now WAIT_FOR rebuilt3';
# Generate some log (delete-mark, delete-unmark, insert etc.)
eval $innodb_metrics_select;
BEGIN;
INSERT INTO t1 SELECT 320 + c1, c2, c3 FROM t1 WHERE c1 > 240;
DELETE FROM t1 WHERE c1 > 320;
ROLLBACK;
BEGIN;
UPDATE t1 SET c2 = c2 + 1;
DELETE FROM t1;
ROLLBACK;
eval $innodb_metrics_select;
# Release con1.
SET DEBUG_SYNC = 'now SIGNAL dml3_done';
--echo # session con1
connection con1;
reap;
eval $innodb_metrics_select;
SELECT COUNT(c22f) FROM t1;
CHECK TABLE t1;
# Create a column prefix index.
--error ER_DUP_ENTRY
ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY c3p5(c3(5));
UPDATE t1 SET c3 = NULL WHERE c3 = '';
SET lock_wait_timeout = 1;
--error ER_MULTIPLE_PRI_KEY
ALTER TABLE t1 DROP COLUMN c22f, ADD PRIMARY KEY c3p5(c3(5));
SET @old_sql_mode = @@sql_mode;
# NULL -> NOT NULL only allowed INPLACE if strict sql_mode is on.
# And adding a PRIMARY KEY will also add NOT NULL implicitly!
SET @@sql_mode = 'STRICT_TRANS_TABLES';
--error ER_INVALID_USE_OF_NULL
ALTER TABLE t1 DROP COLUMN c22f, DROP PRIMARY KEY, ADD PRIMARY KEY c3p5(c3(5)),
ALGORITHM = INPLACE;
--error ER_INVALID_USE_OF_NULL
ALTER TABLE t1 MODIFY c3 TEXT NOT NULL;
SET @@sql_mode = @old_sql_mode;
UPDATE t1 SET c3=CONCAT(c1,REPEAT('foo',c1)) WHERE c3 IS NULL;
SET DEBUG_SYNC = 'row_log_table_apply1_before SIGNAL c3p5_created0 WAIT_FOR ins_done0';
# NULL -> NOT NULL only allowed INPLACE if strict sql_mode is on.
SET @@sql_mode = 'STRICT_TRANS_TABLES';
--send
ALTER TABLE t1 MODIFY c3 TEXT NOT NULL, DROP COLUMN c22f,
ADD COLUMN c5 CHAR(5) DEFAULT 'tired' FIRST;
--echo # session default
connection default;
SET DEBUG_SYNC = 'now WAIT_FOR c3p5_created0';
BEGIN;
INSERT INTO t1 VALUES(347,33101,'Pikku kakkosen posti','YLETV2');
INSERT INTO t1 VALUES(33101,347,NULL,'');
SET DEBUG_SYNC = 'now SIGNAL ins_done0';
--echo # session con1
connection con1;
--error ER_INVALID_USE_OF_NULL
reap;
SET @@sql_mode = @old_sql_mode;
--echo # session default
connection default;
ROLLBACK;
--echo # session con1
connection con1;
ALTER TABLE t1 MODIFY c3 TEXT NOT NULL;
SET DEBUG_SYNC = 'row_log_table_apply1_before SIGNAL c3p5_created WAIT_FOR ins_done';
--send
ALTER TABLE t1 DROP PRIMARY KEY, DROP COLUMN c22f,
ADD COLUMN c6 VARCHAR(1000) DEFAULT
'I love tracking down hard-to-reproduce bugs.',
ADD PRIMARY KEY c3p5(c3(5), c6(2));
--echo # session default
connection default;
SET DEBUG_SYNC = 'now WAIT_FOR c3p5_created';
SET DEBUG_SYNC = 'ib_after_row_insert SIGNAL ins_done WAIT_FOR ddl_timed_out';
--error ER_BAD_NULL_ERROR
INSERT INTO t1 VALUES(347,33101,NULL,'');
--send
INSERT INTO t1 VALUES(347,33101,'Pikku kakkosen posti','');
--echo # session con1
connection con1;
--error ER_LOCK_WAIT_TIMEOUT
reap;
SET DEBUG_SYNC = 'now SIGNAL ddl_timed_out';
eval $innodb_metrics_select;
--echo # session default
connection default;
reap;
SELECT COUNT(*) FROM t1;
ALTER TABLE t1 ROW_FORMAT=REDUNDANT;
SELECT * FROM t1 LIMIT 10;
--echo # session con1
connection con1;
ALTER TABLE t1 DISCARD TABLESPACE;
--echo # Disconnect session con1
disconnect con1;
--echo # session default
connection default;
SHOW CREATE TABLE t1;
SET DEBUG_SYNC = 'RESET';
SET GLOBAL innodb_monitor_disable = module_ddl;
DROP TABLE t1;
# Check that all connections opened by test cases in this file are really
# gone so execution of other tests won't be affected by their presence.
--source include/wait_until_count_sessions.inc
SET GLOBAL innodb_file_per_table = @global_innodb_file_per_table_orig;
--disable_warnings
SET GLOBAL innodb_monitor_enable = default;
SET GLOBAL innodb_monitor_disable = default;
--enable_warnings
--loose-innodb-sys-indexes
--loose-innodb-sys-columns
--loose-innodb-sys-fields
--echo #
--echo # This is a copy of innodb-alter.test except using remote tablespaces
--echo # and showing those files.
--echo #
--source include/have_innodb.inc
--disable_query_log
# These values can change during the test
LET $innodb_file_per_table_orig=`select @@innodb_file_per_table`;
LET $regexp=/FTS_([0-9a-f_]+)([A-Z0-9_]+)\.ibd/FTS_AUX_\2.ibd/;
# Set up some variables
LET $MYSQL_DATA_DIR = `select @@datadir`;
LET $data_directory_clause = DATA DIRECTORY='$MYSQL_TMP_DIR/alt_dir';
--enable_query_log
SET default_storage_engine=InnoDB;
SET GLOBAL innodb_file_per_table=ON;
SET NAMES utf8;
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
eval CREATE TABLE t1 (
c1 INT PRIMARY KEY, c2 INT DEFAULT 1, ct TEXT,
INDEX(c2))
ENGINE=InnoDB $data_directory_clause;
INSERT INTO t1 SET c1=1;
CREATE TABLE sys_tables SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES
WHERE NAME LIKE 'test/t%';
CREATE TABLE sys_indexes SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES i
INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID;
CREATE TABLE t1p LIKE t1;
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
eval CREATE TABLE t1c (c1 INT PRIMARY KEY, c2 INT, c3 INT, INDEX(c2), INDEX(c3),
CONSTRAINT t1c2 FOREIGN KEY (c2) REFERENCES t1(c2),
CONSTRAINT t1c3 FOREIGN KEY (c3) REFERENCES t1p(c2))
ENGINE=InnoDB $data_directory_clause;
CREATE TABLE sys_foreign SELECT i.*
FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN i
WHERE FOR_NAME LIKE 'test/t%';
SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i
INNER JOIN sys_foreign sf ON i.ID = sf.ID;
-- source suite/innodb/include/innodb_dict.inc
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
SHOW CREATE TABLE t1;
ALTER TABLE t1 ALTER c2 DROP DEFAULT;
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
SHOW CREATE TABLE t1;
--echo ### files in MYSQL_DATA_DIR/test
--replace_regex $regexp
--list_files $MYSQL_DATA_DIR/test
--echo ### files in MYSQL_TMP_DIR/alt_dir/test
--replace_regex $regexp
--list_files $MYSQL_TMP_DIR/alt_dir/test
-- source suite/innodb/include/innodb_dict.inc
# These should be no-op.
ALTER TABLE t1 CHANGE c2 c2 INT AFTER c1;
ALTER TABLE t1 CHANGE c1 c1 INT FIRST;
--echo ### files in MYSQL_DATA_DIR/test
--replace_regex $regexp
--list_files $MYSQL_DATA_DIR/test
--echo ### files in MYSQL_TMP_DIR/alt_dir/test
--replace_regex $regexp
--list_files $MYSQL_TMP_DIR/alt_dir/test
-- source suite/innodb/include/innodb_dict.inc
ALTER TABLE t1 CHANGE C2 c3 INT;
--echo ### files in MYSQL_DATA_DIR/test
--replace_regex $regexp
--list_files $MYSQL_DATA_DIR/test
--echo ### files in MYSQL_TMP_DIR/alt_dir/test
--replace_regex $regexp
--list_files $MYSQL_TMP_DIR/alt_dir/test
-- source suite/innodb/include/innodb_dict.inc
ALTER TABLE t1 CHANGE c3 C INT;
--echo ### files in MYSQL_DATA_DIR/test
--replace_regex $regexp
--list_files $MYSQL_DATA_DIR/test
--echo ### files in MYSQL_TMP_DIR/alt_dir/test
--replace_regex $regexp
--list_files $MYSQL_TMP_DIR/alt_dir/test
-- source suite/innodb/include/innodb_dict.inc
ALTER TABLE t1 CHANGE C Cöŀumň_TWO INT;
--echo ### files in MYSQL_DATA_DIR/test
--replace_regex $regexp
--list_files $MYSQL_DATA_DIR/test
--echo ### files in MYSQL_TMP_DIR/alt_dir/test
--replace_regex $regexp
--list_files $MYSQL_TMP_DIR/alt_dir/test
SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i
INNER JOIN sys_foreign sf ON i.ID = sf.ID;
-- source suite/innodb/include/innodb_dict.inc
-- error ER_BAD_FIELD_ERROR
ALTER TABLE t1 CHANGE cöĿǖmň_two c3 INT;
ALTER TABLE t1 CHANGE cÖĿUMŇ_two c3 INT, RENAME TO t3;
--echo ### files in MYSQL_DATA_DIR/test
--replace_regex $regexp
--list_files $MYSQL_DATA_DIR/test
--echo ### files in MYSQL_TMP_DIR/alt_dir/test
--replace_regex $regexp
--list_files $MYSQL_TMP_DIR/alt_dir/test
SELECT st.NAME, i.NAME
FROM sys_tables st INNER JOIN INFORMATION_SCHEMA.INNODB_SYS_TABLES i
ON i.TABLE_ID=st.TABLE_ID;
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
SHOW CREATE TABLE t3;
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
SHOW CREATE TABLE t1c;
# The maximum column name length should be 64 characters.
--error ER_TOO_LONG_IDENT
ALTER TABLE t3 CHANGE c3
`12345678901234567890123456789012345678901234567890123456789012345` INT;
ALTER TABLE t3 CHANGE c3
`1234567890123456789012345678901234567890123456789012345678901234` INT;
--echo ### files in MYSQL_DATA_DIR/test
--replace_regex $regexp
--list_files $MYSQL_DATA_DIR/test
--echo ### files in MYSQL_TMP_DIR/alt_dir/test
--replace_regex $regexp
--list_files $MYSQL_TMP_DIR/alt_dir/test
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
SHOW CREATE TABLE t3;
# Test the length limit with non-ASCII utf-8 characters.
--error ER_TOO_LONG_IDENT
ALTER TABLE t3 CHANGE
`1234567890123456789012345678901234567890123456789012345678901234`
`倀倁倂倃倄倅倆倇倈倉倊個倌倍倎倏倐們倒倓倔倕倖倗倘候倚倛倜倝倞借倠倡倢倣値倥倦倧倨倩倪倫倬倭倮倯倰倱倲倳倴倵倶倷倸倹债倻值倽倾倿偀` INT;
--error ER_TOO_LONG_IDENT
ALTER TABLE t3 CHANGE
`1234567890123456789012345678901234567890123456789012345678901234`
`倀倁倂倃倄倅倆倇倈倉倊個倌倍倎倏倐們倒倓倔倕倖倗倘候倚倛倜倝倞借倠倡倢倣値倥倦倧倨倩倪倫倬倭倮倯倰倱倲倳倴倵倶倷倸倹债倻值倽倾倿ä` INT;
ALTER TABLE t3 CHANGE
`1234567890123456789012345678901234567890123456789012345678901234`
`倀倁倂倃倄倅倆倇倈倉倊個倌倍倎倏倐們倒倓倔倕倖倗倘候倚倛倜倝倞借倠倡倢倣値倥倦倧倨倩倪倫倬倭倮倯倰倱倲倳倴倵倶倷倸倹债倻值倽倾ä` INT;
--echo ### files in MYSQL_DATA_DIR/test
--replace_regex $regexp
--list_files $MYSQL_DATA_DIR/test
--echo ### files in MYSQL_TMP_DIR/alt_dir/test
--replace_regex $regexp
--list_files $MYSQL_TMP_DIR/alt_dir/test
# check that the rename is case-insensitive (note the upper-case ä at end)
ALTER TABLE t3 CHANGE
`倀倁倂倃倄倅倆倇倈倉倊個倌倍倎倏倐們倒倓倔倕倖倗倘候倚倛倜倝倞借倠倡倢倣値倥倦倧倨倩倪倫倬倭倮倯倰倱倲倳倴倵倶倷倸倹债倻值倽倾Ä`
c3 INT;
--echo ### files in MYSQL_DATA_DIR/test
--replace_regex $regexp
--list_files $MYSQL_DATA_DIR/test
--echo ### files in MYSQL_TMP_DIR/alt_dir/test
--replace_regex $regexp
--list_files $MYSQL_TMP_DIR/alt_dir/test
# test with 4-byte UTF-8 (should be disallowed)
--error ER_INVALID_CHARACTER_STRING
ALTER TABLE t3 CHANGE c3 𐌀𐌁𐌂𐌃𐌄𐌅𐌆𐌇𐌈𐌉𐌊𐌋𐌌𐌍𐌎𐌏𐌐𐌑𐌒𐌓𐌔𐌕𐌖𐌗𐌘𐌙𐌚𐌛𐌜 INT;
--error ER_INVALID_CHARACTER_STRING
ALTER TABLE t3 CHANGE c3 😲 INT;
ALTER TABLE t3 RENAME TO t2;
--echo ### files in MYSQL_DATA_DIR/test
--replace_regex $regexp
--list_files $MYSQL_DATA_DIR/test
--echo ### files in MYSQL_TMP_DIR/alt_dir/test
--replace_regex $regexp
--list_files $MYSQL_TMP_DIR/alt_dir/test
SELECT st.NAME, i.NAME
FROM sys_tables st INNER JOIN INFORMATION_SCHEMA.INNODB_SYS_TABLES i
ON i.TABLE_ID=st.TABLE_ID;
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
SHOW CREATE TABLE t2;
RENAME TABLE t2 TO t1;
SELECT st.NAME, i.NAME
FROM sys_tables st INNER JOIN INFORMATION_SCHEMA.INNODB_SYS_TABLES i
ON i.TABLE_ID=st.TABLE_ID;
--echo ### files in MYSQL_DATA_DIR/test
--replace_regex $regexp
--list_files $MYSQL_DATA_DIR/test
--echo ### files in MYSQL_TMP_DIR/alt_dir/test
--replace_regex $regexp
--list_files $MYSQL_TMP_DIR/alt_dir/test
-- source suite/innodb/include/innodb_dict.inc
--error ER_DROP_INDEX_FK
ALTER TABLE t1 DROP INDEX c2;
--error ER_CANT_DROP_FIELD_OR_KEY
ALTER TABLE t1 DROP INDEX c4;
--error ER_CANT_DROP_FIELD_OR_KEY
ALTER TABLE t1c DROP FOREIGN KEY c2;
--error ER_CANT_DROP_FIELD_OR_KEY
ALTER TABLE t1c DROP FOREIGN KEY t1c2, DROP FOREIGN KEY c2;
--error ER_CANT_DROP_FIELD_OR_KEY
ALTER TABLE t1c DROP FOREIGN KEY t1c2, DROP FOREIGN KEY c2, DROP INDEX c2;
--error ER_DROP_INDEX_FK
ALTER TABLE t1c DROP INDEX c2;
--error ER_CANT_DROP_FIELD_OR_KEY
ALTER TABLE t1c DROP FOREIGN KEY ẗ1C2;
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
SHOW CREATE TABLE t1c;
SET foreign_key_checks=0;
DROP TABLE t1p;
SET foreign_key_checks=1;
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
SHOW CREATE TABLE t1c;
--echo ### files in MYSQL_DATA_DIR/test
--replace_regex $regexp
--list_files $MYSQL_DATA_DIR/test
--echo ### files in MYSQL_TMP_DIR/alt_dir/test
--replace_regex $regexp
--list_files $MYSQL_TMP_DIR/alt_dir/test
-- source suite/innodb/include/innodb_dict.inc
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
eval CREATE TABLE t1p (c1 INT PRIMARY KEY, c2 INT, INDEX(c2))
ENGINE=InnoDB $data_directory_clause;
--error ER_DROP_INDEX_FK
ALTER TABLE t1c DROP INDEX C2, DROP INDEX C3;
--error ER_DROP_INDEX_FK
ALTER TABLE t1c DROP INDEX C3;
SET foreign_key_checks=0;
ALTER TABLE t1c DROP INDEX C3;
--echo ### files in MYSQL_DATA_DIR/test
--replace_regex $regexp
--list_files $MYSQL_DATA_DIR/test
--echo ### files in MYSQL_TMP_DIR/alt_dir/test
--replace_regex $regexp
--list_files $MYSQL_TMP_DIR/alt_dir/test
SET foreign_key_checks=1;
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
SHOW CREATE TABLE t1c;
-- source suite/innodb/include/innodb_dict.inc
ALTER TABLE t1c DROP FOREIGN KEY t1C3;
--echo ### files in MYSQL_DATA_DIR/test
--list_files $MYSQL_DATA_DIR/test
--replace_regex $regexp
--echo ### files in MYSQL_TMP_DIR/alt_dir/test
--replace_regex $regexp
--list_files $MYSQL_TMP_DIR/alt_dir/test
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
SHOW CREATE TABLE t1c;
-- source suite/innodb/include/innodb_dict.inc
ALTER TABLE t1c DROP INDEX c2, DROP FOREIGN KEY t1C2;
--echo ### files in MYSQL_DATA_DIR/test
--replace_regex $regexp
--list_files $MYSQL_DATA_DIR/test
--echo ### files in MYSQL_TMP_DIR/alt_dir/test
--replace_regex $regexp
--list_files $MYSQL_TMP_DIR/alt_dir/test
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
SHOW CREATE TABLE t1c;
-- source suite/innodb/include/innodb_dict.inc
ALTER TABLE t1 DROP INDEX c2, CHANGE c3 c2 INT;
--echo ### files in MYSQL_DATA_DIR/test
--replace_regex $regexp
--list_files $MYSQL_DATA_DIR/test
--echo ### files in MYSQL_TMP_DIR/alt_dir/test
--replace_regex $regexp
--list_files $MYSQL_TMP_DIR/alt_dir/test
-- source suite/innodb/include/innodb_dict.inc
CREATE TABLE t1o LIKE t1;
# This will implicitly add a DOC_ID column.
# The LOCK=NONE should thus fail.
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
ALTER TABLE t1 ADD FULLTEXT INDEX (ct),
CHANGE c1 pk INT, ALTER c2 SET DEFAULT 42, RENAME TO tt,
ALGORITHM=INPLACE, LOCK=NONE;
# Retry with LOCK=EXCLUSIVE.
ALTER TABLE t1 ADD FULLTEXT INDEX (ct),
CHANGE c1 pk INT, ALTER c2 SET DEFAULT 42, RENAME TO tt,
ALGORITHM=INPLACE, LOCK=SHARED;
--echo ### files in MYSQL_DATA_DIR/test
--replace_regex $regexp
--list_files $MYSQL_DATA_DIR/test
--echo ### files in MYSQL_TMP_DIR/alt_dir/test
--replace_regex $regexp
--list_files $MYSQL_TMP_DIR/alt_dir/test
# The output should be empty, because index->id was reassigned.
-- source suite/innodb/include/innodb_dict.inc
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
SHOW CREATE TABLE tt;
# DB_ROW_ID, DB_TRX_ID, DB_ROLL_PTR are reserved InnoDB system column names.
--error ER_WRONG_COLUMN_NAME
ALTER TABLE t1o CHANGE c1 dB_row_Id INT, ALGORITHM=COPY;
--error ER_WRONG_COLUMN_NAME
ALTER TABLE t1o CHANGE c1 dB_row_Id INT, ALGORITHM=INPLACE;
--error ER_WRONG_COLUMN_NAME
ALTER TABLE t1o CHANGE c1 DB_TRX_ID INT;
--error ER_WRONG_COLUMN_NAME
ALTER TABLE t1o CHANGE c1 db_roll_ptr INT;
# FTS_DOC_ID is the internal row identifier for full-text search.
# It should be of type BIGINT UNSIGNED NOT NULL.
--error ER_WRONG_COLUMN_NAME
ALTER TABLE t1o ADD FULLTEXT INDEX(ct), CHANGE c1 FTS_DOC_ID INT,
ALGORITHM=COPY;
--error ER_INNODB_FT_WRONG_DOCID_COLUMN
ALTER TABLE t1o ADD FULLTEXT INDEX(ct), CHANGE c1 FTS_DOC_ID INT,
ALGORITHM=INPLACE;
--error ER_WRONG_COLUMN_NAME
ALTER TABLE t1o ADD FULLTEXT INDEX(ct), CHANGE c1 FTS_Doc_ID INT,
ALGORITHM=INPLACE;
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
ALTER TABLE t1o ADD FULLTEXT INDEX(ct),
CHANGE c1 FTS_DOC_ID BIGINT UNSIGNED NOT NULL,
ALGORITHM=INPLACE;
CREATE TABLE t1n LIKE t1o;
ALTER TABLE t1n ADD FULLTEXT INDEX(ct);
--echo ### files in MYSQL_DATA_DIR/test
--replace_regex $regexp
--list_files $MYSQL_DATA_DIR/test
--echo ### files in MYSQL_TMP_DIR/alt_dir/test
--replace_regex $regexp
--list_files $MYSQL_TMP_DIR/alt_dir/test
--error ER_WRONG_COLUMN_NAME
ALTER TABLE t1n CHANGE c1 Fts_DOC_ID INT, ALGORITHM=INPLACE;
--error ER_WRONG_COLUMN_NAME
ALTER TABLE t1n CHANGE c1 Fts_DOC_ID INT, ALGORITHM=COPY;
--error ER_BAD_FIELD_ERROR
ALTER TABLE t1n CHANGE FTS_DOC_ID c11 INT, ALGORITHM=INPLACE;
ALTER TABLE t1n CHANGE c1 FTS_DOC_ïD INT, ALGORITHM=INPLACE;
--echo ### files in MYSQL_DATA_DIR/test
--replace_regex $regexp
--list_files $MYSQL_DATA_DIR/test
--echo ### files in MYSQL_TMP_DIR/alt_dir/test
--replace_regex $regexp
--list_files $MYSQL_TMP_DIR/alt_dir/test
ALTER TABLE t1n CHANGE FTS_DOC_ÏD c1 INT, ALGORITHM=INPLACE;
--echo ### files in MYSQL_DATA_DIR/test
--replace_regex $regexp
--list_files $MYSQL_DATA_DIR/test
--echo ### files in MYSQL_TMP_DIR/alt_dir/test
--replace_regex $regexp
--list_files $MYSQL_TMP_DIR/alt_dir/test
ALTER TABLE t1n CHANGE c1 c2 INT, CHANGE c2 ct INT, CHANGE ct c1 TEXT,
ALGORITHM=INPLACE;
--echo ### files in MYSQL_DATA_DIR/test
--replace_regex $regexp
--list_files $MYSQL_DATA_DIR/test
--echo ### files in MYSQL_TMP_DIR/alt_dir/test
--replace_regex $regexp
--list_files $MYSQL_TMP_DIR/alt_dir/test
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
SHOW CREATE TABLE t1n;
ALTER TABLE t1n CHANGE c2 c1 INT, CHANGE ct c2 INT, CHANGE c1 ct TEXT,
ALGORITHM=COPY;
--echo ### files in MYSQL_DATA_DIR/test
--replace_regex $regexp
--list_files $MYSQL_DATA_DIR/test
--echo ### files in MYSQL_TMP_DIR/alt_dir/test
--replace_regex $regexp
--list_files $MYSQL_TMP_DIR/alt_dir/test
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
SHOW CREATE TABLE t1n;
--error ER_KEY_COLUMN_DOES_NOT_EXITS
ALTER TABLE t1n ADD INDEX(c2), CHANGE c2 c4 INT, ALGORITHM=INPLACE;
--error ER_KEY_COLUMN_DOES_NOT_EXITS
ALTER TABLE t1n ADD INDEX(c2), CHANGE c2 c4 INT, ALGORITHM=COPY;
# FIXME: MDEV-13668 InnoDB unnecessarily rebuilds table
# when renaming a column and adding index
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
ALTER TABLE t1n ADD INDEX(c4), CHANGE c2 c4 INT, ALGORITHM=INPLACE;
ALTER TABLE t1n CHANGE c2 c4 INT, LOCK=NONE;
ALTER TABLE t1n ADD INDEX(c4), LOCK=NONE;
--echo ### files in MYSQL_DATA_DIR/test
--replace_regex $regexp
--list_files $MYSQL_DATA_DIR/test
--echo ### files in MYSQL_TMP_DIR/alt_dir/test
--replace_regex $regexp
--list_files $MYSQL_TMP_DIR/alt_dir/test
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
SHOW CREATE TABLE t1n;
ALTER TABLE t1n DROP INDEX c4;
--echo ### files in MYSQL_DATA_DIR/test
--replace_regex $regexp
--list_files $MYSQL_DATA_DIR/test
--echo ### files in MYSQL_TMP_DIR/alt_dir/test
--replace_regex $regexp
--list_files $MYSQL_TMP_DIR/alt_dir/test
--error ER_DUP_FIELDNAME
ALTER TABLE t1n CHANGE c4 c1 INT, ADD INDEX(c1), ALGORITHM=INPLACE;
# FIXME: MDEV-13668
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
ALTER TABLE t1n CHANGE c4 c11 INT, ADD INDEX(c11), ALGORITHM=INPLACE;
ALTER TABLE t1n CHANGE c4 c11 INT, LOCK=NONE;
ALTER TABLE t1n ADD INDEX(c11), LOCK=NONE;
--echo ### files in MYSQL_DATA_DIR/test
--replace_regex $regexp
--list_files $MYSQL_DATA_DIR/test
--echo ### files in MYSQL_TMP_DIR/alt_dir/test
--replace_regex $regexp
--list_files $MYSQL_TMP_DIR/alt_dir/test
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
SHOW CREATE TABLE t1n;
DROP TABLE t1n;
ALTER TABLE t1o MODIFY c1 BIGINT UNSIGNED NOT NULL;
--echo ### files in MYSQL_DATA_DIR/test
--replace_regex $regexp
--list_files $MYSQL_DATA_DIR/test
--echo ### files in MYSQL_TMP_DIR/alt_dir/test
--replace_regex $regexp
--list_files $MYSQL_TMP_DIR/alt_dir/test
# FIXME: MDEV-9469 'Incorrect key file' on ALTER TABLE
call mtr.add_suppression("Error: no matching column for .FTS_DOC_ID. in index .ct.--temporary-- of table .test...t1o");
--error ER_NOT_KEYFILE
ALTER TABLE t1o ADD FULLTEXT INDEX(ct),
CHANGE c1 FTS_DOC_ID BIGINT UNSIGNED NOT NULL,
ALGORITHM=INPLACE;
ALTER TABLE t1o CHANGE c1 FTS_DOC_ID BIGINT UNSIGNED NOT NULL, LOCK=NONE;
ALTER TABLE t1o ADD FULLTEXT INDEX(ct), ALGORITHM=INPLACE;
# end of MDEV-9469 FIXME
--echo ### files in MYSQL_DATA_DIR/test
--replace_regex $regexp
--list_files $MYSQL_DATA_DIR/test
--echo ### files in MYSQL_TMP_DIR/alt_dir/test
--replace_regex $regexp
--list_files $MYSQL_TMP_DIR/alt_dir/test
# This would create a hidden FTS_DOC_ID column, which cannot be done online.
# FIXME: MDEV-9469 (enable this)
#--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
#ALTER TABLE t1o CHANGE FTS_DOC_ID foo_id BIGINT UNSIGNED NOT NULL,
#LOCK=NONE;
#end of MDEV-9469 FIXME
# This should not show duplicates.
SELECT sc.pos FROM information_schema.innodb_sys_columns sc
INNER JOIN information_schema.innodb_sys_tables st
ON sc.TABLE_ID=st.TABLE_ID
WHERE st.NAME='test/t1o' AND sc.NAME='FTS_DOC_ID';
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
SHOW CREATE TABLE t1o;
# FIXME: MDEV-13668
ALTER TABLE t1o CHANGE FTS_DOC_ID foo_id BIGINT UNSIGNED NOT NULL,
DROP INDEX ct, LOCK=NONE;
--echo ### files in MYSQL_DATA_DIR/test
--replace_regex $regexp
--list_files $MYSQL_DATA_DIR/test
--echo ### files in MYSQL_TMP_DIR/alt_dir/test
--replace_regex $regexp
--list_files $MYSQL_TMP_DIR/alt_dir/test
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
SHOW CREATE TABLE t1o;
DROP TABLE t1c, t1p, sys_tables, sys_indexes, sys_foreign;
# Check the internal schemata of tt, t1o.
CREATE TABLE sys_tables SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES
WHERE NAME='test/t1o';
CREATE TABLE sys_indexes SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES i
INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID;
CREATE TABLE sys_foreign SELECT i.*
FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN i WHERE FOR_NAME='test/t1o';
-- source suite/innodb/include/innodb_dict.inc
# Ensure that there exists no hidden FTS_DOC_ID_INDEX on foo_id.
ALTER TABLE t1o ADD UNIQUE INDEX FTS_DOC_ID_INDEX(foo_id);
--echo ### files in MYSQL_DATA_DIR/test
--replace_regex $regexp
--list_files $MYSQL_DATA_DIR/test
--echo ### files in MYSQL_TMP_DIR/alt_dir/test
--replace_regex $regexp
--list_files $MYSQL_TMP_DIR/alt_dir/test
# FIXME: MDEV-9469 'Incorrect key file' on ALTER TABLE
--error ER_NOT_KEYFILE
ALTER TABLE t1o CHANGE foo_id FTS_DOC_ID BIGINT UNSIGNED NOT NULL,
ADD FULLTEXT INDEX(ct);
ALTER TABLE t1o CHANGE foo_id FTS_DOC_ID BIGINT UNSIGNED NOT NULL, LOCK=NONE;
ALTER TABLE t1o ADD FULLTEXT INDEX(ct), ALGORITHM=INPLACE;
#end of MDEV-9469 FIXME
--echo ### files in MYSQL_DATA_DIR/test
--replace_regex $regexp
--list_files $MYSQL_DATA_DIR/test
--echo ### files in MYSQL_TMP_DIR/alt_dir/test
--replace_regex $regexp
--list_files $MYSQL_TMP_DIR/alt_dir/test
--error ER_INNODB_FT_WRONG_DOCID_INDEX
ALTER TABLE t1o CHANGE FTS_DOC_ID foo_id BIGINT UNSIGNED NOT NULL;
DROP TABLE sys_indexes;
CREATE TABLE sys_indexes SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES i
INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID;
-- source suite/innodb/include/innodb_dict.inc
--echo #
--echo # Cleanup
--echo #
DROP TABLE tt, t1o, sys_tables, sys_indexes, sys_foreign;
--echo ### files in MYSQL_DATA_DIR/test
--replace_regex $regexp
--list_files $MYSQL_DATA_DIR/test
--echo ### files in MYSQL_TMP_DIR/alt_dir/test
--replace_regex $regexp
--list_files $MYSQL_TMP_DIR/alt_dir/test
--rmdir $MYSQL_TMP_DIR/alt_dir/test
--rmdir $MYSQL_TMP_DIR/alt_dir
-- disable_query_log
eval set global innodb_file_per_table=$innodb_file_per_table_orig;
call mtr.add_suppression("deleting orphaned .ibd file");
-- enable_query_log
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