From 7779cc28dec061686034018bb33232600c63679d Mon Sep 17 00:00:00 2001 From: hnwyllmm Date: Mon, 11 Jul 2022 13:28:07 +0800 Subject: [PATCH] compiled by gcc --- src/observer/sql/stmt/delete_stmt.cpp | 2 +- src/observer/sql/stmt/filter_stmt.cpp | 8 ++--- src/observer/sql/stmt/filter_stmt.h | 4 +-- src/observer/sql/stmt/select_stmt.cpp | 2 +- src/observer/storage/common/record.h | 1 + .../storage/default/default_storage_stage.cpp | 34 ------------------- 6 files changed, 9 insertions(+), 42 deletions(-) diff --git a/src/observer/sql/stmt/delete_stmt.cpp b/src/observer/sql/stmt/delete_stmt.cpp index 114e4f8..452f0be 100644 --- a/src/observer/sql/stmt/delete_stmt.cpp +++ b/src/observer/sql/stmt/delete_stmt.cpp @@ -46,7 +46,7 @@ RC DeleteStmt::create(Db *db, const Deletes &delete_sql, Stmt *&stmt) return RC::SCHEMA_TABLE_NOT_EXIST; } - std::unordered_map table_map; + std::unordered_map table_map; table_map.insert(std::pair(std::string_view(table_name), table)); FilterStmt *filter_stmt = nullptr; diff --git a/src/observer/sql/stmt/filter_stmt.cpp b/src/observer/sql/stmt/filter_stmt.cpp index cbc4ece..19d3b58 100644 --- a/src/observer/sql/stmt/filter_stmt.cpp +++ b/src/observer/sql/stmt/filter_stmt.cpp @@ -27,7 +27,7 @@ FilterStmt::~FilterStmt() filter_units_.clear(); } -RC FilterStmt::create(Db *db, Table *default_table, std::unordered_map *tables, +RC FilterStmt::create(Db *db, Table *default_table, std::unordered_map *tables, const Condition *conditions, int condition_num, FilterStmt *&stmt) { @@ -50,13 +50,13 @@ RC FilterStmt::create(Db *db, Table *default_table, std::unordered_map *tables, +RC get_table_and_field(Db *db, Table *default_table, std::unordered_map *tables, const RelAttr &attr, Table *&table, const FieldMeta *&field) { if (common::is_blank(attr.relation_name)) { table = default_table; } else if (nullptr != tables) { - auto iter = tables->find(std::string_view(attr.relation_name)); + auto iter = tables->find(std::string(attr.relation_name)); if (iter != tables->end()) { table = iter->second; } @@ -78,7 +78,7 @@ RC get_table_and_field(Db *db, Table *default_table, std::unordered_map *tables, +RC FilterStmt::create_filter_unit(Db *db, Table *default_table, std::unordered_map *tables, const Condition &condition, FilterUnit *&filter_unit) { RC rc = RC::SUCCESS; diff --git a/src/observer/sql/stmt/filter_stmt.h b/src/observer/sql/stmt/filter_stmt.h index b5c6f64..518e4d7 100644 --- a/src/observer/sql/stmt/filter_stmt.h +++ b/src/observer/sql/stmt/filter_stmt.h @@ -86,11 +86,11 @@ public: } public: - static RC create(Db *db, Table *default_table, std::unordered_map *tables, + static RC create(Db *db, Table *default_table, std::unordered_map *tables, const Condition *conditions, int condition_num, FilterStmt *&stmt); - static RC create_filter_unit(Db *db, Table *default_table, std::unordered_map *tables, + static RC create_filter_unit(Db *db, Table *default_table, std::unordered_map *tables, const Condition &condition, FilterUnit *&filter_unit); private: diff --git a/src/observer/sql/stmt/select_stmt.cpp b/src/observer/sql/stmt/select_stmt.cpp index a8eca82..aa56ea5 100644 --- a/src/observer/sql/stmt/select_stmt.cpp +++ b/src/observer/sql/stmt/select_stmt.cpp @@ -45,7 +45,7 @@ RC SelectStmt::create(Db *db, const Selects &select_sql, Stmt *&stmt) // collect tables in `from` statement std::vector tables; - std::unordered_map table_map; + std::unordered_map table_map; for (int i = 0; i < select_sql.relation_num; i++) { const char *table_name = select_sql.relations[i]; if (nullptr == table_name) { diff --git a/src/observer/storage/common/record.h b/src/observer/storage/common/record.h index 963a371..28c6faf 100644 --- a/src/observer/storage/common/record.h +++ b/src/observer/storage/common/record.h @@ -16,6 +16,7 @@ See the Mulan PSL v2 for more details. */ #include #include +#include #include #include "rc.h" diff --git a/src/observer/storage/default/default_storage_stage.cpp b/src/observer/storage/default/default_storage_stage.cpp index 5fb9413..d59334d 100644 --- a/src/observer/storage/default/default_storage_stage.cpp +++ b/src/observer/storage/default/default_storage_stage.cpp @@ -158,40 +158,6 @@ void DefaultStorageStage::handle_event(StageEvent *event) char response[256]; switch (sql->flag) { - case SCF_INSERT: { // insert into - const Inserts &inserts = sql->sstr.insertion; - const char *table_name = inserts.relation_name; - //rc = handler_->insert_record(current_trx, current_db, table_name, inserts.value_num, inserts.values); - snprintf(response, sizeof(response), "%s\n", rc == RC::SUCCESS ? "SUCCESS" : "FAILURE"); - } break; - case SCF_UPDATE: { - const Updates &updates = sql->sstr.update; - const char *table_name = updates.relation_name; - const char *field_name = updates.attribute_name; - int updated_count = 0; - #if 0 - rc = handler_->update_record(current_trx, - current_db, - table_name, - field_name, - &updates.value, - updates.condition_num, - updates.conditions, - &updated_count); - #endif - snprintf(response, sizeof(response), "%s\n", rc == RC::SUCCESS ? "SUCCESS" : "FAILURE"); - } break; - case SCF_DELETE: { - const Deletes &deletes = sql->sstr.deletion; - const char *table_name = deletes.relation_name; - int deleted_count = 0; - #if 0 - rc = handler_->delete_record( - current_trx, current_db, table_name, deletes.condition_num, deletes.conditions, &deleted_count); - #endif - snprintf(response, sizeof(response), "%s\n", rc == RC::SUCCESS ? "SUCCESS" : "FAILURE"); - } break; - case SCF_LOAD_DATA: { /* 从文件导入数据,如果做性能测试,需要保持这些代码可以正常工作 -- GitLab