Skip to content

Commit

Permalink
Fix schema version setting to -1 when bootstrap (#278)
Browse files Browse the repository at this point in the history
  • Loading branch information
zanmato1984 authored Oct 12, 2019
1 parent a3f9370 commit 9fa88a2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions dbms/src/Storages/Transaction/SchemaBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@
#include <Parsers/ASTLiteral.h>
#include <Parsers/ASTRenameQuery.h>
#include <Parsers/ParserCreateQuery.h>
#include <Parsers/ParserDropQuery.h>
#include <Parsers/parseQuery.h>
#include <Storages/MutableSupport.h>
#include <Storages/Transaction/SchemaBuilder.h>
#include <Storages/Transaction/SchemaBuilder-internal.h>
#include <Storages/Transaction/SchemaBuilder.h>
#include <Storages/Transaction/TMTContext.h>
#include <Storages/Transaction/TypeMapping.h>

Expand Down Expand Up @@ -342,7 +341,8 @@ void SchemaBuilder<Getter>::applyAlterPartition(TiDB::DBInfoPtr db_info, TableID
orig_defs.begin(), orig_defs.end(), [&](const PartitionDefinition & orig_def) { return new_def.id == orig_def.id; });
if (it == orig_defs.end())
{
applyCreatePhysicalTableImpl(*db_info, table_info->producePartitionTableInfo(new_def.id));
auto part_table_info = table_info->producePartitionTableInfo(new_def.id);
applyCreatePhysicalTableImpl(*db_info, part_table_info);
}
}
}
Expand Down Expand Up @@ -551,8 +551,10 @@ String createTableStmt(const DBInfo & db_info, const TableInfo & table_info)
}

template <typename Getter>
void SchemaBuilder<Getter>::applyCreatePhysicalTableImpl(const TiDB::DBInfo & db_info, const TiDB::TableInfo & table_info)
void SchemaBuilder<Getter>::applyCreatePhysicalTableImpl(const TiDB::DBInfo & db_info, TiDB::TableInfo & table_info)
{
table_info.schema_version = target_version;

String stmt = createTableStmt(db_info, table_info);

LOG_INFO(log, "try to create table with stmt: " << stmt);
Expand Down Expand Up @@ -586,7 +588,6 @@ void SchemaBuilder<Getter>::applyCreateTable(TiDB::DBInfoPtr db_info, Int64 tabl
template <typename Getter>
void SchemaBuilder<Getter>::applyCreateTableImpl(const TiDB::DBInfo & db_info, TiDB::TableInfo & table_info)
{
table_info.schema_version = target_version;
if (table_info.isLogicalPartitionTable())
{
// create partition table.
Expand Down
2 changes: 1 addition & 1 deletion dbms/src/Storages/Transaction/SchemaBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ struct SchemaBuilder

void applyAlterPartition(TiDB::DBInfoPtr db_info, Int64 table_id);

void applyCreatePhysicalTableImpl(const TiDB::DBInfo & db_info, const TiDB::TableInfo & table_info);
void applyCreatePhysicalTableImpl(const TiDB::DBInfo & db_info, TiDB::TableInfo & table_info);

void applyCreateTableImpl(const TiDB::DBInfo & db_info, TiDB::TableInfo & table_info);

Expand Down

0 comments on commit 9fa88a2

Please sign in to comment.