mirror of
				https://github.com/MariaDB/server.git
				synced 2025-10-31 19:06:14 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			789 lines
		
	
	
	
		
			23 KiB
		
	
	
	
		
			Text
		
	
	
	
	
	
			
		
		
	
	
			789 lines
		
	
	
	
		
			23 KiB
		
	
	
	
		
			Text
		
	
	
	
	
	
| #
 | |
| # Test create options with sequences
 | |
| #
 | |
| --source include/have_innodb.inc
 | |
| --source include/have_archive.inc
 | |
| 
 | |
| drop table if exists t1;
 | |
| 
 | |
| #
 | |
| # Check some sample engines
 | |
| #
 | |
| 
 | |
| create or replace sequence t1 engine=myisam;
 | |
| show create sequence t1;
 | |
| show create table t1;
 | |
| select * from t1;
 | |
| create or replace sequence t1 engine=innodb;
 | |
| show create sequence t1;
 | |
| show create table t1;
 | |
| select * from t1;
 | |
| create or replace sequence t1 engine=maria;
 | |
| show create sequence t1;
 | |
| show create table t1;
 | |
| select * from t1;
 | |
| --error ER_ILLEGAL_HA_CREATE_OPTION
 | |
| create or replace sequence t1 engine=archive;
 | |
| #
 | |
| # The following error should be fixed. We shouldn't delete old table on errors
 | |
| #
 | |
| --error ER_NO_SUCH_TABLE
 | |
| show create table t1;
 | |
| 
 | |
| 
 | |
| # Check start values
 | |
| create or replace sequence t1 start with 10;
 | |
| show create sequence t1;
 | |
| select * from t1;
 | |
| create or replace sequence t1 minvalue=11;
 | |
| show create sequence t1;
 | |
| select * from t1;
 | |
| create or replace sequence t1 maxvalue=13 increment by -1;
 | |
| show create sequence t1;
 | |
| select * from t1;
 | |
| 
 | |
| create or replace sequence t1 increment by -1 cache 100;
 | |
| show create sequence t1;
 | |
| select * from t1;
 | |
| create or replace sequence t1 cycle;
 | |
| show create sequence t1;
 | |
| select * from t1;
 | |
| create or replace sequence t1 nocycle;
 | |
| show create sequence t1;
 | |
| select * from t1;
 | |
| show create sequence t1;
 | |
| create or replace sequence t1 cycle minvalue= 14;
 | |
| show create sequence t1;
 | |
| select * from t1;
 | |
| create or replace sequence t1 cycle increment by -1;
 | |
| show create sequence t1;
 | |
| 
 | |
| drop sequence t1;
 | |
| create sequence if not exists t1;
 | |
| create sequence if not exists t1 start with 10;
 | |
| select * from t1;
 | |
| show create sequence t1;
 | |
| 
 | |
| create or replace sequence t1 start with 10 minvalue=10 maxvalue=11 nocache cycle;
 | |
| show create sequence t1;
 | |
| select * from t1;
 | |
| create or replace sequence t1 start with 10 minvalue=-10 maxvalue=11 cache=10 cycle increment by 10;
 | |
| show create sequence t1;
 | |
| select * from t1;
 | |
| 
 | |
| # NO MINVALUE, NO MAXVALUE
 | |
| create or replace sequence t1 start with 10 NO MAXVALUE NO MINVALUE;
 | |
| 
 | |
| # Some edge cases
 | |
| 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 maxvalue 11 cycle;
 | |
| create or replace sequence t1 start with 10 maxvalue=9223372036854775806;
 | |
| create or replace sequence t1 start with 10 minvalue=-9223372036854775807;
 | |
| drop sequence if exists t1;
 | |
| 
 | |
| create sequence t1 increment by 0;
 | |
| show create sequence t1;
 | |
| select * from t1;
 | |
| drop sequence t1;
 | |
| 
 | |
| #
 | |
| # Wrong usage and arguments to create sequence
 | |
| #
 | |
| 
 | |
| create table t1 (a int);
 | |
| --error ER_NOT_SEQUENCE
 | |
| show create sequence t1;
 | |
| --error ER_NOT_SEQUENCE2
 | |
| drop sequence t1;
 | |
| drop sequence if exists t1;
 | |
| 
 | |
| --error ER_SEQUENCE_INVALID_DATA
 | |
| create sequence t1 start with 10 maxvalue=9;
 | |
| --error ER_SEQUENCE_INVALID_DATA
 | |
| create sequence t1 minvalue= 100 maxvalue=10;
 | |
| --error ER_SEQUENCE_INVALID_DATA
 | |
| create sequence t1 start with 9 minvalue=10;
 | |
| --error ER_PARSE_ERROR
 | |
| create or replace sequence t1 maxvalue=13, increment by -1;
 | |
| --error ER_PARSE_ERROR
 | |
| create or replace sequence t1 start with= 10 maxvalue=13;
 | |
| --error ER_PARSE_ERROR
 | |
| create or replace sequence t1 maxvalue=13, increment= -1;
 | |
| --error ER_PARSE_ERROR
 | |
| create or replace sequence t1 start with 10 min_value=1 NO MINVALUE;
 | |
| --error ER_PARSE_ERROR
 | |
| create or replace sequence t1 start with 10 min_value=1 NO MINVALUE;
 | |
| --error ER_PARSE_ERROR
 | |
| create sequence t1 RESTART WITH 10;
 | |
| --error ER_DUP_ARGUMENT
 | |
| create or replace sequence t1 start with 10 NO MINVALUE minvalue=1;
 | |
| # hidden constraints cache < (LONGLONG_MAX - max_increment) / max_increment
 | |
| --error ER_SEQUENCE_INVALID_DATA
 | |
| create sequence s increment by 3234567890123456789;
 | |
| 
 | |
| #
 | |
| # Test with LIST COLUMNS as first command
 | |
| #
 | |
| create or replace sequence t1;
 | |
| show fields from t1;
 | |
| flush tables;
 | |
| show fields from t1;
 | |
| create or replace sequence t1 engine=aria;
 | |
| show fields from t1;
 | |
| show fields from t1;
 | |
| flush tables;
 | |
| 
 | |
| #
 | |
| # Test with other create options
 | |
| #
 | |
| 
 | |
| create or replace sequence t1 comment= "test 1";
 | |
| show create sequence t1;
 | |
| show create table t1;
 | |
| create or replace sequence t1 comment= "test 2" min_rows=1 max_rows=2;
 | |
| show create sequence t1;
 | |
| show create table t1;
 | |
| create or replace sequence t1 start=1 increment= 2;
 | |
| create or replace sequence t1 start 1 increment 2;
 | |
| create or replace sequence t1 cache +1;
 | |
| drop sequence t1;
 | |
| 
 | |
| #
 | |
| # test with create table
 | |
| #
 | |
| 
 | |
| CREATE TABLE t1 (
 | |
|   `next_not_cached_value` bigint(21) NOT NULL,
 | |
|   `minimum_value` bigint(21) NOT NULL,
 | |
|   `maximum_value` bigint(21) NOT NULL,
 | |
|   `start_value` bigint(21) NOT NULL,
 | |
|   `increment` bigint(21) NOT NULL,
 | |
|   `cache_size` bigint(21) unsigned NOT NULL,
 | |
|   `cycle_option` tinyint(1) unsigned NOT NULL,
 | |
|   `cycle_count` bigint(21) NOT NULL
 | |
| ) sequence=1;
 | |
| 
 | |
| show create sequence t1;
 | |
| show create table t1;
 | |
| drop sequence t1;
 | |
| 
 | |
| # Wrong column name
 | |
| 
 | |
| --error ER_SEQUENCE_INVALID_TABLE_STRUCTURE
 | |
| CREATE OR REPLACE TABLE t1 (
 | |
|   `next_not_cached_value` bigint(21) NOT NULL,
 | |
|   `minimum_value` bigint(21) NOT NULL,
 | |
|   `maximum_value` bigint(21) NOT NULL,
 | |
|   `start_value` bigint(21) NOT NULL,
 | |
|   `increment` bigint(21) NOT NULL,
 | |
|   `cache_size` bigint(21) unsigned NOT NULL,
 | |
|   `cycle_option` tinyint(1) unsigned NOT NULL,
 | |
|   `cycle_count_not_exists` bigint(21) NOT NULL
 | |
| ) sequence=1;
 | |
| 
 | |
| # Wrong type
 | |
| 
 | |
| --error ER_SEQUENCE_INVALID_TABLE_STRUCTURE
 | |
| CREATE OR REPLACE TABLE t1 (
 | |
|   `next_not_cached_value` int(21) NOT NULL,
 | |
|   `minimum_value` bigint(21) NOT NULL,
 | |
|   `maximum_value` bigint(21) NOT NULL,
 | |
|   `start_value` bigint(21) NOT NULL,
 | |
|   `increment` bigint(21) NOT NULL,
 | |
|   `cache_size` bigint(21) unsigned NOT NULL,
 | |
|   `cycle_option` tinyint(1) unsigned NOT NULL,
 | |
|   `cycle_count` bigint(21) NOT NULL
 | |
| ) sequence=1;
 | |
| 
 | |
| --error ER_SEQUENCE_INVALID_TABLE_STRUCTURE
 | |
| CREATE OR REPLACE TABLE t1 (
 | |
|   `next_not_cached_value` bigint(21) NOT NULL,
 | |
|   `minimum_value` bigint(21) NOT NULL,
 | |
|   `maximum_value` bigint(21) NOT NULL,
 | |
|   `start_value` bigint(21) NOT NULL,
 | |
|   `increment` bigint(21) NOT NULL,
 | |
|   `cache_size` bigint(21) unsigned NOT NULL,
 | |
|   `cycle` bigint(21) unsigned NOT NULL, /* error */
 | |
|   `cycle_count` bigint(21) NOT NULL
 | |
| ) sequence=1;
 | |
| 
 | |
| 
 | |
| # Missing NOT NULL
 | |
| 
 | |
| --error ER_SEQUENCE_INVALID_TABLE_STRUCTURE
 | |
| CREATE OR REPLACE TABLE t1 (
 | |
|   `next_not_cached_value` bigint(21), /* error */
 | |
|   `minimum_value` bigint(21) NOT NULL,
 | |
|   `maximum_value` bigint(21) NOT NULL,
 | |
|   `start_value` bigint(21) NOT NULL,
 | |
|   `increment` bigint(21) NOT NULL,
 | |
|   `cache_size` bigint(21) unsigned NOT NULL,
 | |
|   `cycle_option` tinyint(1) unsigned NOT NULL,
 | |
|   `cycle_count` bigint(21) NOT NULL
 | |
| ) sequence=1;
 | |
| 
 | |
| # Extra field
 | |
| 
 | |
| --error ER_SEQUENCE_INVALID_TABLE_STRUCTURE
 | |
| CREATE OR REPLACE TABLE t1 (
 | |
|   `next_not_cached_value` bigint(21) NOT NULL,
 | |
|   `minimum_value` bigint(21) NOT NULL,
 | |
|   `maximum_value` bigint(21) NOT NULL,
 | |
|   `start_value` bigint(21) NOT NULL,
 | |
|   `increment` bigint(21) NOT NULL,
 | |
|   `cache_size` bigint(21) unsigned NOT NULL,
 | |
|   `cycle_option` tinyint(1) unsigned NOT NULL,
 | |
|   `cycle_count` bigint(21) NOT NULL,
 | |
|   extra_field bigint(21)
 | |
| ) sequence=1;
 | |
| 
 | |
| # Wrong field order
 | |
| 
 | |
| --error ER_SEQUENCE_INVALID_TABLE_STRUCTURE
 | |
| CREATE OR REPLACE TABLE t1 (
 | |
|   `minimum_value` bigint(21) NOT NULL,
 | |
|   `next_not_cached_value` bigint(21) NOT NULL,
 | |
|   `maximum_value` bigint(21) NOT NULL,
 | |
|   `start_value` bigint(21) NOT NULL,
 | |
|   `increment` bigint(21) NOT NULL,
 | |
|   `cache_size` bigint(21) unsigned NOT NULL,
 | |
|   `cycle_option` tinyint(1) unsigned NOT NULL,
 | |
|   `cycle_count` bigint(21) NOT NULL
 | |
| ) sequence=1;
 | |
| 
 | |
| # key
 | |
| 
 | |
| --error ER_SEQUENCE_INVALID_TABLE_STRUCTURE
 | |
| CREATE OR REPLACE TABLE t1 (
 | |
|   `next_not_cached_value` bigint(21) NOT NULL,
 | |
|   `minimum_value` bigint(21) NOT NULL,
 | |
|   `maximum_value` bigint(21) NOT NULL,
 | |
|   `start_value` bigint(21) NOT NULL,
 | |
|   `increment` bigint(21) NOT NULL,
 | |
|   `cache_size` bigint(21) unsigned NOT NULL,
 | |
|   `cycle_option` tinyint(1) unsigned NOT NULL,
 | |
|   `cycle_count` bigint(21) NOT NULL,
 | |
|   key key1 (next_not_cached_value)
 | |
| ) sequence=1;
 | |
| 
 | |
| # Check constraint
 | |
| 
 | |
| --error ER_SEQUENCE_INVALID_TABLE_STRUCTURE
 | |
| CREATE TABLE t1 (
 | |
|   `next_not_cached_value` bigint(21) NOT NULL,
 | |
|   `minimum_value` bigint(21) NOT NULL,
 | |
|   `maximum_value` bigint(21) NOT NULL,
 | |
|   `start_value` bigint(21) NOT NULL,
 | |
|   `increment` bigint(21) NOT NULL,
 | |
|   `cache_size` bigint(21) unsigned NOT NULL,
 | |
|   `cycle_option` tinyint(1) unsigned NOT NULL,
 | |
|   `cycle_count` bigint(21) NOT NULL,
 | |
|   CHECK (start_value < minimum_value)
 | |
| ) sequence=1;
 | |
| 
 | |
| --error ER_SEQUENCE_INVALID_TABLE_STRUCTURE
 | |
| CREATE TABLE t1 (
 | |
|   `next_not_cached_value` bigint(21) NOT NULL,
 | |
|   `minimum_value` bigint(21) NOT NULL,
 | |
|   `maximum_value` bigint(21) NOT NULL,
 | |
|   `start_value` bigint(21) NOT NULL CHECK (start_value < minimum_value),
 | |
|   `increment` bigint(21) NOT NULL,
 | |
|   `cache_size` bigint(21) unsigned NOT NULL,
 | |
|   `cycle_option` tinyint(1) unsigned NOT NULL,
 | |
|   `cycle_count` bigint(21) NOT NULL
 | |
| ) sequence=1;
 | |
| 
 | |
| 
 | |
| # Virtual field
 | |
| 
 | |
| --error ER_SEQUENCE_INVALID_TABLE_STRUCTURE
 | |
| CREATE TABLE t1 (
 | |
|   `next_not_cached_value` bigint(21) NOT NULL,
 | |
|   `minimum_value` bigint(21) NOT NULL,
 | |
|   `maximum_value` bigint(21) NOT NULL,
 | |
|   `start_value` bigint(21) NOT NULL,
 | |
|   `increment` bigint(21) NOT NULL,
 | |
|   `cache_size` bigint(21) unsigned NOT NULL,
 | |
|   `cycle_option` tinyint(1) unsigned NOT NULL,
 | |
|   `cycle_count` bigint(21) generated always as (1) virtual
 | |
| ) sequence=1;
 | |
| 
 | |
| drop sequence if exists t1;
 | |
| 
 | |
| #
 | |
| # DROP SEQUENCE
 | |
| #
 | |
| 
 | |
| create sequence t1;
 | |
| create sequence t2;
 | |
| create table t3 (a int) engine=myisam;
 | |
| select table_catalog, table_schema, table_name, table_type from information_schema.tables where table_catalog="test";
 | |
| 
 | |
| CREATE SEQUENCE s1;
 | |
| drop sequence s1;
 | |
| 
 | |
| drop sequence if exists t1,t2,t3,t4;
 | |
| drop table if exists t1,t2,t3;
 | |
| 
 | |
| CREATE TABLE t1 (a int);
 | |
| CREATE TABLE t2 (a int);
 | |
| CREATE SEQUENCE s1;
 | |
| drop table t1,t2,s1;
 | |
| 
 | |
| CREATE TABLE t1 (a int);
 | |
| CREATE TABLE t2 (a int);
 | |
| CREATE SEQUENCE s1;
 | |
| drop table if exists t1,t2,s1,s2;
 | |
| 
 | |
| CREATE TABLE t1 (a int);
 | |
| CREATE TABLE t2 (a int);
 | |
| CREATE SEQUENCE s1;
 | |
| --error ER_NOT_SEQUENCE2
 | |
| drop sequence t1,t2,s1,s2;
 | |
| drop table if exists t1,t2;
 | |
| 
 | |
| CREATE TABLE t1 (a int);
 | |
| CREATE TABLE t2 (a int);
 | |
| CREATE SEQUENCE s1;
 | |
| drop sequence if exists t1,t2,s1,s2;
 | |
| drop table if exists t1,t2;
 | |
| 
 | |
| CREATE TEMPORARY SEQUENCE s1;
 | |
| DROP SEQUENCE s1;
 | |
| --error ER_UNKNOWN_SEQUENCES
 | |
| DROP TEMPORARY SEQUENCE s1;
 | |
| 
 | |
| CREATE TEMPORARY SEQUENCE s1;
 | |
| CREATE SEQUENCE s2;
 | |
| CREATE TEMPORARY TABLE t1 (a int);
 | |
| CREATE TABLE t2 (a int);
 | |
| --error ER_UNKNOWN_SEQUENCES
 | |
| DROP TEMPORARY SEQUENCE t1,t2,s1,s2;
 | |
| --error ER_UNKNOWN_SEQUENCES
 | |
| DROP TEMPORARY SEQUENCE s1;
 | |
| DROP TEMPORARY TABLE t1;
 | |
| --error ER_BAD_TABLE_ERROR
 | |
| DROP TABLE t1,t2,s1,s2;
 | |
| 
 | |
| create view v1 as (select 1);
 | |
| CREATE SEQUENCE s1;
 | |
| --error ER_IT_IS_A_VIEW
 | |
| DROP SEQUENCE s1,v1;
 | |
| drop view v1;
 | |
| 
 | |
| #
 | |
| # CREATE TEMPORARY SEQUENCE
 | |
| #
 | |
| 
 | |
| --disable_ps2_protocol
 | |
| CREATE TEMPORARY SEQUENCE t1;
 | |
| select next value for t1;
 | |
| drop temporary table t1;
 | |
| --error ER_UNKNOWN_SEQUENCES
 | |
| select previous value for t1;
 | |
| CREATE SEQUENCE t1 start with 1 minvalue 1 maxvalue 10 increment by 1 cache 10;
 | |
| select next value for t1;
 | |
| select previous value for t1;
 | |
| CREATE TEMPORARY SEQUENCE t1 start with 100 minvalue 100 maxvalue 200 increment by 1 cache 10;
 | |
| select previous value for t1;
 | |
| select next value for t1;
 | |
| select previous value for t1;
 | |
| drop temporary sequence t1;
 | |
| select previous value for t1;
 | |
| drop sequence t1;
 | |
| 
 | |
| CREATE TEMPORARY SEQUENCE t1 engine=innodb;
 | |
| select next value for t1;
 | |
| drop temporary table t1;
 | |
| --error ER_UNKNOWN_SEQUENCES
 | |
| select previous value for t1;
 | |
| CREATE SEQUENCE t1 start with 1 minvalue 1 maxvalue 10 increment by 1 cache 10 engine=innodb;
 | |
| select next value for t1;
 | |
| select previous value for t1;
 | |
| CREATE TEMPORARY SEQUENCE t1 start with 100 minvalue 100 maxvalue 200 increment by 1 cache 10 engine=innodb;
 | |
| START TRANSACTION WITH CONSISTENT SNAPSHOT;
 | |
| select previous value for t1;
 | |
| select next value for t1;
 | |
| select previous value for t1;
 | |
| drop temporary sequence t1;
 | |
| select previous value for t1;
 | |
| drop sequence t1;
 | |
| --enable_ps2_protocol
 | |
| 
 | |
| #
 | |
| # Check that we can't create anything with the sequence engine
 | |
| #
 | |
| 
 | |
| --error ER_UNKNOWN_STORAGE_ENGINE
 | |
| create table t1 (a int) engine=sql_sequence;
 | |
| 
 | |
| --echo #
 | |
| --echo # MDEV-13711 assertion on CREATE LIKE fix
 | |
| --echo #
 | |
| 
 | |
| create sequence s;
 | |
| create table t like s;
 | |
| show create table t;
 | |
| show create sequence t;
 | |
| drop tables t, s;
 | |
| 
 | |
| --echo #
 | |
| --echo # MDEV-13714 SEQUENCE option fix
 | |
| --echo #
 | |
| 
 | |
| create or replace table s (
 | |
|   `next_value` bigint(21) not null,
 | |
|   `min_value` bigint(21) not null,
 | |
|   `max_value` bigint(21) not null,
 | |
|   `start` bigint(21) not null,
 | |
|   `increment` bigint(21) not null,
 | |
|   `cache` bigint(21) not null,
 | |
|   `cycle` tinyint(1) unsigned not null,
 | |
|   `round` bigint(21) not null)
 | |
| sequence=0;
 | |
| 
 | |
| create or replace table s2 (
 | |
|   `next_value` bigint(21) not null,
 | |
|   `min_value` bigint(21) not null,
 | |
|   `max_value` bigint(21) not null,
 | |
|   `start` bigint(21) not null,
 | |
|   `increment` bigint(21) not null,
 | |
|   `cache` bigint(21) not null,
 | |
|   `cycle` tinyint(1) unsigned not null,
 | |
|   `round` bigint(21) not null)
 | |
| sequence=default;
 | |
| 
 | |
| show create table s;
 | |
| show create table s2;
 | |
| --error ER_NOT_SEQUENCE
 | |
| show create sequence s;
 | |
| --error ER_NOT_SEQUENCE
 | |
| show create sequence s2;
 | |
| drop table s,s2;
 | |
| 
 | |
| --echo #
 | |
| --echo # MDEV-13721 Assertion is_lock_owner() failed in mysql_rm_table_no_locks
 | |
| --echo #
 | |
| 
 | |
| create or replace sequence s;
 | |
| create temporary table s (i int);
 | |
| drop sequence s;
 | |
| show create table s;
 | |
| drop table s;
 | |
| 
 | |
| create or replace sequence s;
 | |
| create temporary sequence s;
 | |
| show create table s;
 | |
| drop sequence s;
 | |
| show create table s;
 | |
| drop table s;
 | |
| 
 | |
| create or replace sequence s;
 | |
| create temporary sequence s;
 | |
| drop temporary sequence s;
 | |
| show create table s;
 | |
| drop table s;
 | |
| 
 | |
| create temporary sequence s;
 | |
| drop temporary table s;
 | |
| create temporary table s (i int);
 | |
| --error ER_UNKNOWN_SEQUENCES
 | |
| drop temporary sequence s;
 | |
| drop table s;
 | |
| 
 | |
| --echo #
 | |
| --echo # MDEV-15115 Assertion failure in CREATE SEQUENCE...ROW_FORMAT=REDUNDANT
 | |
| --echo #
 | |
| CREATE SEQUENCE seq1 ENGINE=InnoDB ROW_FORMAT=REDUNDANT;
 | |
| 
 | |
| --replace_column 1 # 5 #
 | |
| SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE NAME='test/seq1';
 | |
| 
 | |
| DROP SEQUENCE seq1;
 | |
| CREATE TEMPORARY SEQUENCE seq1 ENGINE=InnoDB ROW_FORMAT=REDUNDANT;
 | |
| DROP TEMPORARY SEQUENCE seq1;
 | |
| 
 | |
| --echo #
 | |
| --echo # MDEV-17503 CREATE SEQUENCE failed with innodb_force_primary_key =1
 | |
| --echo #
 | |
| 
 | |
| set global innodb_force_primary_key =1;
 | |
| CREATE SEQUENCE s1 START WITH 100 INCREMENT BY 10 ENGINE=innodb;
 | |
| set global innodb_force_primary_key=default;
 | |
| --error ER_SEQUENCE_INVALID_TABLE_STRUCTURE
 | |
| ALTER TABLE s1 ADD PRIMARY KEY (next_not_cached_value);
 | |
| DROP SEQUENCE s1;
 | |
| 
 | |
| --echo #
 | |
| --echo # Beginning of 10.4 Test
 | |
| --echo #
 | |
| --echo # MDEV-13005: Fixing bugs in SEQUENCE, part 3
 | |
| --echo #
 | |
| 
 | |
| --echo # Task 1:
 | |
| --error ER_UNKNOWN_SEQUENCES
 | |
| SET @x = PREVIOUS VALUE FOR x;
 | |
| 
 | |
| --echo # Task 2:
 | |
| --error ER_SEQUENCE_INVALID_DATA
 | |
| CREATE SEQUENCE x START WITH 1 INCREMENT BY 123456789012345678;
 | |
| 
 | |
| --echo # Task 3:
 | |
| --error ER_SEQUENCE_INVALID_DATA
 | |
| CREATE SEQUENCE seq1 START WITH 1 cache -1;
 | |
| 
 | |
| --echo # Task 4:
 | |
| CREATE TEMPORARY TABLE s1 (s1 INT);
 | |
| --error ER_UNKNOWN_SEQUENCES
 | |
| DROP TEMPORARY SEQUENCE s1;
 | |
| DROP TEMPORARY TABLE s1;
 | |
| 
 | |
| --echo # Task 5:
 | |
| CREATE TEMPORARY TABLE s1 (s1 INT);
 | |
| --error ER_PARSE_ERROR
 | |
| CREATE TEMPORARY SEQUENCE s1 (s1 INT);
 | |
| DROP TEMPORARY TABLE s1;
 | |
| 
 | |
| --echo # Task 6:
 | |
| CREATE SEQUENCE seq1 START WITH 2;
 | |
| --error ER_TRG_ON_VIEW_OR_TEMP_TABLE
 | |
| CREATE TRIGGER s1 BEFORE UPDATE ON seq1 FOR EACH ROW SET @a= 5;
 | |
| DROP SEQUENCE seq1;
 | |
| 
 | |
| --echo #
 | |
| --echo # MDEV-29771: Server crashes in check_sequence_fields upon
 | |
| --echo # CREATE TABLE .. SEQUENCE=1 AS SELECT ..
 | |
| --echo #
 | |
| 
 | |
| --error ER_SEQUENCE_INVALID_TABLE_STRUCTURE
 | |
| create table s sequence=1 as select 1;
 | |
| 
 | |
| --echo #
 | |
| --echo # End of 10.4 test
 | |
| --echo #
 | |
| 
 | |
| --echo #
 | |
| --echo # Ensure that SHOW CREATE TABLE shows used table options
 | |
| --echo #
 | |
| 
 | |
| SET @@innodb_compression_default=ON;
 | |
| CREATE TABLE seq (
 | |
|   `next_not_cached_value` bigint(21) NOT NULL,
 | |
|   `minimum_value` bigint(21) NOT NULL,
 | |
|   `maximum_value` bigint(21) NOT NULL,
 | |
|   `start_value` bigint(21) NOT NULL,
 | |
|   `increment` bigint(21) NOT NULL,
 | |
|   `cache_size` bigint(21) unsigned NOT NULL,
 | |
|   `cycle_option` tinyint(1) unsigned NOT NULL,
 | |
|   `cycle_count` bigint(21) NOT NULL
 | |
| ) engine=innodb,sequence=1;
 | |
| show create sequence seq;
 | |
| show create table seq;
 | |
| drop sequence seq;
 | |
| SET @@innodb_compression_default=DEFAULT;
 | |
| 
 | |
| --echo ######
 | |
| --echo # MDEV-28152 Features for sequence
 | |
| --echo ######
 | |
| 
 | |
| --echo # -----
 | |
| --echo # Truncating out-of-bound numbers for minvalue and maxvalue
 | |
| --echo # -----
 | |
| --disable_ps_protocol
 | |
| create or replace sequence t1 minvalue -999999999999999999999;
 | |
| show create sequence t1;
 | |
| create or replace sequence t1 minvalue -9223372036854775808;
 | |
| show create sequence t1;
 | |
| create or replace sequence t1 minvalue -9223372036854775807;
 | |
| show create sequence t1;
 | |
| create or replace sequence t1 minvalue 9223372036854775805;
 | |
| show create sequence t1;
 | |
| --error ER_SEQUENCE_INVALID_DATA
 | |
| create or replace sequence t1 minvalue 9223372036854775806;
 | |
| --error ER_SEQUENCE_INVALID_DATA
 | |
| create or replace sequence t1 minvalue 9223372036854775807;
 | |
| --error ER_SEQUENCE_INVALID_DATA
 | |
| create or replace sequence t1 minvalue 9223372036854775808;
 | |
| --error ER_SEQUENCE_INVALID_DATA
 | |
| create or replace sequence t1 minvalue 9999999999999999999999;
 | |
| --error ER_SEQUENCE_INVALID_DATA
 | |
| create or replace sequence t1 maxvalue -999999999999999999999 increment by -1;
 | |
| --error ER_SEQUENCE_INVALID_DATA
 | |
| create or replace sequence t1 maxvalue -9223372036854775808 increment by -1;
 | |
| --error ER_SEQUENCE_INVALID_DATA
 | |
| create or replace sequence t1 maxvalue -9223372036854775807 increment by -1;
 | |
| create or replace sequence t1 maxvalue -9223372036854775806 increment by -1;
 | |
| show create sequence t1;
 | |
| create or replace sequence t1 maxvalue 9223372036854775806;
 | |
| show create sequence t1;
 | |
| create or replace sequence t1 maxvalue 9223372036854775807;
 | |
| show create sequence t1;
 | |
| create or replace sequence t1 maxvalue 9223372036854775808;
 | |
| show create sequence t1;
 | |
| create or replace sequence t1 maxvalue 9999999999999999999999;
 | |
| show create sequence t1;
 | |
| --enable_ps_protocol
 | |
| 
 | |
| --echo # -----
 | |
| --echo # Create with value types
 | |
| --echo # -----
 | |
| create or replace sequence t1 as tinyint;
 | |
| show create sequence t1;
 | |
| show create table t1;
 | |
| create or replace sequence t1 as smallint;
 | |
| show create sequence t1;
 | |
| show create table t1;
 | |
| create or replace sequence t1 as mediumint;
 | |
| show create sequence t1;
 | |
| show create table t1;
 | |
| create or replace sequence t1 as int;
 | |
| show create sequence t1;
 | |
| show create table t1;
 | |
| create or replace sequence t1 as bigint;
 | |
| show create sequence t1;
 | |
| show create table t1;
 | |
| create or replace sequence t1 as tinyint unsigned;
 | |
| show create sequence t1;
 | |
| show create table t1;
 | |
| create or replace sequence t1 as smallint unsigned;
 | |
| show create sequence t1;
 | |
| show create table t1;
 | |
| create or replace sequence t1 as mediumint unsigned;
 | |
| show create sequence t1;
 | |
| show create table t1;
 | |
| create or replace sequence t1 as int unsigned;
 | |
| show create sequence t1;
 | |
| show create table t1;
 | |
| create or replace sequence t1 as bigint unsigned;
 | |
| show create sequence t1;
 | |
| show create table t1;
 | |
| create or replace sequence t1 increment -1 as tinyint;
 | |
| show create sequence t1;
 | |
| show create table t1;
 | |
| create or replace sequence t1 increment -1 as smallint;
 | |
| show create sequence t1;
 | |
| show create table t1;
 | |
| create or replace sequence t1 increment -1 as mediumint;
 | |
| show create sequence t1;
 | |
| show create table t1;
 | |
| create or replace sequence t1 increment -1 as int;
 | |
| show create sequence t1;
 | |
| show create table t1;
 | |
| create or replace sequence t1 increment -1 as bigint;
 | |
| show create sequence t1;
 | |
| show create table t1;
 | |
| create or replace sequence t1 increment -1 as tinyint unsigned;
 | |
| show create sequence t1;
 | |
| show create table t1;
 | |
| create or replace sequence t1 increment -1 as smallint unsigned;
 | |
| show create sequence t1;
 | |
| show create table t1;
 | |
| create or replace sequence t1 increment -1 as mediumint unsigned;
 | |
| show create sequence t1;
 | |
| show create table t1;
 | |
| create or replace sequence t1 increment -1 as int unsigned;
 | |
| show create sequence t1;
 | |
| show create table t1;
 | |
| create or replace sequence t1 increment -1 as bigint unsigned;
 | |
| show create sequence t1;
 | |
| show create table t1;
 | |
| 
 | |
| #zerofill is not supported
 | |
| --error ER_BAD_OPTION_VALUE
 | |
| create or replace sequence t1 as tinyint zerofill;
 | |
| 
 | |
| #start with a number between longlong_max and ulonglong_max
 | |
| create or replace sequence t1 as bigint unsigned start with 12345678901234567890;
 | |
| show create sequence t1;
 | |
| show create table t1;
 | |
| 
 | |
| # hidden constraints cache < (LONGLONG_MAX - max_increment) / max_increment
 | |
| --error ER_SEQUENCE_INVALID_DATA
 | |
| create or replace sequence t1 as bigint unsigned increment 12345678901234567;
 | |
| 
 | |
| --echo # -----
 | |
| --echo # value types + truncating
 | |
| --echo # -----
 | |
| --disable_ps_protocol
 | |
| create or replace sequence t1 minvalue -23 maxvalue 9999 as tinyint unsigned;
 | |
| show create sequence t1;
 | |
| show create table t1;
 | |
| create or replace sequence t1 minvalue -32768 maxvalue 32767 as smallint;
 | |
| show create sequence t1;
 | |
| show create table t1;
 | |
| create or replace sequence t1 minvalue 0 maxvalue 65535 as smallint unsigned;
 | |
| show create sequence t1;
 | |
| show create table t1;
 | |
| create or replace sequence t1 minvalue -12345678901234 as mediumint unsigned maxvalue 12345678901234;
 | |
| show create sequence t1;
 | |
| show create table t1;
 | |
| create or replace sequence t1 as bigint unsigned minvalue -12345678901234 maxvalue 12345678901234;
 | |
| show create sequence t1;
 | |
| show create table t1;
 | |
| --enable_ps_protocol
 | |
| 
 | |
| --echo # -----
 | |
| --echo # indistinguishable values during parsing if we did not pass back Longlong_hybrid from the parser.
 | |
| --echo # -----
 | |
| #signed, -1: no truncation. Note that we need a negative increment because this is a nagative sequence
 | |
| create or replace sequence t1 as bigint maxvalue -1 increment by -1;
 | |
| show create sequence t1;
 | |
| show create table t1;
 | |
| --disable_ps_protocol
 | |
| #signed, ulonglong_max: truncating to longlong_max-1
 | |
| create or replace sequence t1 as bigint maxvalue 18446744073709551615;
 | |
| show create sequence t1;
 | |
| show create table t1;
 | |
| #unsigned, -1: truncation and invalid data (max_value truncated to 1 which is equal to min_value)
 | |
| --error ER_SEQUENCE_INVALID_DATA
 | |
| create or replace sequence t1 as bigint unsigned maxvalue -1;
 | |
| #unsigned, ulonglong_max: truncating to ulonglong_max-1
 | |
| create or replace sequence t1 as bigint unsigned maxvalue 18446744073709551615;
 | |
| show create sequence t1;
 | |
| show create table t1;
 | |
| --enable_ps_protocol
 | |
| 
 | |
| --echo # -----
 | |
| --echo # value types + out of range start
 | |
| --echo # -----
 | |
| --error ER_PARSE_ERROR
 | |
| create or replace sequence t1 start with -123456789012345678901 as tinyint unsigned;
 | |
| --error ER_SEQUENCE_INVALID_DATA
 | |
| create or replace sequence t1 start with -1 as tinyint unsigned;
 | |
| --error ER_SEQUENCE_INVALID_DATA
 | |
| create or replace sequence t1 start with 0 as tinyint unsigned;
 | |
| show create sequence t1;
 | |
| create or replace sequence t1 start with 1 as tinyint unsigned;
 | |
| show create sequence t1;
 | |
| create or replace sequence t1 start with 254 as tinyint unsigned;
 | |
| --error ER_SEQUENCE_INVALID_DATA
 | |
| create or replace sequence t1 start with 255 as tinyint unsigned;
 | |
| --error ER_SEQUENCE_INVALID_DATA
 | |
| create or replace sequence t1 start with 256 as tinyint unsigned;
 | |
| --error ER_PARSE_ERROR
 | |
| create or replace sequence t1 start with 123456789012345678901 as tinyint unsigned;
 | |
| 
 | |
| drop sequence t1;
 | |
| 
 | |
| --echo # -----
 | |
| --echo # information_schema.sequences
 | |
| --echo # -----
 | |
| create sequence s1 as tinyint unsigned increment by 23;
 | |
| create sequence s2 start with 42 minvalue -9223372036854775807;
 | |
| create sequence s3 as bigint unsigned start with 12345678901234567890 cycle;
 | |
| #test support of all types in information schema
 | |
| create sequence s4 as tinyint;
 | |
| create sequence s5 as smallint;
 | |
| create sequence s6 as mediumint;
 | |
| create sequence s7 as int;
 | |
| create sequence s8 as bigint;
 | |
| create sequence s9 as tinyint unsigned;
 | |
| create sequence s10 as smallint unsigned;
 | |
| create sequence s11 as mediumint unsigned;
 | |
| create sequence s12 as int unsigned;
 | |
| create sequence s13 as bigint unsigned;
 | |
| select * from information_schema.sequences order by sequence_name;
 | |
| drop sequence s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13;
 | |
| 
 | |
| --echo # End of 11.5 tests
 | 
