From dc76e43d1074b324e716ed93e6594194ce063b25 Mon Sep 17 00:00:00 2001 From: HuangWei Date: Thu, 21 Jul 2022 11:29:26 +0800 Subject: [PATCH] fix: add arg db in NsClient::AddMultiIndex(#2205) --- src/client/ns_client.cc | 4 ++-- src/client/ns_client.h | 2 +- src/nameserver/name_server_impl.cc | 2 +- src/sdk/sql_cluster_router.cc | 8 ++++---- src/sdk/sql_cluster_router.h | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/client/ns_client.cc b/src/client/ns_client.cc index cb9a05067ea..e0c98a88607 100644 --- a/src/client/ns_client.cc +++ b/src/client/ns_client.cc @@ -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; @@ -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) { diff --git a/src/client/ns_client.h b/src/client/ns_client.h index e7c23caf7e2..320540ebb02 100644 --- a/src/client/ns_client.h +++ b/src/client/ns_client.h @@ -217,7 +217,7 @@ class NsClient : public Client { std::vector* 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, diff --git a/src/nameserver/name_server_impl.cc b/src/nameserver/name_server_impl.cc index f548103e0db..a2eef8be8c7 100644 --- a/src/nameserver/name_server_impl.cc +++ b/src/nameserver/name_server_impl.cc @@ -9040,7 +9040,7 @@ void NameServerImpl::AddIndex(RpcController* controller, const AddIndexRequest* std::map> 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) { diff --git a/src/sdk/sql_cluster_router.cc b/src/sdk/sql_cluster_router.cc index e0095ccb990..7a0597deead 100644 --- a/src/sdk/sql_cluster_router.cc +++ b/src/sdk/sql_cluster_router.cc @@ -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; } @@ -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& table_map, const std::map>& 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 { diff --git a/src/sdk/sql_cluster_router.h b/src/sdk/sql_cluster_router.h index 37aa3b2b18a..b71e9872335 100644 --- a/src/sdk/sql_cluster_router.h +++ b/src/sdk/sql_cluster_router.h @@ -384,7 +384,7 @@ class SQLClusterRouter : public SQLRouter { std::map>* new_index_map); hybridse::sdk::Status AddNewIndex( - const std::map& table_map, + const std::string& db, const std::map& table_map, const std::map>& new_index_map); hybridse::sdk::Status HandleCreateFunction(const hybridse::node::CreateFunctionPlanNode* node);