Skip to content

Commit 0bdc15d

Browse files
committed
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
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()
1 parent 7f89d9c commit 0bdc15d

File tree

3 files changed

+33
-2
lines changed

3 files changed

+33
-2
lines changed

mysql-test/suite/sql_sequence/setval.result

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,3 +254,18 @@ def SETVAL(s1,10) 8 20 2 Y 32896 0 63
254254
SETVAL(s1,10)
255255
10
256256
DROP SEQUENCE s1;
257+
#
258+
# MDEV-15732: Assertion `next_free_value % real_increment == offset &&
259+
# next_free_value >= reserved_until' failed in
260+
# sequence_definition::adjust_values upon SETVAL for sequence with
261+
# INCREMENT 0
262+
#
263+
CREATE SEQUENCE s INCREMENT 0;
264+
SELECT NEXTVAL(s);
265+
NEXTVAL(s)
266+
1
267+
SELECT SETVAL(s, 10);
268+
SETVAL(s, 10)
269+
10
270+
DROP SEQUENCE s;
271+
# End of 10.3 tests

mysql-test/suite/sql_sequence/setval.test

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,3 +137,20 @@ SELECT SETVAL(s1,10);
137137
DROP SEQUENCE s1;
138138
--enable_ps_protocol
139139
--disable_metadata
140+
141+
--echo #
142+
--echo # MDEV-15732: Assertion `next_free_value % real_increment == offset &&
143+
--echo # next_free_value >= reserved_until' failed in
144+
--echo # sequence_definition::adjust_values upon SETVAL for sequence with
145+
--echo # INCREMENT 0
146+
--echo #
147+
148+
CREATE SEQUENCE s INCREMENT 0;
149+
SELECT NEXTVAL(s);
150+
SELECT SETVAL(s, 10);
151+
152+
# Cleanup
153+
DROP SEQUENCE s;
154+
155+
156+
--echo # End of 10.3 tests

sql/sql_sequence.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -560,8 +560,7 @@ void sequence_definition::adjust_values(longlong next_value)
560560
else
561561
{
562562
next_free_value+= to_add;
563-
DBUG_ASSERT(next_free_value % real_increment == offset &&
564-
next_free_value >= reserved_until);
563+
DBUG_ASSERT(next_free_value % real_increment == offset);
565564
}
566565
}
567566
}

0 commit comments

Comments
 (0)