summaryrefslogtreecommitdiff
path: root/storage
diff options
context:
space:
mode:
authorThirunarayanan B <thirunarayanan.balathandayuth@oracle.com>2014-02-10 10:13:35 +0530
committerThirunarayanan B <thirunarayanan.balathandayuth@oracle.com>2014-02-10 10:13:35 +0530
commit7acdf29cb4f90498af143430e3bf0e9fd3bd39f5 (patch)
tree407483acf7b199ce206366d6c8216741417fbbfe /storage
parent5ffe40022baad6b727627072a3e421fc9a6fc7ae (diff)
downloadmariadb-git-7acdf29cb4f90498af143430e3bf0e9fd3bd39f5.tar.gz
Bug #14049391 INNODB MISCALCULATES AUTO-INCREMENT AFTER DECREASING
AUTO_INCREMENT_INCREMENT Problem: ======= When auto_increment_increment system variable decreases, immediate next value of auto increment column is not affected. Solution: ======== Get the previous inserted value of auto increment column by subtracting the previous auto_increment_increment from next auto increment value. After that calculate the current autoinc value using newly changed auto_increment_increment variable. Approved by Sunny [rb#4394]
Diffstat (limited to 'storage')
-rw-r--r--storage/innobase/handler/ha_innodb.cc15
1 files changed, 15 insertions, 0 deletions
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index b95a1f52ed5..adedc4fa961 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -10235,6 +10235,21 @@ ha_innobase::get_auto_increment(
current = *first_value > col_max_value ? autoinc : *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) {
+
+ current = autoinc - prebuilt->autoinc_increment;
+
+ current = innobase_next_autoinc(
+ current, 1, increment, 1, col_max_value);
+
+ dict_table_autoinc_initialize(prebuilt->table, current);
+
+ *first_value = current;
+ }
+
/* Compute the last value in the interval */
next_value = innobase_next_autoinc(
current, *nb_reserved_values, increment, offset,