mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
MDEV-6076: Preserve PAGE_ROOT_AUTO_INC when emptying pages.
Thanks to Zhangyuan from Alibaba for pointing out this bug. btr_page_empty(): When a clustered index root page is emptied, preserve PAGE_ROOT_AUTO_INC. This would occur during a page split. page_create_empty(): Preserve PAGE_ROOT_AUTO_INC when a clustered index root page becomes empty. Use a faster method for writing the field. page_zip_copy_recs(): Reset PAGE_MAX_TRX_ID when copying clustered index pages. We must clear the field when the root page was a leaf page and it is being split, so that PAGE_MAX_TRX_ID will continue to be 0 in clustered index non-root pages. page_create_zip(): Add debug assertions for validating PAGE_MAX_TRX_ID and PAGE_ROOT_AUTO_INC.
This commit is contained in:
@@ -629,6 +629,16 @@ ERROR 0A000: LOCK=NONE is not supported. Reason: Adding an auto-increment column
|
||||
ALTER TABLE mdev6076a ADD COLUMN a SERIAL FIRST, ALGORITHM=INPLACE;
|
||||
ALTER TABLE mdev6076b ADD COLUMN a SERIAL FIRST, AUTO_INCREMENT=100,
|
||||
ALGORITHM=INPLACE;
|
||||
# MDEV-6076: Test root page split and page_create_empty()
|
||||
CREATE TABLE mdev6076empty (b SERIAL, pad CHAR(255) NOT NULL DEFAULT '')
|
||||
ENGINE=InnoDB;
|
||||
BEGIN;
|
||||
# Insert records in descending order of AUTO_INCREMENT,
|
||||
# causing a page split on the very last insert.
|
||||
# Without the fix in btr_page_empty() this would lose the counter value.
|
||||
# Without the fix in page_create_empty() the counter value would be lost
|
||||
# when ROLLBACK deletes the last row.
|
||||
ROLLBACK;
|
||||
# Kill and restart
|
||||
INSERT INTO t3 VALUES(0);
|
||||
SELECT MAX(a) AS `Expect 120` FROM t3;
|
||||
@@ -646,7 +656,11 @@ a b
|
||||
100 2
|
||||
101 1
|
||||
102 NULL
|
||||
DROP TABLE mdev6076a, mdev6076b;
|
||||
INSERT INTO mdev6076empty SET b=NULL;
|
||||
SELECT * FROM mdev6076empty;
|
||||
b pad
|
||||
56
|
||||
DROP TABLE mdev6076a, mdev6076b, mdev6076empty;
|
||||
INSERT INTO t3 VALUES(0), (0), (200), (210);
|
||||
# Test the different algorithms in ALTER TABLE
|
||||
CREATE TABLE t_inplace LIKE t3;
|
||||
|
Reference in New Issue
Block a user