summaryrefslogtreecommitdiff
path: root/storage/innobase
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2015-12-05 11:29:00 +0100
committerSergei Golubchik <serg@mariadb.org>2015-12-07 15:20:23 +0100
commitef47b62551b0f37770e5d174ea028150c5b71fd8 (patch)
tree234bc3f7cc47902c791a576a0b040b141ec01ad5 /storage/innobase
parentc8652eefe50fd1894f2e2360e8bd631a7b9c67f5 (diff)
downloadmariadb-git-ef47b62551b0f37770e5d174ea028150c5b71fd8.tar.gz
MDEV-8827 Duplicate key with auto increment
fix innodb auto-increment handling three bugs: 1. innobase_next_autoinc treated the case of current<offset incorrectly 2. ha_innobase::get_auto_increment didn't recalculate current when increment changed 3. ha_innobase::get_auto_increment didn't pass offset down to innobase_next_autoinc
Diffstat (limited to 'storage/innobase')
-rw-r--r--storage/innobase/handler/ha_innodb.cc12
1 files changed, 5 insertions, 7 deletions
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index 17cf15e6b84..95216d30aae 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -1504,10 +1504,11 @@ innobase_next_autoinc(
if (next_value == 0) {
ulonglong next;
- if (current > offset) {
+ if (current >= offset) {
next = (current - offset) / step;
} else {
- next = (offset - current) / step;
+ next = 0;
+ block -= step;
}
ut_a(max_value > next);
@@ -10445,15 +10446,12 @@ ha_innobase::get_auto_increment(
current = *first_value;
- /* If the increment step of the auto increment column
- decreases then it is not affecting the immediate
- next value in the series. */
- if (prebuilt->autoinc_increment > increment) {
+ if (prebuilt->autoinc_increment != increment) {
current = autoinc - prebuilt->autoinc_increment;
current = innobase_next_autoinc(
- current, 1, increment, 1, col_max_value);
+ current, 1, increment, offset, col_max_value);
dict_table_autoinc_initialize(prebuilt->table, current);