Skip to content

Commit

Permalink
fix internal catalog tables cannot be updated with SQL.
Browse files Browse the repository at this point in the history
  • Loading branch information
liyichao committed Apr 23, 2022
1 parent 79276e6 commit 214603c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/optimizer/plan_generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -906,7 +906,7 @@ void PlanGenerator::Visit(const Update *op) {
}
}

std::unordered_set<std::string> update_column_names;
std::unordered_set<catalog::col_oid_t> update_column_oids;

// Evaluate update expression and add to target list
auto updates = op->GetUpdateClauses();
Expand All @@ -922,7 +922,7 @@ void PlanGenerator::Visit(const Update *op) {
auto upd_value = parser::ExpressionUtil::EvaluateExpression(children_expr_map_, update->GetUpdateValue()).release();
builder.AddSetClause(std::make_pair(col_id, common::ManagedPointer(upd_value)));

update_column_names.insert(update->GetColumnName());
update_column_oids.insert(col_id);
RegisterPointerCleanup<parser::AbstractExpression>(upd_value, true, true);
}

Expand All @@ -931,8 +931,8 @@ void PlanGenerator::Visit(const Update *op) {
// TODO(tanujnay112) can optimize if we stored updated column oids in the update nodes during binding
// such that we didn't have to store string sets
for (auto &cve : cves) {
if (update_column_names.find(cve.CastManagedPointerTo<parser::ColumnValueExpression>()->GetColumnName()) !=
update_column_names.end()) {
if (update_column_oids.find(cve.CastManagedPointerTo<parser::ColumnValueExpression>()->GetColumnOid()) !=
update_column_oids.end()) {
indexed_update = true;
break;
}
Expand Down

0 comments on commit 214603c

Please sign in to comment.