| 1 |
--source include/have_sequence.inc |
| 2 |
|
| 3 |
# |
| 4 |
# tests with auto_increment_increment and auto_increment_offset |
| 5 |
# |
| 6 |
|
| 7 |
--disable_ps2_protocol |
| 8 |
set global auto_increment_increment= 2, auto_increment_offset= 2; |
| 9 |
|
| 10 |
create sequence s start with -3 minvalue= -1000 increment 0; |
| 11 |
|
| 12 |
select nextval(s); |
| 13 |
select nextval(s); |
| 14 |
flush tables; |
| 15 |
select nextval(s); |
| 16 |
drop sequence s; |
| 17 |
|
| 18 |
set global auto_increment_increment= 2, auto_increment_offset= 1; |
| 19 |
|
| 20 |
create sequence s start with -3 minvalue= -1000 increment 0; |
| 21 |
|
| 22 |
select nextval(s); |
| 23 |
select nextval(s); |
| 24 |
select nextval(s); |
| 25 |
flush tables; |
| 26 |
select nextval(s); |
| 27 |
drop sequence s; |
| 28 |
|
| 29 |
# Clean up |
| 30 |
|
| 31 |
set global auto_increment_increment= default, auto_increment_offset= default; |
| 32 |
|
| 33 |
--echo # |
| 34 |
--echo # MDEV-28152 Features for sequence |
| 35 |
--echo # |
| 36 |
|
| 37 |
set global auto_increment_increment= 100; |
| 38 |
set global auto_increment_offset= 42; |
| 39 |
create sequence s as bigint unsigned start with 9223372036854775800 increment 0; |
| 40 |
select next value for s; |
| 41 |
select next value for s; |
| 42 |
drop sequence s; |
| 43 |
|
| 44 |
set global auto_increment_increment= 100; |
| 45 |
set global auto_increment_offset= 5; |
| 46 |
# Test underflow |
| 47 |
create sequence s as bigint start with -9223372036854775805 minvalue -9223372036854775807 maxvalue -9223372036854775800 increment 0; |
| 48 |
drop sequence s; |
| 49 |
|
| 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; |
| 68 |
--enable_ps2_protocol |
| 69 |
|
| 70 |
--echo # |
| 71 |
--echo # End of 11.5 tests |
| 72 |
--echo # |