Skip to content

Commit

Permalink
handling special case in DROP TABLE
Browse files Browse the repository at this point in the history
  • Loading branch information
hannes committed Oct 2, 2019
1 parent a26deaa commit 1134aa3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/include/parser/parsed_data/drop_info.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ struct DropInfo {
//! are any)
bool cascade = false;

DropInfo() : schema(DEFAULT_SCHEMA), if_exists(false), cascade(false) {
DropInfo() : schema(INVALID_SCHEMA), if_exists(false), cascade(false) {
}
};

Expand Down
13 changes: 6 additions & 7 deletions src/planner/planner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,12 @@ void Planner::CreatePlan(unique_ptr<SQLStatement> statement) {
context.catalog.DropView(context.ActiveTransaction(), stmt.info.get());
break;
case CatalogType::TABLE: {
// handle temporary tables, they take name precedence

// TODO if there is an explicit schema set in the stmt, dont do this
// TODO check schema name and then act accordingly
auto temp = context.temporary_objects->GetTableOrNull(context.ActiveTransaction(), stmt.info->name);
if (temp) {
context.temporary_objects->DropTable(context.ActiveTransaction(), stmt.info.get());
// handle temporary tables, they take name precedence, but only if no non-temp schema is set
if (stmt.info->schema == INVALID_SCHEMA || stmt.info->schema == TEMP_SCHEMA) {
auto temp = context.temporary_objects->GetTableOrNull(context.ActiveTransaction(), stmt.info->name);
if (temp) {
context.temporary_objects->DropTable(context.ActiveTransaction(), stmt.info.get());
}
}
else {
context.catalog.DropTable(context.ActiveTransaction(), stmt.info.get());
Expand Down

0 comments on commit 1134aa3

Please sign in to comment.