Skip to content
This repository has been archived by the owner on Sep 27, 2019. It is now read-only.

Commit

Permalink
change type quick fix
Browse files Browse the repository at this point in the history
  • Loading branch information
DeanChensj committed May 13, 2018
1 parent 5b9818c commit 939df35
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
1 change: 0 additions & 1 deletion src/catalog/column.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ void Column::SetInlined() {
switch (column_type) {
case type::TypeId::VARCHAR:
case type::TypeId::VARBINARY:
is_inlined = false;
break; // No change of inlined setting

default:
Expand Down
19 changes: 11 additions & 8 deletions src/planner/alter_plan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ AlterPlan::AlterPlan(
database_name(database_name),
dropped_columns(dropped_columns),
type(a_type) {
this->added_columns = std::unique_ptr<catalog::Schema>(new catalog::Schema(*added_columns));
this->changed_type_columns = std::unique_ptr<catalog::Schema>(new catalog::Schema(*changed_type_columns));
this->added_columns =
std::unique_ptr<catalog::Schema>(new catalog::Schema(*added_columns));
this->changed_type_columns = std::unique_ptr<catalog::Schema>(
new catalog::Schema(*changed_type_columns));
}

AlterPlan::AlterPlan(const std::string &database_name,
Expand Down Expand Up @@ -85,25 +87,26 @@ AlterPlan::AlterPlan(parser::AlterTableStatement *parse_tree) {
}
columns.emplace_back(column);
}
added_columns = std::unique_ptr<catalog::Schema>(new catalog::Schema(columns));
added_columns =
std::unique_ptr<catalog::Schema>(new catalog::Schema(columns));
columns.clear();
// deal with change column types
for (size_t i = 0; i < (*parse_tree->changed_type_columns).size(); i++) {
auto &tmp = (*parse_tree->changed_type_columns)[i];
type::TypeId val = parser::ColumnDefinition::GetValueType(tmp.get()->type);
bool is_inline = (val == type::TypeId::VARCHAR) ? false : true;
type::TypeId val =
parser::ColumnDefinition::GetValueType(tmp.get()->type);
auto column = catalog::Column(
val, type::Type::GetTypeSize(val),
std::string((*parse_tree->changed_type_columns)[i].get()->name),
is_inline);
std::string((*parse_tree->changed_type_columns)[i].get()->name));
if ((*parse_tree->changed_type_columns)[i].get()->not_null) {
catalog::Constraint constraint(ConstraintType::NOTNULL,
"con_not_null");
column.AddConstraint(constraint);
}
columns.emplace_back(column);
}
changed_type_columns = std::unique_ptr<catalog::Schema>(new catalog::Schema(columns));
changed_type_columns =
std::unique_ptr<catalog::Schema>(new catalog::Schema(columns));
break;
}
default:
Expand Down

0 comments on commit 939df35

Please sign in to comment.