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

Commit 196f663

Browse files
ksaito7tli2
authored andcommitted
Fix TPC-C segfault (#1455)
1 parent e5c2213 commit 196f663

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

+3423
-1583
lines changed

Diff for: src/catalog/abstract_catalog.cpp

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

3131
#include "executor/executor_context.h"
32+
#include "executor/create_executor.h"
3233
#include "executor/delete_executor.h"
3334
#include "executor/index_scan_executor.h"
3435
#include "executor/insert_executor.h"
@@ -60,30 +61,24 @@ AbstractCatalog::AbstractCatalog(storage::Database *pg_catalog,
6061

6162
AbstractCatalog::AbstractCatalog(concurrency::TransactionContext *txn,
6263
const std::string &catalog_table_ddl) {
63-
// get catalog table schema
64+
// Execute create catalog table
6465
auto &peloton_parser = parser::PostgresParser::GetInstance();
66+
std::unique_ptr<executor::ExecutorContext> context(
67+
new executor::ExecutorContext(txn));
6568
auto create_plan = std::dynamic_pointer_cast<planner::CreatePlan>(
6669
optimizer::Optimizer().BuildPelotonPlanTree(
6770
peloton_parser.BuildParseTree(catalog_table_ddl), txn));
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);
71+
executor::CreateExecutor executor(create_plan.get(), context.get());
72+
73+
executor.Init();
74+
executor.Execute();
8175

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

8883
// set catalog_table_
8984
try {

Diff for: src/catalog/catalog.cpp

+601-106
Large diffs are not rendered by default.

Diff for: src/catalog/column.cpp

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

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

5153
if (is_inlined_) {
@@ -54,19 +56,17 @@ const std::string Column::GetInfo() const {
5456
os << "VarLength:" << variable_length_;
5557
}
5658

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 << "}";
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+
6968
}
69+
7070
os << "]";
7171

7272
return (os.str());

0 commit comments

Comments
 (0)