Skip to content

Commit

Permalink
MDEV-30796 Auto_increment values not updated after bulk insert operation
Browse files Browse the repository at this point in the history
- InnoDB fails to update the autoinc persistently after
bulk insert operation.

row_merge_bulk_t::write_to_index(): Update the autoinc value
persistently
  • Loading branch information
Thirunarayanan committed Jul 26, 2023
1 parent 864bbd4 commit 4700f2a
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
14 changes: 14 additions & 0 deletions mysql-test/suite/innodb/r/insert_into_empty_notembedded.result
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,17 @@ DROP DATABASE db1;
#
# End of 10.6 tests
#
#
# MDEV-30796 Auto_increment values not updated after bulk
# insert operation
#
CREATE TABLE t1(f1 INT NOT NULL AUTO_INCREMENT,
f2 INT NOT NULL, PRIMARY KEY(f1))ENGINE=InnoDB;
INSERT INTO t1 VALUES(1, 2), (25, 3), (2, 4);
# restart
INSERT INTO t1(f2) VALUES(5);
SELECT max(f1) FROM t1;
max(f1)
26
DROP TABLE t1;
# End of 10.9 tests
14 changes: 14 additions & 0 deletions mysql-test/suite/innodb/t/insert_into_empty_notembedded.test
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,17 @@ DROP DATABASE db1;
--echo #
--echo # End of 10.6 tests
--echo #

--echo #
--echo # MDEV-30796 Auto_increment values not updated after bulk
--echo # insert operation
--echo #
CREATE TABLE t1(f1 INT NOT NULL AUTO_INCREMENT,
f2 INT NOT NULL, PRIMARY KEY(f1))ENGINE=InnoDB;
INSERT INTO t1 VALUES(1, 2), (25, 3), (2, 4);
--source include/restart_mysqld.inc
INSERT INTO t1(f2) VALUES(5);
SELECT max(f1) FROM t1;
DROP TABLE t1;

--echo # End of 10.9 tests
2 changes: 2 additions & 0 deletions storage/innobase/row/row0merge.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5336,6 +5336,8 @@ dberr_t row_merge_bulk_t::write_to_index(ulint index_no, trx_t *trx)
func_exit:
if (err != DB_SUCCESS)
trx->error_info= index;
else if (index->is_primary() && table->persistent_autoinc)
btr_write_autoinc(index, table->autoinc);
err= btr_bulk.finish(err);
return err;
}
Expand Down

0 comments on commit 4700f2a

Please sign in to comment.