mirror of
https://github.com/MariaDB/server.git
synced 2025-05-29 21:42:28 +03:00
183 lines
4.2 KiB
Plaintext
183 lines
4.2 KiB
Plaintext
--source include/have_sequence.inc
|
|
--source include/have_innodb.inc
|
|
|
|
#
|
|
# Test various combinations of operations on sequence
|
|
#
|
|
|
|
--echo #
|
|
--echo # Create and check
|
|
--echo #
|
|
|
|
create sequence s1 engine=innodb;
|
|
check table s1;
|
|
select next value for s1;
|
|
flush tables;
|
|
check table s1;
|
|
select next value for s1;
|
|
flush tables;
|
|
repair table s1;
|
|
select next value for s1;
|
|
drop sequence s1;
|
|
|
|
create or replace sequence s1 engine=innodb;
|
|
select next value for s1;
|
|
repair table s1;
|
|
check table s1;
|
|
select next value for s1;
|
|
select * from s1;
|
|
drop sequence s1;
|
|
|
|
--echo #
|
|
--echo # INSERT
|
|
--echo #
|
|
|
|
create sequence s1;
|
|
create sequence s2;
|
|
--error ER_NO_DEFAULT_FOR_FIELD
|
|
insert into s1 (next_not_cached_value, minimum_value) values (100,1000);
|
|
--error ER_UPDATE_TABLE_USED
|
|
insert into s1 values (next value for s1, 1,9223372036854775806,1,1,1000,0,0);
|
|
--error ER_SEQUENCE_INVALID_DATA
|
|
insert into s1 values(1000,9223372036854775806,1,1,1,1000,0,0);
|
|
--error ER_SEQUENCE_INVALID_DATA
|
|
insert into s1 values(0,9223372036854775806,1,1,1,1000,0,0);
|
|
select * from s1;
|
|
insert into s1 values(1000,1,9223372036854775806,1,1,1000,0,0);
|
|
select * from s1;
|
|
select next value for s1;
|
|
select * from s1;
|
|
--error ER_SEQUENCE_INVALID_DATA
|
|
insert into s2 values(0, 1, 10, 1, 2, 1, 1, 0);
|
|
|
|
select * from s1;
|
|
insert into s1 values (next value for s2, 1,9223372036854775806,1,1,1000,0,0);
|
|
select * from s1;
|
|
select * from s2;
|
|
insert into s1 select * from s2;
|
|
select * from s1;
|
|
drop sequence s1,s2;
|
|
|
|
--echo #
|
|
--echo # UPDATE and DELETE
|
|
--echo #
|
|
|
|
create sequence s1;
|
|
--error ER_ILLEGAL_HA
|
|
update s1 set next_not_cached_value=100;
|
|
--error ER_ILLEGAL_HA
|
|
delete from s1 where next_not_cached_value > 0;
|
|
drop sequence s1;
|
|
|
|
--echo #
|
|
--echo # SHOW TABLES
|
|
--echo #
|
|
|
|
create sequence s1;
|
|
create table t1 (a int);
|
|
create view v1 as select * from s1;
|
|
show full tables;
|
|
SELECT TABLE_TYPE,ENGINE FROM INFORMATION_SCHEMA.TABLES where table_schema="test" ORDER BY TABLE_NAME;
|
|
drop table t1,s1;
|
|
drop view v1;
|
|
|
|
--echo #
|
|
--echo # LOCK TABLES (as in mysqldump)
|
|
--echo #
|
|
|
|
create sequence s1 engine=innodb;
|
|
LOCK TABLES s1 READ;
|
|
SELECT * from s1;
|
|
UNLOCK TABLES;
|
|
LOCK TABLES s1 WRITE;
|
|
insert into s1 values (1,1,9223372036854775806, 1, 1, 1000, 0, 0);
|
|
UNLOCK TABLES;
|
|
drop table s1;
|
|
|
|
--echo #
|
|
--echo # Many sequence calls with innodb
|
|
--echo #
|
|
|
|
create sequence s1 cache=1000 engine=innodb;
|
|
start transaction;
|
|
select count(nextval(s1)) from seq_1_to_2000;
|
|
commit;
|
|
select * from s1;
|
|
drop sequence s1;
|
|
|
|
create sequence s1 cache=1000 engine=innodb;
|
|
start transaction;
|
|
select count(nextval(s1)) from seq_1_to_2000;
|
|
|
|
connect (addconroot, localhost, root,,);
|
|
connection addconroot;
|
|
start transaction;
|
|
select count(nextval(s1)) from seq_1_to_2000;
|
|
select * from s1;
|
|
commit;
|
|
disconnect addconroot;
|
|
connection default;
|
|
select * from s1;
|
|
commit;
|
|
drop sequence s1;
|
|
|
|
--echo #
|
|
--echo # Flush tables with read lock
|
|
--echo #
|
|
|
|
create sequence s1;
|
|
select next value for s1;
|
|
flush tables with read lock;
|
|
--error 1223
|
|
create sequence s2;
|
|
--error 1223
|
|
select next value for s1;
|
|
unlock tables;
|
|
drop sequence s1;
|
|
|
|
--echo #
|
|
--echo # MDEV-14761
|
|
--echo # Assertion `!mysql_parse_status || thd->is_error() ||
|
|
--echo # thd->get_internal_handler()' failed in parse_sql
|
|
--echo #
|
|
|
|
CREATE SEQUENCE s1;
|
|
--error ER_DUP_ARGUMENT
|
|
ALTER SEQUENCE s1 MAXVALUE 100 NO MAXVALUE;
|
|
DROP SEQUENCE s1;
|
|
|
|
--echo #
|
|
--echo # Don't allow SEQUENCE to be used with CHECK or virtual fields
|
|
--echo #
|
|
|
|
CREATE SEQUENCE s1 nocache engine=myisam;
|
|
--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
|
CREATE table t1 (a int check (next value for s1 > 0));
|
|
--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
|
CREATE table t1 (a int check (previous value for s1 > 0));
|
|
--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
|
CREATE table t1 (a int check (setval(s1,10)));
|
|
--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
|
CREATE TABLE t1 (a int, b int as (next value for s1 > 0));
|
|
drop sequence s1;
|
|
|
|
|
|
--echo #
|
|
--echo # MDEV-13024: Server crashes in my_store_ptr upon DELETE from
|
|
--echo # sequence in multi-table format
|
|
--echo #
|
|
CREATE SEQUENCE s;
|
|
CREATE table t1 (a int);
|
|
insert into t1 values (1),(2);
|
|
--error ER_ILLEGAL_HA
|
|
DELETE s FROM s;
|
|
--error ER_ILLEGAL_HA
|
|
delete t1,s from s,t1;
|
|
--error ER_ILLEGAL_HA
|
|
delete s,t1 from t1,s;
|
|
DROP SEQUENCE s;
|
|
DROP TABLE t1;
|
|
|
|
|
|
--echo # End of 10.3 tests
|