diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2019-07-23 11:01:44 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2019-07-23 11:01:44 +0300 |
commit | 7153e155424de4b42bc0f96ceb6433e4ed1f827a (patch) | |
tree | cb77379346a10b5730deb6b0bfc27a9d327c5fd4 /storage | |
parent | 07ba5560da805c766da68811692272dd9eebdaf7 (diff) | |
download | mariadb-git-7153e155424de4b42bc0f96ceb6433e4ed1f827a.tar.gz |
Revert "MDEV-8827 Duplicate key with auto increment"
This reverts commit ef47b62551b0f37770e5d174ea028150c5b71fd8.
The parent commit 07ba5560da805c766da68811692272dd9eebdaf7
which is a backport of
mysql/mysql-server@1198267c331b045b9cad26be72b1a5b4f8930a79
fixes the issue differently.
Diffstat (limited to 'storage')
-rw-r--r-- | storage/innobase/handler/ha_innodb.cc | 12 | ||||
-rw-r--r-- | storage/xtradb/handler/ha_innodb.cc | 12 |
2 files changed, 14 insertions, 10 deletions
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 8b48552eed4..dab43efbf94 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -1504,11 +1504,10 @@ innobase_next_autoinc( if (next_value == 0) { ulonglong next; - if (current >= offset) { + if (current > offset) { next = (current - offset) / step; } else { - next = 0; - block -= step; + next = (offset - current) / step; } ut_a(max_value > next); @@ -10530,12 +10529,15 @@ ha_innobase::get_auto_increment( current = *first_value; - if (prebuilt->autoinc_increment != increment) { + /* 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) { current = autoinc - prebuilt->autoinc_increment; current = innobase_next_autoinc( - current, 1, increment, offset, col_max_value); + current, 1, increment, 1, col_max_value); dict_table_autoinc_initialize(prebuilt->table, current); diff --git a/storage/xtradb/handler/ha_innodb.cc b/storage/xtradb/handler/ha_innodb.cc index d148ab8c8d8..5f3639a8ea9 100644 --- a/storage/xtradb/handler/ha_innodb.cc +++ b/storage/xtradb/handler/ha_innodb.cc @@ -1774,11 +1774,10 @@ innobase_next_autoinc( if (next_value == 0) { ulonglong next; - if (current >= offset) { + if (current > offset) { next = (current - offset) / step; } else { - next = 0; - block -= step; + next = (offset - current) / step; } ut_a(max_value > next); @@ -11799,12 +11798,15 @@ ha_innobase::get_auto_increment( current = *first_value; - if (prebuilt->autoinc_increment != increment) { + /* 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) { current = autoinc - prebuilt->autoinc_increment; current = innobase_next_autoinc( - current, 1, increment, offset, col_max_value); + current, 1, increment, 1, col_max_value); dict_table_autoinc_initialize(prebuilt->table, current); |