Generate the next auto-increment number based on increment and offset. computes the lowest number - strictly greater than "nr" - of the form: auto_increment_offset + N * auto_increment_increment If overflow happened then return MAX_ULONGLONG value as an indication of overflow. In most cases increment= offset= 1, in which case we get: @verbatim 1,2,3,4,5,... @endverbatim If increm
| 4384 | @verbatim 1,5,15,25,35,... @endverbatim |
| 4385 | */ |
| 4386 | inline ulonglong |
| 4387 | compute_next_insert_id(ulonglong nr,struct system_variables *variables) |
| 4388 | { |
| 4389 | const ulonglong save_nr= nr; |
| 4390 | |
| 4391 | if (variables->auto_increment_increment == 1) |
| 4392 | nr= nr + 1; // optimization of the formula below |
| 4393 | else |
| 4394 | { |
| 4395 | /* |
| 4396 | Calculating the number of complete auto_increment_increment extents: |
| 4397 | */ |
| 4398 | nr= (nr + variables->auto_increment_increment - |
| 4399 | variables->auto_increment_offset) / |
| 4400 | (ulonglong) variables->auto_increment_increment; |
| 4401 | /* |
| 4402 | Adding an offset to the auto_increment_increment extent boundary: |
| 4403 | */ |
| 4404 | nr= nr * (ulonglong) variables->auto_increment_increment + |
| 4405 | variables->auto_increment_offset; |
| 4406 | } |
| 4407 | |
| 4408 | if (unlikely(nr <= save_nr)) |
| 4409 | return ULONGLONG_MAX; |
| 4410 | |
| 4411 | return nr; |
| 4412 | } |
| 4413 | |
| 4414 | |
| 4415 | void handler::adjust_next_insert_id_after_explicit_value(ulonglong nr) |
no outgoing calls
no test coverage detected