File tree Expand file tree Collapse file tree 5 files changed +101
-9
lines changed Expand file tree Collapse file tree 5 files changed +101
-9
lines changed Original file line number Diff line number Diff line change
1
+ #
2
+ # MDEV-28416 Incorrect AUTO_INCREMENT may be issued
3
+ #
4
+ SET @aii=@@auto_increment_increment;
5
+ SET auto_increment_increment=300;
6
+ CREATE TABLE t1 (a SERIAL) ENGINE=innodb
7
+ PARTITION BY RANGE (a) (
8
+ PARTITION p0 VALUES LESS THAN (6),
9
+ PARTITION p1 VALUES LESS THAN MAXVALUE
10
+ );
11
+ INSERT INTO t1 VALUES (18446744073709551613);
12
+ SHOW CREATE TABLE t1;
13
+ Table Create Table
14
+ t1 CREATE TABLE `t1` (
15
+ `a` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
16
+ UNIQUE KEY `a` (`a`)
17
+ ) ENGINE=InnoDB AUTO_INCREMENT=18446744073709551614 DEFAULT CHARSET=latin1
18
+ PARTITION BY RANGE (`a`)
19
+ (PARTITION `p0` VALUES LESS THAN (6) ENGINE = InnoDB,
20
+ PARTITION `p1` VALUES LESS THAN MAXVALUE ENGINE = InnoDB)
21
+ INSERT INTO t1 VALUES (NULL);
22
+ ERROR 22003: Out of range value for column 'a' at row 1
23
+ SHOW CREATE TABLE t1;
24
+ Table Create Table
25
+ t1 CREATE TABLE `t1` (
26
+ `a` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
27
+ UNIQUE KEY `a` (`a`)
28
+ ) ENGINE=InnoDB AUTO_INCREMENT=298 DEFAULT CHARSET=latin1
29
+ PARTITION BY RANGE (`a`)
30
+ (PARTITION `p0` VALUES LESS THAN (6) ENGINE = InnoDB,
31
+ PARTITION `p1` VALUES LESS THAN MAXVALUE ENGINE = InnoDB)
32
+ DROP TABLE t1;
33
+ SET auto_increment_increment=@aii;
34
+ # End of 10.2 tests
Original file line number Diff line number Diff line change 1
- drop table if exists t1;
2
1
CREATE TABLE t1 (c1 BIGINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
3
2
INSERT INTO t1 VALUES (9223372036854775807, null);
4
3
INSERT INTO t1 (c2) VALUES ('innodb');
@@ -1619,3 +1618,27 @@ id name
1619
1618
-1 dog
1620
1619
2 cat
1621
1620
DROP PROCEDURE autoinc_mdev15353_one;
1621
+ #
1622
+ # MDEV-28416 Incorrect AUTO_INCREMENT may be issued
1623
+ #
1624
+ SET @aii=@@auto_increment_increment;
1625
+ SET auto_increment_increment=300;
1626
+ CREATE TABLE t1 (a SERIAL) ENGINE=innodb;
1627
+ INSERT INTO t1 VALUES (18446744073709551613);
1628
+ SHOW CREATE TABLE t1;
1629
+ Table Create Table
1630
+ t1 CREATE TABLE `t1` (
1631
+ `a` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
1632
+ UNIQUE KEY `a` (`a`)
1633
+ ) ENGINE=InnoDB AUTO_INCREMENT=18446744073709551614 DEFAULT CHARSET=latin1
1634
+ INSERT INTO t1 VALUES (NULL);
1635
+ ERROR 22003: Out of range value for column 'a' at row 1
1636
+ SHOW CREATE TABLE t1;
1637
+ Table Create Table
1638
+ t1 CREATE TABLE `t1` (
1639
+ `a` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
1640
+ UNIQUE KEY `a` (`a`)
1641
+ ) ENGINE=InnoDB AUTO_INCREMENT=18446744073709551615 DEFAULT CHARSET=latin1
1642
+ DROP TABLE t1;
1643
+ SET auto_increment_increment=@aii;
1644
+ # End of 10.2 tests
Original file line number Diff line number Diff line change
1
+ --source include/have_partition.inc
2
+ --source include/have_innodb.inc
3
+
4
+ --echo #
5
+ --echo # MDEV-28416 Incorrect AUTO_INCREMENT may be issued
6
+ --echo #
7
+
8
+ SET @aii=@@auto_increment_increment;
9
+ SET auto_increment_increment=300;
10
+
11
+ CREATE TABLE t1 (a SERIAL) ENGINE=innodb
12
+ PARTITION BY RANGE (a) (
13
+ PARTITION p0 VALUES LESS THAN (6),
14
+ PARTITION p1 VALUES LESS THAN MAXVALUE
15
+ );
16
+ INSERT INTO t1 VALUES (18446744073709551613);
17
+ SHOW CREATE TABLE t1;
18
+ --error HA_ERR_AUTOINC_ERANGE
19
+ INSERT INTO t1 VALUES (NULL);
20
+ SHOW CREATE TABLE t1;
21
+ DROP TABLE t1;
22
+ SET auto_increment_increment=@aii;
23
+
24
+ --echo # End of 10.2 tests
Original file line number Diff line number Diff line change 1
1
--source include/have_innodb.inc
2
- # embedded server ignores 'delayed', so skip this
3
- -- source include/not_embedded.inc
4
-
5
- --disable_warnings
6
- drop table if exists t1;
7
- --enable_warnings
8
2
9
3
#
10
4
# Bug #34335
@@ -770,3 +764,20 @@ DROP TABLE t1;
770
764
771
765
SET @engine='INNODB';
772
766
--source include/autoinc_mdev15353.inc
767
+
768
+ --echo #
769
+ --echo # MDEV-28416 Incorrect AUTO_INCREMENT may be issued
770
+ --echo #
771
+
772
+ SET @aii=@@auto_increment_increment;
773
+ SET auto_increment_increment=300;
774
+ CREATE TABLE t1 (a SERIAL) ENGINE=innodb;
775
+ INSERT INTO t1 VALUES (18446744073709551613);
776
+ SHOW CREATE TABLE t1;
777
+ --error HA_ERR_AUTOINC_ERANGE
778
+ INSERT INTO t1 VALUES (NULL);
779
+ SHOW CREATE TABLE t1;
780
+ DROP TABLE t1;
781
+ SET auto_increment_increment=@aii;
782
+
783
+ --echo # End of 10.2 tests
Original file line number Diff line number Diff line change @@ -16970,8 +16970,8 @@ ha_innobase::get_auto_increment(
16970
16970
16971
16971
(3) It is restricted only for insert operations. */
16972
16972
16973
- if (increment > 1 && thd_sql_command(m_user_thd) != SQLCOM_ALTER_TABLE
16974
- && autoinc < col_max_value ) {
16973
+ if (increment > 1 && increment <= ~autoinc && autoinc < col_max_value
16974
+ && thd_sql_command(m_user_thd) != SQLCOM_ALTER_TABLE ) {
16975
16975
16976
16976
ulonglong prev_auto_inc = autoinc;
16977
16977
You can’t perform that action at this time.
0 commit comments