1212
1313#include " catalog/abstract_catalog.h"
1414
15- #include " binder/bind_node_visitor.h"
16-
1715#include " common/statement.h"
1816
17+ #include " catalog/catalog.h"
1918#include " catalog/database_catalog.h"
2019#include " catalog/table_catalog.h"
2120
@@ -59,25 +58,11 @@ AbstractCatalog::AbstractCatalog(oid_t catalog_table_oid,
5958
6059AbstractCatalog::AbstractCatalog (const std::string &catalog_table_ddl,
6160 concurrency::TransactionContext *txn) {
62- // Get catalog table schema
61+ // get catalog table schema
6362 auto &peloton_parser = parser::PostgresParser::GetInstance ();
64-
65- // Build the parse tree
66- const auto parse_tree_list = peloton_parser.BuildParseTree (catalog_table_ddl);
67- if (parse_tree_list->GetStatements ().empty ()) {
68- throw CatalogException (
69- " Parse tree list has no parse trees. Cannot build plan" );
70- }
71- // TODO: support multi-statement queries
72- auto parse_tree = parse_tree_list->GetStatement (0 );
73-
74- // Run binder
75- auto bind_node_visitor = binder::BindNodeVisitor (txn, DATABASE_CATALOG_NAME);
76- bind_node_visitor.BindNameToNode (parse_tree);
77-
78- // Create the plan tree
7963 auto create_plan = std::dynamic_pointer_cast<planner::CreatePlan>(
80- optimizer::Optimizer ().BuildPelotonPlanTree (parse_tree_list, txn));
64+ optimizer::Optimizer ().BuildPelotonPlanTree (
65+ peloton_parser.BuildParseTree (catalog_table_ddl), txn));
8166 auto catalog_table_schema = create_plan->GetSchema ();
8267 auto catalog_table_name = create_plan->GetTableName ();
8368 auto catalog_schema_name = create_plan->GetSchemaName ();
@@ -88,15 +73,17 @@ AbstractCatalog::AbstractCatalog(const std::string &catalog_table_ddl,
8873 catalog_database_name, catalog_schema_name, catalog_table_name,
8974 std::unique_ptr<catalog::Schema>(catalog_table_schema), txn, true );
9075
91- // Get catalog table oid
76+ // get catalog table oid
9277 auto catalog_table_object = Catalog::GetInstance ()->GetTableObject (
9378 catalog_database_name, catalog_schema_name, catalog_table_name, txn);
9479
95- // Set catalog_table_
80+ // set catalog_table_
9681 try {
9782 catalog_table_ = storage::StorageManager::GetInstance ()->GetTableWithOid (
9883 catalog_table_object->GetDatabaseOid (),
9984 catalog_table_object->GetTableOid ());
85+ // set database_oid
86+ database_oid = catalog_table_object->GetDatabaseOid ();
10087 } catch (CatalogException &e) {
10188 LOG_TRACE (" Can't find table %d! Return false" ,
10289 catalog_table_object->GetTableOid ());
@@ -336,7 +323,8 @@ bool AbstractCatalog::UpdateWithIndexScan(
336323 std::vector<expression::AbstractExpression *> runtime_keys;
337324
338325 planner::IndexScanPlan::IndexScanDesc index_scan_desc (
339- index, key_column_offsets, expr_types, scan_values, runtime_keys);
326+ index->GetOid (), key_column_offsets, expr_types, scan_values,
327+ runtime_keys);
340328
341329 planner::IndexScanPlan index_scan_node (catalog_table_, nullptr ,
342330 update_columns, index_scan_desc);
0 commit comments