mirror of
				https://github.com/MariaDB/server.git
				synced 2025-10-31 15:50:51 +03:00 
			
		
		
		
	Problem: ======= Autoincrement value gives duplicate values because of the following reasons. (1) In InnoDB handler function, current autoincrement value is not changed based on newly set auto_increment_increment or auto_increment_offset variable. (2) Handler function does the rounding logic and changes the current autoincrement value and InnoDB doesn't aware of the change in current autoincrement value. Solution: ======== Fix the problem(1), InnoDB always respect the auto_increment_increment and auto_increment_offset value in case of current autoincrement value. By fixing the problem (2), handler layer won't change any current autoincrement value. Reviewed-by: Jimmy Yang <jimmy.yang@oracle.com> RB: 13748
		
			
				
	
	
		
			101 lines
		
	
	
		
			2.7 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			101 lines
		
	
	
		
			2.7 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
| CREATE TABLE t1 (id INT AUTO_INCREMENT PRIMARY KEY)ENGINE=INNODB;
 | |
| # SETTING auto_increment_increment IN CONNECTION DEFAULT
 | |
| SET AUTO_INCREMENT_INCREMENT = 1;
 | |
| INSERT INTO t1 VALUES(NULL);
 | |
| SELECT * FROM t1;
 | |
| id
 | |
| 1
 | |
| SHOW CREATE TABLE t1;
 | |
| Table	Create Table
 | |
| t1	CREATE TABLE `t1` (
 | |
|   `id` int(11) NOT NULL AUTO_INCREMENT,
 | |
|   PRIMARY KEY (`id`)
 | |
| ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1
 | |
| # SETTING auto_increment_increment IN CONNECTION1
 | |
| SET AUTO_INCREMENT_INCREMENT = 2;
 | |
| SET DEBUG_SYNC= 'ib_after_row_insert SIGNAL opened WAIT_FOR flushed1';
 | |
| INSERT INTO t1 VALUES(NULL);
 | |
| connect con1, localhost, root,,;
 | |
| SET AUTO_INCREMENT_INCREMENT = 2;
 | |
| SET DEBUG_SYNC= 'now WAIT_FOR opened';
 | |
| SET DEBUG_SYNC= 'ib_after_row_insert_step SIGNAL flushed1 WAIT_FOR opened1';
 | |
| insert into t1 values(NULL);
 | |
| connection default;
 | |
| SELECT * FROM t1;
 | |
| id
 | |
| 1
 | |
| 3
 | |
| SHOW CREATE TABLE t1;
 | |
| Table	Create Table
 | |
| t1	CREATE TABLE `t1` (
 | |
|   `id` int(11) NOT NULL AUTO_INCREMENT,
 | |
|   PRIMARY KEY (`id`)
 | |
| ) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=latin1
 | |
| SET DEBUG_SYNC= 'now SIGNAL opened1';
 | |
| connection con1;
 | |
| SELECT * FROM t1;
 | |
| id
 | |
| 1
 | |
| 3
 | |
| 5
 | |
| SHOW CREATE TABLE t1;
 | |
| Table	Create Table
 | |
| t1	CREATE TABLE `t1` (
 | |
|   `id` int(11) NOT NULL AUTO_INCREMENT,
 | |
|   PRIMARY KEY (`id`)
 | |
| ) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=latin1
 | |
| connection default;
 | |
| disconnect con1;
 | |
| DROP TABLE t1;
 | |
| CREATE TABLE t1(id INT AUTO_INCREMENT PRIMARY KEY)ENGINE=INNODB;
 | |
| # SETTING auto_increment_increment IN CONNECTION DEFAULT
 | |
| SET AUTO_INCREMENT_INCREMENT = 1;
 | |
| INSERT INTO t1 VALUES(NULL);
 | |
| SELECT * FROM t1;
 | |
| id
 | |
| 1
 | |
| SHOW CREATE TABLE t1;
 | |
| Table	Create Table
 | |
| t1	CREATE TABLE `t1` (
 | |
|   `id` int(11) NOT NULL AUTO_INCREMENT,
 | |
|   PRIMARY KEY (`id`)
 | |
| ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1
 | |
| SET DEBUG_SYNC = 'now SIGNAL flushed';
 | |
| connect con1, localhost, root,,;
 | |
| # SETTING auto_increment_increment in connection1
 | |
| SET AUTO_INCREMENT_INCREMENT = 2;
 | |
| SET DEBUG_SYNC= 'now WAIT_FOR flushed';
 | |
| SET DEBUG_SYNC= 'ib_after_row_insert SIGNAL opened WAIT_FOR flushed1';
 | |
| INSERT INTO t1 values(NULL);
 | |
| connection default;
 | |
| SET DEBUG_SYNC= 'now WAIT_FOR opened';
 | |
| SET DEBUG_SYNC= 'ib_after_row_insert_step SIGNAL flushed1 WAIT_FOR opened1';
 | |
| INSERT INTO t1 VALUES(NULL);
 | |
| connection con1;
 | |
| SELECT * FROM t1;
 | |
| id
 | |
| 1
 | |
| 3
 | |
| SHOW CREATE TABLE t1;
 | |
| Table	Create Table
 | |
| t1	CREATE TABLE `t1` (
 | |
|   `id` int(11) NOT NULL AUTO_INCREMENT,
 | |
|   PRIMARY KEY (`id`)
 | |
| ) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=latin1
 | |
| SET DEBUG_SYNC= 'now SIGNAL opened1';
 | |
| disconnect con1;
 | |
| connection default;
 | |
| SELECT * FROM t1;
 | |
| id
 | |
| 1
 | |
| 3
 | |
| 5
 | |
| SHOW CREATE TABLE t1;
 | |
| Table	Create Table
 | |
| t1	CREATE TABLE `t1` (
 | |
|   `id` int(11) NOT NULL AUTO_INCREMENT,
 | |
|   PRIMARY KEY (`id`)
 | |
| ) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=latin1
 | |
| DROP TABLE t1;
 | |
| SET DEBUG_SYNC='RESET';
 |