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

Commit e5c2213

Browse files
mbutrovichtli2
authored andcommitted
Revert 1415 (#1453)
* Revert "Constraint refactoring (#1415)" This reverts commit 898219f
1 parent cd681eb commit e5c2213

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+1591
-3415
lines changed

src/catalog/abstract_catalog.cpp

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
#include "planner/seq_scan_plan.h"
3030

3131
#include "executor/executor_context.h"
32-
#include "executor/create_executor.h"
3332
#include "executor/delete_executor.h"
3433
#include "executor/index_scan_executor.h"
3534
#include "executor/insert_executor.h"
@@ -61,24 +60,30 @@ AbstractCatalog::AbstractCatalog(storage::Database *pg_catalog,
6160

6261
AbstractCatalog::AbstractCatalog(concurrency::TransactionContext *txn,
6362
const std::string &catalog_table_ddl) {
64-
// Execute create catalog table
63+
// get catalog table schema
6564
auto &peloton_parser = parser::PostgresParser::GetInstance();
66-
std::unique_ptr<executor::ExecutorContext> context(
67-
new executor::ExecutorContext(txn));
6865
auto create_plan = std::dynamic_pointer_cast<planner::CreatePlan>(
6966
optimizer::Optimizer().BuildPelotonPlanTree(
7067
peloton_parser.BuildParseTree(catalog_table_ddl), txn));
71-
executor::CreateExecutor executor(create_plan.get(), context.get());
72-
73-
executor.Init();
74-
executor.Execute();
68+
auto catalog_table_schema = create_plan->GetSchema();
69+
auto catalog_table_name = create_plan->GetTableName();
70+
auto catalog_schema_name = create_plan->GetSchemaName();
71+
auto catalog_database_name = create_plan->GetDatabaseName();
72+
PELOTON_ASSERT(catalog_schema_name == std::string(CATALOG_SCHEMA_NAME));
73+
// create catalog table
74+
Catalog::GetInstance()->CreateTable(txn,
75+
catalog_database_name,
76+
catalog_schema_name,
77+
std::unique_ptr<catalog::Schema>(
78+
catalog_table_schema),
79+
catalog_table_name,
80+
true);
7581

7682
// get catalog table oid
77-
auto catalog_table_object =
78-
Catalog::GetInstance()->GetTableCatalogEntry(txn,
79-
create_plan->GetDatabaseName(),
80-
create_plan->GetSchemaName(),
81-
create_plan->GetTableName());
83+
auto catalog_table_object = Catalog::GetInstance()->GetTableCatalogEntry(txn,
84+
catalog_database_name,
85+
catalog_schema_name,
86+
catalog_table_name);
8287

8388
// set catalog_table_
8489
try {

src/catalog/catalog.cpp

Lines changed: 106 additions & 601 deletions
Large diffs are not rendered by default.

src/catalog/column.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,7 @@ void Column::SetInlined() {
4545
const std::string Column::GetInfo() const {
4646
std::ostringstream os;
4747

48-
os << "Column[" << column_name_ << ", "
49-
<< TypeIdToString(column_type_) << ", "
50-
48+
os << "Column[" << column_name << ", " << TypeIdToString(column_type_) << ", "
5149
<< "Offset:" << column_offset_ << ", ";
5250

5351
if (is_inlined_) {
@@ -56,17 +54,19 @@ const std::string Column::GetInfo() const {
5654
os << "VarLength:" << variable_length_;
5755
}
5856

59-
if (is_not_null_ && has_default_) {
60-
os << ", {NOT NULL, DEFAULT:"
61-
<< default_value_->ToString() << "}";
62-
} else if (is_not_null_) {
63-
os << ", {NOT NULL}";
64-
} else if (has_default_) {
65-
os << ", {DEFAULT:"
66-
<< default_value_->ToString() << "}";
67-
57+
if (constraints_.empty() == false) {
58+
os << ", {";
59+
bool first = true;
60+
for (auto constraint : constraints_) {
61+
if (first) {
62+
first = false;
63+
} else {
64+
os << ", ";
65+
}
66+
os << constraint.GetInfo();
67+
}
68+
os << "}";
6869
}
69-
7070
os << "]";
7171

7272
return (os.str());

0 commit comments

Comments
 (0)