diff --git a/mysql-test/suite/rocksdb/r/autoinc_vars.result b/mysql-test/suite/rocksdb/r/autoinc_vars.result index 3dc61ab400b4..3955406a9ad1 100644 --- a/mysql-test/suite/rocksdb/r/autoinc_vars.result +++ b/mysql-test/suite/rocksdb/r/autoinc_vars.result @@ -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; diff --git a/mysql-test/suite/rocksdb/t/autoinc_vars.test b/mysql-test/suite/rocksdb/t/autoinc_vars.test index 8a030ff1dbea..1b48501c542a 100644 --- a/mysql-test/suite/rocksdb/t/autoinc_vars.test +++ b/mysql-test/suite/rocksdb/t/autoinc_vars.test @@ -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; diff --git a/storage/rocksdb/ha_rocksdb.cc b/storage/rocksdb/ha_rocksdb.cc index b79d156d0029..94e01d53f591 100644 --- a/storage/rocksdb/ha_rocksdb.cc +++ b/storage/rocksdb/ha_rocksdb.cc @@ -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(); }