Commit 87cdc8f8 authored by Yuchen Pei's avatar Yuchen Pei

MDEV-28152 create sequences with various signed value types

- Support signed types. Unsigned types to be worked out in the next patch.
- Sequence (definition) tables uses the value type for the field type
  of minvalue, maxvalue, startvalue, next_not_cached_value, so that
  the value type can be inferred from this type.
parent 84675ed9
...@@ -6369,16 +6369,16 @@ NEXTVAL(d.s1) NEXTVAL(d.s2) NEXTVAL(d.s3) NEXTVAL(d.s4) ...@@ -6369,16 +6369,16 @@ NEXTVAL(d.s1) NEXTVAL(d.s2) NEXTVAL(d.s3) NEXTVAL(d.s4)
# Show create before dump # Show create before dump
show create sequence d.s1; show create sequence d.s1;
Table Create Table Table Create Table
s1 CREATE SEQUENCE `s1` start with 100 minvalue 100 maxvalue 1100 increment by 10 cache 1000 cycle ENGINE=MyISAM s1 CREATE SEQUENCE `s1` as bigint start with 100 minvalue 100 maxvalue 1100 increment by 10 cache 1000 cycle ENGINE=MyISAM
show create sequence d.s2; show create sequence d.s2;
Table Create Table Table Create Table
s2 CREATE SEQUENCE `s2` start with 200 minvalue 200 maxvalue 1200 increment by 20 cache 1000 cycle ENGINE=MyISAM s2 CREATE SEQUENCE `s2` as bigint start with 200 minvalue 200 maxvalue 1200 increment by 20 cache 1000 cycle ENGINE=MyISAM
show create sequence d.s3; show create sequence d.s3;
Table Create Table Table Create Table
s3 CREATE SEQUENCE `s3` start with 300 minvalue 300 maxvalue 1300 increment by 30 cache 1000 cycle ENGINE=MyISAM s3 CREATE SEQUENCE `s3` as bigint start with 300 minvalue 300 maxvalue 1300 increment by 30 cache 1000 cycle ENGINE=MyISAM
show create sequence d.s4; show create sequence d.s4;
Table Create Table Table Create Table
s4 CREATE SEQUENCE `s4` start with 400 minvalue 400 maxvalue 1400 increment by 40 cache 1000 cycle ENGINE=MyISAM s4 CREATE SEQUENCE `s4` as bigint start with 400 minvalue 400 maxvalue 1400 increment by 40 cache 1000 cycle ENGINE=MyISAM
# Dump sequence without `--no-data` # Dump sequence without `--no-data`
# Restore from mysqldump # Restore from mysqldump
SETVAL(`s1`, 1101, 0) SETVAL(`s1`, 1101, 0)
...@@ -6392,16 +6392,16 @@ SETVAL(`s4`, 1401, 0) ...@@ -6392,16 +6392,16 @@ SETVAL(`s4`, 1401, 0)
# Show create after restore # Show create after restore
show create sequence d.s1; show create sequence d.s1;
Table Create Table Table Create Table
s1 CREATE SEQUENCE `s1` start with 100 minvalue 100 maxvalue 1100 increment by 10 cache 1000 cycle ENGINE=MyISAM s1 CREATE SEQUENCE `s1` as bigint start with 100 minvalue 100 maxvalue 1100 increment by 10 cache 1000 cycle ENGINE=MyISAM
show create sequence d.s2; show create sequence d.s2;
Table Create Table Table Create Table
s2 CREATE SEQUENCE `s2` start with 200 minvalue 200 maxvalue 1200 increment by 20 cache 1000 cycle ENGINE=MyISAM s2 CREATE SEQUENCE `s2` as bigint start with 200 minvalue 200 maxvalue 1200 increment by 20 cache 1000 cycle ENGINE=MyISAM
show create sequence d.s3; show create sequence d.s3;
Table Create Table Table Create Table
s3 CREATE SEQUENCE `s3` start with 300 minvalue 300 maxvalue 1300 increment by 30 cache 1000 cycle ENGINE=MyISAM s3 CREATE SEQUENCE `s3` as bigint start with 300 minvalue 300 maxvalue 1300 increment by 30 cache 1000 cycle ENGINE=MyISAM
show create sequence d.s4; show create sequence d.s4;
Table Create Table Table Create Table
s4 CREATE SEQUENCE `s4` start with 400 minvalue 400 maxvalue 1400 increment by 40 cache 1000 cycle ENGINE=MyISAM s4 CREATE SEQUENCE `s4` as bigint start with 400 minvalue 400 maxvalue 1400 increment by 40 cache 1000 cycle ENGINE=MyISAM
SELECT NEXTVAL(d.s1),NEXTVAL(d.s2),NEXTVAL(d.s3), NEXTVAL(d.s4); SELECT NEXTVAL(d.s1),NEXTVAL(d.s2),NEXTVAL(d.s3), NEXTVAL(d.s4);
NEXTVAL(d.s1) NEXTVAL(d.s2) NEXTVAL(d.s3) NEXTVAL(d.s4) NEXTVAL(d.s1) NEXTVAL(d.s2) NEXTVAL(d.s3) NEXTVAL(d.s4)
100 200 300 400 100 200 300 400
...@@ -6418,16 +6418,16 @@ SETVAL(`s4`, 1401, 0) ...@@ -6418,16 +6418,16 @@ SETVAL(`s4`, 1401, 0)
# Show create after restore `--no-data` # Show create after restore `--no-data`
show create sequence d.s1; show create sequence d.s1;
Table Create Table Table Create Table
s1 CREATE SEQUENCE `s1` start with 100 minvalue 100 maxvalue 1100 increment by 10 cache 1000 cycle ENGINE=MyISAM s1 CREATE SEQUENCE `s1` as bigint start with 100 minvalue 100 maxvalue 1100 increment by 10 cache 1000 cycle ENGINE=MyISAM
show create sequence d.s2; show create sequence d.s2;
Table Create Table Table Create Table
s2 CREATE SEQUENCE `s2` start with 200 minvalue 200 maxvalue 1200 increment by 20 cache 1000 cycle ENGINE=MyISAM s2 CREATE SEQUENCE `s2` as bigint start with 200 minvalue 200 maxvalue 1200 increment by 20 cache 1000 cycle ENGINE=MyISAM
show create sequence d.s3; show create sequence d.s3;
Table Create Table Table Create Table
s3 CREATE SEQUENCE `s3` start with 300 minvalue 300 maxvalue 1300 increment by 30 cache 1000 cycle ENGINE=MyISAM s3 CREATE SEQUENCE `s3` as bigint start with 300 minvalue 300 maxvalue 1300 increment by 30 cache 1000 cycle ENGINE=MyISAM
show create sequence d.s4; show create sequence d.s4;
Table Create Table Table Create Table
s4 CREATE SEQUENCE `s4` start with 400 minvalue 400 maxvalue 1400 increment by 40 cache 1000 cycle ENGINE=MyISAM s4 CREATE SEQUENCE `s4` as bigint start with 400 minvalue 400 maxvalue 1400 increment by 40 cache 1000 cycle ENGINE=MyISAM
SELECT NEXTVAL(d.s1),NEXTVAL(d.s2),NEXTVAL(d.s3), NEXTVAL(d.s4); SELECT NEXTVAL(d.s1),NEXTVAL(d.s2),NEXTVAL(d.s3), NEXTVAL(d.s4);
NEXTVAL(d.s1) NEXTVAL(d.s2) NEXTVAL(d.s3) NEXTVAL(d.s4) NEXTVAL(d.s1) NEXTVAL(d.s2) NEXTVAL(d.s3) NEXTVAL(d.s4)
100 200 300 400 100 200 300 400
...@@ -6443,7 +6443,7 @@ SETVAL(`s4`, 1401, 0) ...@@ -6443,7 +6443,7 @@ SETVAL(`s4`, 1401, 0)
1401 1401
show create sequence d2.s1; show create sequence d2.s1;
Table Create Table Table Create Table
s1 CREATE SEQUENCE `s1` start with 100 minvalue 100 maxvalue 1100 increment by 10 cache 1000 cycle ENGINE=MyISAM s1 CREATE SEQUENCE `s1` as bigint start with 100 minvalue 100 maxvalue 1100 increment by 10 cache 1000 cycle ENGINE=MyISAM
drop sequence d.s1, d.s2, d.s3, d.s4; drop sequence d.s1, d.s2, d.s3, d.s4;
drop database d; drop database d;
drop database d2; drop database d2;
......
...@@ -14,7 +14,7 @@ next value for t1 ...@@ -14,7 +14,7 @@ next value for t1
alter sequence t1 start=50; alter sequence t1 start=50;
show create sequence t1; show create sequence t1;
Table Create Table Table Create Table
t1 CREATE SEQUENCE `t1` start with 50 minvalue 1 maxvalue 9223372036854775806 increment by 1 nocache nocycle ENGINE=MyISAM t1 CREATE SEQUENCE `t1` as bigint start with 50 minvalue 1 maxvalue 9223372036854775806 increment by 1 nocache nocycle ENGINE=MyISAM
select * from t1; select * from t1;
next_not_cached_value minimum_value maximum_value start_value increment cache_size cycle_option cycle_count next_not_cached_value minimum_value maximum_value start_value increment cache_size cycle_option cycle_count
2 1 9223372036854775806 50 1 0 0 0 2 1 9223372036854775806 50 1 0 0 0
...@@ -24,7 +24,7 @@ next value for t1 ...@@ -24,7 +24,7 @@ next value for t1
alter sequence t1 minvalue=-100; alter sequence t1 minvalue=-100;
show create sequence t1; show create sequence t1;
Table Create Table Table Create Table
t1 CREATE SEQUENCE `t1` start with 50 minvalue -100 maxvalue 9223372036854775806 increment by 1 nocache nocycle ENGINE=MyISAM t1 CREATE SEQUENCE `t1` as bigint start with 50 minvalue -100 maxvalue 9223372036854775806 increment by 1 nocache nocycle ENGINE=MyISAM
select * from t1; select * from t1;
next_not_cached_value minimum_value maximum_value start_value increment cache_size cycle_option cycle_count next_not_cached_value minimum_value maximum_value start_value increment cache_size cycle_option cycle_count
3 -100 9223372036854775806 50 1 0 0 0 3 -100 9223372036854775806 50 1 0 0 0
...@@ -33,14 +33,14 @@ ERROR HY000: Sequence 'test.t1' has out of range value for options ...@@ -33,14 +33,14 @@ ERROR HY000: Sequence 'test.t1' has out of range value for options
alter sequence t1 minvalue=100 start=100 restart=100; alter sequence t1 minvalue=100 start=100 restart=100;
show create sequence t1; show create sequence t1;
Table Create Table Table Create Table
t1 CREATE SEQUENCE `t1` start with 100 minvalue 100 maxvalue 9223372036854775806 increment by 1 nocache nocycle ENGINE=MyISAM t1 CREATE SEQUENCE `t1` as bigint start with 100 minvalue 100 maxvalue 9223372036854775806 increment by 1 nocache nocycle ENGINE=MyISAM
select * from t1; select * from t1;
next_not_cached_value minimum_value maximum_value start_value increment cache_size cycle_option cycle_count next_not_cached_value minimum_value maximum_value start_value increment cache_size cycle_option cycle_count
100 100 9223372036854775806 100 1 0 0 0 100 100 9223372036854775806 100 1 0 0 0
alter sequence t1 maxvalue=500; alter sequence t1 maxvalue=500;
show create sequence t1; show create sequence t1;
Table Create Table Table Create Table
t1 CREATE SEQUENCE `t1` start with 100 minvalue 100 maxvalue 500 increment by 1 nocache nocycle ENGINE=MyISAM t1 CREATE SEQUENCE `t1` as bigint start with 100 minvalue 100 maxvalue 500 increment by 1 nocache nocycle ENGINE=MyISAM
select * from t1; select * from t1;
next_not_cached_value minimum_value maximum_value start_value increment cache_size cycle_option cycle_count next_not_cached_value minimum_value maximum_value start_value increment cache_size cycle_option cycle_count
100 100 500 100 1 0 0 0 100 100 500 100 1 0 0 0
...@@ -49,20 +49,20 @@ CREATE SEQUENCE t1 engine=myisam; ...@@ -49,20 +49,20 @@ CREATE SEQUENCE t1 engine=myisam;
alter sequence t1 nocache; alter sequence t1 nocache;
show create sequence t1; show create sequence t1;
Table Create Table Table Create Table
t1 CREATE SEQUENCE `t1` start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 nocache nocycle ENGINE=MyISAM t1 CREATE SEQUENCE `t1` as bigint start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 nocache nocycle ENGINE=MyISAM
alter sequence t1 cache=100; alter sequence t1 cache=100;
flush tables; flush tables;
show create sequence t1; show create sequence t1;
Table Create Table Table Create Table
t1 CREATE SEQUENCE `t1` start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 100 nocycle ENGINE=MyISAM t1 CREATE SEQUENCE `t1` as bigint start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 100 nocycle ENGINE=MyISAM
alter sequence t1 nocache; alter sequence t1 nocache;
show create sequence t1; show create sequence t1;
Table Create Table Table Create Table
t1 CREATE SEQUENCE `t1` start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 nocache nocycle ENGINE=MyISAM t1 CREATE SEQUENCE `t1` as bigint start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 nocache nocycle ENGINE=MyISAM
flush tables; flush tables;
show create sequence t1; show create sequence t1;
Table Create Table Table Create Table
t1 CREATE SEQUENCE `t1` start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 nocache nocycle ENGINE=MyISAM t1 CREATE SEQUENCE `t1` as bigint start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 nocache nocycle ENGINE=MyISAM
select * from t1; select * from t1;
next_not_cached_value minimum_value maximum_value start_value increment cache_size cycle_option cycle_count next_not_cached_value minimum_value maximum_value start_value increment cache_size cycle_option cycle_count
1 1 9223372036854775806 1 1 0 0 0 1 1 9223372036854775806 1 1 0 0 0
...@@ -83,19 +83,19 @@ CREATE SEQUENCE t1 maxvalue=100 engine=myisam; ...@@ -83,19 +83,19 @@ CREATE SEQUENCE t1 maxvalue=100 engine=myisam;
alter sequence t1 no maxvalue; alter sequence t1 no maxvalue;
show create sequence t1; show create sequence t1;
Table Create Table Table Create Table
t1 CREATE SEQUENCE `t1` start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=MyISAM t1 CREATE SEQUENCE `t1` as bigint start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=MyISAM
select * from t1; select * from t1;
next_not_cached_value minimum_value maximum_value start_value increment cache_size cycle_option cycle_count next_not_cached_value minimum_value maximum_value start_value increment cache_size cycle_option cycle_count
1 1 9223372036854775806 1 1 1000 0 0 1 1 9223372036854775806 1 1 1000 0 0
alter sequence t1 cycle; alter sequence t1 cycle;
show create sequence t1; show create sequence t1;
Table Create Table Table Create Table
t1 CREATE SEQUENCE `t1` start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 cycle ENGINE=MyISAM t1 CREATE SEQUENCE `t1` as bigint start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 cycle ENGINE=MyISAM
alter sequence t1 nocycle; alter sequence t1 nocycle;
alter sequence t1 start=15 restart minvalue=10 maxvalue=20 cycle; alter sequence t1 start=15 restart minvalue=10 maxvalue=20 cycle;
show create sequence t1; show create sequence t1;
Table Create Table Table Create Table
t1 CREATE SEQUENCE `t1` start with 15 minvalue 10 maxvalue 20 increment by 1 cache 1000 cycle ENGINE=MyISAM t1 CREATE SEQUENCE `t1` as bigint start with 15 minvalue 10 maxvalue 20 increment by 1 cache 1000 cycle ENGINE=MyISAM
select * from t1; select * from t1;
next_not_cached_value minimum_value maximum_value start_value increment cache_size cycle_option cycle_count next_not_cached_value minimum_value maximum_value start_value increment cache_size cycle_option cycle_count
15 10 20 15 1 1000 1 0 15 10 20 15 1 1000 1 0
...@@ -129,7 +129,7 @@ CREATE SEQUENCE t1 maxvalue=100; ...@@ -129,7 +129,7 @@ CREATE SEQUENCE t1 maxvalue=100;
alter sequence t1 increment=-2 start with 50 minvalue=-100; alter sequence t1 increment=-2 start with 50 minvalue=-100;
show create sequence t1; show create sequence t1;
Table Create Table Table Create Table
t1 CREATE SEQUENCE `t1` start with 50 minvalue -100 maxvalue 100 increment by -2 cache 1000 nocycle ENGINE=MyISAM t1 CREATE SEQUENCE `t1` as bigint start with 50 minvalue -100 maxvalue 100 increment by -2 cache 1000 nocycle ENGINE=MyISAM
select * from t1; select * from t1;
next_not_cached_value minimum_value maximum_value start_value increment cache_size cycle_option cycle_count next_not_cached_value minimum_value maximum_value start_value increment cache_size cycle_option cycle_count
1 -100 100 50 -2 1000 0 0 1 -100 100 50 -2 1000 0 0
...@@ -159,7 +159,7 @@ next value for t1 ...@@ -159,7 +159,7 @@ next value for t1
alter sequence t1 start=100; alter sequence t1 start=100;
show create sequence t1; show create sequence t1;
Table Create Table Table Create Table
t1 CREATE SEQUENCE `t1` start with 100 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 10 nocycle ENGINE=InnoDB t1 CREATE SEQUENCE `t1` as bigint start with 100 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 10 nocycle ENGINE=InnoDB
select * from t1; select * from t1;
next_not_cached_value minimum_value maximum_value start_value increment cache_size cycle_option cycle_count next_not_cached_value minimum_value maximum_value start_value increment cache_size cycle_option cycle_count
11 1 9223372036854775806 100 1 10 0 0 11 1 9223372036854775806 100 1 10 0 0
...@@ -185,15 +185,15 @@ next value for t1 ...@@ -185,15 +185,15 @@ next value for t1
alter table t1 comment="foo"; alter table t1 comment="foo";
show create sequence t1; show create sequence t1;
Table Create Table Table Create Table
t1 CREATE SEQUENCE `t1` start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=InnoDB COMMENT='foo' t1 CREATE SEQUENCE `t1` as bigint start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=InnoDB COMMENT='foo'
alter table t1 engine=myisam; alter table t1 engine=myisam;
show create sequence t1; show create sequence t1;
Table Create Table Table Create Table
t1 CREATE SEQUENCE `t1` start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=MyISAM COMMENT='foo' t1 CREATE SEQUENCE `t1` as bigint start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=MyISAM COMMENT='foo'
alter table t1 engine=innodb; alter table t1 engine=innodb;
show create sequence t1; show create sequence t1;
Table Create Table Table Create Table
t1 CREATE SEQUENCE `t1` start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=InnoDB COMMENT='foo' t1 CREATE SEQUENCE `t1` as bigint start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=InnoDB COMMENT='foo'
select * from t1; select * from t1;
next_not_cached_value minimum_value maximum_value start_value increment cache_size cycle_option cycle_count next_not_cached_value minimum_value maximum_value start_value increment cache_size cycle_option cycle_count
3001 1 9223372036854775806 1 1 1000 0 0 3001 1 9223372036854775806 1 1 1000 0 0
......
...@@ -12,7 +12,7 @@ select nextval(s1); ...@@ -12,7 +12,7 @@ select nextval(s1);
ERROR 42000: INSERT command denied to user 'normal_1'@'localhost' for table `s_db`.`s1` ERROR 42000: INSERT command denied to user 'normal_1'@'localhost' for table `s_db`.`s1`
show create sequence s1; show create sequence s1;
Table Create Table Table Create Table
s1 CREATE SEQUENCE `s1` start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=MyISAM s1 CREATE SEQUENCE `s1` as bigint start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=MyISAM
alter sequence s1 restart 50; alter sequence s1 restart 50;
ERROR 42000: ALTER command denied to user 'normal_1'@'localhost' for table `s_db`.`s1` ERROR 42000: ALTER command denied to user 'normal_1'@'localhost' for table `s_db`.`s1`
connection default; connection default;
......
...@@ -2,7 +2,7 @@ set @@default_storage_engine="aria"; ...@@ -2,7 +2,7 @@ set @@default_storage_engine="aria";
CREATE SEQUENCE t1 cache=10; CREATE SEQUENCE t1 cache=10;
show create sequence t1; show create sequence t1;
Table Create Table Table Create Table
t1 CREATE SEQUENCE `t1` start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 10 nocycle ENGINE=Aria t1 CREATE SEQUENCE `t1` as bigint start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 10 nocycle ENGINE=Aria
select NEXT VALUE for t1,seq from seq_1_to_20; select NEXT VALUE for t1,seq from seq_1_to_20;
NEXT VALUE for t1 seq NEXT VALUE for t1 seq
1 1 1 1
......
...@@ -4,7 +4,7 @@ Note 1051 Unknown table 'test.t1' ...@@ -4,7 +4,7 @@ Note 1051 Unknown table 'test.t1'
create or replace sequence t1 engine=myisam; create or replace sequence t1 engine=myisam;
show create sequence t1; show create sequence t1;
Table Create Table Table Create Table
t1 CREATE SEQUENCE `t1` start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=MyISAM t1 CREATE SEQUENCE `t1` as bigint start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=MyISAM
show create table t1; show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
...@@ -23,7 +23,7 @@ next_not_cached_value minimum_value maximum_value start_value increment cache_si ...@@ -23,7 +23,7 @@ next_not_cached_value minimum_value maximum_value start_value increment cache_si
create or replace sequence t1 engine=innodb; create or replace sequence t1 engine=innodb;
show create sequence t1; show create sequence t1;
Table Create Table Table Create Table
t1 CREATE SEQUENCE `t1` start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=InnoDB t1 CREATE SEQUENCE `t1` as bigint start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=InnoDB
show create table t1; show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
...@@ -42,7 +42,7 @@ next_not_cached_value minimum_value maximum_value start_value increment cache_si ...@@ -42,7 +42,7 @@ next_not_cached_value minimum_value maximum_value start_value increment cache_si
create or replace sequence t1 engine=maria; create or replace sequence t1 engine=maria;
show create sequence t1; show create sequence t1;
Table Create Table Table Create Table
t1 CREATE SEQUENCE `t1` start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=Aria t1 CREATE SEQUENCE `t1` as bigint start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=Aria
show create table t1; show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
...@@ -65,59 +65,59 @@ ERROR 42S02: Table 'test.t1' doesn't exist ...@@ -65,59 +65,59 @@ ERROR 42S02: Table 'test.t1' doesn't exist
create or replace sequence t1 start with 10; create or replace sequence t1 start with 10;
show create sequence t1; show create sequence t1;
Table Create Table Table Create Table
t1 CREATE SEQUENCE `t1` start with 10 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=MyISAM t1 CREATE SEQUENCE `t1` as bigint start with 10 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=MyISAM
select * from t1; select * from t1;
next_not_cached_value minimum_value maximum_value start_value increment cache_size cycle_option cycle_count next_not_cached_value minimum_value maximum_value start_value increment cache_size cycle_option cycle_count
10 1 9223372036854775806 10 1 1000 0 0 10 1 9223372036854775806 10 1 1000 0 0
create or replace sequence t1 minvalue=11; create or replace sequence t1 minvalue=11;
show create sequence t1; show create sequence t1;
Table Create Table Table Create Table
t1 CREATE SEQUENCE `t1` start with 11 minvalue 11 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=MyISAM t1 CREATE SEQUENCE `t1` as bigint start with 11 minvalue 11 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=MyISAM
select * from t1; select * from t1;
next_not_cached_value minimum_value maximum_value start_value increment cache_size cycle_option cycle_count next_not_cached_value minimum_value maximum_value start_value increment cache_size cycle_option cycle_count
11 11 9223372036854775806 11 1 1000 0 0 11 11 9223372036854775806 11 1 1000 0 0
create or replace sequence t1 maxvalue=13 increment by -1; create or replace sequence t1 maxvalue=13 increment by -1;
show create sequence t1; show create sequence t1;
Table Create Table Table Create Table
t1 CREATE SEQUENCE `t1` start with 13 minvalue -9223372036854775807 maxvalue 13 increment by -1 cache 1000 nocycle ENGINE=MyISAM t1 CREATE SEQUENCE `t1` as bigint start with 13 minvalue -9223372036854775807 maxvalue 13 increment by -1 cache 1000 nocycle ENGINE=MyISAM
select * from t1; select * from t1;
next_not_cached_value minimum_value maximum_value start_value increment cache_size cycle_option cycle_count next_not_cached_value minimum_value maximum_value start_value increment cache_size cycle_option cycle_count
13 -9223372036854775807 13 13 -1 1000 0 0 13 -9223372036854775807 13 13 -1 1000 0 0
create or replace sequence t1 increment by -1 cache 100; create or replace sequence t1 increment by -1 cache 100;
show create sequence t1; show create sequence t1;
Table Create Table Table Create Table
t1 CREATE SEQUENCE `t1` start with -1 minvalue -9223372036854775807 maxvalue -1 increment by -1 cache 100 nocycle ENGINE=MyISAM t1 CREATE SEQUENCE `t1` as bigint start with -1 minvalue -9223372036854775807 maxvalue -1 increment by -1 cache 100 nocycle ENGINE=MyISAM
select * from t1; select * from t1;
next_not_cached_value minimum_value maximum_value start_value increment cache_size cycle_option cycle_count next_not_cached_value minimum_value maximum_value start_value increment cache_size cycle_option cycle_count
-1 -9223372036854775807 -1 -1 -1 100 0 0 -1 -9223372036854775807 -1 -1 -1 100 0 0
create or replace sequence t1 cycle; create or replace sequence t1 cycle;
show create sequence t1; show create sequence t1;
Table Create Table Table Create Table
t1 CREATE SEQUENCE `t1` start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 cycle ENGINE=MyISAM t1 CREATE SEQUENCE `t1` as bigint start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 cycle ENGINE=MyISAM
select * from t1; select * from t1;
next_not_cached_value minimum_value maximum_value start_value increment cache_size cycle_option cycle_count next_not_cached_value minimum_value maximum_value start_value increment cache_size cycle_option cycle_count
1 1 9223372036854775806 1 1 1000 1 0 1 1 9223372036854775806 1 1 1000 1 0
create or replace sequence t1 nocycle; create or replace sequence t1 nocycle;
show create sequence t1; show create sequence t1;
Table Create Table Table Create Table
t1 CREATE SEQUENCE `t1` start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=MyISAM t1 CREATE SEQUENCE `t1` as bigint start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=MyISAM
select * from t1; select * from t1;
next_not_cached_value minimum_value maximum_value start_value increment cache_size cycle_option cycle_count next_not_cached_value minimum_value maximum_value start_value increment cache_size cycle_option cycle_count
1 1 9223372036854775806 1 1 1000 0 0 1 1 9223372036854775806 1 1 1000 0 0
show create sequence t1; show create sequence t1;
Table Create Table Table Create Table
t1 CREATE SEQUENCE `t1` start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=MyISAM t1 CREATE SEQUENCE `t1` as bigint start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=MyISAM
create or replace sequence t1 cycle minvalue= 14; create or replace sequence t1 cycle minvalue= 14;
show create sequence t1; show create sequence t1;
Table Create Table Table Create Table
t1 CREATE SEQUENCE `t1` start with 14 minvalue 14 maxvalue 9223372036854775806 increment by 1 cache 1000 cycle ENGINE=MyISAM t1 CREATE SEQUENCE `t1` as bigint start with 14 minvalue 14 maxvalue 9223372036854775806 increment by 1 cache 1000 cycle ENGINE=MyISAM
select * from t1; select * from t1;
next_not_cached_value minimum_value maximum_value start_value increment cache_size cycle_option cycle_count next_not_cached_value minimum_value maximum_value start_value increment cache_size cycle_option cycle_count
14 14 9223372036854775806 14 1 1000 1 0 14 14 9223372036854775806 14 1 1000 1 0
create or replace sequence t1 cycle increment by -1; create or replace sequence t1 cycle increment by -1;
show create sequence t1; show create sequence t1;
Table Create Table Table Create Table
t1 CREATE SEQUENCE `t1` start with -1 minvalue -9223372036854775807 maxvalue -1 increment by -1 cache 1000 cycle ENGINE=MyISAM t1 CREATE SEQUENCE `t1` as bigint start with -1 minvalue -9223372036854775807 maxvalue -1 increment by -1 cache 1000 cycle ENGINE=MyISAM
drop sequence t1; drop sequence t1;
create sequence if not exists t1; create sequence if not exists t1;
create sequence if not exists t1 start with 10; create sequence if not exists t1 start with 10;
...@@ -128,18 +128,18 @@ next_not_cached_value minimum_value maximum_value start_value increment cache_si ...@@ -128,18 +128,18 @@ next_not_cached_value minimum_value maximum_value start_value increment cache_si
1 1 9223372036854775806 1 1 1000 0 0 1 1 9223372036854775806 1 1 1000 0 0
show create sequence t1; show create sequence t1;
Table Create Table Table Create Table
t1 CREATE SEQUENCE `t1` start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=MyISAM t1 CREATE SEQUENCE `t1` as bigint start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=MyISAM
create or replace sequence t1 start with 10 minvalue=10 maxvalue=11 nocache cycle; create or replace sequence t1 start with 10 minvalue=10 maxvalue=11 nocache cycle;
show create sequence t1; show create sequence t1;
Table Create Table Table Create Table
t1 CREATE SEQUENCE `t1` start with 10 minvalue 10 maxvalue 11 increment by 1 nocache cycle ENGINE=MyISAM t1 CREATE SEQUENCE `t1` as bigint start with 10 minvalue 10 maxvalue 11 increment by 1 nocache cycle ENGINE=MyISAM
select * from t1; select * from t1;
next_not_cached_value minimum_value maximum_value start_value increment cache_size cycle_option cycle_count next_not_cached_value minimum_value maximum_value start_value increment cache_size cycle_option cycle_count
10 10 11 10 1 0 1 0 10 10 11 10 1 0 1 0
create or replace sequence t1 start with 10 minvalue=-10 maxvalue=11 cache=10 cycle increment by 10; create or replace sequence t1 start with 10 minvalue=-10 maxvalue=11 cache=10 cycle increment by 10;
show create sequence t1; show create sequence t1;
Table Create Table Table Create Table
t1 CREATE SEQUENCE `t1` start with 10 minvalue -10 maxvalue 11 increment by 10 cache 10 cycle ENGINE=MyISAM t1 CREATE SEQUENCE `t1` as bigint start with 10 minvalue -10 maxvalue 11 increment by 10 cache 10 cycle ENGINE=MyISAM
select * from t1; select * from t1;
next_not_cached_value minimum_value maximum_value start_value increment cache_size cycle_option cycle_count next_not_cached_value minimum_value maximum_value start_value increment cache_size cycle_option cycle_count
10 -10 11 10 10 10 1 0 10 -10 11 10 10 10 1 0
...@@ -148,21 +148,21 @@ Warnings: ...@@ -148,21 +148,21 @@ Warnings:
Note 1292 Truncated incorrect INTEGER value: 'MINVALUE' Note 1292 Truncated incorrect INTEGER value: 'MINVALUE'
show create sequence t1; show create sequence t1;
Table Create Table Table Create Table
t1 CREATE SEQUENCE `t1` start with -9223372036854775807 minvalue -9223372036854775807 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=MyISAM t1 CREATE SEQUENCE `t1` as bigint start with -9223372036854775807 minvalue -9223372036854775807 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=MyISAM
create or replace sequence t1 minvalue -9223372036854775808; create or replace sequence t1 minvalue -9223372036854775808;
Warnings: Warnings:
Note 1292 Truncated incorrect INTEGER value: 'MINVALUE' Note 1292 Truncated incorrect INTEGER value: 'MINVALUE'
show create sequence t1; show create sequence t1;
Table Create Table Table Create Table
t1 CREATE SEQUENCE `t1` start with -9223372036854775807 minvalue -9223372036854775807 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=MyISAM t1 CREATE SEQUENCE `t1` as bigint start with -9223372036854775807 minvalue -9223372036854775807 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=MyISAM
create or replace sequence t1 minvalue -9223372036854775807; create or replace sequence t1 minvalue -9223372036854775807;
show create sequence t1; show create sequence t1;
Table Create Table Table Create Table
t1 CREATE SEQUENCE `t1` start with -9223372036854775807 minvalue -9223372036854775807 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=MyISAM t1 CREATE SEQUENCE `t1` as bigint start with -9223372036854775807 minvalue -9223372036854775807 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=MyISAM
create or replace sequence t1 minvalue 9223372036854775805; create or replace sequence t1 minvalue 9223372036854775805;
show create sequence t1; show create sequence t1;
Table Create Table Table Create Table
t1 CREATE SEQUENCE `t1` start with 9223372036854775805 minvalue 9223372036854775805 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=MyISAM t1 CREATE SEQUENCE `t1` as bigint start with 9223372036854775805 minvalue 9223372036854775805 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=MyISAM
create or replace sequence t1 minvalue 9223372036854775806; create or replace sequence t1 minvalue 9223372036854775806;
ERROR HY000: Sequence 'test.t1' has out of range value for options ERROR HY000: Sequence 'test.t1' has out of range value for options
create or replace sequence t1 minvalue 9223372036854775807; create or replace sequence t1 minvalue 9223372036854775807;
...@@ -180,30 +180,50 @@ ERROR HY000: Sequence 'test.t1' has out of range value for options ...@@ -180,30 +180,50 @@ ERROR HY000: Sequence 'test.t1' has out of range value for options
create or replace sequence t1 maxvalue -9223372036854775806 increment by -1; create or replace sequence t1 maxvalue -9223372036854775806 increment by -1;
show create sequence t1; show create sequence t1;
Table Create Table Table Create Table
t1 CREATE SEQUENCE `t1` start with -9223372036854775806 minvalue -9223372036854775807 maxvalue -9223372036854775806 increment by -1 cache 1000 nocycle ENGINE=MyISAM t1 CREATE SEQUENCE `t1` as bigint start with -9223372036854775806 minvalue -9223372036854775807 maxvalue -9223372036854775806 increment by -1 cache 1000 nocycle ENGINE=MyISAM
create or replace sequence t1 maxvalue 9223372036854775806; create or replace sequence t1 maxvalue 9223372036854775806;
show create sequence t1; show create sequence t1;
Table Create Table Table Create Table
t1 CREATE SEQUENCE `t1` start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=MyISAM t1 CREATE SEQUENCE `t1` as bigint start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=MyISAM
create or replace sequence t1 maxvalue 9223372036854775807; create or replace sequence t1 maxvalue 9223372036854775807;
Warnings: Warnings:
Note 1292 Truncated incorrect INTEGER value: 'MAXVALUE' Note 1292 Truncated incorrect INTEGER value: 'MAXVALUE'
show create sequence t1; show create sequence t1;
Table Create Table Table Create Table
t1 CREATE SEQUENCE `t1` start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=MyISAM t1 CREATE SEQUENCE `t1` as bigint start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=MyISAM
create or replace sequence t1 maxvalue 9223372036854775808; create or replace sequence t1 maxvalue 9223372036854775808;
Warnings: Warnings:
Note 1292 Truncated incorrect INTEGER value: 'MAXVALUE' Note 1292 Truncated incorrect INTEGER value: 'MAXVALUE'
show create sequence t1; show create sequence t1;
Table Create Table Table Create Table
t1 CREATE SEQUENCE `t1` start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=MyISAM t1 CREATE SEQUENCE `t1` as bigint start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=MyISAM
create or replace sequence t1 maxvalue 9999999999999999999999; create or replace sequence t1 maxvalue 9999999999999999999999;
Warnings: Warnings:
Note 1292 Truncated incorrect INTEGER value: 'MAXVALUE' Note 1292 Truncated incorrect INTEGER value: 'MAXVALUE'
show create sequence t1; show create sequence t1;
Table Create Table Table Create Table
t1 CREATE SEQUENCE `t1` start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=MyISAM t1 CREATE SEQUENCE `t1` as bigint start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=MyISAM
create or replace sequence t1 start with 10 NO MAXVALUE NO MINVALUE; create or replace sequence t1 start with 10 NO MAXVALUE NO MINVALUE;
create or replace sequence t1 as tinyint;
show create sequence t1;
Table Create Table
t1 CREATE SEQUENCE `t1` as tinyint start with 1 minvalue 1 maxvalue 126 increment by 1 cache 1000 nocycle ENGINE=MyISAM
create or replace sequence t1 as smallint;
show create sequence t1;
Table Create Table
t1 CREATE SEQUENCE `t1` as smallint start with 1 minvalue 1 maxvalue 32766 increment by 1 cache 1000 nocycle ENGINE=MyISAM
create or replace sequence t1 as mediumint;
show create sequence t1;
Table Create Table
t1 CREATE SEQUENCE `t1` as mediumint start with 1 minvalue 1 maxvalue 8388606 increment by 1 cache 1000 nocycle ENGINE=MyISAM
create or replace sequence t1 as int;
show create sequence t1;
Table Create Table
t1 CREATE SEQUENCE `t1` as int start with 1 minvalue 1 maxvalue 2147483646 increment by 1 cache 1000 nocycle ENGINE=MyISAM
create or replace sequence t1 as bigint;
show create sequence t1;
Table Create Table
t1 CREATE SEQUENCE `t1` as bigint start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=MyISAM
create or replace sequence t1 start with 10 maxvalue 10; create or replace sequence t1 start with 10 maxvalue 10;
create or replace sequence t1 start with 10 minvalue 10; create or replace sequence t1 start with 10 minvalue 10;
create or replace sequence t1 start with 10 minvalue 10 maxvalue 11 cycle; create or replace sequence t1 start with 10 minvalue 10 maxvalue 11 cycle;
...@@ -213,7 +233,7 @@ drop sequence if exists t1; ...@@ -213,7 +233,7 @@ drop sequence if exists t1;
create sequence t1 increment by 0; create sequence t1 increment by 0;
show create sequence t1; show create sequence t1;
Table Create Table Table Create Table
t1 CREATE SEQUENCE `t1` start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 0 cache 1000 nocycle ENGINE=MyISAM t1 CREATE SEQUENCE `t1` as bigint start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 0 cache 1000 nocycle ENGINE=MyISAM
select * from t1; select * from t1;
next_not_cached_value minimum_value maximum_value start_value increment cache_size cycle_option cycle_count next_not_cached_value minimum_value maximum_value start_value increment cache_size cycle_option cycle_count
1 1 9223372036854775806 1 0 1000 0 0 1 1 9223372036854775806 1 0 1000 0 0
...@@ -293,7 +313,7 @@ flush tables; ...@@ -293,7 +313,7 @@ flush tables;
create or replace sequence t1 comment= "test 1"; create or replace sequence t1 comment= "test 1";
show create sequence t1; show create sequence t1;
Table Create Table Table Create Table
t1 CREATE SEQUENCE `t1` start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=MyISAM COMMENT='test 1' t1 CREATE SEQUENCE `t1` as bigint start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=MyISAM COMMENT='test 1'
show create table t1; show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
...@@ -309,7 +329,7 @@ t1 CREATE TABLE `t1` ( ...@@ -309,7 +329,7 @@ t1 CREATE TABLE `t1` (
create or replace sequence t1 comment= "test 2" min_rows=1 max_rows=2; create or replace sequence t1 comment= "test 2" min_rows=1 max_rows=2;
show create sequence t1; show create sequence t1;
Table Create Table Table Create Table
t1 CREATE SEQUENCE `t1` start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=MyISAM COMMENT='test 2' t1 CREATE SEQUENCE `t1` as bigint start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=MyISAM COMMENT='test 2'
show create table t1; show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
...@@ -338,7 +358,7 @@ CREATE TABLE t1 ( ...@@ -338,7 +358,7 @@ CREATE TABLE t1 (
) sequence=1; ) sequence=1;
show create sequence t1; show create sequence t1;
Table Create Table Table Create Table
t1 CREATE SEQUENCE `t1` start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=MyISAM t1 CREATE SEQUENCE `t1` as bigint start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=MyISAM
show create table t1; show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
...@@ -373,7 +393,7 @@ CREATE OR REPLACE TABLE t1 ( ...@@ -373,7 +393,7 @@ CREATE OR REPLACE TABLE t1 (
`cycle_option` tinyint(1) unsigned NOT NULL, `cycle_option` tinyint(1) unsigned NOT NULL,
`cycle_count` bigint(21) NOT NULL `cycle_count` bigint(21) NOT NULL
) sequence=1; ) sequence=1;
ERROR HY000: Sequence 'test.t1' table structure is invalid (next_not_cached_value) ERROR HY000: Sequence 'test.t1' table structure is invalid (minimum_value)
CREATE OR REPLACE TABLE t1 ( CREATE OR REPLACE TABLE t1 (
`next_not_cached_value` bigint(21) NOT NULL, `next_not_cached_value` bigint(21) NOT NULL,
`minimum_value` bigint(21) NOT NULL, `minimum_value` bigint(21) NOT NULL,
...@@ -607,7 +627,7 @@ t CREATE TABLE `t` ( ...@@ -607,7 +627,7 @@ t CREATE TABLE `t` (
) ENGINE=MyISAM SEQUENCE=1 ) ENGINE=MyISAM SEQUENCE=1
show create sequence t; show create sequence t;
Table Create Table Table Create Table
t CREATE SEQUENCE `t` start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=MyISAM t CREATE SEQUENCE `t` as bigint start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=MyISAM
drop tables t, s; drop tables t, s;
# #
# MDEV-13714 SEQUENCE option fix # MDEV-13714 SEQUENCE option fix
......
...@@ -109,6 +109,18 @@ show create sequence t1; ...@@ -109,6 +109,18 @@ show create sequence t1;
# NO MINVALUE, NO MAXVALUE # NO MINVALUE, NO MAXVALUE
create or replace sequence t1 start with 10 NO MAXVALUE NO MINVALUE; create or replace sequence t1 start with 10 NO MAXVALUE NO MINVALUE;
# Create with value types
create or replace sequence t1 as tinyint;
show create sequence t1;
create or replace sequence t1 as smallint;
show create sequence t1;
create or replace sequence t1 as mediumint;
show create sequence t1;
create or replace sequence t1 as int;
show create sequence t1;
create or replace sequence t1 as bigint;
show create sequence t1;
# Some edge cases # Some edge cases
create or replace sequence t1 start with 10 maxvalue 10; create or replace sequence t1 start with 10 maxvalue 10;
create or replace sequence t1 start with 10 minvalue 10; create or replace sequence t1 start with 10 minvalue 10;
......
...@@ -3,9 +3,9 @@ CREATE TABLE t1(a INT, KEY (a)) KEY_BLOCK_SIZE=1024; ...@@ -3,9 +3,9 @@ CREATE TABLE t1(a INT, KEY (a)) KEY_BLOCK_SIZE=1024;
insert into t1 values (1),(2); insert into t1 values (1),(2);
CREATE SEQUENCE x1 engine=innodb; CREATE SEQUENCE x1 engine=innodb;
# dump whole database # dump whole database
CREATE SEQUENCE `a1` start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=Aria; CREATE SEQUENCE `a1` as bigint start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=Aria;
SELECT SETVAL(`a1`, 1, 0); SELECT SETVAL(`a1`, 1, 0);
CREATE SEQUENCE `x1` start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=InnoDB; CREATE SEQUENCE `x1` as bigint start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=InnoDB;
SELECT SETVAL(`x1`, 1, 0); SELECT SETVAL(`x1`, 1, 0);
/*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */; /*!40101 SET character_set_client = utf8 */;
...@@ -18,9 +18,9 @@ INSERT INTO `t1` VALUES ...@@ -18,9 +18,9 @@ INSERT INTO `t1` VALUES
(1), (1),
(2); (2);
# dump by tables order 1 # dump by tables order 1
CREATE SEQUENCE `a1` start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=Aria; CREATE SEQUENCE `a1` as bigint start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=Aria;
SELECT SETVAL(`a1`, 1, 0); SELECT SETVAL(`a1`, 1, 0);
CREATE SEQUENCE `x1` start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=InnoDB; CREATE SEQUENCE `x1` as bigint start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=InnoDB;
SELECT SETVAL(`x1`, 1, 0); SELECT SETVAL(`x1`, 1, 0);
/*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */; /*!40101 SET character_set_client = utf8 */;
...@@ -33,9 +33,9 @@ INSERT INTO `t1` VALUES ...@@ -33,9 +33,9 @@ INSERT INTO `t1` VALUES
(1), (1),
(2); (2);
# dump by tables order 2 # dump by tables order 2
CREATE SEQUENCE `a1` start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=Aria; CREATE SEQUENCE `a1` as bigint start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=Aria;
SELECT SETVAL(`a1`, 1, 0); SELECT SETVAL(`a1`, 1, 0);
CREATE SEQUENCE `x1` start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=InnoDB; CREATE SEQUENCE `x1` as bigint start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=InnoDB;
SELECT SETVAL(`x1`, 1, 0); SELECT SETVAL(`x1`, 1, 0);
/*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */; /*!40101 SET character_set_client = utf8 */;
...@@ -59,9 +59,9 @@ INSERT INTO `t1` VALUES ...@@ -59,9 +59,9 @@ INSERT INTO `t1` VALUES
(1), (1),
(2); (2);
# dump by tables only sequences # dump by tables only sequences
CREATE SEQUENCE `a1` start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=Aria; CREATE SEQUENCE `a1` as bigint start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=Aria;
SELECT SETVAL(`a1`, 1, 0); SELECT SETVAL(`a1`, 1, 0);
CREATE SEQUENCE `x1` start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=InnoDB; CREATE SEQUENCE `x1` as bigint start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=InnoDB;
SELECT SETVAL(`x1`, 1, 0); SELECT SETVAL(`x1`, 1, 0);
# end of dumps # end of dumps
DROP TABLE a1,t1,x1; DROP TABLE a1,t1,x1;
......
...@@ -149,7 +149,7 @@ CREATE TABLE `s2` ( ...@@ -149,7 +149,7 @@ CREATE TABLE `s2` (
) ENGINE=myisam DEFAULT CHARSET=latin1 sequence=1; ) ENGINE=myisam DEFAULT CHARSET=latin1 sequence=1;
show create sequence s2; show create sequence s2;
Table Create Table Table Create Table
s2 CREATE SEQUENCE `s2` start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=MyISAM s2 CREATE SEQUENCE `s2` as bigint start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=MyISAM
drop sequence s2; drop sequence s2;
########################################### ###########################################
select sequence syntax test select sequence syntax test
...@@ -188,7 +188,7 @@ alter table s2 rename to s2_1; ...@@ -188,7 +188,7 @@ alter table s2 rename to s2_1;
rename table s2_1 to s2_2; rename table s2_1 to s2_2;
show create sequence s2_2; show create sequence s2_2;
Table Create Table Table Create Table
s2_2 CREATE SEQUENCE `s2_2` start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=MyISAM s2_2 CREATE SEQUENCE `s2_2` as bigint start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=MyISAM
select * from s2_2; select * from s2_2;
next_not_cached_value minimum_value maximum_value start_value increment cache_size cycle_option cycle_count next_not_cached_value minimum_value maximum_value start_value increment cache_size cycle_option cycle_count
1 1 9223372036854775806 1 1 1000 0 0 1 1 9223372036854775806 1 1 1000 0 0
......
...@@ -4,7 +4,7 @@ CREATE SEQUENCE s; ...@@ -4,7 +4,7 @@ CREATE SEQUENCE s;
INSERT INTO s VALUES (1,1,4,1,1,1,0,0); INSERT INTO s VALUES (1,1,4,1,1,1,0,0);
show create sequence s; show create sequence s;
Table Create Table Table Create Table
s CREATE SEQUENCE `s` start with 1 minvalue 1 maxvalue 4 increment by 1 cache 1 nocycle ENGINE=MyISAM s CREATE SEQUENCE `s` as bigint start with 1 minvalue 1 maxvalue 4 increment by 1 cache 1 nocycle ENGINE=MyISAM
SELECT NEXTVAL(s); SELECT NEXTVAL(s);
NEXTVAL(s) NEXTVAL(s)
1 1
...@@ -38,7 +38,7 @@ CREATE SEQUENCE s; ...@@ -38,7 +38,7 @@ CREATE SEQUENCE s;
INSERT INTO s VALUES (1,1,3,1,1,1,1,0); INSERT INTO s VALUES (1,1,3,1,1,1,1,0);
show create sequence s; show create sequence s;
Table Create Table Table Create Table
s CREATE SEQUENCE `s` start with 1 minvalue 1 maxvalue 3 increment by 1 cache 1 cycle ENGINE=MyISAM s CREATE SEQUENCE `s` as bigint start with 1 minvalue 1 maxvalue 3 increment by 1 cache 1 cycle ENGINE=MyISAM
SELECT NEXTVAL(s); SELECT NEXTVAL(s);
NEXTVAL(s) NEXTVAL(s)
1 1
......
...@@ -30,15 +30,6 @@ ...@@ -30,15 +30,6 @@
#include "wsrep_mysqld.h" #include "wsrep_mysqld.h"
#endif #endif
struct Field_definition
{
const char *field_name;
uint length;
const Type_handler *type_handler;
LEX_CSTRING comment;
ulong flags;
};
/* /*
Structure for all SEQUENCE tables Structure for all SEQUENCE tables
...@@ -48,30 +39,61 @@ struct Field_definition ...@@ -48,30 +39,61 @@ struct Field_definition
a column named NEXTVAL. a column named NEXTVAL.
*/ */
#define FL (NOT_NULL_FLAG | NO_DEFAULT_VALUE_FLAG) #define MAX_AUTO_INCREMENT_VALUE 65535
static Field_definition sequence_structure[]= Sequence_row_definition sequence_structure(const Type_handler* handler)
{ {
{"next_not_cached_value", 21, &type_handler_slonglong, // We don't really care about src because it is unused in max_display_length_for_field().
{STRING_WITH_LEN("")}, FL}, const Conv_source src(handler, 0, system_charset_info);
{"minimum_value", 21, &type_handler_slonglong, {STRING_WITH_LEN("")}, FL}, const uint32 len= handler->max_display_length_for_field(src) + 1;
{"maximum_value", 21, &type_handler_slonglong, {STRING_WITH_LEN("")}, FL}, const LEX_CSTRING empty= {STRING_WITH_LEN("")};
{"start_value", 21, &type_handler_slonglong, {STRING_WITH_LEN("start value when sequences is created or value if RESTART is used")}, FL}, #define FL (NOT_NULL_FLAG | NO_DEFAULT_VALUE_FLAG)
return {{{"next_not_cached_value", len, handler, empty, FL},
{"minimum_value", len, handler, empty, FL},
{"maximum_value", len, handler, empty, FL},
{"start_value", len, handler,
{STRING_WITH_LEN("start value when sequences is created or value "
"if RESTART is used")}, FL},
{"increment", 21, &type_handler_slonglong, {"increment", 21, &type_handler_slonglong,
{STRING_WITH_LEN("increment value")}, FL}, {STRING_WITH_LEN("increment value")}, FL},
{"cache_size", 21, &type_handler_ulonglong, {STRING_WITH_LEN("")}, {"cache_size", 21, &type_handler_ulonglong, empty,
FL | UNSIGNED_FLAG}, FL | UNSIGNED_FLAG},
{"cycle_option", 1, &type_handler_utiny, {STRING_WITH_LEN("0 if no cycles are allowed, 1 if the sequence should begin a new cycle when maximum_value is passed")}, {"cycle_option", 1, &type_handler_utiny,
FL | UNSIGNED_FLAG }, {STRING_WITH_LEN("0 if no cycles are allowed, 1 if the sequence " "should begin a new cycle when maximum_value is " "passed")}, FL | UNSIGNED_FLAG},
{"cycle_count", 21, &type_handler_slonglong, {"cycle_count", 21, &type_handler_slonglong,
{STRING_WITH_LEN("How many cycles have been done")}, FL}, {STRING_WITH_LEN("How many cycles have been done")}, FL},
{NULL, 0, &type_handler_slonglong, {STRING_WITH_LEN("")}, 0} {NULL, 0, &type_handler_slonglong, {STRING_WITH_LEN("")}, 0}}};
};
#undef FL #undef FL
}
bool sequence_definition::is_allowed_value_type(enum_field_types type)
{
switch (type)
{
case MYSQL_TYPE_TINY:
case MYSQL_TYPE_SHORT:
case MYSQL_TYPE_LONG:
case MYSQL_TYPE_INT24:
case MYSQL_TYPE_LONGLONG:
return true;
default:
return false;
}
}
#define MAX_AUTO_INCREMENT_VALUE 65535 Type_handler const *sequence_definition::value_type_handler()
{
return Type_handler::get_handler_by_field_type(value_type);
}
longlong sequence_definition::value_type_max()
{
return ~ value_type_min();
}
longlong sequence_definition::value_type_min() {
return ~0ULL << (8 * value_type_handler()->calc_pack_length(0) - 1);
}
/* /*
Check whether sequence values are valid. Check whether sequence values are valid.
...@@ -85,7 +107,7 @@ static Field_definition sequence_structure[]= ...@@ -85,7 +107,7 @@ static Field_definition sequence_structure[]=
bool sequence_definition::check_and_adjust(THD *thd, bool set_reserved_until) bool sequence_definition::check_and_adjust(THD *thd, bool set_reserved_until)
{ {
longlong max_increment; longlong max_increment;
DBUG_ENTER("sequence_definition::check"); DBUG_ENTER("sequence_definition::check_and_adjust");
if (!(real_increment= increment)) if (!(real_increment= increment))
real_increment= global_system_variables.auto_increment_increment; real_increment= global_system_variables.auto_increment_increment;
...@@ -94,30 +116,30 @@ bool sequence_definition::check_and_adjust(THD *thd, bool set_reserved_until) ...@@ -94,30 +116,30 @@ bool sequence_definition::check_and_adjust(THD *thd, bool set_reserved_until)
If min_value is not set, set it to LONGLONG_MIN or 1, depending on If min_value is not set, set it to LONGLONG_MIN or 1, depending on
real_increment real_increment
*/ */
if (!(used_fields & seq_field_used_min_value)) if (!(used_fields & seq_field_specified_min_value))
min_value= real_increment < 0 ? LONGLONG_MIN+1 : 1; min_value= real_increment < 0 ? value_type_min()+1 : 1;
/* /*
If max_value is not set, set it to LONGLONG_MAX or -1, depending on If max_value is not set, set it to LONGLONG_MAX or -1, depending on
real_increment real_increment
*/ */
if (!(used_fields & seq_field_used_max_value)) if (!(used_fields & seq_field_specified_max_value))
max_value= real_increment < 0 ? -1 : LONGLONG_MAX-1; max_value= real_increment < 0 ? -1 : value_type_max()-1;
if (max_value == LONGLONG_MAX) if (max_value >= value_type_max())
{ {
push_warning_printf(thd, Sql_condition::WARN_LEVEL_NOTE, push_warning_printf(thd, Sql_condition::WARN_LEVEL_NOTE,
ER_TRUNCATED_WRONG_VALUE, ER_TRUNCATED_WRONG_VALUE,
ER_THD(thd, ER_TRUNCATED_WRONG_VALUE), ER_THD(thd, ER_TRUNCATED_WRONG_VALUE),
"INTEGER", "MAXVALUE"); "INTEGER", "MAXVALUE");
max_value= LONGLONG_MAX - 1; max_value= value_type_max() - 1;
} }
if (min_value == LONGLONG_MIN) if (min_value <= value_type_min())
{ {
push_warning_printf( push_warning_printf(
thd, Sql_condition::WARN_LEVEL_NOTE, ER_TRUNCATED_WRONG_VALUE, thd, Sql_condition::WARN_LEVEL_NOTE, ER_TRUNCATED_WRONG_VALUE,
ER_THD(thd, ER_TRUNCATED_WRONG_VALUE), "INTEGER", "MINVALUE"); ER_THD(thd, ER_TRUNCATED_WRONG_VALUE), "INTEGER", "MINVALUE");
min_value= LONGLONG_MIN + 1; min_value= value_type_min() + 1;
} }
if (!(used_fields & seq_field_used_start)) if (!(used_fields & seq_field_used_start))
...@@ -136,14 +158,11 @@ bool sequence_definition::check_and_adjust(THD *thd, bool set_reserved_until) ...@@ -136,14 +158,11 @@ bool sequence_definition::check_and_adjust(THD *thd, bool set_reserved_until)
llabs(real_increment) : llabs(real_increment) :
MAX_AUTO_INCREMENT_VALUE); MAX_AUTO_INCREMENT_VALUE);
if (max_value >= start && if (max_value >= start && max_value > min_value && start >= min_value &&
max_value > min_value &&
start >= min_value &&
max_value != LONGLONG_MAX &&
min_value != LONGLONG_MIN &&
cache >= 0 && cache < (LONGLONG_MAX - max_increment) / max_increment && cache >= 0 && cache < (LONGLONG_MAX - max_increment) / max_increment &&
((real_increment > 0 && reserved_until >= min_value) || ((real_increment > 0 && reserved_until >= min_value) ||
(real_increment < 0 && reserved_until <= max_value))) (real_increment < 0 && reserved_until <= max_value)) &&
is_allowed_value_type(value_type))
DBUG_RETURN(FALSE); DBUG_RETURN(FALSE);
DBUG_RETURN(TRUE); // Error DBUG_RETURN(TRUE); // Error
...@@ -165,6 +184,7 @@ void sequence_definition::read_fields(TABLE *table) ...@@ -165,6 +184,7 @@ void sequence_definition::read_fields(TABLE *table)
cache= table->field[5]->val_int(); cache= table->field[5]->val_int();
cycle= table->field[6]->val_int(); cycle= table->field[6]->val_int();
round= table->field[7]->val_int(); round= table->field[7]->val_int();
value_type= table->field[0]->type();
dbug_tmp_restore_column_map(&table->read_set, old_map); dbug_tmp_restore_column_map(&table->read_set, old_map);
used_fields= ~(uint) 0; used_fields= ~(uint) 0;
print_dbug(); print_dbug();
...@@ -210,10 +230,17 @@ bool check_sequence_fields(LEX *lex, List<Create_field> *fields) ...@@ -210,10 +230,17 @@ bool check_sequence_fields(LEX *lex, List<Create_field> *fields)
uint field_count; uint field_count;
uint field_no; uint field_no;
const char *reason; const char *reason;
Sequence_row_definition row_structure;
DBUG_ENTER("check_sequence_fields"); DBUG_ENTER("check_sequence_fields");
field_count= fields->elements; field_count= fields->elements;
if (field_count != array_elements(sequence_structure)-1) if (!field_count)
{
reason= "Wrong number of columns";
goto err;
}
row_structure= sequence_structure(fields->head()->type_handler());
if (field_count != array_elements(row_structure.fields)-1)
{ {
reason= "Wrong number of columns"; reason= "Wrong number of columns";
goto err; goto err;
...@@ -236,7 +263,7 @@ bool check_sequence_fields(LEX *lex, List<Create_field> *fields) ...@@ -236,7 +263,7 @@ bool check_sequence_fields(LEX *lex, List<Create_field> *fields)
for (field_no= 0; (field= it++); field_no++) for (field_no= 0; (field= it++); field_no++)
{ {
Field_definition *field_def= &sequence_structure[field_no]; const Sequence_field_definition *field_def= &row_structure.fields[field_no];
if (my_strcasecmp(system_charset_info, field_def->field_name, if (my_strcasecmp(system_charset_info, field_def->field_name,
field->field_name.str) || field->field_name.str) ||
field->flags != field_def->flags || field->flags != field_def->flags ||
...@@ -265,12 +292,12 @@ bool check_sequence_fields(LEX *lex, List<Create_field> *fields) ...@@ -265,12 +292,12 @@ bool check_sequence_fields(LEX *lex, List<Create_field> *fields)
true Failure (out of memory) true Failure (out of memory)
*/ */
bool prepare_sequence_fields(THD *thd, List<Create_field> *fields) bool sequence_definition::prepare_sequence_fields(List<Create_field> *fields)
{ {
Field_definition *field_info; Sequence_field_definition *field_info;
DBUG_ENTER("prepare_sequence_fields"); DBUG_ENTER("prepare_sequence_fields");
for (field_info= sequence_structure; field_info->field_name ; field_info++) for (field_info= sequence_structure(value_type_handler()).fields; field_info->field_name ; field_info++)
{ {
Create_field *new_field; Create_field *new_field;
LEX_CSTRING field_name= {field_info->field_name, LEX_CSTRING field_name= {field_info->field_name,
......
...@@ -25,12 +25,34 @@ ...@@ -25,12 +25,34 @@
#define seq_field_used_cycle 32 #define seq_field_used_cycle 32
#define seq_field_used_restart 64 #define seq_field_used_restart 64
#define seq_field_used_restart_value 128 #define seq_field_used_restart_value 128
#define seq_field_used_as 256
#define seq_field_specified_min_value 512
#define seq_field_specified_max_value 1024
/* Field position in sequence table for some fields we refer to directly */ /* Field position in sequence table for some fields we refer to directly */
#define NEXT_FIELD_NO 0 #define NEXT_FIELD_NO 0
#define MIN_VALUE_FIELD_NO 1 #define MIN_VALUE_FIELD_NO 1
#define ROUND_FIELD_NO 7 #define ROUND_FIELD_NO 7
#include "mysql_com.h"
class Create_field;
class Type_handler;
struct Sequence_field_definition
{
const char *field_name;
uint length;
const Type_handler *type_handler;
LEX_CSTRING comment;
ulong flags;
};
struct Sequence_row_definition
{
Sequence_field_definition fields[9];
};
/** /**
sequence_definition is used when defining a sequence as part of create sequence_definition is used when defining a sequence as part of create
*/ */
...@@ -40,7 +62,7 @@ class sequence_definition :public Sql_alloc ...@@ -40,7 +62,7 @@ class sequence_definition :public Sql_alloc
public: public:
sequence_definition(): sequence_definition():
min_value(1), max_value(LONGLONG_MAX-1), start(1), increment(1), min_value(1), max_value(LONGLONG_MAX-1), start(1), increment(1),
cache(1000), round(0), restart(0), cycle(0), used_fields(0) cache(1000), round(0), restart(0), cycle(0), used_fields(0), value_type(MYSQL_TYPE_LONGLONG)
{} {}
longlong reserved_until; longlong reserved_until;
longlong min_value; longlong min_value;
...@@ -52,7 +74,13 @@ class sequence_definition :public Sql_alloc ...@@ -52,7 +74,13 @@ class sequence_definition :public Sql_alloc
longlong restart; // alter sequence restart value longlong restart; // alter sequence restart value
bool cycle; bool cycle;
uint used_fields; // Which fields where used in CREATE uint used_fields; // Which fields where used in CREATE
enum_field_types value_type; // value type of the sequence
Type_handler const *value_type_handler();
// max value for the value type, e.g. 32767 for smallint.
longlong value_type_max();
// min value for the value type, e.g. -32768 for smallint.
longlong value_type_min();
bool check_and_adjust(THD *thd, bool set_reserved_until); bool check_and_adjust(THD *thd, bool set_reserved_until);
void store_fields(TABLE *table); void store_fields(TABLE *table);
void read_fields(TABLE *table); void read_fields(TABLE *table);
...@@ -66,6 +94,9 @@ class sequence_definition :public Sql_alloc ...@@ -66,6 +94,9 @@ class sequence_definition :public Sql_alloc
reserved_until, start, increment, min_value, reserved_until, start, increment, min_value,
max_value, cache, round)); max_value, cache, round));
} }
static bool is_allowed_value_type(enum_field_types type);
bool prepare_sequence_fields(List<Create_field> *fields);
protected: protected:
/* /*
The following values are the values from sequence_definition The following values are the values from sequence_definition
...@@ -159,9 +190,6 @@ class SEQUENCE_LAST_VALUE ...@@ -159,9 +190,6 @@ class SEQUENCE_LAST_VALUE
uchar table_version[MY_UUID_SIZE]; uchar table_version[MY_UUID_SIZE];
}; };
class Create_field;
extern bool prepare_sequence_fields(THD *thd, List<Create_field> *fields);
extern bool check_sequence_fields(LEX *lex, List<Create_field> *fields); extern bool check_sequence_fields(LEX *lex, List<Create_field> *fields);
extern bool sequence_insert(THD *thd, LEX *lex, TABLE_LIST *table_list); extern bool sequence_insert(THD *thd, LEX *lex, TABLE_LIST *table_list);
#endif /* SQL_SEQUENCE_INCLUDED */ #endif /* SQL_SEQUENCE_INCLUDED */
...@@ -2694,6 +2694,8 @@ static int show_create_sequence(THD *thd, TABLE_LIST *table_list, ...@@ -2694,6 +2694,8 @@ static int show_create_sequence(THD *thd, TABLE_LIST *table_list,
packet->append(STRING_WITH_LEN("CREATE SEQUENCE ")); packet->append(STRING_WITH_LEN("CREATE SEQUENCE "));
append_identifier(thd, packet, &alias); append_identifier(thd, packet, &alias);
packet->append(STRING_WITH_LEN(" as "));
packet->append(seq->value_type_handler()->name().lex_cstring());
packet->append(STRING_WITH_LEN(" start with ")); packet->append(STRING_WITH_LEN(" start with "));
packet->append_longlong(seq->start); packet->append_longlong(seq->start);
packet->append(STRING_WITH_LEN(" minvalue ")); packet->append(STRING_WITH_LEN(" minvalue "));
......
...@@ -2433,7 +2433,7 @@ create: ...@@ -2433,7 +2433,7 @@ create:
} }
/* No fields specified, generate them */ /* No fields specified, generate them */
if (unlikely(prepare_sequence_fields(thd, if (unlikely(lex->create_info.seq_create_info->prepare_sequence_fields(
&lex->alter_info.create_list))) &lex->alter_info.create_list)))
MYSQL_YYABORT; MYSQL_YYABORT;
...@@ -2609,7 +2609,14 @@ sequence_defs: ...@@ -2609,7 +2609,14 @@ sequence_defs:
; ;
sequence_def: sequence_def:
MINVALUE_SYM opt_equal ulonglong_num AS int_type
{
if (unlikely(Lex->create_info.seq_create_info->used_fields &
seq_field_used_as))
my_yyabort_error((ER_DUP_ARGUMENT, MYF(0), "AS"));
Lex->create_info.seq_create_info->value_type = $2->field_type();
}
| MINVALUE_SYM opt_equal ulonglong_num
{ {
if (unlikely(Lex->create_info.seq_create_info->used_fields & if (unlikely(Lex->create_info.seq_create_info->used_fields &
seq_field_used_min_value)) seq_field_used_min_value))
...@@ -2619,6 +2626,7 @@ sequence_def: ...@@ -2619,6 +2626,7 @@ sequence_def:
else else
Lex->create_info.seq_create_info->min_value= (longlong) $3; Lex->create_info.seq_create_info->min_value= (longlong) $3;
Lex->create_info.seq_create_info->used_fields|= seq_field_used_min_value; Lex->create_info.seq_create_info->used_fields|= seq_field_used_min_value;
Lex->create_info.seq_create_info->used_fields|= seq_field_specified_min_value;
} }
| MINVALUE_SYM opt_equal minus_ulonglong_num | MINVALUE_SYM opt_equal minus_ulonglong_num
{ {
...@@ -2630,6 +2638,7 @@ sequence_def: ...@@ -2630,6 +2638,7 @@ sequence_def:
else else
Lex->create_info.seq_create_info->min_value= - (longlong) $3; Lex->create_info.seq_create_info->min_value= - (longlong) $3;
Lex->create_info.seq_create_info->used_fields|= seq_field_used_min_value; Lex->create_info.seq_create_info->used_fields|= seq_field_used_min_value;
Lex->create_info.seq_create_info->used_fields|= seq_field_specified_min_value;
} }
| MINVALUE_SYM opt_equal DECIMAL_NUM | MINVALUE_SYM opt_equal DECIMAL_NUM
{ {
...@@ -2638,6 +2647,7 @@ sequence_def: ...@@ -2638,6 +2647,7 @@ sequence_def:
my_yyabort_error((ER_DUP_ARGUMENT, MYF(0), "MINVALUE")); my_yyabort_error((ER_DUP_ARGUMENT, MYF(0), "MINVALUE"));
Lex->create_info.seq_create_info->min_value= LONGLONG_MAX; Lex->create_info.seq_create_info->min_value= LONGLONG_MAX;
Lex->create_info.seq_create_info->used_fields|= seq_field_used_min_value; Lex->create_info.seq_create_info->used_fields|= seq_field_used_min_value;
Lex->create_info.seq_create_info->used_fields|= seq_field_specified_min_value;
} }
| MINVALUE_SYM opt_equal '-' DECIMAL_NUM | MINVALUE_SYM opt_equal '-' DECIMAL_NUM
{ {
...@@ -2646,6 +2656,7 @@ sequence_def: ...@@ -2646,6 +2656,7 @@ sequence_def:
my_yyabort_error((ER_DUP_ARGUMENT, MYF(0), "MINVALUE")); my_yyabort_error((ER_DUP_ARGUMENT, MYF(0), "MINVALUE"));
Lex->create_info.seq_create_info->min_value= LONGLONG_MIN; Lex->create_info.seq_create_info->min_value= LONGLONG_MIN;
Lex->create_info.seq_create_info->used_fields|= seq_field_used_min_value; Lex->create_info.seq_create_info->used_fields|= seq_field_used_min_value;
Lex->create_info.seq_create_info->used_fields|= seq_field_specified_min_value;
} }
| NO_SYM MINVALUE_SYM | NO_SYM MINVALUE_SYM
{ {
...@@ -2669,6 +2680,7 @@ sequence_def: ...@@ -2669,6 +2680,7 @@ sequence_def:
else else
Lex->create_info.seq_create_info->max_value= (longlong) $3; Lex->create_info.seq_create_info->max_value= (longlong) $3;
Lex->create_info.seq_create_info->used_fields|= seq_field_used_max_value; Lex->create_info.seq_create_info->used_fields|= seq_field_used_max_value;
Lex->create_info.seq_create_info->used_fields|= seq_field_specified_max_value;
} }
| MAXVALUE_SYM opt_equal minus_ulonglong_num | MAXVALUE_SYM opt_equal minus_ulonglong_num
{ {
...@@ -2680,6 +2692,7 @@ sequence_def: ...@@ -2680,6 +2692,7 @@ sequence_def:
else else
Lex->create_info.seq_create_info->max_value= - (longlong) $3; Lex->create_info.seq_create_info->max_value= - (longlong) $3;
Lex->create_info.seq_create_info->used_fields|= seq_field_used_max_value; Lex->create_info.seq_create_info->used_fields|= seq_field_used_max_value;
Lex->create_info.seq_create_info->used_fields|= seq_field_specified_max_value;
} }
| MAXVALUE_SYM opt_equal DECIMAL_NUM | MAXVALUE_SYM opt_equal DECIMAL_NUM
{ {
...@@ -2688,6 +2701,7 @@ sequence_def: ...@@ -2688,6 +2701,7 @@ sequence_def:
my_yyabort_error((ER_DUP_ARGUMENT, MYF(0), "MAXVALUE")); my_yyabort_error((ER_DUP_ARGUMENT, MYF(0), "MAXVALUE"));
Lex->create_info.seq_create_info->max_value= LONGLONG_MAX; Lex->create_info.seq_create_info->max_value= LONGLONG_MAX;
Lex->create_info.seq_create_info->used_fields|= seq_field_used_max_value; Lex->create_info.seq_create_info->used_fields|= seq_field_used_max_value;
Lex->create_info.seq_create_info->used_fields|= seq_field_specified_max_value;
} }
| MAXVALUE_SYM opt_equal '-' DECIMAL_NUM | MAXVALUE_SYM opt_equal '-' DECIMAL_NUM
{ {
...@@ -2696,6 +2710,7 @@ sequence_def: ...@@ -2696,6 +2710,7 @@ sequence_def:
my_yyabort_error((ER_DUP_ARGUMENT, MYF(0), "MAXVALUE")); my_yyabort_error((ER_DUP_ARGUMENT, MYF(0), "MAXVALUE"));
Lex->create_info.seq_create_info->max_value= LONGLONG_MIN; Lex->create_info.seq_create_info->max_value= LONGLONG_MIN;
Lex->create_info.seq_create_info->used_fields|= seq_field_used_max_value; Lex->create_info.seq_create_info->used_fields|= seq_field_used_max_value;
Lex->create_info.seq_create_info->used_fields|= seq_field_specified_max_value;
} }
| NO_SYM MAXVALUE_SYM | NO_SYM MAXVALUE_SYM
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment