From 67cf978f0fdbc43e218d3136ca90a041f8c1bb35 Mon Sep 17 00:00:00 2001 From: Chloe Date: Mon, 17 May 2021 10:43:54 -0700 Subject: [PATCH] Added compatible names of SQL plugin for ODBC to check the ES connection (#1112) * added sql plugin compatible names when checking the installed plugins in odbc * update --- sql-odbc/src/odfesqlodbc/es_communication.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/sql-odbc/src/odfesqlodbc/es_communication.cpp b/sql-odbc/src/odfesqlodbc/es_communication.cpp index e40f170c79..0f7dde2b9c 100644 --- a/sql-odbc/src/odfesqlodbc/es_communication.cpp +++ b/sql-odbc/src/odfesqlodbc/es_communication.cpp @@ -21,6 +21,7 @@ // clang-format off #include "es_odbc.h" #include "mylog.h" +#include "array" #include #include #include @@ -37,6 +38,7 @@ static const std::string SQL_ENDPOINT_CLOSE_CURSOR = "/_opendistro/_sql/close"; static const std::string PLUGIN_ENDPOINT_FORMAT_JSON = "/_cat/plugins?format=json"; static const std::string OPENDISTRO_SQL_PLUGIN_NAME = "opendistro-sql"; +static const std::array< std::string, 2 > SQL_PLUGIN_COMPATIBLE_NAMES = {"opendistro-sql", "opendistro_sql"}; static const std::string ALLOCATION_TAG = "AWS_SIGV4_AUTH"; static const std::string SERVICE_NAME = "es"; static const std::string ESODBC_PROFILE_NAME = "elasticsearchodbc"; @@ -427,13 +429,15 @@ bool ESCommunication::IsSQLPluginInstalled(const std::string& plugin_response) { for (auto it : plugin_array) { if (it.has("component") && it.has("version")) { std::string plugin_name = it.at("component").as_string(); - if (!plugin_name.compare(OPENDISTRO_SQL_PLUGIN_NAME)) { - std::string sql_plugin_version = - it.at("version").as_string(); - LogMsg(ES_INFO, std::string("Found SQL plugin version '" - + sql_plugin_version + "'.") - .c_str()); - return true; + for (auto compatible_name : SQL_PLUGIN_COMPATIBLE_NAMES) { + if (!plugin_name.compare(compatible_name)) { + std::string sql_plugin_version = + it.at("version").as_string(); + LogMsg(ES_INFO, std::string("Found SQL plugin version '" + + sql_plugin_version + "'.") + .c_str()); + return true; + } } } else { m_error_message =