2017-05-08 01:44:55 +02:00
|
|
|
--source include/have_sequence.inc
|
|
|
|
--source include/have_innodb.inc
|
|
|
|
|
|
|
|
drop table if exists t1;
|
|
|
|
|
|
|
|
--echo #
|
|
|
|
--echo # Test alter sequence
|
|
|
|
--echo #
|
|
|
|
|
|
|
|
CREATE SEQUENCE t1 nocache engine=myisam;
|
|
|
|
select * from t1;
|
|
|
|
select next value for t1;
|
|
|
|
alter sequence t1 start=50;
|
|
|
|
show create sequence t1;
|
|
|
|
select * from t1;
|
|
|
|
select next value for t1;
|
|
|
|
|
|
|
|
alter sequence t1 minvalue=-100;
|
|
|
|
show create sequence t1;
|
|
|
|
select * from t1;
|
2017-05-23 16:18:31 +02:00
|
|
|
--error ER_SEQUENCE_INVALID_DATA
|
2017-05-08 01:44:55 +02:00
|
|
|
alter sequence t1 minvalue=100 start=100;
|
2017-05-23 16:18:31 +02:00
|
|
|
alter sequence t1 minvalue=100 start=100 restart=100;
|
2017-05-08 01:44:55 +02:00
|
|
|
show create sequence t1;
|
|
|
|
select * from t1;
|
|
|
|
|
|
|
|
alter sequence t1 maxvalue=500;
|
|
|
|
show create sequence t1;
|
|
|
|
select * from t1;
|
|
|
|
drop sequence t1;
|
|
|
|
|
|
|
|
CREATE SEQUENCE t1 engine=myisam;
|
|
|
|
alter sequence t1 nocache;
|
|
|
|
show create sequence t1;
|
|
|
|
alter sequence t1 cache=100;
|
|
|
|
flush tables;
|
|
|
|
show create sequence t1;
|
|
|
|
alter sequence t1 nocache;
|
|
|
|
show create sequence t1;
|
|
|
|
flush tables;
|
|
|
|
show create sequence t1;
|
|
|
|
select * from t1;
|
|
|
|
select next value for t1;
|
|
|
|
select next value for t1;
|
|
|
|
select next value for t1;
|
2017-06-03 15:08:23 +02:00
|
|
|
select next_not_cached_value, cycle_count from t1;
|
2017-05-08 01:44:55 +02:00
|
|
|
drop sequence t1;
|
|
|
|
|
|
|
|
CREATE SEQUENCE t1 maxvalue=100 engine=myisam;
|
|
|
|
alter sequence t1 no maxvalue;
|
|
|
|
show create sequence t1;
|
|
|
|
select * from t1;
|
|
|
|
alter sequence t1 cycle;
|
|
|
|
show create sequence t1;
|
|
|
|
alter sequence t1 nocycle;
|
|
|
|
alter sequence t1 start=15 restart minvalue=10 maxvalue=20 cycle;
|
|
|
|
show create sequence t1;
|
|
|
|
select * from t1;
|
|
|
|
select NEXT VALUE for t1 from seq_1_to_10;
|
|
|
|
alter sequence t1 restart with 17 minvalue=10 maxvalue=20 cycle;
|
|
|
|
select NEXT VALUE for t1 from seq_1_to_10;
|
|
|
|
drop sequence t1;
|
|
|
|
|
|
|
|
CREATE SEQUENCE t1 maxvalue=100;
|
|
|
|
alter sequence t1 increment=-2 start with 50 minvalue=-100;
|
|
|
|
show create sequence t1;
|
|
|
|
select * from t1;
|
|
|
|
select NEXT VALUE for t1 from seq_1_to_10;
|
|
|
|
drop sequence t1;
|
|
|
|
|
|
|
|
--echo #
|
|
|
|
--echo # InnoDB (some things work different with InnoDB)
|
|
|
|
--echo
|
|
|
|
|
|
|
|
CREATE SEQUENCE t1 cache 10 engine=innodb;
|
|
|
|
select * from t1;
|
|
|
|
select next value for t1;
|
|
|
|
alter sequence t1 start=100;
|
|
|
|
show create sequence t1;
|
|
|
|
select * from t1;
|
|
|
|
select next value for t1;
|
|
|
|
drop sequence t1;
|
|
|
|
|
|
|
|
--echo #
|
|
|
|
--echo # ALTER TABLE
|
|
|
|
--echo #
|
|
|
|
|
|
|
|
CREATE SEQUENCE t1 engine=innodb;
|
|
|
|
select next value for t1;
|
|
|
|
alter table t1 rename t2;
|
|
|
|
select next value for t2;
|
|
|
|
rename table t2 to t1;
|
|
|
|
select next value for t1;
|
|
|
|
alter table t1 comment="foo";
|
|
|
|
show create sequence t1;
|
|
|
|
alter table t1 engine=myisam;
|
|
|
|
show create sequence t1;
|
|
|
|
alter table t1 engine=innodb;
|
|
|
|
show create sequence t1;
|
|
|
|
select * from t1;
|
|
|
|
drop sequence t1;
|
|
|
|
|
|
|
|
#
|
|
|
|
# Some error testing
|
|
|
|
#
|
|
|
|
|
|
|
|
CREATE SEQUENCE t1 engine=myisam;
|
|
|
|
--error ER_SEQUENCE_INVALID_DATA
|
|
|
|
alter sequence t1 minvalue=100;
|
|
|
|
drop sequence t1;
|
|
|
|
|
|
|
|
CREATE SEQUENCE t1 engine=myisam;
|
|
|
|
--error ER_SEQUENCE_INVALID_DATA
|
|
|
|
alter sequence t1 minvalue=25 maxvalue=20;
|
|
|
|
drop sequence t1;
|
|
|
|
|
|
|
|
create table t1 (a int);
|
|
|
|
--error ER_NOT_SEQUENCE
|
|
|
|
alter sequence t1 minvalue=100;
|
|
|
|
drop table t1;
|
|
|
|
|
|
|
|
alter sequence if exists t1 minvalue=100;
|
|
|
|
--error ER_NO_SUCH_TABLE
|
|
|
|
alter sequence t1 minvalue=100;
|
|
|
|
|
|
|
|
create sequence t1;
|
|
|
|
--error ER_PARSE_ERROR
|
|
|
|
alter sequence t1;
|
|
|
|
drop sequence t1;
|
|
|
|
|
|
|
|
CREATE SEQUENCE t1 maxvalue=100;
|
|
|
|
alter sequence t1 increment=-2 start with 50;
|
|
|
|
select next value for t1;
|
|
|
|
--error ER_SEQUENCE_RUN_OUT
|
|
|
|
select next value for t1;
|
|
|
|
select * from t1;
|
|
|
|
alter sequence t1 restart;
|
|
|
|
select next value for t1;
|
|
|
|
alter sequence t1 restart with 90;
|
|
|
|
select next value for t1;
|
|
|
|
drop sequence t1;
|
2020-06-07 15:23:44 +02:00
|
|
|
|
|
|
|
#
|
|
|
|
# MDEV-19977 Assertion `(0xFUL & mode) == LOCK_S || (0xFUL & mode) == LOCK_X'
|
|
|
|
# failed in lock_rec_lock
|
|
|
|
#
|
|
|
|
|
|
|
|
CREATE SEQUENCE t1 engine=innodb;
|
|
|
|
--error ER_SEQUENCE_INVALID_TABLE_STRUCTURE
|
|
|
|
ALTER IGNORE TABLE t1 ADD CHECK (start_value < minimum_value);
|
|
|
|
DROP SEQUENCE t1;
|
2020-06-07 15:30:50 +02:00
|
|
|
|
|
|
|
#
|
|
|
|
# MDEV-19320 Sequence gets corrupted and produces ER_KEY_NOT_FOUND (Can't
|
|
|
|
# find record) after ALTER .. ORDER BY
|
|
|
|
#
|
|
|
|
|
|
|
|
CREATE SEQUENCE s;
|
|
|
|
--error ER_SEQUENCE_INVALID_TABLE_STRUCTURE
|
|
|
|
ALTER TABLE s ORDER BY cache_size;
|
|
|
|
SELECT NEXTVAL(s);
|
|
|
|
DROP SEQUENCE s;
|