diff --git a/tests/sequence_sharding_optimistic/run.sh b/tests/sequence_sharding_optimistic/run.sh index d0b9ab7127..d03edd54b0 100755 --- a/tests/sequence_sharding_optimistic/run.sh +++ b/tests/sequence_sharding_optimistic/run.sh @@ -157,7 +157,7 @@ run() { # try to get schema for the table, the latest schema got. curl -X PUT ${API_URL} -d '{"op":1, "task":"sequence_sharding_optimistic", "sources": ["mysql-replica-01"], "database":"sharding_seq_opt", "table":"t1"}' > ${WORK_DIR}/get_schema.log # this is NON-CLUSTERED index - check_log_contains ${WORK_DIR}/get_schema.log 'CREATE TABLE `t1` ( `id` bigint(20) NOT NULL, `c2` varchar(20) DEFAULT NULL, `c3` int(11) DEFAULT NULL, PRIMARY KEY (`id`) /\*T!\[clustered_index\] NONCLUSTERED \*/) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin' 1 + check_log_contains ${WORK_DIR}/get_schema.log 'CREATE TABLE `t1` ( `id` bigint(20) NOT NULL, `c2` varchar(20) DEFAULT NULL, `c3` int(11) DEFAULT NULL, PRIMARY KEY (`id`) .*) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin' 1 # drop the schema. curl -X PUT ${API_URL} -d '{"op":3, "task":"sequence_sharding_optimistic", "sources": ["mysql-replica-01"], "database":"sharding_seq_opt", "table":"t1"}' > ${WORK_DIR}/remove_schema.log @@ -188,7 +188,7 @@ run() { curl -X PUT ${API_URL} -d '{"op":1, "task":"sequence_sharding_optimistic", "sources": ["mysql-replica-01"], "database":"sharding_seq_opt", "table":"t1"}' > ${WORK_DIR}/get_schema.log cat ${WORK_DIR}/get_schema.log # schema tracker enables alter-primary-key, so this is NONCLUSTERED index - check_log_contains ${WORK_DIR}/get_schema.log 'CREATE TABLE `t1` ( `id` bigint(20) NOT NULL, `c2` varchar(20) DEFAULT NULL, `c3` bigint(11) DEFAULT NULL, PRIMARY KEY (`id`) /\*T!\[clustered_index\] NONCLUSTERED \*/) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin' 1 + check_log_contains ${WORK_DIR}/get_schema.log 'CREATE TABLE `t1` ( `id` bigint(20) NOT NULL, `c2` varchar(20) DEFAULT NULL, `c3` bigint(11) DEFAULT NULL, PRIMARY KEY (`id`) .*) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin' 1 # more data run_sql_file $cur/data/db1.increment2.sql $MYSQL_HOST1 $MYSQL_PORT1 $MYSQL_PASSWORD1 diff --git a/tests/shardddl3/conf/tidb-alter-pk-config.toml b/tests/shardddl3/conf/tidb-alter-pk-config.toml new file mode 100644 index 0000000000..a1257473a3 --- /dev/null +++ b/tests/shardddl3/conf/tidb-alter-pk-config.toml @@ -0,0 +1,6 @@ +# TiDB Configuration. + +# alter-primary-key is used to control alter primary key feature. Default is false, indicate the alter primary key feature is disabled. +# If it is true, we can add the primary key by "alter table". However, if a table already exists before the switch is turned true and the data type of its primary key column is an integer, +# the primary key cannot be dropped. +alter-primary-key = true diff --git a/tests/shardddl3/run.sh b/tests/shardddl3/run.sh index dc0f04d4b0..8e23e39325 100644 --- a/tests/shardddl3/run.sh +++ b/tests/shardddl3/run.sh @@ -114,9 +114,15 @@ function DM_078_CASE() { } function DM_078() { + # start a TiDB alter-pk + pkill -hup tidb-server 2>/dev/null || true + wait_process_exit tidb-server + run_tidb_server 4000 $TIDB_PASSWORD $cur/conf/tidb-alter-pk-config.toml + run_case 078 "single-source-pessimistic" "run_sql_source1 \"create table ${shardddl1}.${tb1} (id int unique, a int, b varchar(10));\"" "clean_table" "" run_case 078 "single-source-optimistic" "run_sql_source1 \"create table ${shardddl1}.${tb1} (id int unique, a int, b varchar(10));\"" "clean_table" "" + # don't revert tidb until DM_079 } function DM_079_CASE() { @@ -130,6 +136,11 @@ function DM_079_CASE() { function DM_079() { run_case 079 "single-source-pessimistic" "run_sql_source1 \"create table ${shardddl1}.${tb1} (a int primary key, b varchar(10));\"" "clean_table" "" run_case 079 "single-source-optimistic" "run_sql_source1 \"create table ${shardddl1}.${tb1} (a int primary key, b varchar(10));\"" "clean_table" "" + + # revert tidb + pkill -hup tidb-server 2>/dev/null || true + wait_process_exit tidb-server + run_tidb_server 4000 $TIDB_PASSWORD } function DM_080_CASE() {