Skip to content

Commit

Permalink
MDEV-15732: Assertion `next_free_value % real_increment == offset && …
Browse files Browse the repository at this point in the history
…next_free_value >= reserved_until' failed in sequence_definition::adjust_values upon SETVAL for sequence with INCREMENT 0

there was a problem with "next_free_value >= reserved_until" condition:
SEQUENCE::set_value handle next_free_value & reserved_until after adjust_values() call, so it is incorect to put assert on it in adjust_values()
  • Loading branch information
sanja-byelkin committed Apr 26, 2018
1 parent 7f89d9c commit 0bdc15d
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
15 changes: 15 additions & 0 deletions mysql-test/suite/sql_sequence/setval.result
Original file line number Diff line number Diff line change
Expand Up @@ -254,3 +254,18 @@ def SETVAL(s1,10) 8 20 2 Y 32896 0 63
SETVAL(s1,10)
10
DROP SEQUENCE s1;
#
# MDEV-15732: Assertion `next_free_value % real_increment == offset &&
# next_free_value >= reserved_until' failed in
# sequence_definition::adjust_values upon SETVAL for sequence with
# INCREMENT 0
#
CREATE SEQUENCE s INCREMENT 0;
SELECT NEXTVAL(s);
NEXTVAL(s)
1
SELECT SETVAL(s, 10);
SETVAL(s, 10)
10
DROP SEQUENCE s;
# End of 10.3 tests
17 changes: 17 additions & 0 deletions mysql-test/suite/sql_sequence/setval.test
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,20 @@ SELECT SETVAL(s1,10);
DROP SEQUENCE s1;
--enable_ps_protocol
--disable_metadata

--echo #
--echo # MDEV-15732: Assertion `next_free_value % real_increment == offset &&
--echo # next_free_value >= reserved_until' failed in
--echo # sequence_definition::adjust_values upon SETVAL for sequence with
--echo # INCREMENT 0
--echo #

CREATE SEQUENCE s INCREMENT 0;
SELECT NEXTVAL(s);
SELECT SETVAL(s, 10);

# Cleanup
DROP SEQUENCE s;


--echo # End of 10.3 tests
3 changes: 1 addition & 2 deletions sql/sql_sequence.cc
Original file line number Diff line number Diff line change
Expand Up @@ -560,8 +560,7 @@ void sequence_definition::adjust_values(longlong next_value)
else
{
next_free_value+= to_add;
DBUG_ASSERT(next_free_value % real_increment == offset &&
next_free_value >= reserved_until);
DBUG_ASSERT(next_free_value % real_increment == offset);
}
}
}
Expand Down

0 comments on commit 0bdc15d

Please sign in to comment.