Skip to content

Commit

Permalink
Update AUTO_INCREMENT in the UPDATE statement (percona#868)
Browse files Browse the repository at this point in the history
Upstream commit ID : fb-mysql-5.6.35/f8ea6852be5484ed15ffbac844b3719673f0f057
PS-5217 : Merge fb-prod201803

Summary:
Currently RocksDB engine doesn't update AUTO_INCREMENT in the UPDATE statement.
For example,

CREATE TABLE t1 (pk INT AUTO_INCREMENT, a INT, PRIMARY KEY(pk)) ENGINE=RocksDB;
INSERT INTO t1 (a) VALUES (1);
UPDATE t1 SET pk = 3; ==> AUTO_INCREMENT should be updated to 4.

Without this fix, it hits the Assertion `dd_val >= last_val' failed in
myrocks::ha_rocksdb::load_auto_incr_value_from_index.

Please see detail at:
https://jira.mariadb.org/browse/MDEV-16703
Pull Request resolved: facebook/mysql-5.6#868

Differential Revision: D9360242

Pulled By: lth

fbshipit-source-id: 70ee31cb90f
  • Loading branch information
minggr authored and oleksandr-kachan committed Apr 16, 2024
1 parent 5b9809e commit f44ee4b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
8 changes: 8 additions & 0 deletions mysql-test/suite/rocksdb/r/autoinc_vars.result
Original file line number Diff line number Diff line change
Expand Up @@ -155,3 +155,11 @@ CREATE TABLE t0(c0 BLOB) ENGINE=ROCKSDB;
INSERT INTO t0 VALUES(0);
ALTER TABLE t0 AUTO_INCREMENT=0;
DROP TABLE t0;
#----------------------------------
# Issue #869 Crash in autoincrement
#----------------------------------
CREATE TABLE t1 (pk INT AUTO_INCREMENT, a INT, PRIMARY KEY(pk)) ENGINE=RocksDB;
INSERT INTO t1 (a) VALUES (1);
UPDATE t1 SET pk = 3;
ALTER TABLE t1 AUTO_INCREMENT 2;
DROP TABLE t1;
10 changes: 10 additions & 0 deletions mysql-test/suite/rocksdb/t/autoinc_vars.test
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,13 @@ CREATE TABLE t0(c0 BLOB) ENGINE=ROCKSDB;
INSERT INTO t0 VALUES(0);
ALTER TABLE t0 AUTO_INCREMENT=0;
DROP TABLE t0;

--echo #----------------------------------
--echo # Issue #869 Crash in autoincrement
--echo #----------------------------------

CREATE TABLE t1 (pk INT AUTO_INCREMENT, a INT, PRIMARY KEY(pk)) ENGINE=RocksDB;
INSERT INTO t1 (a) VALUES (1);
UPDATE t1 SET pk = 3;
ALTER TABLE t1 AUTO_INCREMENT 2;
DROP TABLE t1;
2 changes: 1 addition & 1 deletion storage/rocksdb/ha_rocksdb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8929,7 +8929,7 @@ int ha_rocksdb::update_pk(const Rdb_key_def &kd,
}
}

if (table->next_number_field) {
if (table->found_next_number_field) {
update_auto_incr_val_from_field();
}

Expand Down

0 comments on commit f44ee4b

Please sign in to comment.