Skip to content

Commit

Permalink
executor, tests: move some test cases from ddl_test.go, `split_tabl…
Browse files Browse the repository at this point in the history
…e_test.go` and `write_test.go` to `integrationtest` (#47361)

ref #47076
  • Loading branch information
SeaRise authored Oct 7, 2023
1 parent a3bafcd commit 413a58f
Show file tree
Hide file tree
Showing 12 changed files with 1,896 additions and 974 deletions.
2 changes: 1 addition & 1 deletion executor/test/ddl/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ go_test(
"main_test.go",
],
flaky = True,
shard_count = 42,
shard_count = 27,
deps = [
"//config",
"//ddl/schematracker",
Expand Down
307 changes: 0 additions & 307 deletions executor/test/ddl/ddl_test.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion executor/test/splittest/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ go_test(
],
flaky = True,
race = "on",
shard_count = 6,
shard_count = 5,
deps = [
"//ddl",
"//domain/infosync",
Expand Down
14 changes: 0 additions & 14 deletions executor/test/splittest/split_table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,20 +111,6 @@ func TestSplitTableRegion(t *testing.T) {
tk.MustQuery("split region for partition table t partition (p3,p4) between (100000000) and (1000000000) regions 5;").Check(testkit.Rows("8 1"))
}

func TestSplitRegionEdgeCase(t *testing.T) {
store := testkit.CreateMockStore(t)
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")

tk.MustExec("drop table if exists t;")
tk.MustExec("create table t(a bigint(20) auto_increment primary key);")
tk.MustExec("split table t between (-9223372036854775808) and (9223372036854775807) regions 16;")

tk.MustExec("drop table if exists t;")
tk.MustExec("create table t(a int(20) auto_increment primary key);")
tk.MustGetErrCode("split table t between (-9223372036854775808) and (9223372036854775807) regions 16;", errno.ErrDataOutOfRange)
}

func TestClusterIndexSplitTableIntegration(t *testing.T) {
store := testkit.CreateMockStore(t)
tk := testkit.NewTestKit(t, store)
Expand Down
2 changes: 1 addition & 1 deletion executor/test/writetest/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ go_test(
"write_test.go",
],
flaky = True,
shard_count = 50,
shard_count = 44,
deps = [
"//br/pkg/lightning/mydump",
"//config",
Expand Down
650 changes: 0 additions & 650 deletions executor/test/writetest/write_test.go

Large diffs are not rendered by default.

298 changes: 298 additions & 0 deletions tests/integrationtest/r/executor/ddl.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,298 @@
drop table if exists truncate_test;
create table truncate_test (a int);
insert truncate_test values (1),(2),(3);
select * from truncate_test;
a
1
2
3
truncate table truncate_test;
select * from truncate_test;
a
drop table if exists t;
drop view if exists recursive_view1, recursive_view2;
create table if not exists t(a int);
create definer='root'@'localhost' view recursive_view1 as select * from t;
create definer='root'@'localhost' view recursive_view2 as select * from recursive_view1;
drop table t;
rename table recursive_view2 to t;
select * from recursive_view1;
Error 1462 (HY000): `executor__ddl`.`recursive_view1` contains view recursion
drop view recursive_view1, t;
drop table if exists t;
drop view if exists recursive_view1, recursive_view2;
create table if not exists t(a int);
create view view_issue16250 as select * from t;
truncate table view_issue16250;
Error 1146 (42S02): Table 'executor__ddl.view_issue16250' doesn't exist
drop table if exists t;
drop view if exists view_issue16250;
drop table if exists zy_tab;
create table if not exists zy_tab (
zy_code int,
zy_name varchar(100)
);
drop table if exists bj_tab;
create table if not exists bj_tab (
bj_code int,
bj_name varchar(100),
bj_addr varchar(100),
bj_person_count int,
zy_code int
);
drop table if exists st_tab;
create table if not exists st_tab (
st_code int,
st_name varchar(100),
bj_code int
);
drop view if exists v_st_2;
create definer='root'@'localhost' view v_st_2 as
select st.st_name,bj.bj_name,zy.zy_name
from (
select bj_code,
bj_name,
zy_code
from bj_tab as b
where b.bj_code = 1
) as bj
left join zy_tab as zy on zy.zy_code = bj.zy_code
left join st_tab as st on bj.bj_code = st.bj_code;
show create view v_st_2;
View Create View character_set_client collation_connection
v_st_2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v_st_2` (`st_name`, `bj_name`, `zy_name`) AS SELECT `st`.`st_name` AS `st_name`,`bj`.`bj_name` AS `bj_name`,`zy`.`zy_name` AS `zy_name` FROM ((SELECT `bj_code` AS `bj_code`,`bj_name` AS `bj_name`,`zy_code` AS `zy_code` FROM `executor__ddl`.`bj_tab` AS `b` WHERE `b`.`bj_code`=1) AS `bj` LEFT JOIN `executor__ddl`.`zy_tab` AS `zy` ON `zy`.`zy_code`=`bj`.`zy_code`) LEFT JOIN `executor__ddl`.`st_tab` AS `st` ON `bj`.`bj_code`=`st`.`bj_code` utf8mb4 utf8mb4_general_ci
select * from v_st_2;
st_name bj_name zy_name
drop view if exists v_st_2;
drop table if exists zy_tab;
drop table if exists bj_tab;
drop table if exists st_tab;
drop sequence if exists seq;
drop sequence if exists seq1;
create sequence if not exists seq;
truncate table seq;
Error 1146 (42S02): Table 'executor__ddl.seq' doesn't exist
create sequence if not exists seq1 start 10 increment 2 maxvalue 10000 cycle;
truncate table seq1;
Error 1146 (42S02): Table 'executor__ddl.seq1' doesn't exist
drop sequence if exists seq;
drop sequence if exists seq1;
drop table if exists drop_test;
create table if not exists drop_test (a int);
create index idx_a on drop_test (a);
drop index idx_a on drop_test;
drop table drop_test;
drop table if exists t;
create table t (a bigint auto_random(5), b int, primary key (a, b) clustered);
insert into t (b) values (1);
set @@allow_auto_random_explicit_insert = 0;
insert into t values (100, 2);
Error 8216 (HY000): Invalid auto random: Explicit insertion on auto_random column is disabled. Try to set @@allow_auto_random_explicit_insert = true.
set @@allow_auto_random_explicit_insert = 1;
insert into t values (100, 2);
select b from t order by b;
b
1
2
alter table t modify column a bigint auto_random(6);
drop table t;
create table t (a bigint, b bigint auto_random(4, 32), primary key (b, a) clustered);
insert into t (a) values (1);
select a from t;
a
1
drop table if exists t;
set @@allow_auto_random_explicit_insert = default;
drop table if exists t;
create table t(a bigint PRIMARY KEY, b int);
insert into t values(9223372036854775807, 1);
insert into t values(-9223372036854775808, 1);
alter table t add index idx_b(b);
admin check table t;

create table t1(a bigint UNSIGNED PRIMARY KEY, b int);
insert into t1 values(18446744073709551615, 1);
insert into t1 values(0, 1);
alter table t1 add index idx_b(b);
admin check table t1;

drop table if exists t;
drop table if exists t;
create table t(c time DEFAULT '12:12:12.8');
show create table `t`;
Table Create Table
t CREATE TABLE `t` (
`c` time DEFAULT '12:12:13'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
alter table t add column c1 time default '12:12:12.000000';
show create table `t`;
Table Create Table
t CREATE TABLE `t` (
`c` time DEFAULT '12:12:13',
`c1` time DEFAULT '12:12:12'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
alter table t alter column c1 set default '2019-02-01 12:12:10.4';
show create table `t`;
Table Create Table
t CREATE TABLE `t` (
`c` time DEFAULT '12:12:13',
`c1` time DEFAULT '12:12:10'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
alter table t modify c1 time DEFAULT '770:12:12.000000';
show create table `t`;
Table Create Table
t CREATE TABLE `t` (
`c` time DEFAULT '12:12:13',
`c1` time DEFAULT '770:12:12'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
drop table if exists t;
drop table if exists t, t2, t3;
create table t ( tt timestamp default now(1));
Error 1067 (42000): Invalid default value for 'tt'
create table t ( tt timestamp(1) default current_timestamp);
Error 1067 (42000): Invalid default value for 'tt'
create table t ( tt timestamp(1) default now(2));
Error 1067 (42000): Invalid default value for 'tt'
create table t ( tt timestamp(1) default now(1));
create table t2 ( tt timestamp default current_timestamp());
create table t3 ( tt timestamp default current_timestamp(0));
alter table t add column ttt timestamp default now(2);
Error 1067 (42000): Invalid default value for 'ttt'
alter table t add column ttt timestamp(5) default current_timestamp;
Error 1067 (42000): Invalid default value for 'ttt'
alter table t add column ttt timestamp(5) default now(2);
Error 1067 (42000): Invalid default value for 'ttt'
alter table t modify column tt timestamp(1) default now();
Error 1067 (42000): Invalid default value for 'tt'
alter table t modify column tt timestamp(4) default now(5);
Error 1067 (42000): Invalid default value for 'tt'
alter table t change column tt tttt timestamp(4) default now(5);
Error 1067 (42000): Invalid default value for 'tttt'
alter table t change column tt tttt timestamp(1) default now();
Error 1067 (42000): Invalid default value for 'tttt'
drop table if exists t, t2, t3;
drop table if exists tdv;
create table tdv(a int);
ALTER TABLE tdv ADD COLUMN ts timestamp DEFAULT '1970-01-01 08:00:01';
drop table if exists tdv;
drop table if exists t;
CREATE TABLE t (created_at datetime) TTL = `created_at` + INTERVAL 5 DAY;
SHOW CREATE TABLE t;
Table Create Table
t CREATE TABLE `t` (
`created_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin /*T![ttl] TTL=`created_at` + INTERVAL 5 DAY */ /*T![ttl] TTL_ENABLE='ON' */ /*T![ttl] TTL_JOB_INTERVAL='1h' */
DROP TABLE t;
CREATE TABLE t (id int) TTL = `id` + INTERVAL 5 DAY;
Error 8148 (HY000): Field 'id' is of a not supported type for TTL config, expect DATETIME, DATE or TIMESTAMP
CREATE TABLE t (id int) TTL_ENABLE = 'ON';
Error 8150 (HY000): Cannot set TTL_ENABLE on a table without TTL config
CREATE TABLE t (id int) TTL_JOB_INTERVAL = '1h';
Error 8150 (HY000): Cannot set TTL_JOB_INTERVAL on a table without TTL config
CREATE TABLE t (created_at datetime) TTL_ENABLE = 'ON' TTL = `created_at` + INTERVAL 1 DAY TTL_ENABLE = 'OFF' TTL_JOB_INTERVAL = '1d';
SHOW CREATE TABLE t;
Table Create Table
t CREATE TABLE `t` (
`created_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin /*T![ttl] TTL=`created_at` + INTERVAL 1 DAY */ /*T![ttl] TTL_ENABLE='OFF' */ /*T![ttl] TTL_JOB_INTERVAL='1d' */
DROP TABLE t;
CREATE TABLE t (created_at datetime) TTL_ENABLE = 'ON' TTL = `created_at` + INTERVAL 1 DAY TTL = `created_at` + INTERVAL 2 DAY TTL = `created_at` + INTERVAL 3 DAY TTL_ENABLE = 'OFF';
SHOW CREATE TABLE t;
Table Create Table
t CREATE TABLE `t` (
`created_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin /*T![ttl] TTL=`created_at` + INTERVAL 3 DAY */ /*T![ttl] TTL_ENABLE='OFF' */ /*T![ttl] TTL_JOB_INTERVAL='1h' */
DROP TABLE t;
drop table if exists t;
CREATE TABLE t (created_at datetime, updated_at datetime, wrong_type int) TTL = `created_at` + INTERVAL 5 DAY;
ALTER TABLE t TTL = `updated_at` + INTERVAL 2 YEAR;
SHOW CREATE TABLE t;
Table Create Table
t CREATE TABLE `t` (
`created_at` datetime DEFAULT NULL,
`updated_at` datetime DEFAULT NULL,
`wrong_type` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin /*T![ttl] TTL=`updated_at` + INTERVAL 2 YEAR */ /*T![ttl] TTL_ENABLE='ON' */ /*T![ttl] TTL_JOB_INTERVAL='1h' */
ALTER TABLE t TTL_ENABLE = 'OFF';
SHOW CREATE TABLE t;
Table Create Table
t CREATE TABLE `t` (
`created_at` datetime DEFAULT NULL,
`updated_at` datetime DEFAULT NULL,
`wrong_type` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin /*T![ttl] TTL=`updated_at` + INTERVAL 2 YEAR */ /*T![ttl] TTL_ENABLE='OFF' */ /*T![ttl] TTL_JOB_INTERVAL='1h' */
ALTER TABLE t TTL_JOB_INTERVAL = '1d';
SHOW CREATE TABLE t;
Table Create Table
t CREATE TABLE `t` (
`created_at` datetime DEFAULT NULL,
`updated_at` datetime DEFAULT NULL,
`wrong_type` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin /*T![ttl] TTL=`updated_at` + INTERVAL 2 YEAR */ /*T![ttl] TTL_ENABLE='OFF' */ /*T![ttl] TTL_JOB_INTERVAL='1d' */
ALTER TABLE t TTL = `not_exist` + INTERVAL 2 YEAR;
Error 1054 (42S22): Unknown column 'not_exist' in 'TTL config'
ALTER TABLE t TTL = `wrong_type` + INTERVAL 2 YEAR;
Error 8148 (HY000): Field 'wrong_type' is of a not supported type for TTL config, expect DATETIME, DATE or TIMESTAMP
ALTER TABLE t DROP COLUMN updated_at;
Error 8149 (HY000): Cannot drop column 'updated_at': needed in TTL config
ALTER TABLE t CHANGE updated_at updated_at_new INT;
Error 8148 (HY000): Field 'updated_at_new' is of a not supported type for TTL config, expect DATETIME, DATE or TIMESTAMP
ALTER TABLE t RENAME COLUMN `updated_at` TO `updated_at_2`;
SHOW CREATE TABLE t;
Table Create Table
t CREATE TABLE `t` (
`created_at` datetime DEFAULT NULL,
`updated_at_2` datetime DEFAULT NULL,
`wrong_type` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin /*T![ttl] TTL=`updated_at_2` + INTERVAL 2 YEAR */ /*T![ttl] TTL_ENABLE='OFF' */ /*T![ttl] TTL_JOB_INTERVAL='1d' */
ALTER TABLE t CHANGE `updated_at_2` `updated_at_3` date;
SHOW CREATE TABLE t;
Table Create Table
t CREATE TABLE `t` (
`created_at` datetime DEFAULT NULL,
`updated_at_3` date DEFAULT NULL,
`wrong_type` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin /*T![ttl] TTL=`updated_at_3` + INTERVAL 2 YEAR */ /*T![ttl] TTL_ENABLE='OFF' */ /*T![ttl] TTL_JOB_INTERVAL='1d' */
ALTER TABLE t TTL = `updated_at_3` + INTERVAL 3 YEAR;
SHOW CREATE TABLE t;
Table Create Table
t CREATE TABLE `t` (
`created_at` datetime DEFAULT NULL,
`updated_at_3` date DEFAULT NULL,
`wrong_type` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin /*T![ttl] TTL=`updated_at_3` + INTERVAL 3 YEAR */ /*T![ttl] TTL_ENABLE='OFF' */ /*T![ttl] TTL_JOB_INTERVAL='1d' */
ALTER TABLE t TTL_ENABLE = 'OFF' REMOVE TTL;
Error 8200 (HY000): Unsupported multi schema change for alter table ttl
ALTER TABLE t REMOVE TTL;
SHOW CREATE TABLE t;
Table Create Table
t CREATE TABLE `t` (
`created_at` datetime DEFAULT NULL,
`updated_at_3` date DEFAULT NULL,
`wrong_type` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
ALTER TABLE t TTL_ENABLE = 'OFF';
Error 8150 (HY000): Cannot set TTL_ENABLE on a table without TTL config
ALTER TABLE t TTL_JOB_INTERVAL = '1h';
Error 8150 (HY000): Cannot set TTL_JOB_INTERVAL on a table without TTL config
drop table if exists t;
drop table if exists t;
CREATE TEMPORARY TABLE t (created_at datetime) TTL = `created_at` + INTERVAL 5 DAY;
Error 8151 (HY000): Set TTL for temporary table is not allowed
set global tidb_enable_foreign_key='ON';
drop table if exists t, t_1;
CREATE TABLE t (id int primary key, created_at datetime);
CREATE TABLE t_1 (t_id int, foreign key fk_t_id(t_id) references t(id));
ALTER TABLE t TTL = created_at + INTERVAL 5 YEAR;
Error 8152 (HY000): Set TTL for a table referenced by foreign key is not allowed
drop table t,t_1;
CREATE TABLE t (id int primary key, created_at datetime) TTL = created_at + INTERVAL 5 YEAR;
CREATE TABLE t_1 (t_id int, foreign key fk_t_id(t_id) references t(id));
Error 8152 (HY000): Set TTL for a table referenced by foreign key is not allowed
drop table t;
CREATE TABLE t (id int primary key, created_at datetime) TTL = created_at + INTERVAL 5 YEAR;
CREATE TABLE t_1 (t_id int);
ALTER TABLE t_1 ADD FOREIGN KEY fk_t_id(t_id) references t(id);
Error 8152 (HY000): Set TTL for a table referenced by foreign key is not allowed
drop table t,t_1;
set global tidb_enable_foreign_key=default;
8 changes: 8 additions & 0 deletions tests/integrationtest/r/executor/split_table.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
drop table if exists t;
create table t(a bigint(20) auto_increment primary key);
split table t between (-9223372036854775808) and (9223372036854775807) regions 16;
drop table if exists t;
create table t(a int(20) auto_increment primary key);
split table t between (-9223372036854775808) and (9223372036854775807) regions 16;
Error 1690 (22003): constant -9223372036854775808 overflows int
drop table if exists t;
Loading

0 comments on commit 413a58f

Please sign in to comment.