From 7aa80ba66b042bbcd6f2576522bb87a1fc83a281 Mon Sep 17 00:00:00 2001 From: Monty Date: Thu, 30 Aug 2018 17:32:26 +0300 Subject: Sequences with negative numbers and auto_increment_increment crashes This also fixes MDEV-16313 Assertion `next_free_value % real_increment == offset' fails upon CREATE SEQUENCE in galera cluster Fixed by adding llabs() to assert. Also adjusted auto_increment_offset to mod auto_increment_increment. --- sql/sql_sequence.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'sql/sql_sequence.cc') diff --git a/sql/sql_sequence.cc b/sql/sql_sequence.cc index 21a8781087f..1fb2e5e7714 100644 --- a/sql/sql_sequence.cc +++ b/sql/sql_sequence.cc @@ -542,7 +542,8 @@ void sequence_definition::adjust_values(longlong next_value) if ((real_increment= global_system_variables.auto_increment_increment) != 1) - offset= global_system_variables.auto_increment_offset; + offset= (global_system_variables.auto_increment_offset % + global_system_variables.auto_increment_increment); /* Ensure that next_free_value has the right offset, so that we @@ -564,7 +565,7 @@ void sequence_definition::adjust_values(longlong next_value) else { next_free_value+= to_add; - DBUG_ASSERT(next_free_value % real_increment == offset); + DBUG_ASSERT(llabs(next_free_value % real_increment) == offset); } } } -- cgit v1.2.1