Skip to content

Commit

Permalink
Skip read regenerate_schema_map is not present (#6672)
Browse files Browse the repository at this point in the history
close #6580
  • Loading branch information
CalvinNeo authored Jan 20, 2023
1 parent 73f8c22 commit 1f9ec07
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
5 changes: 4 additions & 1 deletion dbms/src/TiDB/Schema/SchemaGetter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,10 @@ void SchemaDiff::deserialize(const String & data)
old_table_id = obj->getValue<Int64>("old_table_id");
old_schema_id = obj->getValue<Int64>("old_schema_id");

regenerate_schema_map = obj->getValue<bool>("regenerate_schema_map");
if (obj->has("regenerate_schema_map"))
{
regenerate_schema_map = obj->getValue<bool>("regenerate_schema_map");
}

affected_opts.clear();
auto affected_arr = obj->getArray("affected_options");
Expand Down
12 changes: 11 additions & 1 deletion dbms/src/TiDB/Schema/tests/gtest_schema_sync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ extern const char force_context_path[];
} // namespace FailPoints
namespace tests
{

class SchemaSyncTest : public ::testing::Test
{
public:
Expand Down Expand Up @@ -179,6 +178,17 @@ class SchemaSyncTest : public ::testing::Test
Context & global_ctx;
};

TEST_F(SchemaSyncTest, SchemaDiff)
try
{
// Note that if we want to add new fields here, please firstly check if it is present.
// Otherwise it will break when doing upgrading test.
SchemaDiff diff;
std::string data = "{\"version\":40,\"type\":31,\"schema_id\":69,\"table_id\":71,\"old_table_id\":0,\"old_schema_id\":0,\"affected_options\":null}";
ASSERT_NO_THROW(diff.deserialize(data));
}
CATCH

TEST_F(SchemaSyncTest, RenameTables)
try
{
Expand Down

0 comments on commit 1f9ec07

Please sign in to comment.