mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Bug#28573894 ALTER PARTITIONED TABLE ADD AUTO_INCREMENT DIFF RESULT DEPENDING ON ALGORITHM
For partitioned table, ensure that the AUTO_INCREMENT values will be assigned from the same sequence. This is based on the following change in MySQL 5.6.44: commit aaba359c13d9200747a609730dafafc3b63cd4d6 Author: Rahul Malik <rahul.m.malik@oracle.com> Date: Mon Feb 4 13:31:41 2019 +0530 Bug#28573894 ALTER PARTITIONED TABLE ADD AUTO_INCREMENT DIFF RESULT DEPENDING ON ALGORITHM Problem: When a partition table is in-place altered to add an auto-increment column, then its values are starting over for each partition. Analysis: In the case of in-place alter, InnoDB is creating a new sequence object for each partition. It is default initialized. So auto-increment columns start over for each partition. Fix: Assign old sequence of the partition to the sequence of next partition so it won't start over. RB#21148 Reviewed by Bin Su <bin.x.su@oracle.com>
This commit is contained in:
@ -918,3 +918,45 @@ ERROR HY000: CHECK OPTION failed 'test.v'
|
||||
SET GLOBAL innodb_stats_persistent= @save_isp;
|
||||
DROP view v;
|
||||
DROP TABLE t;
|
||||
#
|
||||
# Bug#28573894 ALTER PARTITIONED TABLE ADD AUTO_INCREMENT DIFF RESULT
|
||||
#
|
||||
CREATE TABLE t (a VARCHAR(10) NOT NULL,b INT,PRIMARY KEY (b)) ENGINE=INNODB
|
||||
PARTITION BY RANGE (b)
|
||||
(PARTITION pa VALUES LESS THAN (2),
|
||||
PARTITION pb VALUES LESS THAN (20),
|
||||
PARTITION pc VALUES LESS THAN (30),
|
||||
PARTITION pd VALUES LESS THAN (40));
|
||||
INSERT INTO t
|
||||
VALUES('A',0),('B',1),('C',2),('D',3),('E',4),('F',5),('G',25),('H',35);
|
||||
CREATE TABLE t_copy LIKE t;
|
||||
INSERT INTO t_copy SELECT * FROM t;
|
||||
ALTER TABLE t ADD COLUMN r INT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
ADD UNIQUE KEY (r,b);
|
||||
affected rows: 0
|
||||
info: Records: 0 Duplicates: 0 Warnings: 0
|
||||
ALTER TABLE t_copy ADD COLUMN r INT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
ADD UNIQUE KEY (r,b), ALGORITHM=COPY;
|
||||
affected rows: 8
|
||||
info: Records: 8 Duplicates: 0 Warnings: 0
|
||||
SELECT * FROM t;
|
||||
a b r
|
||||
A 0 1
|
||||
B 1 2
|
||||
C 2 3
|
||||
D 3 4
|
||||
E 4 5
|
||||
F 5 6
|
||||
G 25 7
|
||||
H 35 8
|
||||
SELECT * FROM t_copy;
|
||||
a b r
|
||||
A 0 1
|
||||
B 1 2
|
||||
C 2 3
|
||||
D 3 4
|
||||
E 4 5
|
||||
F 5 6
|
||||
G 25 7
|
||||
H 35 8
|
||||
DROP TABLE t,t_copy;
|
||||
|
Reference in New Issue
Block a user