Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
Signed-off-by: xufei <xufeixw@mail.ustc.edu.cn>
  • Loading branch information
windtalker committed Oct 19, 2022
1 parent 9e35992 commit dae275e
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 5 deletions.
6 changes: 3 additions & 3 deletions dbms/src/Storages/Transaction/TiDB.cpp
Expand Up @@ -765,6 +765,8 @@ try
is_invisible = json->getValue<bool>("is_invisible");
if (json->has("is_global"))
is_global = json->getValue<bool>("is_global");
if (json->has("is_redistributed"))
is_redistributed = json->getValue<bool>("is_redistributed");
}
catch (const Poco::Exception & e)
{
Expand Down Expand Up @@ -885,7 +887,7 @@ try
{
auto index_info_json = index_arr->getObject(i);
IndexInfo index_info(index_info_json);
if (index_info.is_primary)
if (index_info.is_primary || index_info.is_redistributed)
index_infos.emplace_back(index_info);
}
}
Expand All @@ -894,8 +896,6 @@ try
pk_is_handle = obj->getValue<bool>("pk_is_handle");
if (obj->has("is_common_handle"))
is_common_handle = obj->getValue<bool>("is_common_handle");
if (!is_common_handle)
index_infos.clear();
comment = obj->getValue<String>("comment");
if (obj->has("update_timestamp"))
update_timestamp = obj->getValue<Timestamp>("update_timestamp");
Expand Down
21 changes: 19 additions & 2 deletions dbms/src/Storages/Transaction/TiDB.h
Expand Up @@ -341,6 +341,7 @@ struct IndexInfo
bool is_primary;
bool is_invisible;
bool is_global;
bool is_redistributed;
};

struct TableInfo
Expand Down Expand Up @@ -411,9 +412,25 @@ struct TableInfo
/// due to we will not update IndexInfo except RENAME DDL action,
/// but DDL like add column / drop column may change the offset of columns
/// Thus, please be very careful when you must have to use offset information !!!!!
const IndexInfo & getPrimaryIndexInfo() const { return index_infos[0]; }
const IndexInfo & getPrimaryIndexInfo() const
{
for (const auto & index_info : index_infos)
{
if (index_info.is_primary)
return index_info;
}
throw DB::Exception("Should not reach here");
}

IndexInfo & getPrimaryIndexInfo() { return index_infos[0]; }
IndexInfo & getPrimaryIndexInfo()
{
for (auto & index_info : index_infos)
{
if (index_info.is_primary)
return index_info;
}
throw DB::Exception("Should not reach here");
}
};

using DBInfoPtr = std::shared_ptr<DBInfo>;
Expand Down
12 changes: 12 additions & 0 deletions dbms/src/TiDB/Schema/SchemaBuilder.cpp
Expand Up @@ -1138,6 +1138,18 @@ void SchemaBuilder<Getter, NameMapper>::applyCreateLogicalTable(const TiDB::DBIn
// Create logical table at last, only logical table creation will be treated as "complete".
// Intermediate failure will hide the logical table creation so that schema syncing when restart will re-create all (despite some physical tables may have created).
applyCreatePhysicalTable(db_info, table_info);
for (auto & index_info : table_info->index_infos)
{
if (index_info.is_redistributed)
{
auto new_table = std::make_shared<TableInfo>();
*new_table = *table_info;
new_table->id = table_info->id << 32 | index_info.id;
new_table->index_infos.clear();
new_table->name = name_mapper.mapPartitionName(*new_table);
applyCreatePhysicalTable(db_info, new_table);
}
}
}

template <typename Getter, typename NameMapper>
Expand Down

0 comments on commit dae275e

Please sign in to comment.