[MDEV-6839] Auto-increment behavior if offset > increment is random and does not correspond documentation Created: 2014-10-05 Updated: 2023-05-09 |
|
| Status: | Open |
| Project: | MariaDB Server |
| Component/s: | Documentation |
| Affects Version/s: | 5.5.39, 10.0.14 |
| Fix Version/s: | N/A |
| Type: | Bug | Priority: | Minor |
| Reporter: | Elena Stepanova | Assignee: | Ian Gilfillan |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | upstream | ||
| Description |
|
Description of autoincrement behavior in regard to @@auto_increment_increment and @@auto_increment_offset (http://dev.mysql.com/doc/refman/5.6/en/replication-options-master.html#sysvar_auto_increme...) says: "auto_increment_offset determines the starting point for the AUTO_INCREMENT column value." "When the value of auto_increment_offset is greater than that of auto_increment_increment, the value of auto_increment_offset is ignored." "...the series of AUTO_INCREMENT values is calculated without regard to any values already present in the column, and the next value inserted is the least value in the series that is greater than the maximum existing value in the AUTO_INCREMENT column. The series is calculated like this: The second quote, however, does not specify what exactly it means, the value is ignored. It cannot be ignored completely, since it determines the starting point of a sequence, and participates in the sequence formula. Is it considered equal to 0? Or equal to 1? Or equal to the previous value? I can't find a confirmation to any of these theories, the behavior changes depending on factors unknown to me. See examples below. In the example 1, the last insert apparently uses the offset value 600, even though it should be ignored, according to the manual.
|
| Comments |
| Comment by Michael Widenius [ 2020-04-24 ] |
|
First, the assumption with using auto_increment offset is that 0 <= auto_increment_offset < auto_increment_increment. If that is not the case, just assume things will not work. Auto_increment_offset can be 1 if auto_increment_increment is 1. Looking at first case: With offset 200 and increment 300, the series that will be used is: Second case is not important as it doesn't satisfy the above requirement. What should be done at some point is to give an error if one gives wrong value to the variables. |
| Comment by Ian Gilfillan [ 2020-04-26 ] |
|
I will expand the documentation to clarify this. |