mirror of
https://github.com/MariaDB/server.git
synced 2025-12-04 17:23:46 +03:00
233 lines
8.2 KiB
Plaintext
233 lines
8.2 KiB
Plaintext
--source include/have_partition.inc
|
|
|
|
# Test both myisam and innodb
|
|
--source suite/period/engines.inc
|
|
|
|
let $default_engine= `select @@default_storage_engine`;
|
|
|
|
create or replace table t(id int, s date, e date,
|
|
period for p(s,e),
|
|
primary key(id, p without overlaps)
|
|
) partition by key (id);
|
|
|
|
--replace_result $default_engine DEFAULT_ENGINE
|
|
show create table t;
|
|
|
|
|
|
insert into t values (1, '2003-01-01', '2003-03-01'),
|
|
(1, '2003-05-01', '2003-07-01');
|
|
|
|
--error ER_DUP_ENTRY
|
|
insert into t values (1, '2003-02-01', '2003-04-01');
|
|
--error ER_DUP_ENTRY
|
|
insert into t values (1, '2003-04-01', '2003-06-01');
|
|
--error ER_DUP_ENTRY
|
|
insert into t values (1, '2003-05-15', '2003-06-15');
|
|
--error ER_DUP_ENTRY
|
|
insert into t values (1, '2003-04-01', '2003-08-01');
|
|
|
|
insert into t values (1, '2003-03-01', '2003-05-01');
|
|
|
|
--echo # expand/shrink period
|
|
update t set s= '2002-12-01' where s = '2003-01-01';
|
|
update t set s= '2003-01-01' where s = '2002-12-01';
|
|
|
|
update t set e= '2003-08-01' where s = '2003-05-01';
|
|
update t set e= '2003-07-01' where s = '2003-05-01';
|
|
|
|
--echo # move left/right
|
|
update t set s= '2002-12-15', e= '2003-01-15' where s = '2003-01-01';
|
|
update t set s= '2003-01-01', e= '2003-02-01' where s = '2002-12-15';
|
|
|
|
--echo # diminish/enlarge
|
|
update t set s= '2003-01-10', e= '2003-01-20' where s = '2003-01-01';
|
|
update t set s= '2003-01-01', e= '2003-02-01' where s = '2003-01-10';
|
|
|
|
select * from t;
|
|
|
|
--echo # intersect left/right, strict inclusion/containment
|
|
--error ER_DUP_ENTRY
|
|
update t set e= '2003-04-01' where s = '2003-01-01';
|
|
--error ER_DUP_ENTRY
|
|
update t set s= '2003-04-01' where s = '2003-05-01';
|
|
--error ER_DUP_ENTRY
|
|
update t set s= '2003-03-10', e= '2003-03-20' where s = '2003-01-01';
|
|
--error ER_DUP_ENTRY
|
|
update t set s= '2003-04-01', e= '2003-08-01' where s = '2003-03-01';
|
|
|
|
--echo # inclusion/containment with partial match
|
|
--error ER_DUP_ENTRY
|
|
update t set s= '2003-03-01', e= '2003-04-01' where s = '2003-01-01';
|
|
--error ER_DUP_ENTRY
|
|
update t set s= '2003-04-01', e= '2003-05-01' where s = '2003-01-01';
|
|
--error ER_DUP_ENTRY
|
|
update t set s= '2003-03-01' where s = '2003-05-01';
|
|
--error ER_DUP_ENTRY
|
|
update t set e= '2003-05-01' where s = '2003-01-01';
|
|
|
|
select * from t where year(s) = 2003;
|
|
|
|
--error ER_PERIOD_NOT_FOUND
|
|
create or replace table t(id int, s date, e date,
|
|
period for p(s,e),
|
|
primary key(id, q without overlaps));
|
|
|
|
--error ER_PERIOD_NOT_FOUND
|
|
create or replace table t(id int, s date, e date,
|
|
primary key(id, p without overlaps));
|
|
|
|
--error ER_KEY_CONTAINS_PERIOD_FIELDS
|
|
create or replace table t(id int, s date, e date,
|
|
period for p(s,e),
|
|
primary key(id, s, p without overlaps));
|
|
|
|
create or replace table t(id int, s date, e date,
|
|
period for p(s,e),
|
|
primary key(id));
|
|
insert into t values (1, '2003-03-01', '2003-05-01');
|
|
--error ER_DUP_ENTRY
|
|
insert into t values (1, '2003-04-01', '2003-05-01');
|
|
|
|
create or replace table t(id int, u int, s date, e date,
|
|
period for p(s,e),
|
|
primary key(id, p without overlaps),
|
|
unique(u));
|
|
--replace_result $default_engine DEFAULT_ENGINE
|
|
show create table t;
|
|
insert into t values (1, 1, '2003-03-01', '2003-05-01');
|
|
insert into t values (1, 2, '2003-05-01', '2003-07-01');
|
|
--error ER_DUP_ENTRY
|
|
insert into t values (1, 3, '2003-04-01', '2003-05-01');
|
|
|
|
|
|
|
|
create or replace table t(id int, u int, s date, e date,
|
|
period for p(s,e),
|
|
primary key(id, p without overlaps),
|
|
unique(u, p without overlaps));
|
|
--replace_result $default_engine DEFAULT_ENGINE
|
|
show create table t;
|
|
|
|
insert into t values (2, NULL, '2003-03-01', '2003-05-01');
|
|
--error ER_DUP_ENTRY
|
|
insert into t values (2, NULL, '2003-03-01', '2003-05-01');
|
|
insert into t values (3, NULL, '2003-03-01', '2003-05-01');
|
|
insert into t values (1, 1, '2003-03-01', '2003-05-01');
|
|
insert into t values (1, 2, '2003-05-01', '2003-07-01');
|
|
insert into t values (4, NULL, '2003-03-01', '2003-05-01');
|
|
|
|
create sequence seq start=5;
|
|
update t set id= nextval(seq), u= nextval(seq), s='2003-05-01', e='2003-07-01'
|
|
where u is NULL;
|
|
|
|
--sorted_result
|
|
select * from t;
|
|
|
|
create or replace table t(id int, s date, e date,
|
|
period for p(s,e));
|
|
|
|
insert into t values (1, '2003-01-01', '2003-03-01'),
|
|
(1, '2003-05-01', '2003-07-01'),
|
|
(1, '2003-02-01', '2003-04-01');
|
|
|
|
--replace_regex /#sql-\w+/#sql-temp/
|
|
--error ER_DUP_ENTRY
|
|
alter table t add primary key(id, p without overlaps);
|
|
|
|
--echo # Historical rows are not checked against constraints
|
|
set @@system_versioning_alter_history= keep;
|
|
alter table t add system versioning;
|
|
delete from t;
|
|
alter table t add primary key(id, p without overlaps);
|
|
|
|
insert into t values (1, '2003-01-01', '2003-03-01'),
|
|
(1, '2003-03-01', '2003-05-01');
|
|
|
|
|
|
--echo # `without overlaps` is not lost on alter table
|
|
alter table t add y int;
|
|
--replace_result $default_engine DEFAULT_ENGINE
|
|
show create table t;
|
|
alter table t drop y;
|
|
|
|
create or replace table t1 like t;
|
|
--replace_result $default_engine DEFAULT_ENGINE
|
|
show create table t1;
|
|
|
|
create or replace table t1 (x int, s date, e date,
|
|
period for p(s,e),
|
|
primary key(x, p without overlaps));
|
|
alter table t1 partition by key (x);
|
|
|
|
create or replace table t1 (x int, s date, e date, period for p (s, e))
|
|
partition by hash (x);
|
|
alter table t1 add primary key (x, p without overlaps);
|
|
|
|
--error ER_PARSE_ERROR
|
|
create or replace table t2 (x int, s date, e date,
|
|
period for p (s, e),
|
|
key(x, p without overlaps));
|
|
|
|
--error ER_PARSE_ERROR
|
|
create or replace table t2 (x int, s date, e date,
|
|
period for p (s, e),
|
|
unique(x, p without overlaps, x, p without overlaps));
|
|
|
|
create or replace table t1 (x varchar(100), s date, e date,
|
|
period for p(s,e),
|
|
primary key(x, p without overlaps));
|
|
|
|
--error ER_COMPRESSED_COLUMN_USED_AS_KEY
|
|
create or replace table t1 (x varchar(100) compressed, s date, e date,
|
|
period for p(s,e),
|
|
primary key(x, p without overlaps));
|
|
|
|
--error ER_KEY_CANT_HAVE_WITHOUT_OVERLAPS
|
|
create or replace table t (x int, s date, e date, period for apptime(s,e),
|
|
unique(x, apptime without overlaps) using hash);
|
|
|
|
--error ER_KEY_CANT_HAVE_WITHOUT_OVERLAPS
|
|
create or replace table t (x int, s date, e date, period for apptime(s,e),
|
|
b blob, unique(x, b, apptime without overlaps));
|
|
|
|
create or replace table t (x int, s date, e date, b blob unique,
|
|
period for apptime(s,e),
|
|
unique(x, apptime without overlaps));
|
|
|
|
insert into t values (1, '2020-03-01', '2020-03-05', 'test');
|
|
--error ER_DUP_ENTRY
|
|
insert into t values (1, '2020-03-05', '2020-03-10', 'test');
|
|
insert into t values (1, '2020-03-05', '2020-03-10', 'test2');
|
|
--error ER_DUP_ENTRY
|
|
insert into t values (1, '2020-03-03', '2020-03-10', 'test3');
|
|
|
|
let $MYSQLD_DATADIR= `select @@datadir`;
|
|
create or replace table t (x int, s date, e date, period for apptime(s,e),
|
|
unique(x, apptime without overlaps));
|
|
--error ER_NOT_SUPPORTED_YET
|
|
replace into t values (1, '2020-03-03', '2020-03-10');
|
|
--error ER_NOT_SUPPORTED_YET
|
|
insert into t values (1, '2020-03-03', '2020-03-10')
|
|
on duplicate key update x = 2;
|
|
|
|
select * from t;
|
|
select * into outfile 'tmp_t.txt' from t;
|
|
load data infile 'tmp_t.txt' into table t;
|
|
--error ER_NOT_SUPPORTED_YET
|
|
load data infile 'tmp_t.txt' replace into table t;
|
|
remove_file $MYSQLD_DATADIR/test/tmp_t.txt;
|
|
|
|
insert into t values (1, '2020-03-01', '2020-03-05');
|
|
select * into outfile 'tmp_t.txt' from t;
|
|
--error ER_DUP_ENTRY
|
|
load data infile 'tmp_t.txt' into table t;
|
|
|
|
load data infile 'tmp_t.txt' ignore into table t;
|
|
|
|
--error ER_NOT_SUPPORTED_YET
|
|
load data infile 'tmp_t.txt' replace into table t;
|
|
|
|
remove_file $MYSQLD_DATADIR/test/tmp_t.txt;
|
|
|
|
create or replace database test;
|