MDEV-16703: Update AUTO_INCREMENT in the UPDATE statement

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.
This commit is contained in:
Ming Lin 2018-08-16 10:28:29 -07:00
parent c43d11b96e
commit f7154242b8
3 changed files with 19 additions and 1 deletions

View file

@ -9553,7 +9553,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();
}

View file

@ -150,3 +150,11 @@ CREATE TABLE t0(c0 BLOB) ENGINE=ROCKSDB;
INSERT INTO t0 VALUES(0);
ALTER TABLE t0 AUTO_INCREMENT=0;
DROP TABLE t0;
#---------------------------------------------------------------
# MDEV-16703 Assertion failed in load_auto_incr_value_from_index
#---------------------------------------------------------------
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;

View file

@ -116,3 +116,13 @@ CREATE TABLE t0(c0 BLOB) ENGINE=ROCKSDB;
INSERT INTO t0 VALUES(0);
ALTER TABLE t0 AUTO_INCREMENT=0;
DROP TABLE t0;
--echo #---------------------------------------------------------------
--echo # MDEV-16703 Assertion failed in load_auto_incr_value_from_index
--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;