mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Bug #14049391 INNODB MISCALCULATES AUTO-INCREMENT AFTER DECREASING
AUTO_INCREMENT_INCREMENT Problem: ======= When auto_increment_increment system variable decreases, immediate next value of auto increment column is not affected. Solution: ======== Get the previous inserted value of auto increment column by subtracting the previous auto_increment_increment from next auto increment value. After that calculate the current autoinc value using newly changed auto_increment_increment variable. Approved by Sunny [rb#4394]
This commit is contained in:
@ -1357,3 +1357,30 @@ t1 CREATE TABLE `t1` (
|
||||
INSERT INTO t1 VALUES ();
|
||||
ERROR HY000: Failed to read auto-increment value from storage engine
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# Bug #14049391 INNODB MISCALCULATES AUTO-INCREMENT
|
||||
# AFTER CHANGING AUTO_INCREMENT_INCREMEMENT
|
||||
#
|
||||
CREATE TABLE t ( i INT AUTO_INCREMENT, KEY(i) ) ENGINE=InnoDB;
|
||||
SET auto_increment_increment = 300;
|
||||
INSERT INTO t VALUES (NULL), (NULL);
|
||||
SHOW CREATE TABLE t;
|
||||
Table Create Table
|
||||
t CREATE TABLE `t` (
|
||||
`i` int(11) NOT NULL AUTO_INCREMENT,
|
||||
KEY `i` (`i`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=601 DEFAULT CHARSET=latin1
|
||||
SET auto_increment_increment = 50;
|
||||
INSERT INTO t VALUES (NULL);
|
||||
SELECT * FROM t;
|
||||
i
|
||||
1
|
||||
301
|
||||
351
|
||||
SHOW CREATE TABLE t;
|
||||
Table Create Table
|
||||
t CREATE TABLE `t` (
|
||||
`i` int(11) NOT NULL AUTO_INCREMENT,
|
||||
KEY `i` (`i`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=401 DEFAULT CHARSET=latin1
|
||||
DROP TABLE t;
|
||||
|
@ -685,3 +685,17 @@ SHOW CREATE TABLE t1;
|
||||
--error 1467
|
||||
INSERT INTO t1 VALUES ();
|
||||
DROP TABLE t1;
|
||||
|
||||
--echo #
|
||||
--echo # Bug #14049391 INNODB MISCALCULATES AUTO-INCREMENT
|
||||
--echo # AFTER CHANGING AUTO_INCREMENT_INCREMEMENT
|
||||
--echo #
|
||||
CREATE TABLE t ( i INT AUTO_INCREMENT, KEY(i) ) ENGINE=InnoDB;
|
||||
SET auto_increment_increment = 300;
|
||||
INSERT INTO t VALUES (NULL), (NULL);
|
||||
SHOW CREATE TABLE t;
|
||||
SET auto_increment_increment = 50;
|
||||
INSERT INTO t VALUES (NULL);
|
||||
SELECT * FROM t;
|
||||
SHOW CREATE TABLE t;
|
||||
DROP TABLE t;
|
||||
|
Reference in New Issue
Block a user