[Commits] ddb1e1d009a: 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
revision-id: ddb1e1d009aaf0272a46ffdd9977bcde32c89305 (mariadb-10.3.6-49-gddb1e1d009a) parent(s): b4ee699a89ccf4f3cf52a18236e821f0d8466e8d author: Oleksandr Byelkin committer: Oleksandr Byelkin timestamp: 2018-04-25 21:32:47 +0200 message: 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 2 problems with "next_free_value >= reserved_until" condition: 1) it should be <= 2) 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() --- mysql-test/suite/sql_sequence/setval.result | 15 +++++++++++++++ mysql-test/suite/sql_sequence/setval.test | 17 +++++++++++++++++ sql/sql_sequence.cc | 3 +-- 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/mysql-test/suite/sql_sequence/setval.result b/mysql-test/suite/sql_sequence/setval.result index b7cda27cf96..504d460fea5 100644 --- a/mysql-test/suite/sql_sequence/setval.result +++ b/mysql-test/suite/sql_sequence/setval.result @@ -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 diff --git a/mysql-test/suite/sql_sequence/setval.test b/mysql-test/suite/sql_sequence/setval.test index 8f8059fdcae..1993bdbe077 100644 --- a/mysql-test/suite/sql_sequence/setval.test +++ b/mysql-test/suite/sql_sequence/setval.test @@ -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 diff --git a/sql/sql_sequence.cc b/sql/sql_sequence.cc index 18f0028908f..4d0f15386e7 100644 --- a/sql/sql_sequence.cc +++ b/sql/sql_sequence.cc @@ -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); } } }
participants (1)
-
Oleksandr Byelkin