240 lines
7.6 KiB
Plaintext
240 lines
7.6 KiB
Plaintext
# TestTruncateTable
|
|
drop table if exists truncate_test;
|
|
create table truncate_test (a int);
|
|
insert truncate_test values (1),(2),(3);
|
|
select * from truncate_test;
|
|
truncate table truncate_test;
|
|
select * from truncate_test;
|
|
|
|
# TestViewRecursion
|
|
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;
|
|
--error 1462
|
|
select * from recursive_view1;
|
|
drop view recursive_view1, t;
|
|
drop table if exists t;
|
|
drop view if exists recursive_view1, recursive_view2;
|
|
|
|
# TestIssue16250
|
|
create table if not exists t(a int);
|
|
create view view_issue16250 as select * from t;
|
|
-- error 1146
|
|
truncate table view_issue16250;
|
|
drop table if exists t;
|
|
drop view if exists view_issue16250;
|
|
|
|
# TestIssue24771
|
|
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;
|
|
select * from v_st_2;
|
|
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;
|
|
|
|
# TestTruncateSequence
|
|
drop sequence if exists seq;
|
|
drop sequence if exists seq1;
|
|
create sequence if not exists seq;
|
|
-- error 1146
|
|
truncate table seq;
|
|
create sequence if not exists seq1 start 10 increment 2 maxvalue 10000 cycle;
|
|
-- error 1146
|
|
truncate table seq1;
|
|
drop sequence if exists seq;
|
|
drop sequence if exists seq1;
|
|
|
|
# TestCreateDropIndex
|
|
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;
|
|
|
|
# TestAutoRandomClusteredPrimaryKey
|
|
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;
|
|
-- error 8216
|
|
insert into t values (100, 2);
|
|
set @@allow_auto_random_explicit_insert = 1;
|
|
insert into t values (100, 2);
|
|
select b from t order by b;
|
|
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;
|
|
drop table if exists t;
|
|
set @@allow_auto_random_explicit_insert = default;
|
|
|
|
# TestMaxHandleAddIndex
|
|
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;
|
|
|
|
# TestIssue9205
|
|
drop table if exists t;
|
|
create table t(c time DEFAULT '12:12:12.8');
|
|
show create table `t`;
|
|
alter table t add column c1 time default '12:12:12.000000';
|
|
show create table `t`;
|
|
alter table t alter column c1 set default '2019-02-01 12:12:10.4';
|
|
show create table `t`;
|
|
alter table t modify c1 time DEFAULT '770:12:12.000000';
|
|
show create table `t`;
|
|
drop table if exists t;
|
|
|
|
# TestCheckDefaultFsp
|
|
drop table if exists t, t2, t3;
|
|
-- error 1067
|
|
create table t ( tt timestamp default now(1));
|
|
-- error 1067
|
|
create table t ( tt timestamp(1) default current_timestamp);
|
|
-- error 1067
|
|
create table t ( tt timestamp(1) default now(2));
|
|
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));
|
|
-- error 1067
|
|
alter table t add column ttt timestamp default now(2);
|
|
-- error 1067
|
|
alter table t add column ttt timestamp(5) default current_timestamp;
|
|
-- error 1067
|
|
alter table t add column ttt timestamp(5) default now(2);
|
|
-- error 1067
|
|
alter table t modify column tt timestamp(1) default now();
|
|
-- error 1067
|
|
alter table t modify column tt timestamp(4) default now(5);
|
|
-- error 1067
|
|
alter table t change column tt tttt timestamp(4) default now(5);
|
|
-- error 1067
|
|
alter table t change column tt tttt timestamp(1) default now();
|
|
drop table if exists t, t2, t3;
|
|
|
|
# TestTimestampMinDefaultValue
|
|
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;
|
|
|
|
# TestCreateTableWithTTL
|
|
drop table if exists t;
|
|
CREATE TABLE t (created_at datetime) TTL = `created_at` + INTERVAL 5 DAY;
|
|
SHOW CREATE TABLE t;
|
|
DROP TABLE t;
|
|
-- error 8148
|
|
CREATE TABLE t (id int) TTL = `id` + INTERVAL 5 DAY;
|
|
-- error 8150
|
|
CREATE TABLE t (id int) TTL_ENABLE = 'ON';
|
|
-- error 8150
|
|
CREATE TABLE t (id int) TTL_JOB_INTERVAL = '1h';
|
|
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;
|
|
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;
|
|
DROP TABLE t;
|
|
|
|
# TestAlterTTLInfo
|
|
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;
|
|
ALTER TABLE t TTL_ENABLE = 'OFF';
|
|
SHOW CREATE TABLE t;
|
|
ALTER TABLE t TTL_JOB_INTERVAL = '1d';
|
|
SHOW CREATE TABLE t;
|
|
-- error 1054
|
|
ALTER TABLE t TTL = `not_exist` + INTERVAL 2 YEAR;
|
|
-- error 8148
|
|
ALTER TABLE t TTL = `wrong_type` + INTERVAL 2 YEAR;
|
|
-- error 8149
|
|
ALTER TABLE t DROP COLUMN updated_at;
|
|
-- error 8148
|
|
ALTER TABLE t CHANGE updated_at updated_at_new INT;
|
|
ALTER TABLE t RENAME COLUMN `updated_at` TO `updated_at_2`;
|
|
SHOW CREATE TABLE t;
|
|
ALTER TABLE t CHANGE `updated_at_2` `updated_at_3` date;
|
|
SHOW CREATE TABLE t;
|
|
ALTER TABLE t TTL = `updated_at_3` + INTERVAL 3 YEAR;
|
|
SHOW CREATE TABLE t;
|
|
-- error 8200
|
|
ALTER TABLE t TTL_ENABLE = 'OFF' REMOVE TTL;
|
|
ALTER TABLE t REMOVE TTL;
|
|
SHOW CREATE TABLE t;
|
|
-- error 8150
|
|
ALTER TABLE t TTL_ENABLE = 'OFF';
|
|
-- error 8150
|
|
ALTER TABLE t TTL_JOB_INTERVAL = '1h';
|
|
drop table if exists t;
|
|
|
|
# TestDisableTTLForTempTable
|
|
drop table if exists t;
|
|
--error 8151
|
|
CREATE TEMPORARY TABLE t (created_at datetime) TTL = `created_at` + INTERVAL 5 DAY;
|
|
|
|
# TestDisableTTLForFKParentTable
|
|
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));
|
|
--error 8152
|
|
ALTER TABLE t TTL = created_at + INTERVAL 5 YEAR;
|
|
drop table t,t_1;
|
|
CREATE TABLE t (id int primary key, created_at datetime) TTL = created_at + INTERVAL 5 YEAR;
|
|
--error 8152
|
|
CREATE TABLE t_1 (t_id int, foreign key fk_t_id(t_id) references t(id));
|
|
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);
|
|
--error 8152
|
|
ALTER TABLE t_1 ADD FOREIGN KEY fk_t_id(t_id) references t(id);
|
|
drop table t,t_1;
|
|
set global tidb_enable_foreign_key=default;
|