提交 1c40013d 编写于 作者: 羽飞's avatar 羽飞

add newline after response

上级 6c23afd0
......@@ -176,8 +176,7 @@ void ExecuteStage::handle_request(common::StageEvent *event)
session_event->set_response(strrc(rc));
} break;
case SCF_BEGIN: {
session->set_trx_multi_operation_mode(true);
session_event->set_response(strrc(RC::SUCCESS));
session_event->set_response("SUCCESS\n");
} break;
case SCF_COMMIT: {
Trx *trx = session->current_trx();
......@@ -273,7 +272,6 @@ IndexScanOperator *try_to_create_index_scan_operator(FilterStmt *filter_stmt)
Expression *left = filter_unit->left();
Expression *right = filter_unit->right();
CompOp comp = filter_unit->comp();
if (left->type() == ExprType::FIELD && right->type() == ExprType::VALUE) {
} else if (left->type() == ExprType::VALUE && right->type() == ExprType::FIELD) {
std::swap(left, right);
......@@ -458,9 +456,9 @@ RC ExecuteStage::do_create_table(SQLStageEvent *sql_event)
RC rc = db->create_table(create_table.relation_name,
create_table.attribute_count, create_table.attributes);
if (rc == RC::SUCCESS) {
session_event->set_response("SUCCESS");
session_event->set_response("SUCCESS\n");
} else {
session_event->set_response("FAILURE");
session_event->set_response("FAILURE\n");
}
return rc;
}
......@@ -471,12 +469,12 @@ RC ExecuteStage::do_create_index(SQLStageEvent *sql_event)
const CreateIndex &create_index = sql_event->query()->sstr.create_index;
Table *table = db->find_table(create_index.relation_name);
if (nullptr == table) {
session_event->set_response("FAILURE");
session_event->set_response("FAILURE\n");
return RC::SCHEMA_TABLE_NOT_EXIST;
}
RC rc = table->create_index(nullptr, create_index.index_name, create_index.attribute_name);
sql_event->session_event()->set_response(rc == RC::SUCCESS ? "SUCCESS" : "FAILURE");
sql_event->session_event()->set_response(rc == RC::SUCCESS ? "SUCCESS\n" : "FAILURE\n");
return rc;
}
......@@ -529,9 +527,9 @@ RC ExecuteStage::do_insert(SQLStageEvent *sql_event)
Table *table = insert_stmt->table();
RC rc = table->insert_record(nullptr, insert_stmt->value_amount(), insert_stmt->values());
if (rc == RC::SUCCESS) {
session_event->set_response("SUCCESS");
session_event->set_response("SUCCESS\n");
} else {
session_event->set_response("FAILURE");
session_event->set_response("FAILURE\n");
}
return rc;
}
......@@ -555,9 +553,9 @@ RC ExecuteStage::do_delete(SQLStageEvent *sql_event)
RC rc = delete_oper.open();
if (rc != RC::SUCCESS) {
session_event->set_response("FAILURE");
session_event->set_response("FAILURE\n");
} else {
session_event->set_response("SUCCESS");
session_event->set_response("SUCCESS\n");
}
return rc;
}
......@@ -132,7 +132,7 @@ RC ParseStage::handle_request(StageEvent *event)
RC ret = parse(sql.c_str(), query_result);
if (ret != RC::SUCCESS) {
// set error information to event
sql_event->session_event()->set_response("Failed to parse sql");
sql_event->session_event()->set_response("Failed to parse sql\n");
query_destroy(query_result);
return RC::INTERNAL;
}
......
......@@ -78,44 +78,44 @@ RC SelectStmt::create(Db *db, const Selects &select_sql, Stmt *&stmt)
const char *field_name = relation_attr.attribute_name;
if (0 == strcmp(table_name, "*")) {
if (0 != strcmp(field_name, "*")) {
LOG_WARN("invalid field name while table is *. attr=%s", field_name);
return RC::SCHEMA_FIELD_MISSING;
}
for (Table *table : tables) {
wildcard_fields(table, query_fields);
}
if (0 != strcmp(field_name, "*")) {
LOG_WARN("invalid field name while table is *. attr=%s", field_name);
return RC::SCHEMA_FIELD_MISSING;
}
for (Table *table : tables) {
wildcard_fields(table, query_fields);
}
} else {
auto iter = table_map.find(table_name);
if (iter == table_map.end()) {
LOG_WARN("no such table in from list: %s", table_name);
return RC::SCHEMA_FIELD_MISSING;
}
Table *table = iter->second;
if (0 == strcmp(field_name, "*")) {
wildcard_fields(table, query_fields);
} else {
const FieldMeta *field_meta = table->table_meta().field(field_name);
if (nullptr == field_meta) {
LOG_WARN("no such field. field=%s.%s.%s", db->name(), table->name(), field_name);
return RC::SCHEMA_FIELD_MISSING;
}
query_fields.push_back(Field(table, field_meta));
}
auto iter = table_map.find(table_name);
if (iter == table_map.end()) {
LOG_WARN("no such table in from list: %s", table_name);
return RC::SCHEMA_FIELD_MISSING;
}
Table *table = iter->second;
if (0 == strcmp(field_name, "*")) {
wildcard_fields(table, query_fields);
} else {
const FieldMeta *field_meta = table->table_meta().field(field_name);
if (nullptr == field_meta) {
LOG_WARN("no such field. field=%s.%s.%s", db->name(), table->name(), field_name);
return RC::SCHEMA_FIELD_MISSING;
}
query_fields.push_back(Field(table, field_meta));
}
}
} else {
if (tables.size() != 1) {
LOG_WARN("invalid. I do not know the attr's table. attr=%s", relation_attr.attribute_name);
return RC::SCHEMA_FIELD_MISSING;
LOG_WARN("invalid. I do not know the attr's table. attr=%s", relation_attr.attribute_name);
return RC::SCHEMA_FIELD_MISSING;
}
Table *table = tables[0];
const FieldMeta *field_meta = table->table_meta().field(relation_attr.attribute_name);
if (nullptr == field_meta) {
LOG_WARN("no such field. field=%s.%s.%s", db->name(), table->name(), relation_attr.attribute_name);
return RC::SCHEMA_FIELD_MISSING;
LOG_WARN("no such field. field=%s.%s.%s", db->name(), table->name(), relation_attr.attribute_name);
return RC::SCHEMA_FIELD_MISSING;
}
query_fields.push_back(Field(table, field_meta));
......@@ -132,7 +132,7 @@ RC SelectStmt::create(Db *db, const Selects &select_sql, Stmt *&stmt)
// create filter statement in `where` statement
FilterStmt *filter_stmt = nullptr;
RC rc = FilterStmt::create(db, default_table, &table_map,
select_sql.conditions, select_sql.condition_num, filter_stmt);
select_sql.conditions, select_sql.condition_num, filter_stmt);
if (rc != RC::SUCCESS) {
LOG_WARN("cannot construct filter stmt");
return rc;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册