-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MDEV-13625 Merge InnoDB test cases from MySQL 5.6 (part 1)
Import some ALTER TABLE test cases from MySQL 5.6 without modification. The adjustments will be in a separate commit.
- Loading branch information
Showing
27 changed files
with
6,904 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# 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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
# | ||
# 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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# | ||
# 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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,174 @@ | ||
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=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; |
Oops, something went wrong.