Skip to content

Commit

Permalink
Skip first state change of EXCHANGE Partition. (#7945) (#8099)
Browse files Browse the repository at this point in the history
close #7941
  • Loading branch information
ti-chi-bot authored Sep 17, 2023
1 parent 56a286f commit d21cded
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
19 changes: 19 additions & 0 deletions dbms/src/TiDB/Schema/SchemaBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,25 @@ void SchemaBuilder<Getter, NameMapper>::applyRenamePhysicalTable(
template <typename Getter, typename NameMapper>
void SchemaBuilder<Getter, NameMapper>::applyExchangeTablePartition(const SchemaDiff & diff)
{
if (diff.old_table_id == diff.table_id && diff.old_schema_id == diff.schema_id)
{
// Only internal changes in non-partitioned table, not affecting TiFlash
LOG_DEBUG(
log,
"Table is going to be exchanged, skipping for now. database_id={} table_id={}",
diff.schema_id,
diff.table_id);
return;
}
LOG_DEBUG(
log,
"Table and partition is exchanged. database_id={} table_id={}, part_db_id={}, part_table_id={} partition_id={}",
diff.old_schema_id,
diff.old_table_id,
diff.affected_opts[0].schema_id,
diff.affected_opts[0].table_id,
diff.table_id);

/// Exchange table partition is used for ddl:
/// alter table partition_table exchange partition partition_name with table non_partition_table
/// It involves three table/partition: partition_table, partition_name and non_partition_table
Expand Down
2 changes: 1 addition & 1 deletion tests/_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ fi
export storage_server="127.0.0.1"

# Server port for connecting
export storage_port="9000"
export storage_port=${storage_port:-9000}

# Default database for scripts
export storage_db="default"
Expand Down

0 comments on commit d21cded

Please sign in to comment.