101 lines
3.5 KiB
Plaintext
101 lines
3.5 KiB
Plaintext
--source suite/xengine/include/have_xengine.inc
|
|
--source include/have_debug.inc
|
|
###################################################################
|
|
# test the online DML&DDL
|
|
###################################################################
|
|
|
|
--disable_warnings
|
|
drop table if exists t1;
|
|
--enable_warnings
|
|
|
|
set @save_sql_mode=@@sql_mode;
|
|
set sql_mode = "STRICT_ALL_TABLES";
|
|
|
|
CREATE TABLE `t1` (
|
|
`id` int(11) NOT NULL,
|
|
`c1` int(11) NOT NULL,
|
|
`c2` varchar(100) DEFAULT NULL,
|
|
`c3` int(11) DEFAULT NULL,
|
|
`c4` int(11) NOT NULL DEFAULT '5',
|
|
`c5` varchar(100) DEFAULT NULL,
|
|
PRIMARY KEY (`id`),
|
|
KEY `idx_c4` (`c4`),
|
|
KEY `idx_c5` (`c5`)
|
|
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
|
insert into t1 values(1,1,'abc',1,1,'abc');
|
|
insert into t1 values(2,2,'cde',2,2,'cde');
|
|
insert into t1 values(3,3,'xyz',3,3,'xyz');
|
|
|
|
#####
|
|
#test modify primary key columns
|
|
#####
|
|
alter table t1 drop primary key, add primary key(c1,c4), ALGORITHM = INPLACE, LOCK=DEFAULT;
|
|
show create table t1;
|
|
select * from t1;
|
|
|
|
alter table t1 drop primary key, add primary key(c4),ALGORITHM = INPLACE, LOCK=DEFAULT;
|
|
show create table t1;
|
|
|
|
#####
|
|
#test column is null be part of new table primary key
|
|
#####
|
|
|
|
insert into t1 values(4,4,null,4,4,null);
|
|
select * from t1;
|
|
--error 1138
|
|
alter table t1 drop primary key, add primary key(c5),ALGORITHM = INPLACE, LOCK=DEFAULT;
|
|
|
|
delete from t1 where id=4;
|
|
select * from t1;
|
|
alter table t1 drop primary key, add primary key(c5),ALGORITHM = INPLACE, LOCK=DEFAULT;
|
|
show create table t1;
|
|
select * from t1;
|
|
drop table t1;
|
|
|
|
######
|
|
#test add primary key
|
|
######
|
|
CREATE TABLE `t1` (
|
|
`id` int(11) NOT NULL,
|
|
`c1` int(11) NOT NULL,
|
|
`c2` varchar(100) DEFAULT NULL,
|
|
`c3` int(11) DEFAULT NULL,
|
|
`c4` int(11) NOT NULL DEFAULT '5',
|
|
`c5` varchar(100) DEFAULT NULL,
|
|
KEY `idx_c4` (`c4`),
|
|
UNIQUE KEY `idx_c5` (`c5`)
|
|
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
|
insert into t1 values(1,1,'abc',1,1,'abc');
|
|
insert into t1 values(2,2,'cde',2,2,'cde');
|
|
insert into t1 values(3,3,'xyz',3,3,'xyz');
|
|
alter table t1 add primary key idx_pk(id),ALGORITHM = INPLACE, LOCK=DEFAULT;
|
|
show create table t1;
|
|
select * from t1;
|
|
|
|
####
|
|
#test rename index
|
|
####
|
|
# non-rebuild inplace DDL
|
|
ALTER TABLE t1 RENAME INDEX idx_c4 TO key_c4, RENAME INDEX idx_c5 TO key_c5, ALGORITHM=INPLACE;
|
|
SHOW CREATE TABLE t1;
|
|
|
|
# rebuild inplace DDL
|
|
ALTER TABLE t1 ADD COLUMN c6 CHAR(1), RENAME INDEX key_c4 TO idx_c4, RENAME INDEX key_c5 TO idx_c5, ALGORITHM=INPLACE;
|
|
SHOW CREATE TABLE t1;
|
|
|
|
######
|
|
#test drop primary key
|
|
#####
|
|
--error 1846
|
|
alter table t1 drop primary key, ALGORITHM = INPLACE, LOCK=DEFAULT;
|
|
|
|
alter table t1 drop primary key;
|
|
show create table t1;
|
|
select * from t1;
|
|
|
|
drop table t1;
|
|
|
|
set sql_mode = @save_sql_mode;
|
|
|
|
--source suite/xengine/include/check_xengine_log_error.inc
|