Commit 8d929816 authored by Marko Mäkelä's avatar Marko Mäkelä

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.
parent 888a8b69
# 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;
#
# 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=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;
This diff is collapsed.
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 SESSION DEBUG='+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 SESSION DEBUG=DEFAULT;
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='+d,ib_row_merge_buf_add_two';
CREATE UNIQUE INDEX ui ON bug13861218(c1);
SET DEBUG='-d,ib_row_merge_buf_add_two';
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='+d,ib_row_merge_buf_add_two';
CREATE UNIQUE INDEX ui ON bug13861218(c1);
SET DEBUG='-d,ib_row_merge_buf_add_two';
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 = '+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 = '-d,innobase_tmpfile_creation_failure';
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;
This diff is collapsed.
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;
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
--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
--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;
This diff is collapsed.
-- 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 SESSION DEBUG='+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 SESSION DEBUG=DEFAULT;
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='+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='-d,ib_row_merge_buf_add_two';
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='+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='-d,ib_row_merge_buf_add_two';
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 = '+d,innobase_tmpfile_creation_failure';
--error ER_OUT_OF_RESOURCES
alter table t1 force, algorithm=inplace;
SET DEBUG = '-d,innobase_tmpfile_creation_failure';
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
This diff is collapsed.
--innodb-sort-buffer-size=64k --innodb-online-alter-log-max-size=64k --innodb-buffer-pool-size=5M --innodb-log-buffer-size=256k
This diff is collapsed.
This diff is collapsed.
--innodb-sort-buffer-size=64k --innodb-online-alter-log-max-size=64k --innodb-buffer-pool-size=5M --innodb-log-buffer-size=256k
This diff is collapsed.
This diff is collapsed.
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