[Commits] Rev 4877: Explicit insert into an auto-inc column is not noticed by RocksDB in file:///home/psergey/chroot/saucy-x64/home/psergey/dev2/mysql-5.6-rocksdb-r2/

Sergey Petrunya psergey at askmonty.org
Fri Jul 11 19:48:21 EEST 2014


At file:///home/psergey/chroot/saucy-x64/home/psergey/dev2/mysql-5.6-rocksdb-r2/

------------------------------------------------------------
revno: 4877
revision-id: psergey at askmonty.org-20140711164820-pdiifzs3u4kw94p0
parent: psergey at askmonty.org-20140711162114-051drr4tocqpbx30
committer: Sergey Petrunya <psergey at askmonty.org>
branch nick: mysql-5.6-rocksdb-r2
timestamp: Fri 2014-07-11 20:48:20 +0400
message:
  Explicit insert into an auto-inc column is not noticed by RocksDB
  - Basic fix: don't forget to update the table-wide auto-increment value.
=== modified file 'mysql-test/r/rocksdb.result'
--- a/mysql-test/r/rocksdb.result	2014-07-11 16:21:14 +0000
+++ b/mysql-test/r/rocksdb.result	2014-07-11 16:48:20 +0000
@@ -688,6 +688,7 @@ DROP TABLE t33;
 #
 #  Unique indexes can be created, but uniqueness won't be enforced
 create table t33 (pk int primary key, u int, unique index(u)) engine=RocksDB;
+drop table t33;
 #
 # MDEV-4077: RocksDB: Wrong result (duplicate row) on select with range 
 #
@@ -1169,3 +1170,34 @@ set rocksdb_max_row_locks= 20;
 update t1 set a=a+10;
 ERROR HY000: Got error 189 'Number of locks held reached @@rocksdb_max_row_locks' from ROCKSDB
 DROP TABLE t1;
+# 
+# Test AUTO_INCREMENT behavior problem,
+#  "explicit insert into an auto-inc column is not noticed by RocksDB"
+# 
+create table t1 (i int primary key auto_increment) engine=RocksDB;
+insert into t1 values (null);
+insert into t1 values (null);
+select * from t1;
+i
+1
+2
+drop table t1;
+create table t2 (i int primary key auto_increment) engine=RocksDB;
+insert into t2 values (1);
+select * from t2;
+i
+1
+# this fails (ie. used to fail), RocksDB engine did not notice use of '1' above
+insert into t2 values (null);
+select * from t2;
+i
+1
+2
+# but then this succeeds, so previous statement must have incremented next number counter
+insert into t2 values (null);
+select * from t2;
+i
+1
+2
+3
+drop table t2;

=== modified file 'mysql-test/t/rocksdb.test'
--- a/mysql-test/t/rocksdb.test	2014-07-11 16:21:14 +0000
+++ b/mysql-test/t/rocksdb.test	2014-07-11 16:48:20 +0000
@@ -613,7 +613,7 @@ DROP TABLE t33;
 #--error ER_GET_ERRMSG
 --echo #  Unique indexes can be created, but uniqueness won't be enforced
 create table t33 (pk int primary key, u int, unique index(u)) engine=RocksDB;
-
+drop table t33;
 
 --echo #
 --echo # MDEV-4077: RocksDB: Wrong result (duplicate row) on select with range 
@@ -1052,3 +1052,29 @@ set rocksdb_max_row_locks= 20;
 update t1 set a=a+10;
 DROP TABLE t1;
 
+
+--echo # 
+--echo # Test AUTO_INCREMENT behavior problem,
+--echo #  "explicit insert into an auto-inc column is not noticed by RocksDB"
+--echo # 
+create table t1 (i int primary key auto_increment) engine=RocksDB;
+
+insert into t1 values (null);
+insert into t1 values (null);
+select * from t1;
+drop table t1;
+
+create table t2 (i int primary key auto_increment) engine=RocksDB;
+
+insert into t2 values (1);
+select * from t2;
+
+--echo # this fails (ie. used to fail), RocksDB engine did not notice use of '1' above
+insert into t2 values (null);
+select * from t2;
+
+--echo # but then this succeeds, so previous statement must have incremented next number counter
+insert into t2 values (null);
+select * from t2;
+drop table t2;
+

=== modified file 'storage/rocksdb/ha_rocksdb.cc'
--- a/storage/rocksdb/ha_rocksdb.cc	2014-07-11 16:21:14 +0000
+++ b/storage/rocksdb/ha_rocksdb.cc	2014-07-11 16:48:20 +0000
@@ -1693,7 +1693,7 @@ int ha_rocksdb::write_row(uchar *buf)
   DBUG_ASSERT(lock_rows);
   
   /* Update AUTO_INCREMENT column */
-  bool using_auto_incr_value= false;
+  //bool using_auto_incr_value= false;
 
   /*
     Note: "buf == table->record[0]" is copied from innodb. I am not aware of 
@@ -1706,7 +1706,7 @@ int ha_rocksdb::write_row(uchar *buf)
     {
       DBUG_RETURN(err);
     }
-    using_auto_incr_value= true;
+    //using_auto_incr_value= true;
   }
 
   /* Get a packed primary key value */
@@ -1775,7 +1775,7 @@ int ha_rocksdb::write_row(uchar *buf)
   }
  
   /* Write primary_key -> record */
-  if (!using_auto_incr_value && table->next_number_field)
+  if (/*!using_auto_incr_value &&*/ table->next_number_field)
     update_auto_incr_val();
 
   rocksdb::Slice value_slice;



More information about the commits mailing list