mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Bug#50392: insert_id is not reset for partitioned tables
auto_increment on duplicate entry The bug was that when INSERT_ID was used and the storage engine was told to release any reserved but not used auto_increment values, it set the highest auto_increment value to INSERT_ID. The fix was to check if the auto_increment value was forced by user (INSERT_ID) or by slave-thread, i.e. not auto- generated. So that it is only allowed to release generated values. mysql-test/r/partition_error.result: Bug#50392: insert_id is not reset for partitioned tables auto_increment on duplicate entry updated result mysql-test/suite/parts/inc/partition_auto_increment.inc: Bug#50392: insert_id is not reset for partitioned tables auto_increment on duplicate entry Added test mysql-test/suite/parts/r/partition_auto_increment_archive.result: Bug#50392: insert_id is not reset for partitioned tables auto_increment on duplicate entry Added result, note that archive does only allow increasing auto_increment values mysql-test/suite/parts/r/partition_auto_increment_blackhole.result: Bug#50392: insert_id is not reset for partitioned tables auto_increment on duplicate entry Added result, note that blackhole accepts all inserts :) mysql-test/suite/parts/r/partition_auto_increment_innodb.result: Bug#50392: insert_id is not reset for partitioned tables auto_increment on duplicate entry Added result, note that innodb rolls back inserts on error, but keeps the auto_increment value. mysql-test/suite/parts/r/partition_auto_increment_memory.result: Bug#50392: insert_id is not reset for partitioned tables auto_increment on duplicate entry Added result, note that memory and myisam inserts all rows before the error. mysql-test/suite/parts/r/partition_auto_increment_myisam.result: Bug#50392: insert_id is not reset for partitioned tables auto_increment on duplicate entry Added result, note that memory and myisam inserts all rows before the error. mysql-test/suite/parts/r/partition_auto_increment_ndb.result: Bug#50392: insert_id is not reset for partitioned tables auto_increment on duplicate entry Added result, note that NDB does not seem to handle INSERT_ID as other engines. (Martin will look into it). mysql-test/t/partition_error.test: Bug#50392: insert_id is not reset for partitioned tables auto_increment on duplicate entry Added test sql/ha_partition.cc: Bug#50392: insert_id is not reset for partitioned tables auto_increment on duplicate entry If the next_insert_id comes from non generated (i.e forced by INSERT_ID or slave-thread) then we cannot lower the reserved auto_increment value, since it have not reserved any values.
This commit is contained in:
@ -1,4 +1,46 @@
|
||||
drop table if exists t1;
|
||||
#
|
||||
# Bug#50392: insert_id is not reset for partitioned tables
|
||||
# auto_increment on duplicate entry
|
||||
CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY);
|
||||
SET INSERT_ID= 13;
|
||||
INSERT INTO t1 VALUES (NULL);
|
||||
SET INSERT_ID= 12;
|
||||
INSERT INTO t1 VALUES (NULL), (NULL), (NULL);
|
||||
ERROR 23000: Duplicate entry '13' for key 'PRIMARY'
|
||||
SHOW CREATE TABLE t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) NOT NULL AUTO_INCREMENT,
|
||||
PRIMARY KEY (`a`)
|
||||
) ENGINE=MyISAM AUTO_INCREMENT=14 DEFAULT CHARSET=latin1
|
||||
INSERT INTO t1 VALUES (NULL);
|
||||
SELECT * FROM t1;
|
||||
a
|
||||
12
|
||||
13
|
||||
14
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY) PARTITION BY KEY(a);
|
||||
SET INSERT_ID= 13;
|
||||
INSERT INTO t1 VALUES (NULL);
|
||||
SET INSERT_ID= 12;
|
||||
INSERT INTO t1 VALUES (NULL), (NULL), (NULL);
|
||||
ERROR 23000: Duplicate entry '13' for key 'PRIMARY'
|
||||
SHOW CREATE TABLE t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) NOT NULL AUTO_INCREMENT,
|
||||
PRIMARY KEY (`a`)
|
||||
) ENGINE=MyISAM AUTO_INCREMENT=14 DEFAULT CHARSET=latin1
|
||||
/*!50100 PARTITION BY KEY (a) */
|
||||
INSERT INTO t1 VALUES (NULL);
|
||||
SELECT * FROM t1;
|
||||
a
|
||||
12
|
||||
13
|
||||
14
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (a INTEGER NOT NULL, PRIMARY KEY (a));
|
||||
INSERT INTO t1 VALUES (1),(1);
|
||||
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
|
||||
|
Reference in New Issue
Block a user