diff --git a/src/observer/sql/expr/tuple.h b/src/observer/sql/expr/tuple.h index cd0a10e1cf79cc2eb83625fae0a19a4d9841fbfe..07c33c793e17a61f9f2cd4bb1cf01ca90fc7f06c 100644 --- a/src/observer/sql/expr/tuple.h +++ b/src/observer/sql/expr/tuple.h @@ -55,7 +55,6 @@ public: } private: - // TODO table and field cannot describe all scenerio, should be expression const char *alias_ = nullptr; Expression *expression_ = nullptr; }; diff --git a/src/observer/sql/expr/tuple_cell.cpp b/src/observer/sql/expr/tuple_cell.cpp index d9bc40a2fb2b12f1dc78de3c9ae1a19b869f246b..9ccd3d393cb27aa0df6923d1b33df298216baf29 100644 --- a/src/observer/sql/expr/tuple_cell.cpp +++ b/src/observer/sql/expr/tuple_cell.cpp @@ -29,7 +29,7 @@ void TupleCell::to_string(std::ostream &os) const case CHARS: { for (int i = 0; i < 4; i++) { // the max length of CHARS is 4 if (data_[i] == '\0') { - break; + break; } os << data_[i]; } diff --git a/src/observer/sql/operator/join_operator.h b/src/observer/sql/operator/join_operator.h index 4bfe26136a25c8f376289359d25911cdc21ff067..97e4f7e6dce3f84a44a5e3b0a3ba1223edf39753 100644 --- a/src/observer/sql/operator/join_operator.h +++ b/src/observer/sql/operator/join_operator.h @@ -18,8 +18,7 @@ See the Mulan PSL v2 for more details. */ #include "sql/operator/operator.h" #include "rc.h" -class JoinPredicate; - +// TODO fixme class JoinOperator : public Operator { public: @@ -35,6 +34,5 @@ public: private: Operator *left_ = nullptr; Operator *right_ = nullptr; - JoinPredicate *predicate_ = nullptr; bool round_done_ = true; }; diff --git a/src/observer/sql/parser/#parse_stage.h# b/src/observer/sql/parser/#parse_stage.h# deleted file mode 100644 index b14e40a9d2fbcd926a2c3829c7a66825efc90d8d..0000000000000000000000000000000000000000 --- a/src/observer/sql/parser/#parse_stage.h# +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright (c) 2021 Xie Meiyi(xiemeiyi@hust.edu.cn) and OceanBase and/or its affiliates. All rights reserved. -miniob is licensed under Mulan PSL v2. -You can use this software according to the terms and conditions of the Mulan PSL v2. -You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 -THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, -EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, -MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. -See the Mulan PSL v2 for more details. */ - -// -// Created by Longda on 2021/4/13. -// - -#ifndef __OBSERVER_SQL_PARSE_STAGE_H__ -#define __OBSERVER_SQL_PARSE_STAGE_H__ - -#include "common/seda/stage.h" - -class ParseStage : public common::Stage { -public: - ~ParseStage(); - static Stage *make_stage(const std::string &tag); - -protected: - // common function - ParseStage(const char *tag); - bool set_properties(); - - bool initialize(); - void cleanup(); - void handle_event(common::StageEvent *event); - void callback_event(common::StageEvent *event, common::CallbackContext *context); - -protected: - common::StageEvent *handle_request(common::StageEvent *event); - -private: - Stage *resolve_stage_ = nullptr; -}; - -#endif //__OBSERVER_SQL_PARSE_STAGE_H__ diff --git a/src/observer/sql/stmt/update_stmt.cpp b/src/observer/sql/stmt/update_stmt.cpp index a0cf4bf18f6b951ef87680afdba98c2e22f9817f..89331f54c740b0a26432cb7a92da4a406365e0d8 100644 --- a/src/observer/sql/stmt/update_stmt.cpp +++ b/src/observer/sql/stmt/update_stmt.cpp @@ -21,45 +21,6 @@ UpdateStmt::UpdateStmt(Table *table, Value *values, int value_amount) RC UpdateStmt::create(Db *db, const Updates &update, Stmt *&stmt) { // TODO - #if 0 - const char *table_name = update.relation_name; - if (nullptr == db || nullptr == table_name || update.value_num <= 0) { - LOG_WARN("invalid argument. db=%p, table_name=%p, value_num=%d", - db, table_name, inserts.value_num); - return RC::INVALID_ARGUMENT; - } - - // check whether the table exists - Table *table = db->find_table(table_name); - if (nullptr == table) { - LOG_WARN("no such table. db=%s, table_name=%s", db->name(), table_name); - return RC::SCHEMA_TABLE_NOT_EXIST; - } - - // check the fields number - const Value *values = inserts.values; - const int value_num = inserts.value_num; - const TableMeta &table_meta = table->table_meta(); - const int field_num = table_meta.field_num() - table_meta.sys_field_num(); - if (field_num != value_num) { - LOG_WARN("schema mismatch. value num=%d, field num in schema=%d", value_num, field_num); - return RC::SCHEMA_FIELD_MISSING; - } - - // check fields type - for (int i = table_meta.sys_field_num(); i < table_meta.field_num(); i++) { - const FieldMeta *field_meta = table_meta.field(i); - const AttrType field_type = field_meta->type(); - const AttrType value_type = values[i].type; - if (field_type != value_type) { // TODO try to convert the value type to field type - LOG_WARN("field type mismatch. table=%s, field=%s, field type=%d, value_type=%d", - table_name, field_meta->name(), field_type, value_type); - return RC::SCHEMA_FIELD_TYPE_MISMATCH; - } - } - - // everything alright - stmt = new InsertStmt(table, values, value_num); - #endif + stmt = nullptr; return RC::INTERNAL; } diff --git a/src/observer/storage/common/table.cpp b/src/observer/storage/common/table.cpp index 4309f022cec43981d3eb3e8f9abd4fa2705a9fef..7ff43cab5cc255c2aa937b7805a392a3553a1d9f 100644 --- a/src/observer/storage/common/table.cpp +++ b/src/observer/storage/common/table.cpp @@ -392,15 +392,16 @@ static RC scan_record_reader_adapter(Record *record, void *context) return RC::SUCCESS; } -RC Table::scan_record( - Trx *trx, ConditionFilter *filter, int limit, void *context, void (*record_reader)(const char *data, void *context)) +RC Table::scan_record(Trx *trx, ConditionFilter *filter, + int limit, void *context, + void (*record_reader)(const char *data, void *context)) { RecordReaderScanAdapter adapter(record_reader, context); return scan_record(trx, filter, limit, (void *)&adapter, scan_record_reader_adapter); } RC Table::scan_record(Trx *trx, ConditionFilter *filter, int limit, void *context, - RC (*record_reader)(Record *record, void *context)) + RC (*record_reader)(Record *record, void *context)) { if (nullptr == record_reader) { return RC::INVALID_ARGUMENT; @@ -448,8 +449,9 @@ RC Table::scan_record(Trx *trx, ConditionFilter *filter, int limit, void *contex return rc; } -RC Table::scan_record_by_index(Trx *trx, IndexScanner *scanner, ConditionFilter *filter, int limit, void *context, - RC (*record_reader)(Record *, void *)) +RC Table::scan_record_by_index(Trx *trx, IndexScanner *scanner, ConditionFilter *filter, + int limit, void *context, + RC (*record_reader)(Record *, void *)) { RC rc = RC::SUCCESS; RID rid; @@ -515,9 +517,7 @@ RC Table::create_index(Trx *trx, const char *index_name, const char *attribute_n } if (table_meta_.index(index_name) != nullptr || table_meta_.find_index_by_field((attribute_name))) { LOG_INFO("Invalid input arguments, table name is %s, index %s exist or attribute %s exist index", - name(), - index_name, - attribute_name); + name(), index_name, attribute_name); return RC::SCHEMA_INDEX_EXIST; } @@ -530,7 +530,8 @@ RC Table::create_index(Trx *trx, const char *index_name, const char *attribute_n IndexMeta new_index_meta; RC rc = new_index_meta.init(index_name, *field_meta); if (rc != RC::SUCCESS) { - LOG_INFO("Failed to init IndexMeta in table:%s, index_name:%s, field_name:%s", name(), index_name, attribute_name); + LOG_INFO("Failed to init IndexMeta in table:%s, index_name:%s, field_name:%s", + name(), index_name, attribute_name); return rc; } @@ -654,10 +655,7 @@ RC Table::delete_record(Trx *trx, Record *record) rc = delete_entry_of_indexes(record->data(), record->rid(), false); // 重复代码 refer to commit_delete if (rc != RC::SUCCESS) { LOG_ERROR("Failed to delete indexes of record (rid=%d.%d). rc=%d:%s", - record->rid().page_num, - record->rid().slot_num, - rc, - strrc(rc)); + record->rid().page_num, record->rid().slot_num, rc, strrc(rc)); } else { rc = record_handler_->delete_record(&record->rid()); } @@ -676,10 +674,7 @@ RC Table::commit_delete(Trx *trx, const RID &rid) rc = delete_entry_of_indexes(record.data(), record.rid(), false); if (rc != RC::SUCCESS) { LOG_ERROR("Failed to delete indexes of record(rid=%d.%d). rc=%d:%s", - rid.page_num, - rid.slot_num, - rc, - strrc(rc)); // panic? + rid.page_num, rid.slot_num, rc, strrc(rc)); // panic? } rc = record_handler_->delete_record(&rid); @@ -854,10 +849,7 @@ RC Table::sync() rc = index->sync(); if (rc != RC::SUCCESS) { LOG_ERROR("Failed to flush index's pages. table=%s, index=%s, rc=%d:%s", - name(), - index->index_meta().name(), - rc, - strrc(rc)); + name(), index->index_meta().name(), rc, strrc(rc)); return rc; } } diff --git a/src/observer/storage/row/row.h b/src/observer/storage/row/row.h deleted file mode 100644 index 6898c0658b84bab826f58947d55c7f11043cccdc..0000000000000000000000000000000000000000 --- a/src/observer/storage/row/row.h +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright (c) 2021 Xie Meiyi(xiemeiyi@hust.edu.cn) and OceanBase and/or its affiliates. All rights reserved. -miniob is licensed under Mulan PSL v2. -You can use this software according to the terms and conditions of the Mulan PSL v2. -You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 -THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, -EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, -MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. -See the Mulan PSL v2 for more details. */ - -// -// Created by Wangyunlai on 2022/5/3. -// - -#ifndef __OBSERVER_STORAGE_ROW_ROW_H_ -#define __OBSERVER_STORAGE_ROW_ROW_H_ - -#include -#include - -#include "rc.h" -#include "storage/common/index_meta.h" -#include "storage/common/field_meta.h" -#include "storage/common/record_manager.h" - -class Row { - -public: - Row() = default; - ~Row() = default; - - RC init(const FieldMeta *fields_, int num); - - RC set_projector(); - -private: - std::vector fields_; - std::vector projector_; - char *data_; -}; - -#endif // __OBSERVER_STORAGE_ROW_ROW_H_