summaryrefslogtreecommitdiff
path: root/mysql-test/suite/innodb
diff options
context:
space:
mode:
Diffstat (limited to 'mysql-test/suite/innodb')
-rw-r--r--mysql-test/suite/innodb/r/alter_persistent_autoinc.result42
-rw-r--r--mysql-test/suite/innodb/r/foreign_key.result27
-rw-r--r--mysql-test/suite/innodb/r/gap_lock_split.result27
-rw-r--r--mysql-test/suite/innodb/r/innodb-autoinc-part.result34
-rw-r--r--mysql-test/suite/innodb/r/innodb-autoinc.result25
-rw-r--r--mysql-test/suite/innodb/t/alter_persistent_autoinc.test86
-rw-r--r--mysql-test/suite/innodb/t/foreign_key.test34
-rw-r--r--mysql-test/suite/innodb/t/gap_lock_split.test39
-rw-r--r--mysql-test/suite/innodb/t/innodb-autoinc-part.test24
-rw-r--r--mysql-test/suite/innodb/t/innodb-autoinc.test23
10 files changed, 354 insertions, 7 deletions
diff --git a/mysql-test/suite/innodb/r/alter_persistent_autoinc.result b/mysql-test/suite/innodb/r/alter_persistent_autoinc.result
new file mode 100644
index 00000000000..52ac4d83ad9
--- /dev/null
+++ b/mysql-test/suite/innodb/r/alter_persistent_autoinc.result
@@ -0,0 +1,42 @@
+CREATE TABLE t1 (c INT AUTO_INCREMENT NULL UNIQUE) ENGINE=InnoDB;
+ALTER TABLE t1 MODIFY c INT NULL, ALGORITHM=INSTANT;
+INSERT INTO t1 SET c=1;
+CREATE TABLE t2 (c INT AUTO_INCREMENT NULL UNIQUE) ENGINE=InnoDB;
+ALTER TABLE t2 MODIFY c INT NULL, FORCE, ALGORITHM=INPLACE;
+INSERT INTO t2 SET c=1;
+CREATE TABLE t3 (c INT AUTO_INCREMENT NULL UNIQUE) ENGINE=InnoDB;
+ALTER TABLE t3 MODIFY c INT NULL, ALGORITHM=INPLACE;
+INSERT INTO t3 SET c=1;
+CREATE TABLE t4 (c1 INT AUTO_INCREMENT NULL UNIQUE, c2 INT) ENGINE=InnoDB;
+ALTER TABLE t4 MODIFY c1 INT NULL, CHANGE COLUMN c2 c3 INT, ALGORITHM=INPLACE;
+INSERT INTO t4 SET c1=1;
+CREATE TABLE t5 (c1 INT AUTO_INCREMENT NULL UNIQUE, c2 INT, c3 INTEGER GENERATED ALWAYS AS (c2)) ENGINE=InnoDB;
+ALTER TABLE t5 MODIFY c1 INT NULL, MODIFY COLUMN c2 INT FIRST, ALGORITHM=INPLACE;
+INSERT INTO t5 SET c1=1;
+CREATE TABLE t6 (c INT AUTO_INCREMENT NULL UNIQUE) ENGINE=InnoDB
+PARTITION BY LIST(c) (
+PARTITION p1 VALUES IN (1),
+PARTITION p2 VALUES IN (2)
+);
+ALTER TABLE t6 MODIFY c INT NULL, ALGORITHM=INSTANT;
+INSERT INTO t6 SET c=1;
+INSERT INTO t6 SET c=2;
+CREATE TABLE t7 (c INT AUTO_INCREMENT NULL UNIQUE) ENGINE=InnoDB
+PARTITION BY LIST(c) (
+PARTITION p1 VALUES IN (1),
+PARTITION p2 VALUES IN (2)
+);
+ALTER TABLE t7 MODIFY c INT NULL, ALGORITHM=INPLACE;
+INSERT INTO t7 SET c=1;
+INSERT INTO t7 SET c=2;
+CREATE TABLE t8 (c1 INT AUTO_INCREMENT NULL UNIQUE, c2 INT) ENGINE=InnoDB
+PARTITION BY LIST(c1) (
+PARTITION p1 VALUES IN (1), PARTITION p2 VALUES IN (2));
+ALTER TABLE t8 MODIFY c1 INT NULL, CHANGE COLUMN c2 c3 INT, ALGORITHM=INPLACE;
+INSERT INTO t8 SET c1=1;
+INSERT INTO t8 SET c1=2;
+FLUSH TABLES t1, t2, t3, t4, t5, t6, t7, t8 FOR EXPORT;
+AUTO_INCREMENT not partitioned: 0 0 0 0 0
+AUTO_INCREMENT partitioned: (0, 0) (0, 0) (0, 0)
+UNLOCK TABLES;
+DROP TABLE t1, t2, t3, t4, t5, t6, t7, t8;
diff --git a/mysql-test/suite/innodb/r/foreign_key.result b/mysql-test/suite/innodb/r/foreign_key.result
index da784ba2acf..376ea821279 100644
--- a/mysql-test/suite/innodb/r/foreign_key.result
+++ b/mysql-test/suite/innodb/r/foreign_key.result
@@ -137,7 +137,34 @@ SELECT unique_constraint_name FROM information_schema.referential_constraints
WHERE table_name = 't2';
unique_constraint_name
PRIMARY
+#
+# MDEV-28317 Assertion failure on rollback of FOREIGN KEY operation
+#
+SET foreign_key_checks=0;
+CREATE TABLE parent(a INT PRIMARY KEY) ENGINE=InnoDB;
+CREATE TABLE child(a INT,FOREIGN KEY(a) REFERENCES parent(a) ON DELETE CASCADE)
+ENGINE=InnoDB;
+INSERT INTO child VALUES(1);
+ALTER TABLE child DROP INDEX a;
+connect incomplete, localhost, root,,;
+BEGIN;
+DELETE FROM child;
+connection default;
+INSERT INTO parent SET a=0;
+FLUSH TABLES;
# restart
+disconnect incomplete;
+INSERT INTO child SET a=0;
+INSERT INTO child SET a=1;
+ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`child`, CONSTRAINT `child_ibfk_1` FOREIGN KEY (`a`) REFERENCES `parent` (`a`) ON DELETE CASCADE)
+DELETE FROM parent;
+ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`child`, CONSTRAINT `child_ibfk_1` FOREIGN KEY (`a`) REFERENCES `parent` (`a`) ON DELETE CASCADE)
+ALTER TABLE child ADD INDEX(a);
+DELETE FROM parent;
+ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`child`, CONSTRAINT `child_ibfk_1` FOREIGN KEY (`a`) REFERENCES `parent` (`a`) ON DELETE CASCADE)
+ALTER TABLE child FORCE;
+DELETE FROM parent;
+DROP TABLE child,parent;
SET @saved_frequency = @@GLOBAL.innodb_purge_rseg_truncate_frequency;
SET GLOBAL innodb_purge_rseg_truncate_frequency = 1;
SELECT unique_constraint_name FROM information_schema.referential_constraints
diff --git a/mysql-test/suite/innodb/r/gap_lock_split.result b/mysql-test/suite/innodb/r/gap_lock_split.result
new file mode 100644
index 00000000000..25a3cf711f9
--- /dev/null
+++ b/mysql-test/suite/innodb/r/gap_lock_split.result
@@ -0,0 +1,27 @@
+SET @save_frequency=@@GLOBAL.innodb_purge_rseg_truncate_frequency;
+SET GLOBAL innodb_purge_rseg_truncate_frequency=1;
+CREATE TABLE t1(id INT PRIMARY key, val VARCHAR(16000)) ENGINE=InnoDB;
+INSERT INTO t1 (id,val) SELECT 2*seq,'x' FROM seq_0_to_1023;
+connect con1,localhost,root,,;
+START TRANSACTION WITH CONSISTENT SNAPSHOT;
+connection default;
+DELETE FROM t1 WHERE id=1788;
+BEGIN;
+SELECT * FROM t1 WHERE id=1788 FOR UPDATE;
+id val
+connection con1;
+COMMIT;
+InnoDB 0 transactions not purged
+connection default;
+INSERT INTO t1 (id,val) VALUES (1787, REPEAT('x',2000));
+connection con1;
+SET innodb_lock_wait_timeout=0;
+INSERT INTO t1 (id,val) VALUES (1788, 'x');
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+SELECT * FROM t1 WHERE id=1788 FOR UPDATE;
+id val
+disconnect con1;
+connection default;
+COMMIT;
+DROP TABLE t1;
+SET GLOBAL innodb_purge_rseg_truncate_frequency=@save_frequency;
diff --git a/mysql-test/suite/innodb/r/innodb-autoinc-part.result b/mysql-test/suite/innodb/r/innodb-autoinc-part.result
new file mode 100644
index 00000000000..6872b5e02f5
--- /dev/null
+++ b/mysql-test/suite/innodb/r/innodb-autoinc-part.result
@@ -0,0 +1,34 @@
+#
+# MDEV-28416 Incorrect AUTO_INCREMENT may be issued
+#
+SET @aii=@@auto_increment_increment;
+SET auto_increment_increment=300;
+CREATE TABLE t1 (a SERIAL) ENGINE=innodb
+PARTITION BY RANGE (a) (
+PARTITION p0 VALUES LESS THAN (6),
+PARTITION p1 VALUES LESS THAN MAXVALUE
+);
+INSERT INTO t1 VALUES (18446744073709551613);
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
+ UNIQUE KEY `a` (`a`)
+) ENGINE=InnoDB AUTO_INCREMENT=18446744073709551614 DEFAULT CHARSET=latin1
+ PARTITION BY RANGE (`a`)
+(PARTITION `p0` VALUES LESS THAN (6) ENGINE = InnoDB,
+ PARTITION `p1` VALUES LESS THAN MAXVALUE ENGINE = InnoDB)
+INSERT INTO t1 VALUES (NULL);
+ERROR 22003: Out of range value for column 'a' at row 1
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
+ UNIQUE KEY `a` (`a`)
+) ENGINE=InnoDB AUTO_INCREMENT=298 DEFAULT CHARSET=latin1
+ PARTITION BY RANGE (`a`)
+(PARTITION `p0` VALUES LESS THAN (6) ENGINE = InnoDB,
+ PARTITION `p1` VALUES LESS THAN MAXVALUE ENGINE = InnoDB)
+DROP TABLE t1;
+SET auto_increment_increment=@aii;
+# End of 10.2 tests
diff --git a/mysql-test/suite/innodb/r/innodb-autoinc.result b/mysql-test/suite/innodb/r/innodb-autoinc.result
index 1efd5c61af7..b41e1c90a43 100644
--- a/mysql-test/suite/innodb/r/innodb-autoinc.result
+++ b/mysql-test/suite/innodb/r/innodb-autoinc.result
@@ -1,4 +1,3 @@
-drop table if exists t1;
CREATE TABLE t1 (c1 BIGINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (9223372036854775807, null);
INSERT INTO t1 (c2) VALUES ('innodb');
@@ -1622,3 +1621,27 @@ id name
-1 dog
2 cat
DROP PROCEDURE autoinc_mdev15353_one;
+#
+# MDEV-28416 Incorrect AUTO_INCREMENT may be issued
+#
+SET @aii=@@auto_increment_increment;
+SET auto_increment_increment=300;
+CREATE TABLE t1 (a SERIAL) ENGINE=innodb;
+INSERT INTO t1 VALUES (18446744073709551613);
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
+ UNIQUE KEY `a` (`a`)
+) ENGINE=InnoDB AUTO_INCREMENT=18446744073709551614 DEFAULT CHARSET=latin1
+INSERT INTO t1 VALUES (NULL);
+ERROR 22003: Out of range value for column 'a' at row 1
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
+ UNIQUE KEY `a` (`a`)
+) ENGINE=InnoDB AUTO_INCREMENT=18446744073709551615 DEFAULT CHARSET=latin1
+DROP TABLE t1;
+SET auto_increment_increment=@aii;
+# End of 10.2 tests
diff --git a/mysql-test/suite/innodb/t/alter_persistent_autoinc.test b/mysql-test/suite/innodb/t/alter_persistent_autoinc.test
new file mode 100644
index 00000000000..dcaea32700c
--- /dev/null
+++ b/mysql-test/suite/innodb/t/alter_persistent_autoinc.test
@@ -0,0 +1,86 @@
+# Test the ability to remove AUTO_INCREMENT attribute
+--source include/have_innodb.inc
+--source include/have_partition.inc
+
+CREATE TABLE t1 (c INT AUTO_INCREMENT NULL UNIQUE) ENGINE=InnoDB;
+ALTER TABLE t1 MODIFY c INT NULL, ALGORITHM=INSTANT;
+INSERT INTO t1 SET c=1;
+
+CREATE TABLE t2 (c INT AUTO_INCREMENT NULL UNIQUE) ENGINE=InnoDB;
+ALTER TABLE t2 MODIFY c INT NULL, FORCE, ALGORITHM=INPLACE;
+INSERT INTO t2 SET c=1;
+
+CREATE TABLE t3 (c INT AUTO_INCREMENT NULL UNIQUE) ENGINE=InnoDB;
+ALTER TABLE t3 MODIFY c INT NULL, ALGORITHM=INPLACE;
+INSERT INTO t3 SET c=1;
+
+CREATE TABLE t4 (c1 INT AUTO_INCREMENT NULL UNIQUE, c2 INT) ENGINE=InnoDB;
+ALTER TABLE t4 MODIFY c1 INT NULL, CHANGE COLUMN c2 c3 INT, ALGORITHM=INPLACE;
+INSERT INTO t4 SET c1=1;
+
+CREATE TABLE t5 (c1 INT AUTO_INCREMENT NULL UNIQUE, c2 INT, c3 INTEGER GENERATED ALWAYS AS (c2)) ENGINE=InnoDB;
+# ha_innobase::commit_inplace_alter_table() should invoke innobase_reload_table()
+ALTER TABLE t5 MODIFY c1 INT NULL, MODIFY COLUMN c2 INT FIRST, ALGORITHM=INPLACE;
+INSERT INTO t5 SET c1=1;
+
+CREATE TABLE t6 (c INT AUTO_INCREMENT NULL UNIQUE) ENGINE=InnoDB
+ PARTITION BY LIST(c) (
+ PARTITION p1 VALUES IN (1),
+ PARTITION p2 VALUES IN (2)
+ );
+ALTER TABLE t6 MODIFY c INT NULL, ALGORITHM=INSTANT;
+INSERT INTO t6 SET c=1;
+INSERT INTO t6 SET c=2;
+
+CREATE TABLE t7 (c INT AUTO_INCREMENT NULL UNIQUE) ENGINE=InnoDB
+ PARTITION BY LIST(c) (
+ PARTITION p1 VALUES IN (1),
+ PARTITION p2 VALUES IN (2)
+ );
+ALTER TABLE t7 MODIFY c INT NULL, ALGORITHM=INPLACE;
+INSERT INTO t7 SET c=1;
+INSERT INTO t7 SET c=2;
+
+CREATE TABLE t8 (c1 INT AUTO_INCREMENT NULL UNIQUE, c2 INT) ENGINE=InnoDB
+ PARTITION BY LIST(c1) (
+ PARTITION p1 VALUES IN (1), PARTITION p2 VALUES IN (2));
+ALTER TABLE t8 MODIFY c1 INT NULL, CHANGE COLUMN c2 c3 INT, ALGORITHM=INPLACE;
+INSERT INTO t8 SET c1=1;
+INSERT INTO t8 SET c1=2;
+
+FLUSH TABLES t1, t2, t3, t4, t5, t6, t7, t8 FOR EXPORT;
+
+--let INNODB_PAGE_SIZE=`select @@innodb_page_size`
+--let MYSQLD_DATADIR = `SELECT @@datadir`
+
+--perl
+my $ps= $ENV{INNODB_PAGE_SIZE};
+my $PAGE_HEADER = 38;
+my $PAGE_ROOT_AUTO_INC = 18;
+print "AUTO_INCREMENT not partitioned: ";
+for (my $i = 1; $i <= 5; ++$i) {
+ my $autoinc= read_autoinc("$ENV{MYSQLD_DATADIR}/test/t$i.ibd");
+ print "$autoinc ";
+}
+print "\n";
+print "AUTO_INCREMENT partitioned: ";
+for (my $i = 6; $i <= 8; ++$i) {
+ my $p1= read_autoinc("$ENV{MYSQLD_DATADIR}/test/t$i#P#p1.ibd");
+ my $p2= read_autoinc("$ENV{MYSQLD_DATADIR}/test/t$i#P#p2.ibd");
+ print "($p1, $p2) ";
+}
+print "\n";
+sub read_autoinc {
+ my $file= shift;
+ open(FILE, "<", $file) || die "Unable to open $file\n";
+ sysseek(FILE, 3*$ps + $PAGE_HEADER + $PAGE_ROOT_AUTO_INC + 4, 0)
+ || die "Unable to seek $file\n";
+ die "Unable to read $file\n" unless sysread(FILE, $_, 4) == 4;
+ my $t1=unpack("N",$_);
+ close(FILE);
+ return $t1;
+}
+EOF
+
+UNLOCK TABLES;
+DROP TABLE t1, t2, t3, t4, t5, t6, t7, t8;
diff --git a/mysql-test/suite/innodb/t/foreign_key.test b/mysql-test/suite/innodb/t/foreign_key.test
index 6f7e5948b05..93c61dc7648 100644
--- a/mysql-test/suite/innodb/t/foreign_key.test
+++ b/mysql-test/suite/innodb/t/foreign_key.test
@@ -102,7 +102,41 @@ INSERT INTO t2 VALUES (1);
SELECT unique_constraint_name FROM information_schema.referential_constraints
WHERE table_name = 't2';
+--echo #
+--echo # MDEV-28317 Assertion failure on rollback of FOREIGN KEY operation
+--echo #
+
+SET foreign_key_checks=0;
+CREATE TABLE parent(a INT PRIMARY KEY) ENGINE=InnoDB;
+CREATE TABLE child(a INT,FOREIGN KEY(a) REFERENCES parent(a) ON DELETE CASCADE)
+ENGINE=InnoDB;
+INSERT INTO child VALUES(1);
+ALTER TABLE child DROP INDEX a;
+
+connect(incomplete, localhost, root,,);
+BEGIN;
+DELETE FROM child;
+
+connection default;
+INSERT INTO parent SET a=0;
+FLUSH TABLES;
+
+--let $shutdown_timeout=0
--source include/restart_mysqld.inc
+--let $shutdown_timeout=
+disconnect incomplete;
+
+INSERT INTO child SET a=0;
+--error ER_NO_REFERENCED_ROW_2
+INSERT INTO child SET a=1;
+--error ER_ROW_IS_REFERENCED_2
+DELETE FROM parent;
+ALTER TABLE child ADD INDEX(a);
+--error ER_ROW_IS_REFERENCED_2
+DELETE FROM parent;
+ALTER TABLE child FORCE;
+DELETE FROM parent;
+DROP TABLE child,parent;
SET @saved_frequency = @@GLOBAL.innodb_purge_rseg_truncate_frequency;
SET GLOBAL innodb_purge_rseg_truncate_frequency = 1;
diff --git a/mysql-test/suite/innodb/t/gap_lock_split.test b/mysql-test/suite/innodb/t/gap_lock_split.test
new file mode 100644
index 00000000000..462f073ddce
--- /dev/null
+++ b/mysql-test/suite/innodb/t/gap_lock_split.test
@@ -0,0 +1,39 @@
+--source include/have_innodb.inc
+--source include/have_sequence.inc
+--source include/have_debug.inc
+
+SET @save_frequency=@@GLOBAL.innodb_purge_rseg_truncate_frequency;
+SET GLOBAL innodb_purge_rseg_truncate_frequency=1;
+
+CREATE TABLE t1(id INT PRIMARY key, val VARCHAR(16000)) ENGINE=InnoDB;
+INSERT INTO t1 (id,val) SELECT 2*seq,'x' FROM seq_0_to_1023;
+
+connect(con1,localhost,root,,);
+# Prevent purge.
+START TRANSACTION WITH CONSISTENT SNAPSHOT;
+connection default;
+
+DELETE FROM t1 WHERE id=1788;
+
+BEGIN;
+# This will return no result, but should acquire a gap lock.
+SELECT * FROM t1 WHERE id=1788 FOR UPDATE;
+
+connection con1;
+COMMIT;
+source include/wait_all_purged.inc;
+connection default;
+
+INSERT INTO t1 (id,val) VALUES (1787, REPEAT('x',2000));
+
+connection con1;
+SET innodb_lock_wait_timeout=0;
+--error ER_LOCK_WAIT_TIMEOUT
+INSERT INTO t1 (id,val) VALUES (1788, 'x');
+SELECT * FROM t1 WHERE id=1788 FOR UPDATE;
+disconnect con1;
+
+connection default;
+COMMIT;
+DROP TABLE t1;
+SET GLOBAL innodb_purge_rseg_truncate_frequency=@save_frequency;
diff --git a/mysql-test/suite/innodb/t/innodb-autoinc-part.test b/mysql-test/suite/innodb/t/innodb-autoinc-part.test
new file mode 100644
index 00000000000..100546704ce
--- /dev/null
+++ b/mysql-test/suite/innodb/t/innodb-autoinc-part.test
@@ -0,0 +1,24 @@
+--source include/have_partition.inc
+--source include/have_innodb.inc
+
+--echo #
+--echo # MDEV-28416 Incorrect AUTO_INCREMENT may be issued
+--echo #
+
+SET @aii=@@auto_increment_increment;
+SET auto_increment_increment=300;
+
+CREATE TABLE t1 (a SERIAL) ENGINE=innodb
+PARTITION BY RANGE (a) (
+ PARTITION p0 VALUES LESS THAN (6),
+ PARTITION p1 VALUES LESS THAN MAXVALUE
+);
+INSERT INTO t1 VALUES (18446744073709551613);
+SHOW CREATE TABLE t1;
+--error HA_ERR_AUTOINC_ERANGE
+INSERT INTO t1 VALUES (NULL);
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+SET auto_increment_increment=@aii;
+
+--echo # End of 10.2 tests
diff --git a/mysql-test/suite/innodb/t/innodb-autoinc.test b/mysql-test/suite/innodb/t/innodb-autoinc.test
index ca7727d4cef..158460558d5 100644
--- a/mysql-test/suite/innodb/t/innodb-autoinc.test
+++ b/mysql-test/suite/innodb/t/innodb-autoinc.test
@@ -1,10 +1,4 @@
--source include/have_innodb.inc
-# embedded server ignores 'delayed', so skip this
--- source include/not_embedded.inc
-
---disable_warnings
-drop table if exists t1;
---enable_warnings
#
# Bug #34335
@@ -770,3 +764,20 @@ DROP TABLE t1;
SET @engine='INNODB';
--source include/autoinc_mdev15353.inc
+
+--echo #
+--echo # MDEV-28416 Incorrect AUTO_INCREMENT may be issued
+--echo #
+
+SET @aii=@@auto_increment_increment;
+SET auto_increment_increment=300;
+CREATE TABLE t1 (a SERIAL) ENGINE=innodb;
+INSERT INTO t1 VALUES (18446744073709551613);
+SHOW CREATE TABLE t1;
+--error HA_ERR_AUTOINC_ERANGE
+INSERT INTO t1 VALUES (NULL);
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+SET auto_increment_increment=@aii;
+
+--echo # End of 10.2 tests