Skip to content

Commit

Permalink
fix: add arg db in NsClient::AddMultiIndex(#2205)
Browse files Browse the repository at this point in the history
  • Loading branch information
vagetablechicken authored Jul 21, 2022
1 parent df28cd3 commit dc76e43
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/client/ns_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,7 @@ bool NsClient::AddIndex(const std::string& db_name,
return false;
}

base::Status NsClient::AddMultiIndex(const std::string& table_name,
base::Status NsClient::AddMultiIndex(const std::string& db, const std::string& table_name,
const std::vector<::openmldb::common::ColumnKey>& column_keys) {
::openmldb::nameserver::AddIndexRequest request;
::openmldb::nameserver::GeneralResponse response;
Expand All @@ -896,7 +896,7 @@ base::Status NsClient::AddMultiIndex(const std::string& table_name,
}
}
request.set_name(table_name);
request.set_db(GetDb());
request.set_db(db);
bool ok = client_.SendRequest(&::openmldb::nameserver::NameServer_Stub::AddIndex, &request, &response,
FLAGS_request_timeout_ms, 1);
if (ok && response.code() == 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/client/ns_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ class NsClient : public Client {
std::vector<openmldb::common::ColumnDesc>* cols,
std::string& msg); // NOLINT

base::Status AddMultiIndex(const std::string& table_name,
base::Status AddMultiIndex(const std::string& db, const std::string& table_name,
const std::vector<::openmldb::common::ColumnKey>& column_keys);

bool DeleteIndex(const std::string& table_name, const std::string& idx_name,
Expand Down
2 changes: 1 addition & 1 deletion src/nameserver/name_server_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9040,7 +9040,7 @@ void NameServerImpl::AddIndex(RpcController* controller, const AddIndexRequest*
std::map<std::string, std::shared_ptr<::openmldb::client::TabletClient>> tablet_client_map;
if (!GetTableInfo(name, db, &table_info)) {
base::SetResponseStatus(ReturnCode::kTableIsNotExist, "table is not exist!", response);
LOG(WARNING) << "table[" << name << "] is not exist!";
LOG(WARNING) << "table[" << db << "." << name << "] is not exist!";
return;
}
if (table_info->storage_mode() != ::openmldb::common::kMemory) {
Expand Down
8 changes: 4 additions & 4 deletions src/sdk/sql_cluster_router.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3054,7 +3054,7 @@ hybridse::sdk::Status SQLClusterRouter::HandleIndex(const std::string& db,
return get_index_status;
}

auto add_index_status = AddNewIndex(table_map, new_index_map);
auto add_index_status = AddNewIndex(db, table_map, new_index_map);
if (!add_index_status.IsOK()) {
return add_index_status;
}
Expand Down Expand Up @@ -3178,16 +3178,16 @@ hybridse::sdk::Status SQLClusterRouter::GetNewIndex(
return {};
}

hybridse::sdk::Status SQLClusterRouter::AddNewIndex(
hybridse::sdk::Status SQLClusterRouter::AddNewIndex(const std::string& db,
const std::map<std::string, ::openmldb::nameserver::TableInfo>& table_map,
const std::map<std::string, std::vector<::openmldb::common::ColumnKey>>& new_index_map) {
auto ns = cluster_sdk_->GetNsClient();
if (cluster_sdk_->IsClusterMode()) {
for (auto& kv : new_index_map) {
auto status = ns->AddMultiIndex(kv.first, kv.second);
auto status = ns->AddMultiIndex(db, kv.first, kv.second);
if (!status.OK()) {
return {::hybridse::common::StatusCode::kCmdError,
"table " + kv.first + " add index failed. " + status.msg};
"table [" + db + "." + kv.first + "] add index failed. " + status.msg};
}
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/sdk/sql_cluster_router.h
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ class SQLClusterRouter : public SQLRouter {
std::map<std::string, std::vector<::openmldb::common::ColumnKey>>* new_index_map);

hybridse::sdk::Status AddNewIndex(
const std::map<std::string, ::openmldb::nameserver::TableInfo>& table_map,
const std::string& db, const std::map<std::string, ::openmldb::nameserver::TableInfo>& table_map,
const std::map<std::string, std::vector<::openmldb::common::ColumnKey>>& new_index_map);

hybridse::sdk::Status HandleCreateFunction(const hybridse::node::CreateFunctionPlanNode* node);
Expand Down

0 comments on commit dc76e43

Please sign in to comment.