File tree Expand file tree Collapse file tree 5 files changed +58
-1
lines changed
mysql-test/suite/sql_sequence Expand file tree Collapse file tree 5 files changed +58
-1
lines changed Original file line number Diff line number Diff line change @@ -47,5 +47,20 @@ create sequence s as bigint start with -9223372036854775805 minvalue -9223372036
47
47
drop sequence s;
48
48
set global auto_increment_increment= default, auto_increment_offset= default;
49
49
#
50
+ # MDEV-33836 Assertion `(ulonglong) next_free_value % real_increment == (ulonglong) offset' failed in void sequence_definition::adjust_values(longlong)
51
+ #
52
+ CREATE SEQUENCE s AS BIGINT UNSIGNED START WITH 9223372036854775800 INCREMENT 0;
53
+ set @old_AUTO_INCREMENT_INCREMENT=@@global.AUTO_INCREMENT_INCREMENT;
54
+ set global AUTO_INCREMENT_INCREMENT=10;
55
+ SELECT NEXTVAL (s);
56
+ NEXTVAL (s)
57
+ 9223372036854775800
58
+ FLUSH TABLES WITH READ LOCK;
59
+ UPDATE s SET a=1;
60
+ Got one of the listed errors
61
+ unlock tables;
62
+ set global AUTO_INCREMENT_INCREMENT=@old_AUTO_INCREMENT_INCREMENT;
63
+ drop sequence s;
64
+ #
50
65
# End of 11.5 tests
51
66
#
Original file line number Diff line number Diff line change @@ -48,6 +48,23 @@ create sequence s as bigint start with -9223372036854775805 minvalue -9223372036
48
48
drop sequence s;
49
49
50
50
set global auto_increment_increment= default, auto_increment_offset= default;
51
+
52
+ --echo #
53
+ --echo # MDEV-33836 Assertion `(ulonglong) next_free_value % real_increment == (ulonglong) offset' failed in void sequence_definition::adjust_values(longlong)
54
+ --echo #
55
+
56
+ CREATE SEQUENCE s AS BIGINT UNSIGNED START WITH 9223372036854775800 INCREMENT 0;
57
+ set @old_AUTO_INCREMENT_INCREMENT=@@global.AUTO_INCREMENT_INCREMENT;
58
+ set global AUTO_INCREMENT_INCREMENT=10;
59
+ SELECT NEXTVAL (s);
60
+ FLUSH TABLES WITH READ LOCK;
61
+ # ER_CANT_UPDATE_WITH_READLOCK when executed normally
62
+ # ER_BAD_FIELD_ERROR when executed as a prepared statement
63
+ --error ER_CANT_UPDATE_WITH_READLOCK,ER_BAD_FIELD_ERROR
64
+ UPDATE s SET a=1;
65
+ unlock tables;
66
+ set global AUTO_INCREMENT_INCREMENT=@old_AUTO_INCREMENT_INCREMENT;
67
+ drop sequence s;
51
68
--enable_ps2_protocol
52
69
53
70
--echo #
Original file line number Diff line number Diff line change @@ -418,4 +418,15 @@ setval(s, 32767)
418
418
select nextval(s);
419
419
ERROR HY000: Sequence 'test.s' has run out
420
420
drop sequence s;
421
+ #
422
+ # MDEV-33836 Assertion `(ulonglong) next_free_value % real_increment == (ulonglong) offset' failed in void sequence_definition::adjust_values(longlong)
423
+ #
424
+ CREATE SEQUENCE s AS BIGINT UNSIGNED START WITH 9223372036854775800 INCREMENT 0;
425
+ set @old_AUTO_INCREMENT_INCREMENT=@@global.AUTO_INCREMENT_INCREMENT;
426
+ set global AUTO_INCREMENT_INCREMENT=100;
427
+ SELECT SETVAL (s,12345678901234567890);
428
+ SETVAL (s,12345678901234567890)
429
+ 12345678901234567890
430
+ drop sequence s;
431
+ set global AUTO_INCREMENT_INCREMENT=@old_AUTO_INCREMENT_INCREMENT;
421
432
# End of 11.5 tests
Original file line number Diff line number Diff line change @@ -253,4 +253,15 @@ select nextval(s);
253
253
drop sequence s;
254
254
--enable_ps2_protocol
255
255
256
+ --echo #
257
+ --echo # MDEV-33836 Assertion `(ulonglong) next_free_value % real_increment == (ulonglong) offset' failed in void sequence_definition::adjust_values(longlong)
258
+ --echo #
259
+
260
+ CREATE SEQUENCE s AS BIGINT UNSIGNED START WITH 9223372036854775800 INCREMENT 0;
261
+ set @old_AUTO_INCREMENT_INCREMENT=@@global.AUTO_INCREMENT_INCREMENT;
262
+ set global AUTO_INCREMENT_INCREMENT=100;
263
+ SELECT SETVAL (s,12345678901234567890);
264
+ drop sequence s;
265
+ set global AUTO_INCREMENT_INCREMENT=@old_AUTO_INCREMENT_INCREMENT;
266
+
256
267
--echo # End of 11.5 tests
Original file line number Diff line number Diff line change @@ -751,7 +751,10 @@ void sequence_definition::adjust_values(longlong next_value)
751
751
752
752
next_free_value % real_increment == offset
753
753
*/
754
- off= next_free_value % real_increment;
754
+ if (is_unsigned)
755
+ off= (ulonglong) next_free_value % real_increment;
756
+ else
757
+ off= next_free_value % real_increment;
755
758
if (off < 0 )
756
759
off+= real_increment;
757
760
to_add= (real_increment + offset - off) % real_increment;
You can’t perform that action at this time.
0 commit comments