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

add newline after response

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