From f39036d01be4fe1767370fd5998dba4e0f594da0 Mon Sep 17 00:00:00 2001 From: currantw Date: Fri, 15 Nov 2024 11:23:18 -0800 Subject: [PATCH] Minor cleanuo Signed-off-by: currantw --- src/sqlodbc/dlg_specific.c | 5 ++--- src/sqlodbc/opensearch_communication.cpp | 7 +++---- src/sqlodbc/opensearch_communication.h | 4 +--- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/sqlodbc/dlg_specific.c b/src/sqlodbc/dlg_specific.c index ea9b37f..954c244 100644 --- a/src/sqlodbc/dlg_specific.c +++ b/src/sqlodbc/dlg_specific.c @@ -38,8 +38,7 @@ void makeConnectString(char *connect_string, const ConnInfo *ci, UWORD len) { /* fundamental info */ nlen = MAX_CONNECT_STRING; - // Format string - const char* connect_string_format = + const char* connect_format_string = "%s=%s;" INI_SERVER "=%s;" "database=OpenSearch;" @@ -59,7 +58,7 @@ void makeConnectString(char *connect_string, const ConnInfo *ci, UWORD len) { olen = snprintf( connect_string, nlen, - connect_string_format, + connect_format_string, got_dsn ? "DSN" : "DRIVER", got_dsn ? ci->dsn : ci->drivername, ci->server, ci->port, diff --git a/src/sqlodbc/opensearch_communication.cpp b/src/sqlodbc/opensearch_communication.cpp index 928efb8..0c1127e 100644 --- a/src/sqlodbc/opensearch_communication.cpp +++ b/src/sqlodbc/opensearch_communication.cpp @@ -407,7 +407,7 @@ OpenSearchCommunication::IssueRequest( // Generate http request Aws::Http::URI host(m_rt_opts.conn.server.c_str()); if (!m_rt_opts.conn.port.empty()) { - host.SetPort((uint16_t)atoi(m_rt_opts.conn.port.c_str())); + host.SetPort((uint16_t) atoi(m_rt_opts.conn.port.c_str())); } host.SetPath(endpoint.c_str()); @@ -439,7 +439,7 @@ OpenSearchCommunication::IssueRequest( } // Handle authentication - std::string& auth_type = m_rt_opts.auth.auth_type; + const std::string& auth_type = m_rt_opts.auth.auth_type; if (auth_type == AUTHTYPE_BASIC) { std::string userpw_str = @@ -452,7 +452,6 @@ OpenSearchCommunication::IssueRequest( request->SetAuthorization("Basic " + hashed_userpw); } - // TODO #70: Handle serverless else if (auth_type == AUTHTYPE_IAM) { std::shared_ptr< Aws::Auth::ProfileConfigFileAWSCredentialsProvider > credential_provider = Aws::MakeShared< @@ -1097,7 +1096,7 @@ void OpenSearchCommunication::SetSqlEndpoint() { */ bool OpenSearchCommunication::isServerless() { - // Specified in DSN configuration + // Specified in DSN configuration. const std::string& is_serverless = m_rt_opts.conn.is_serverless; if(!is_serverless.empty()) { diff --git a/src/sqlodbc/opensearch_communication.h b/src/sqlodbc/opensearch_communication.h index 3a6eea6..1840391 100644 --- a/src/sqlodbc/opensearch_communication.h +++ b/src/sqlodbc/opensearch_communication.h @@ -81,6 +81,7 @@ class OpenSearchCommunication { void SetErrorDetails(std::string reason, std::string message, ConnErrorType error_type); void SetErrorDetails(ErrorDetails details); + bool isServerless(); // TODO #35 - Go through and add error messages on exit conditions std::string m_error_message; @@ -97,9 +98,6 @@ class OpenSearchCommunication { std::string m_response_str; std::shared_ptr< Aws::Http::HttpClient > m_http_client; std::string m_error_message_to_user; - - // TODO #70 - Support serverless - bool isServerless(); }; #endif