diff --git a/LICENSE.txt b/LICENSE.txt index 7d5de9e3bfeb..c1f3c4561982 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -2290,3 +2290,46 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +-------------------------------------------------------------------------------- +The files cpp/src/arrow/vendored/whereami/whereami.h, +cpp/src/arrow/vendored/whereami/whereami.cc are adapted from +Grégory Pakosz's whereami library (https://github.com/gpakosz/whereami) +It is dual licensed under both the WTFPLv2 and MIT licenses. + +The WTFPLv2 License + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + Version 2, December 2004 + + Copyright (C) 2004 Sam Hocevar + + Everyone is permitted to copy and distribute verbatim or modified + copies of this license document, and changing it is allowed as long + as the name is changed. + + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. You just DO WHAT THE FUCK YOU WANT TO. + 1. Bla bla bla + 2. Montesqieu et camembert, vive la France, zut alors! + +The MIT License (MIT) +Copyright Gregory Pakosz + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake index 7f97fbd6cbfd..70b7622522f3 100644 --- a/cpp/cmake_modules/ThirdpartyToolchain.cmake +++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake @@ -1288,6 +1288,9 @@ if(ARROW_USE_BOOST) endif() if(ARROW_BOOST_REQUIRE_LIBRARY) set(ARROW_BOOST_COMPONENTS filesystem system) + if(ARROW_FLIGHT_SQL_ODBC AND MSVC) + list(APPEND ARROW_BOOST_COMPONENTS locale) + endif() set(ARROW_BOOST_OPTIONAL_COMPONENTS process) else() set(ARROW_BOOST_COMPONENTS) @@ -5562,14 +5565,11 @@ if(ARROW_WITH_AZURE_SDK) Azure::azure-storage-blobs Azure::azure-identity) endif() -message(STATUS "All bundled static libraries: ${ARROW_BUNDLED_STATIC_LIBS}") - # ---------------------------------------------------------------------- # Apache Flight SQL ODBC if(ARROW_FLIGHT_SQL_ODBC) find_package(ODBC REQUIRED) - if(MSVC) - find_package(Boost REQUIRED COMPONENTS locale) - endif() endif() + +message(STATUS "All bundled static libraries: ${ARROW_BUNDLED_STATIC_LIBS}") diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/date_array_accessor.cc b/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/date_array_accessor.cc index 3b44f3c9aa48..ac8d079cd0d7 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/date_array_accessor.cc +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/date_array_accessor.cc @@ -17,7 +17,6 @@ #include "arrow/flight/sql/odbc/flight_sql/accessors/date_array_accessor.h" #include -#include "arrow/compute/api.h" #include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/calendar_utils.h" using arrow::Date32Array; diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/primitive_array_accessor_test.cc b/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/primitive_array_accessor_test.cc index 820c0a7bd840..abf18fa9ce8c 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/primitive_array_accessor_test.cc +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/primitive_array_accessor_test.cc @@ -16,7 +16,7 @@ // under the License. #include "arrow/flight/sql/odbc/flight_sql/accessors/primitive_array_accessor.h" -#include +#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/diagnostics.h" #include "arrow/testing/builder.h" #include "gtest/gtest.h" diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/address_info.h b/cpp/src/arrow/flight/sql/odbc/flight_sql/address_info.h index 312d5689a989..4b64f4fc6c10 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/address_info.h +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/address_info.h @@ -20,6 +20,7 @@ #include #include + #include #if !_WIN32 # include diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/config/configuration.cc b/cpp/src/arrow/flight/sql/odbc/flight_sql/config/configuration.cc index 006634b36355..4eb7d5980c20 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/config/configuration.cc +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/config/configuration.cc @@ -34,19 +34,20 @@ static const char DEFAULT_USE_CERT_STORE[] = TRUE_STR; static const char DEFAULT_DISABLE_CERT_VERIFICATION[] = FALSE_STR; namespace { -std::string ReadDsnString(const std::string& dsn, const std::string& key, +std::string ReadDsnString(const std::string& dsn, const std::string_view& key, const std::string& dflt = "") { #define BUFFER_SIZE (1024) std::vector buf(BUFFER_SIZE); - - int ret = SQLGetPrivateProfileString(dsn.c_str(), key.c_str(), dflt.c_str(), buf.data(), - static_cast(buf.size()), "ODBC.INI"); + int ret = + SQLGetPrivateProfileString(dsn.c_str(), key.data(), dflt.c_str(), buf.data(), + static_cast(buf.size()), "ODBC.INI"); if (ret > BUFFER_SIZE) { // If there wasn't enough space, try again with the right size buffer. buf.resize(ret + 1); - ret = SQLGetPrivateProfileString(dsn.c_str(), key.c_str(), dflt.c_str(), buf.data(), - static_cast(buf.size()), "ODBC.INI"); + ret = + SQLGetPrivateProfileString(dsn.c_str(), key.data(), dflt.c_str(), buf.data(), + static_cast(buf.size()), "ODBC.INI"); } return std::string(buf.data(), ret); @@ -131,17 +132,18 @@ void Configuration::LoadDsn(const std::string& dsn) { auto customKeys = ReadAllKeys(dsn); RemoveAllKnownKeys(customKeys); for (auto key : customKeys) { - Set(key, ReadDsnString(dsn, key)); + std::string_view key_sv(key); + Set(key, ReadDsnString(dsn, key_sv)); } } void Configuration::Clear() { this->properties.clear(); } -bool Configuration::IsSet(const std::string& key) const { +bool Configuration::IsSet(const std::string_view& key) const { return 0 != this->properties.count(key); } -const std::string& Configuration::Get(const std::string& key) const { +const std::string& Configuration::Get(const std::string_view& key) const { const auto itr = this->properties.find(key); if (itr == this->properties.cend()) { static const std::string empty(""); @@ -150,7 +152,7 @@ const std::string& Configuration::Get(const std::string& key) const { return itr->second; } -void Configuration::Set(const std::string& key, const std::string& value) { +void Configuration::Set(const std::string_view& key, const std::string& value) { const std::string copy = boost::trim_copy(value); if (!copy.empty()) { this->properties[key] = value; @@ -162,12 +164,12 @@ const driver::odbcabstraction::Connection::ConnPropertyMap& Configuration::GetPr return this->properties; } -std::vector Configuration::GetCustomKeys() const { +std::vector Configuration::GetCustomKeys() const { driver::odbcabstraction::Connection::ConnPropertyMap copyProps(properties); for (auto& key : FlightSqlConnection::ALL_KEYS) { copyProps.erase(key); } - std::vector keys; + std::vector keys; boost::copy(copyProps | boost::adaptors::map_keys, std::back_inserter(keys)); return keys; } diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_connection.cc b/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_connection.cc index 3446944f240f..09764e5c18ba 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_connection.cc +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_connection.cc @@ -62,34 +62,7 @@ using driver::odbcabstraction::DriverException; using driver::odbcabstraction::OdbcVersion; using driver::odbcabstraction::Statement; -// clang-format off -const std::string FlightSqlConnection::DSN = "dsn"; // NOLINT(runtime/string) -const std::string FlightSqlConnection::DRIVER = "driver"; // NOLINT(runtime/string) -const std::string FlightSqlConnection::HOST = "host"; // NOLINT(runtime/string) -const std::string FlightSqlConnection::PORT = "port"; // NOLINT(runtime/string) -const std::string FlightSqlConnection::USER = "user"; // NOLINT(runtime/string) -const std::string FlightSqlConnection::USER_ID = "user id"; // NOLINT(runtime/string) -const std::string FlightSqlConnection::UID = "uid"; // NOLINT(runtime/string) -const std::string FlightSqlConnection::PASSWORD = "password"; // NOLINT(runtime/string) -const std::string FlightSqlConnection::PWD = "pwd"; // NOLINT(runtime/string) -const std::string FlightSqlConnection::TOKEN = "token"; // NOLINT(runtime/string) -const std::string FlightSqlConnection::USE_ENCRYPTION = // NOLINT(runtime/string) - "useEncryption"; -const std::string FlightSqlConnection::DISABLE_CERTIFICATE_VERIFICATION = // NOLINT - "disableCertificateVerification"; -const std::string FlightSqlConnection::TRUSTED_CERTS = // NOLINT(runtime/string) - "trustedCerts"; -const std::string FlightSqlConnection::USE_SYSTEM_TRUST_STORE = // NOLINT(runtime/string) - "useSystemTrustStore"; -const std::string FlightSqlConnection::STRING_COLUMN_LENGTH = // NOLINT(runtime/string) - "StringColumnLength"; -const std::string FlightSqlConnection::USE_WIDE_CHAR = // NOLINT(runtime/string) - "UseWideChar"; -const std::string FlightSqlConnection::CHUNK_BUFFER_CAPACITY = // NOLINT(runtime/string) - "ChunkBufferCapacity"; -// clang-format on - -const std::vector FlightSqlConnection::ALL_KEYS = { +const std::vector FlightSqlConnection::ALL_KEYS = { FlightSqlConnection::DSN, FlightSqlConnection::DRIVER, FlightSqlConnection::HOST, @@ -138,7 +111,7 @@ inline std::string GetCerts() { return ""; } #endif -const std::set +const std::set BUILT_IN_PROPERTIES = {FlightSqlConnection::HOST, FlightSqlConnection::PORT, FlightSqlConnection::USER, @@ -155,8 +128,8 @@ const std::set FlightSqlConnection::USE_WIDE_CHAR}; Connection::ConnPropertyMap::const_iterator TrackMissingRequiredProperty( - const std::string& property, const Connection::ConnPropertyMap& properties, - std::vector& missing_attr) { + const std::string_view& property, const Connection::ConnPropertyMap& properties, + std::vector& missing_attr) { auto prop_iter = properties.find(property); if (properties.end() == prop_iter) { missing_attr.push_back(property); @@ -186,7 +159,7 @@ std::shared_ptr LoadFlightSslConfigs( } void FlightSqlConnection::Connect(const ConnPropertyMap& properties, - std::vector& missing_attr) { + std::vector& missing_attr) { try { auto flight_ssl_configs = LoadFlightSslConfigs(properties); @@ -242,7 +215,7 @@ boost::optional FlightSqlConnection::GetStringColumnLength( } catch (const std::exception& e) { diagnostics_.AddWarning( std::string("Invalid value for connection property " + - FlightSqlConnection::STRING_COLUMN_LENGTH + + std::string(FlightSqlConnection::STRING_COLUMN_LENGTH) + ". Please ensure it has a valid numeric value. Message: " + e.what()), "01000", odbcabstraction::ODBCErrorCodes_GENERAL_WARNING); } @@ -271,7 +244,7 @@ size_t FlightSqlConnection::GetChunkBufferCapacity( } catch (const std::exception& e) { diagnostics_.AddWarning( std::string("Invalid value for connection property " + - FlightSqlConnection::CHUNK_BUFFER_CAPACITY + + std::string(FlightSqlConnection::CHUNK_BUFFER_CAPACITY) + ". Please ensure it has a valid numeric value. Message: " + e.what()), "01000", odbcabstraction::ODBCErrorCodes_GENERAL_WARNING); } @@ -299,7 +272,7 @@ const FlightCallOptions& FlightSqlConnection::PopulateCallOptions( // Connection properties containing spaces will crash gRPC, but some tools // such as the OLE DB to ODBC bridge generate unused properties containing spaces. diagnostics_.AddWarning( - std::string("Ignoring connection option " + prop.first) + + std::string("Ignoring connection option " + std::string(prop.first)) + ". Server-specific options must be valid HTTP header names and " + "cannot contain spaces.", "01000", odbcabstraction::ODBCErrorCodes_GENERAL_WARNING); @@ -308,7 +281,7 @@ const FlightCallOptions& FlightSqlConnection::PopulateCallOptions( // Note: header names must be lower case for gRPC. // gRPC will crash if they are not lower-case. - std::string key_lc = boost::algorithm::to_lower_copy(prop.first); + std::string key_lc = boost::algorithm::to_lower_copy(std::string(prop.first)); call_options_.headers.emplace_back(std::make_pair(key_lc, prop.second)); } @@ -316,7 +289,7 @@ const FlightCallOptions& FlightSqlConnection::PopulateCallOptions( } FlightClientOptions FlightSqlConnection::BuildFlightClientOptions( - const ConnPropertyMap& properties, std::vector& missing_attr, + const ConnPropertyMap& properties, std::vector& missing_attr, const std::shared_ptr& ssl_config) { FlightClientOptions options; // Persist state information using cookies if the FlightProducer supports it. @@ -343,15 +316,17 @@ FlightClientOptions FlightSqlConnection::BuildFlightClientOptions( } Location FlightSqlConnection::BuildLocation( - const ConnPropertyMap& properties, std::vector& missing_attr, + const ConnPropertyMap& properties, std::vector& missing_attr, const std::shared_ptr& ssl_config) { const auto& host_iter = TrackMissingRequiredProperty(HOST, properties, missing_attr); const auto& port_iter = TrackMissingRequiredProperty(PORT, properties, missing_attr); if (!missing_attr.empty()) { + std::vector missing_attr_string_vec(missing_attr.begin(), + missing_attr.end()); std::string missing_attr_str = std::string("Missing required properties: ") + - boost::algorithm::join(missing_attr, ", "); + boost::algorithm::join(missing_attr_string_vec, ", "); throw DriverException(missing_attr_str); } diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_connection.h b/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_connection.h index 7a3bd08bbc71..0ee6d5d53913 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_connection.h +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_connection.h @@ -53,30 +53,31 @@ class FlightSqlConnection : public odbcabstraction::Connection { void PopulateMetadataSettings(const Connection::ConnPropertyMap& connPropertyMap); public: - static const std::vector ALL_KEYS; - static const std::string DSN; - static const std::string DRIVER; - static const std::string HOST; - static const std::string PORT; - static const std::string USER; - static const std::string UID; - static const std::string USER_ID; - static const std::string PASSWORD; - static const std::string PWD; - static const std::string TOKEN; - static const std::string USE_ENCRYPTION; - static const std::string DISABLE_CERTIFICATE_VERIFICATION; - static const std::string TRUSTED_CERTS; - static const std::string USE_SYSTEM_TRUST_STORE; - static const std::string STRING_COLUMN_LENGTH; - static const std::string USE_WIDE_CHAR; - static const std::string CHUNK_BUFFER_CAPACITY; + static const std::vector ALL_KEYS; + static constexpr std::string_view DSN = "dsn"; + static constexpr std::string_view DRIVER = "driver"; + static constexpr std::string_view HOST = "host"; + static constexpr std::string_view PORT = "port"; + static constexpr std::string_view USER = "user"; + static constexpr std::string_view USER_ID = "user id"; + static constexpr std::string_view UID = "uid"; + static constexpr std::string_view PASSWORD = "password"; + static constexpr std::string_view PWD = "pwd"; + static constexpr std::string_view TOKEN = "token"; + static constexpr std::string_view USE_ENCRYPTION = "useEncryption"; + static constexpr std::string_view DISABLE_CERTIFICATE_VERIFICATION = + "disableCertificateVerification"; + static constexpr std::string_view TRUSTED_CERTS = "trustedCerts"; + static constexpr std::string_view USE_SYSTEM_TRUST_STORE = "useSystemTrustStore"; + static constexpr std::string_view STRING_COLUMN_LENGTH = "StringColumnLength"; + static constexpr std::string_view USE_WIDE_CHAR = "UseWideChar"; + static constexpr std::string_view CHUNK_BUFFER_CAPACITY = "ChunkBufferCapacity"; explicit FlightSqlConnection(odbcabstraction::OdbcVersion odbc_version, const std::string& driver_version = "0.9.0.0"); void Connect(const ConnPropertyMap& properties, - std::vector& missing_attr) override; + std::vector& missing_attr) override; void Close() override; @@ -92,13 +93,13 @@ class FlightSqlConnection : public odbcabstraction::Connection { /// \brief Builds a Location used for FlightClient connection. /// \note Visible for testing static arrow::flight::Location BuildLocation( - const ConnPropertyMap& properties, std::vector& missing_attr, + const ConnPropertyMap& properties, std::vector& missing_attr, const std::shared_ptr& ssl_config); /// \brief Builds a FlightClientOptions used for FlightClient connection. /// \note Visible for testing static arrow::flight::FlightClientOptions BuildFlightClientOptions( - const ConnPropertyMap& properties, std::vector& missing_attr, + const ConnPropertyMap& properties, std::vector& missing_attr, const std::shared_ptr& ssl_config); /// \brief Builds a FlightCallOptions used on gRPC calls. diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_connection_test.cc b/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_connection_test.cc index 3fd3ac192ee2..6a519138b637 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_connection_test.cc +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_connection_test.cc @@ -103,7 +103,7 @@ TEST(MetadataSettingsTest, UseWideCharTest) { } TEST(BuildLocationTests, ForTcp) { - std::vector missing_attr; + std::vector missing_attr; Connection::ConnPropertyMap properties = { {FlightSqlConnection::HOST, std::string("localhost")}, {FlightSqlConnection::PORT, std::string("32010")}, @@ -129,7 +129,7 @@ TEST(BuildLocationTests, ForTcp) { } TEST(BuildLocationTests, ForTls) { - std::vector missing_attr; + std::vector missing_attr; Connection::ConnPropertyMap properties = { {FlightSqlConnection::HOST, std::string("localhost")}, {FlightSqlConnection::PORT, std::string("32010")}, diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_result_set_accessors.h b/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_result_set_accessors.h index 3f7d68560832..1d5014140ef9 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_result_set_accessors.h +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_result_set_accessors.h @@ -17,9 +17,9 @@ #pragma once -#include -#include #include +#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/types.h" +#include "arrow/type_fwd.h" namespace driver { namespace flight_sql { diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_result_set_metadata.cc b/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_result_set_metadata.cc index f863d4bc4894..035390981c84 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_result_set_metadata.cc +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_result_set_metadata.cc @@ -16,10 +16,10 @@ // under the License. #include "arrow/flight/sql/odbc/flight_sql/flight_sql_result_set_metadata.h" -#include -#include +#include "arrow/flight/sql/column_metadata.h" #include "arrow/flight/sql/odbc/flight_sql/utils.h" #include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/platform.h" +#include "arrow/util/key_value_metadata.h" #include #include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/exceptions.h" diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_ssl_config.h b/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_ssl_config.h index 67e22c6fd7eb..2369f0aab4d2 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_ssl_config.h +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_ssl_config.h @@ -17,9 +17,9 @@ #pragma once -#include -#include #include +#include "arrow/flight/types.h" +#include "arrow/status.h" namespace driver { namespace flight_sql { @@ -50,7 +50,6 @@ class FlightSqlSslConfig { /// \brief Loads the certificate file and extract the certificate file from it /// and create the object CertKeyPair with it on. /// \param out A CertKeyPair with the cert on it. - /// \return The cert key pair object void populateOptionsWithCerts(arrow::flight::CertKeyPair* out); private: diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_stream_chunk_buffer.h b/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_stream_chunk_buffer.h index 4a84bcbede07..864c025d8b37 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_stream_chunk_buffer.h +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_stream_chunk_buffer.h @@ -17,9 +17,9 @@ #pragma once -#include -#include -#include +#include "arrow/flight/client.h" +#include "arrow/flight/sql/client.h" +#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/blocking_queue.h" namespace driver { namespace flight_sql { diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/get_info_cache.h b/cpp/src/arrow/flight/sql/odbc/flight_sql/get_info_cache.h index a54dda2e13bc..819b095e6a63 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/get_info_cache.h +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/get_info_cache.h @@ -17,12 +17,12 @@ #pragma once -#include -#include #include #include #include #include +#include "arrow/flight/sql/client.h" +#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/spi/connection.h" namespace driver { namespace flight_sql { diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/include/flight_sql/config/configuration.h b/cpp/src/arrow/flight/sql/odbc/flight_sql/include/flight_sql/config/configuration.h index 804c9369d813..69fa8a8696c5 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/include/flight_sql/config/configuration.h +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/include/flight_sql/config/configuration.h @@ -57,16 +57,16 @@ class Configuration { void LoadDsn(const std::string& dsn); void Clear(); - bool IsSet(const std::string& key) const; - const std::string& Get(const std::string& key) const; - void Set(const std::string& key, const std::string& value); + bool IsSet(const std::string_view& key) const; + const std::string& Get(const std::string_view& key) const; + void Set(const std::string_view& key, const std::string& value); /** * Get properties map. */ const driver::odbcabstraction::Connection::ConnPropertyMap& GetProperties() const; - std::vector GetCustomKeys() const; + std::vector GetCustomKeys() const; private: driver::odbcabstraction::Connection::ConnPropertyMap properties; diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/include/flight_sql/flight_sql_driver.h b/cpp/src/arrow/flight/sql/odbc/flight_sql/include/flight_sql/flight_sql_driver.h index 88460cdf5b2f..48f2a16416ab 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/include/flight_sql/flight_sql_driver.h +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/include/flight_sql/flight_sql_driver.h @@ -17,8 +17,8 @@ #pragma once -#include -#include +#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/diagnostics.h" +#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/spi/driver.h" namespace driver { namespace flight_sql { diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/include/flight_sql/ui/add_property_window.h b/cpp/src/arrow/flight/sql/odbc/flight_sql/include/flight_sql/ui/add_property_window.h index 61b2fb2608d0..01d93829a46b 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/include/flight_sql/ui/add_property_window.h +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/include/flight_sql/ui/add_property_window.h @@ -61,14 +61,8 @@ class AddPropertyWindow : public CustomWindow { */ void Create(); - /** - * @copedoc ignite::odbc::system::ui::CustomWindow::OnCreate - */ void OnCreate() override; - /** - * @copedoc ignite::odbc::system::ui::CustomWindow::OnMessage - */ bool OnMessage(UINT msg, WPARAM wParam, LPARAM lParam) override; /** diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/include/flight_sql/ui/dsn_configuration_window.h b/cpp/src/arrow/flight/sql/odbc/flight_sql/include/flight_sql/ui/dsn_configuration_window.h index fbdd572cf6e2..d32e7a6932d7 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/include/flight_sql/ui/dsn_configuration_window.h +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/include/flight_sql/ui/dsn_configuration_window.h @@ -74,6 +74,7 @@ class DsnConfigurationWindow : public CustomWindow { * Constructor. * * @param parent Parent window handle. + * @param config Configuration */ DsnConfigurationWindow(Window* parent, config::Configuration& config); @@ -87,14 +88,8 @@ class DsnConfigurationWindow : public CustomWindow { */ void Create(); - /** - * @copedoc ignite::odbc::system::ui::CustomWindow::OnCreate - */ void OnCreate() override; - /** - * @copedoc ignite::odbc::system::ui::CustomWindow::OnMessage - */ bool OnMessage(UINT msg, WPARAM wParam, LPARAM lParam) override; private: diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/include/flight_sql/ui/window.h b/cpp/src/arrow/flight/sql/odbc/flight_sql/include/flight_sql/ui/window.h index 3ff9a6200b45..e56ad88dec65 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/include/flight_sql/ui/window.h +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/include/flight_sql/ui/window.h @@ -43,7 +43,6 @@ class Window { * @param parent Parent window handle. * @param className Window class name. * @param title Window title. - * @param callback Event processing function. */ Window(Window* parent, const char* className, const char* title); @@ -128,6 +127,7 @@ class Window { * @param sizeY Size by Y coordinate. * @param title Title. * @param id ID to be assigned to the created window. + * @param style Window style. * @return Auto pointer containing new window. */ std::unique_ptr CreateEdit(int posX, int posY, int sizeX, int sizeY, @@ -142,6 +142,7 @@ class Window { * @param sizeY Size by Y coordinate. * @param title Title. * @param id ID to be assigned to the created window. + * @param style Window style. * @return Auto pointer containing new window. */ std::unique_ptr CreateButton(int posX, int posY, int sizeX, int sizeY, @@ -156,6 +157,7 @@ class Window { * @param sizeY Size by Y coordinate. * @param title Title. * @param id ID to be assigned to the created window. + * @param state Checked state of checkbox * @return Auto pointer containing new window. */ std::unique_ptr CreateCheckBox(int posX, int posY, int sizeX, int sizeY, @@ -228,7 +230,7 @@ class Window { /** * Get CheckBox state. * - * @param True if checked. + * @return True if checked. */ bool IsChecked() const; diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/json_converter.cc b/cpp/src/arrow/flight/sql/odbc/flight_sql/json_converter.cc index a4c1d4d7b25e..e9c9df3bac54 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/json_converter.cc +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/json_converter.cc @@ -25,7 +25,7 @@ #include "arrow/scalar.h" #include "arrow/visitor.h" -using namespace arrow; // NOLINT build/namespaces +using arrow::Status; using boost::beast::detail::base64::encode; using boost::beast::detail::base64::encoded_size; @@ -37,8 +37,8 @@ namespace { template Status ConvertScalarToStringAndWrite(const ScalarT& scalar, rapidjson::Writer& writer) { - ARROW_ASSIGN_OR_RAISE(auto string_scalar, scalar.CastTo(utf8())) - const auto& view = reinterpret_cast(string_scalar.get())->view(); + ARROW_ASSIGN_OR_RAISE(auto string_scalar, scalar.CastTo(arrow::utf8())) + const auto& view = reinterpret_cast(string_scalar.get())->view(); writer.String(view.data(), view.length(), true); return Status::OK(); } @@ -86,180 +86,180 @@ class ScalarToJson : public arrow::ScalarVisitor { std::string ToString() { return string_buffer_.GetString(); } - Status Visit(const NullScalar& scalar) override { + Status Visit(const arrow::NullScalar& scalar) override { writer_.Null(); return Status::OK(); } - Status Visit(const BooleanScalar& scalar) override { + Status Visit(const arrow::BooleanScalar& scalar) override { writer_.Bool(scalar.value); return Status::OK(); } - Status Visit(const Int8Scalar& scalar) override { + Status Visit(const arrow::Int8Scalar& scalar) override { writer_.Int(scalar.value); return Status::OK(); } - Status Visit(const Int16Scalar& scalar) override { + Status Visit(const arrow::Int16Scalar& scalar) override { writer_.Int(scalar.value); return Status::OK(); } - Status Visit(const Int32Scalar& scalar) override { + Status Visit(const arrow::Int32Scalar& scalar) override { writer_.Int(scalar.value); return Status::OK(); } - Status Visit(const Int64Scalar& scalar) override { + Status Visit(const arrow::Int64Scalar& scalar) override { writer_.Int64(scalar.value); return Status::OK(); } - Status Visit(const UInt8Scalar& scalar) override { + Status Visit(const arrow::UInt8Scalar& scalar) override { writer_.Uint(scalar.value); return Status::OK(); } - Status Visit(const UInt16Scalar& scalar) override { + Status Visit(const arrow::UInt16Scalar& scalar) override { writer_.Uint(scalar.value); return Status::OK(); } - Status Visit(const UInt32Scalar& scalar) override { + Status Visit(const arrow::UInt32Scalar& scalar) override { writer_.Uint(scalar.value); return Status::OK(); } - Status Visit(const UInt64Scalar& scalar) override { + Status Visit(const arrow::UInt64Scalar& scalar) override { writer_.Uint64(scalar.value); return Status::OK(); } - Status Visit(const HalfFloatScalar& scalar) override { + Status Visit(const arrow::HalfFloatScalar& scalar) override { return Status::NotImplemented("Cannot convert HalfFloatScalar to JSON."); } - Status Visit(const FloatScalar& scalar) override { + Status Visit(const arrow::FloatScalar& scalar) override { writer_.Double(scalar.value); return Status::OK(); } - Status Visit(const DoubleScalar& scalar) override { + Status Visit(const arrow::DoubleScalar& scalar) override { writer_.Double(scalar.value); return Status::OK(); } - Status Visit(const StringScalar& scalar) override { + Status Visit(const arrow::StringScalar& scalar) override { const auto& view = scalar.view(); writer_.String(view.data(), view.length()); return Status::OK(); } - Status Visit(const BinaryScalar& scalar) override { + Status Visit(const arrow::BinaryScalar& scalar) override { return ConvertBinaryToBase64StringAndWrite(scalar, writer_); } - Status Visit(const LargeStringScalar& scalar) override { + Status Visit(const arrow::LargeStringScalar& scalar) override { const auto& view = scalar.view(); writer_.String(view.data(), view.length()); return Status::OK(); } - Status Visit(const LargeBinaryScalar& scalar) override { + Status Visit(const arrow::LargeBinaryScalar& scalar) override { return ConvertBinaryToBase64StringAndWrite(scalar, writer_); } - Status Visit(const FixedSizeBinaryScalar& scalar) override { + Status Visit(const arrow::FixedSizeBinaryScalar& scalar) override { return ConvertBinaryToBase64StringAndWrite(scalar, writer_); } - Status Visit(const Date64Scalar& scalar) override { + Status Visit(const arrow::Date64Scalar& scalar) override { return ConvertScalarToStringAndWrite(scalar, writer_); } - Status Visit(const Date32Scalar& scalar) override { + Status Visit(const arrow::Date32Scalar& scalar) override { return ConvertScalarToStringAndWrite(scalar, writer_); } - Status Visit(const Time32Scalar& scalar) override { + Status Visit(const arrow::Time32Scalar& scalar) override { return ConvertScalarToStringAndWrite(scalar, writer_); } - Status Visit(const Time64Scalar& scalar) override { + Status Visit(const arrow::Time64Scalar& scalar) override { return ConvertScalarToStringAndWrite(scalar, writer_); } - Status Visit(const TimestampScalar& scalar) override { + Status Visit(const arrow::TimestampScalar& scalar) override { return ConvertScalarToStringAndWrite(scalar, writer_); } - Status Visit(const DayTimeIntervalScalar& scalar) override { + Status Visit(const arrow::DayTimeIntervalScalar& scalar) override { return ConvertScalarToStringAndWrite(scalar, writer_); } - Status Visit(const MonthDayNanoIntervalScalar& scalar) override { + Status Visit(const arrow::MonthDayNanoIntervalScalar& scalar) override { return ConvertScalarToStringAndWrite(scalar, writer_); } - Status Visit(const MonthIntervalScalar& scalar) override { + Status Visit(const arrow::MonthIntervalScalar& scalar) override { return ConvertScalarToStringAndWrite(scalar, writer_); } - Status Visit(const DurationScalar& scalar) override { + Status Visit(const arrow::DurationScalar& scalar) override { // TODO: Append TimeUnit on conversion return ConvertScalarToStringAndWrite(scalar, writer_); } - Status Visit(const Decimal128Scalar& scalar) override { + Status Visit(const arrow::Decimal128Scalar& scalar) override { const auto& view = scalar.ToString(); writer_.RawValue(view.data(), view.length(), rapidjson::kNumberType); return Status::OK(); } - Status Visit(const Decimal256Scalar& scalar) override { + Status Visit(const arrow::Decimal256Scalar& scalar) override { const auto& view = scalar.ToString(); writer_.RawValue(view.data(), view.length(), rapidjson::kNumberType); return Status::OK(); } - Status Visit(const ListScalar& scalar) override { + Status Visit(const arrow::ListScalar& scalar) override { return WriteListScalar(scalar, writer_, this); } - Status Visit(const LargeListScalar& scalar) override { + Status Visit(const arrow::LargeListScalar& scalar) override { return WriteListScalar(scalar, writer_, this); } - Status Visit(const MapScalar& scalar) override { + Status Visit(const arrow::MapScalar& scalar) override { return WriteListScalar(scalar, writer_, this); } - Status Visit(const FixedSizeListScalar& scalar) override { + Status Visit(const arrow::FixedSizeListScalar& scalar) override { return WriteListScalar(scalar, writer_, this); } - Status Visit(const StructScalar& scalar) override { + Status Visit(const arrow::StructScalar& scalar) override { writer_.StartObject(); - const std::shared_ptr& data_type = - std::static_pointer_cast(scalar.type); + const std::shared_ptr& data_type = + std::static_pointer_cast(scalar.type); for (int i = 0; i < data_type->num_fields(); ++i) { const auto& result = scalar.field(i); ThrowIfNotOK(result.status()); @@ -275,19 +275,19 @@ class ScalarToJson : public arrow::ScalarVisitor { return Status::OK(); } - Status Visit(const DictionaryScalar& scalar) override { + Status Visit(const arrow::DictionaryScalar& scalar) override { return Status::NotImplemented("Cannot convert DictionaryScalar to JSON."); } - Status Visit(const SparseUnionScalar& scalar) override { + Status Visit(const arrow::SparseUnionScalar& scalar) override { return scalar.child_value().get()->Accept(this); } - Status Visit(const DenseUnionScalar& scalar) override { + Status Visit(const arrow::DenseUnionScalar& scalar) override { return scalar.child_value().get()->Accept(this); } - Status Visit(const ExtensionScalar& scalar) override { + Status Visit(const arrow::ExtensionScalar& scalar) override { return Status::NotImplemented("Cannot convert ExtensionScalar to JSON."); } }; diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/json_converter.h b/cpp/src/arrow/flight/sql/odbc/flight_sql/json_converter.h index de466af4f77d..83809265df4a 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/json_converter.h +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/json_converter.h @@ -17,8 +17,8 @@ #pragma once -#include #include +#include "arrow/type_fwd.h" namespace driver { namespace flight_sql { diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/main.cc b/cpp/src/arrow/flight/sql/odbc/flight_sql/main.cc index 8c67a78984ea..e112fdf67c08 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/main.cc +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/main.cc @@ -208,7 +208,7 @@ int main() { {FlightSqlConnection::PASSWORD, std::string("dremio123")}, {FlightSqlConnection::USE_ENCRYPTION, std::string("false")}, }; - std::vector missing_attr; + std::vector missing_attr; connection->Connect(properties, missing_attr); // TestBindColumnBigInt(connection); diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/record_batch_transformer.h b/cpp/src/arrow/flight/sql/odbc/flight_sql/record_batch_transformer.h index 261b8c1d7c04..15c482cc6310 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/record_batch_transformer.h +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/record_batch_transformer.h @@ -17,9 +17,9 @@ #pragma once -#include -#include #include +#include "arrow/flight/client.h" +#include "arrow/type.h" namespace driver { namespace flight_sql { diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/scalar_function_reporter.h b/cpp/src/arrow/flight/sql/odbc/flight_sql/scalar_function_reporter.h index 5c2ae06cdbac..fd6abf6420e0 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/scalar_function_reporter.h +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/scalar_function_reporter.h @@ -17,7 +17,7 @@ #pragma once -#include +#include "arrow/type.h" namespace driver { namespace flight_sql { diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/system_dsn.cc b/cpp/src/arrow/flight/sql/odbc/flight_sql/system_dsn.cc index cdce639e31a0..67a4c3db3d3d 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/system_dsn.cc +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/system_dsn.cc @@ -119,13 +119,13 @@ bool RegisterDsn(const Configuration& config, LPCSTR driver) { const auto& map = config.GetProperties(); for (auto it = map.begin(); it != map.end(); ++it) { - const std::string& key = it->first; + const std::string_view& key = it->first; if (boost::iequals(FlightSqlConnection::DSN, key) || boost::iequals(FlightSqlConnection::DRIVER, key)) { continue; } - if (!SQLWritePrivateProfileString(dsn.c_str(), key.c_str(), it->second.c_str(), + if (!SQLWritePrivateProfileString(dsn.c_str(), key.data(), it->second.c_str(), "ODBC.INI")) { PostLastInstallerError(); return false; diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/ui/add_property_window.cc b/cpp/src/arrow/flight/sql/odbc/flight_sql/ui/add_property_window.cc index 64cc1797f7ed..75aa491f781b 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/ui/add_property_window.cc +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/ui/add_property_window.cc @@ -24,7 +24,7 @@ #include -#include +#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/exceptions.h" #include "ui/custom_window.h" #include "ui/window.h" diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/ui/custom_window.cc b/cpp/src/arrow/flight/sql/odbc/flight_sql/ui/custom_window.cc index 5443ea0ec8d2..e79e1221e782 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/ui/custom_window.cc +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/ui/custom_window.cc @@ -17,7 +17,7 @@ // platform.h includes windows.h, so it needs to be included // before Windowsx.h and commctrl.h -#include +#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/platform.h" #include #include @@ -25,7 +25,7 @@ #include #include -#include +#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/exceptions.h" #include "ui/custom_window.h" namespace driver { diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/ui/dsn_configuration_window.cc b/cpp/src/arrow/flight/sql/odbc/flight_sql/ui/dsn_configuration_window.cc index 0b43e35aabc0..c47984ca4006 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/ui/dsn_configuration_window.cc +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/ui/dsn_configuration_window.cc @@ -20,11 +20,11 @@ #include #include -#include #include #include #include #include +#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/utils.h" #include "arrow/flight/sql/odbc/flight_sql/include/flight_sql/ui/add_property_window.h" @@ -36,7 +36,7 @@ std::string TestConnection(const driver::flight_sql::config::Configuration& conf std::unique_ptr flightSqlConn( new driver::flight_sql::FlightSqlConnection(driver::odbcabstraction::V_3)); - std::vector missingProperties; + std::vector missingProperties; flightSqlConn->Connect(config.GetProperties(), missingProperties); // This should have been checked before enabling the Test button. @@ -306,7 +306,7 @@ int DsnConfigurationWindow::CreatePropertiesGroup(int posX, int posY, int sizeX) const auto keys = config.GetCustomKeys(); for (const auto& key : keys) { - propertyList->ListAddItem({key, config.Get(key)}); + propertyList->ListAddItem({std::string(key), config.Get(key)}); } SendMessage(propertyList->GetHandle(), LVM_SETEXTENDEDLISTVIEWSTYLE, diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/utils.h b/cpp/src/arrow/flight/sql/odbc/flight_sql/utils.h index 586cfb22a305..8b3e14599a73 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/utils.h +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/utils.h @@ -17,13 +17,13 @@ #pragma once -#include -#include -#include #include #include #include #include +#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/exceptions.h" +#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/types.h" +#include "arrow/flight/types.h" namespace driver { namespace flight_sql { diff --git a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/CMakeLists.txt b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/CMakeLists.txt index 8bb89d3b41f5..c9614b88a5b5 100644 --- a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/CMakeLists.txt +++ b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/CMakeLists.txt @@ -50,8 +50,7 @@ add_library(odbcabstraction logger.cc spd_logger.cc utils.cc - whereami.h - whereami.cc + ../../../../vendored/whereami/whereami.cc odbc_impl/odbc_connection.cc odbc_impl/odbc_descriptor.cc odbc_impl/odbc_environment.cc diff --git a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/diagnostics.cc b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/diagnostics.cc index 8c94978ef997..78ca45ea2fe2 100644 --- a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/diagnostics.cc +++ b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/diagnostics.cc @@ -15,9 +15,9 @@ // specific language governing permissions and limitations // under the License. -#include -#include -#include +#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/diagnostics.h" +#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/platform.h" +#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/types.h" #include diff --git a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/encoding.cc b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/encoding.cc index 95dc920da78f..00718cdbbe56 100644 --- a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/encoding.cc +++ b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/encoding.cc @@ -15,7 +15,7 @@ // specific language governing permissions and limitations // under the License. -#include +#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/encoding.h" #if defined(__APPLE__) # include diff --git a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/exceptions.cc b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/exceptions.cc index fcd8163a500c..2d3bcce8325a 100644 --- a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/exceptions.cc +++ b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/exceptions.cc @@ -15,9 +15,9 @@ // specific language governing permissions and limitations // under the License. -#include -#include +#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/exceptions.h" #include +#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/platform.h" namespace driver { namespace odbcabstraction { diff --git a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/diagnostics.h b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/diagnostics.h index f1c6efe49829..473411efd4f3 100644 --- a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/diagnostics.h +++ b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/diagnostics.h @@ -21,8 +21,8 @@ #include #include -#include -#include +#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/exceptions.h" +#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/types.h" namespace driver { namespace odbcabstraction { diff --git a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/exceptions.h b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/exceptions.h index 48a773e4f4df..82ffebedff6b 100644 --- a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/exceptions.h +++ b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/exceptions.h @@ -17,10 +17,10 @@ #pragma once -#include #include #include #include +#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/error_codes.h" namespace driver { namespace odbcabstraction { diff --git a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/attribute_utils.h b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/attribute_utils.h index 77d25f34483f..e7cfe2891980 100644 --- a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/attribute_utils.h +++ b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/attribute_utils.h @@ -17,16 +17,16 @@ #pragma once -#include -#include -#include #include #include #include #include #include +#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/diagnostics.h" +#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/exceptions.h" +#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/platform.h" -#include +#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/encoding_utils.h" namespace ODBC { using driver::odbcabstraction::WcsToUtf8; diff --git a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/encoding_utils.h b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/encoding_utils.h index 25619bb55551..f5ea651ec625 100644 --- a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/encoding_utils.h +++ b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/encoding_utils.h @@ -17,8 +17,6 @@ #pragma once -#include -#include #include #include #include @@ -27,6 +25,8 @@ #include #include #include +#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/encoding.h" +#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/platform.h" #define _SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING diff --git a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_connection.h b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_connection.h index 3d81e2ce2756..e771f467e6e8 100644 --- a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_connection.h +++ b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_connection.h @@ -17,9 +17,9 @@ #pragma once -#include +#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_handle.h" +#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/spi/connection.h" -#include #include #include #include @@ -50,7 +50,7 @@ class ODBCConnection : public ODBCHandle { bool isConnected() const; void connect(std::string dsn, const driver::odbcabstraction::Connection::ConnPropertyMap& properties, - std::vector& missing_properties); + std::vector& missing_properties); void GetInfo(SQLUSMALLINT infoType, SQLPOINTER value, SQLSMALLINT bufferLength, SQLSMALLINT* outputLength, bool isUnicode); diff --git a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_descriptor.h b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_descriptor.h index 092483f47199..e7656082c5ce 100644 --- a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_descriptor.h +++ b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_descriptor.h @@ -17,7 +17,7 @@ #pragma once -#include +#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_handle.h" #include #include diff --git a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_handle.h b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_handle.h index c2428df394d9..f31184565ad3 100644 --- a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_handle.h +++ b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_handle.h @@ -17,12 +17,14 @@ #pragma once -#include -#include +// platform.h includes windows.h, so it needs to be included first +#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/platform.h" + #include #include #include #include +#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/diagnostics.h" /** * @brief An abstraction over a generic ODBC handle. diff --git a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_statement.h b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_statement.h index bbddfac4185a..29efaec82803 100644 --- a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_statement.h +++ b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_statement.h @@ -17,9 +17,11 @@ #pragma once -#include +// platform.h platform.h includes windows.h so it needs to be included first +#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/platform.h" + +#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_handle.h" -#include #include #include #include diff --git a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/spd_logger.h b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/spd_logger.h index 9bf18699bc83..08672b9e7c2d 100644 --- a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/spd_logger.h +++ b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/spd_logger.h @@ -32,11 +32,11 @@ class SPDLogger : public Logger { std::shared_ptr logger_; public: - static const std::string LOG_LEVEL; - static const std::string LOG_PATH; - static const std::string MAXIMUM_FILE_SIZE; - static const std::string FILE_QUANTITY; - static const std::string LOG_ENABLED; + static constexpr std::string_view LOG_LEVEL = "LogLevel"; + static constexpr std::string_view LOG_PATH = "LogPath"; + static constexpr std::string_view MAXIMUM_FILE_SIZE = "MaximumFileSize"; + static constexpr std::string_view FILE_QUANTITY = "FileQuantity"; + static constexpr std::string_view LOG_ENABLED = "LogEnabled"; SPDLogger() = default; ~SPDLogger() = default; diff --git a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/spi/connection.h b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/spi/connection.h index 2cca7f4a29fc..64b7e6a724b6 100644 --- a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/spi/connection.h +++ b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/spi/connection.h @@ -25,21 +25,21 @@ #include #include -#include -#include +#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/diagnostics.h" +#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/types.h" namespace driver { namespace odbcabstraction { /// \brief Case insensitive comparator struct CaseInsensitiveComparator { - bool operator()(const std::string& s1, const std::string& s2) const { + bool operator()(const std::string_view& s1, const std::string_view& s2) const { return boost::lexicographical_compare(s1, s2, boost::is_iless()); } }; // PropertyMap is case-insensitive for keys. -typedef std::map PropertyMap; +typedef std::map PropertyMap; class Statement; @@ -67,10 +67,10 @@ class Connection { typedef PropertyMap ConnPropertyMap; /// \brief Establish the connection. - /// \param properties[in] properties used to establish the connection. - /// \param missing_properties[out] vector of missing properties (if any). + /// \param properties [in] properties used to establish the connection. + /// \param missing_properties [out] vector of missing properties (if any). virtual void Connect(const ConnPropertyMap& properties, - std::vector& missing_properties) = 0; + std::vector& missing_properties) = 0; /// \brief Close the connection. virtual void Close() = 0; @@ -79,14 +79,14 @@ class Connection { virtual std::shared_ptr CreateStatement() = 0; /// \brief Set a connection attribute (may be called at any time). - /// \param attribute[in] Which attribute to set. + /// \param attribute [in] Which attribute to set. /// \param value The value to be set. /// \return true if the value was set successfully or false if it was substituted with /// a similar value. virtual bool SetAttribute(AttributeId attribute, const Attribute& value) = 0; /// \brief Retrieve a connection attribute - /// \param attribute[in] Attribute to be retrieved. + /// \param attribute [in] Attribute to be retrieved. virtual boost::optional GetAttribute( Connection::AttributeId attribute) = 0; diff --git a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/spi/driver.h b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/spi/driver.h index f13371bf2d55..61d570574c7f 100644 --- a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/spi/driver.h +++ b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/spi/driver.h @@ -19,8 +19,8 @@ #include -#include -#include +#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/diagnostics.h" +#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/types.h" namespace driver { namespace odbcabstraction { diff --git a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/spi/result_set.h b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/spi/result_set.h index 1b3f8eb96d86..4c12a4b59348 100644 --- a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/spi/result_set.h +++ b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/spi/result_set.h @@ -20,9 +20,9 @@ #include #include -#include +#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/platform.h" -#include +#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/types.h" namespace driver { namespace odbcabstraction { diff --git a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/spi/result_set_metadata.h b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/spi/result_set_metadata.h index 6b35c22897b8..636dce21e4a7 100644 --- a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/spi/result_set_metadata.h +++ b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/spi/result_set_metadata.h @@ -17,8 +17,8 @@ #pragma once -#include #include +#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/types.h" namespace driver { namespace odbcabstraction { @@ -36,148 +36,148 @@ class ResultSetMetadata { virtual size_t GetColumnCount() = 0; /// \brief It retrieves the name of a specific column. - /// \param column_position[in] the position of the column, starting from 1. + /// \param column_position [in] the position of the column, starting from 1. /// \return the column name. virtual std::string GetColumnName(int column_position) = 0; /// \brief It retrieves the size of a specific column. - /// \param column_position[in] the position of the column, starting from 1. + /// \param column_position [in] the position of the column, starting from 1. /// \return the column size. virtual size_t GetPrecision(int column_position) = 0; /// \brief It retrieves the total of number of decimal digits. - /// \param column_position[in] the position of the column, starting from 1. + /// \param column_position [in] the position of the column, starting from 1. /// \return amount of decimal digits. virtual size_t GetScale(int column_position) = 0; /// \brief It retrieves the SQL_DATA_TYPE of the column. - /// \param column_position[in] the position of the column, starting from 1. + /// \param column_position [in] the position of the column, starting from 1. /// \return the SQL_DATA_TYPE virtual uint16_t GetDataType(int column_position) = 0; /// \brief It returns a boolean value indicating if the column can have /// null values. - /// \param column_position[in] the position of the column, starting from 1. + /// \param column_position [in] the position of the column, starting from 1. /// \return true if column is nullable. virtual Nullability IsNullable(int column_position) = 0; /// \brief It returns the Schema name for a specific column. - /// \param column_position[in] the position of the column, starting from 1. + /// \param column_position [in] the position of the column, starting from 1. /// \return the Schema name for given column. virtual std::string GetSchemaName(int column_position) = 0; /// \brief It returns the Catalog Name for a specific column. - /// \param column_position[in] the position of the column, starting from 1. + /// \param column_position [in] the position of the column, starting from 1. /// \return the catalog name for given column. virtual std::string GetCatalogName(int column_position) = 0; /// \brief It returns the Table Name for a specific column. - /// \param column_position[in] the position of the column, starting from 1. + /// \param column_position [in] the position of the column, starting from 1. /// \return the Table name for given column. virtual std::string GetTableName(int column_position) = 0; /// \brief It retrieves the column label. - /// \param column_position[in] the position of the column, starting from 1. + /// \param column_position [in] the position of the column, starting from 1. /// \return column label. virtual std::string GetColumnLabel(int column_position) = 0; /// \brief It retrieves the designated column's normal maximum width in /// characters. - /// \param column_position[in] the position of the column, starting from 1. + /// \param column_position [in] the position of the column, starting from 1. /// \return column normal maximum width. virtual size_t GetColumnDisplaySize(int column_position) = 0; /// \brief It retrieves the base name for the column. - /// \param column_position[in] the position of the column, starting from 1. + /// \param column_position [in] the position of the column, starting from 1. /// \return the base column name. virtual std::string GetBaseColumnName(int column_position) = 0; /// \brief It retrieves the base table name that contains the column. - /// \param column_position[in] the position of the column, starting from 1. + /// \param column_position [in] the position of the column, starting from 1. /// \return the base table name. virtual std::string GetBaseTableName(int column_position) = 0; /// \brief It retrieves the concise data type (SQL_DESC_CONCISE_TYPE). - /// \param column_position[in] the position of the column, starting from 1. + /// \param column_position [in] the position of the column, starting from 1. /// \return the concise data type. virtual uint16_t GetConciseType(int column_position) = 0; /// \brief It retrieves the maximum or the actual character length /// of a character string or binary data type. - /// \param column_position[in] the position of the column, starting from 1. + /// \param column_position [in] the position of the column, starting from 1. /// \return the maximum length virtual size_t GetLength(int column_position) = 0; /// \brief It retrieves the character or characters that the driver uses /// as prefix for literal values. - /// \param column_position[in] the position of the column, starting from 1. + /// \param column_position [in] the position of the column, starting from 1. /// \return the prefix character(s). virtual std::string GetLiteralPrefix(int column_position) = 0; /// \brief It retrieves the character or characters that the driver uses /// as prefix for literal values. - /// \param column_position[in] the position of the column, starting from 1. + /// \param column_position [in] the position of the column, starting from 1. /// \return the suffix character(s). virtual std::string GetLiteralSuffix(int column_position) = 0; /// \brief It retrieves the local type name for a specific column. - /// \param column_position[in] the position of the column, starting from 1. + /// \param column_position [in] the position of the column, starting from 1. /// \return the local type name. virtual std::string GetLocalTypeName(int column_position) = 0; /// \brief It returns the column name alias. If it has no alias /// it returns the column name. - /// \param column_position[in] the position of the column, starting from 1. + /// \param column_position [in] the position of the column, starting from 1. /// \return the column name alias. virtual std::string GetName(int column_position) = 0; /// \brief It returns a numeric value to indicate if the data /// is an approximate or exact numeric data type. - /// \param column_position[in] the position of the column, starting from 1. + /// \param column_position [in] the position of the column, starting from 1. virtual size_t GetNumPrecRadix(int column_position) = 0; /// \brief It returns the length in bytes from a string or binary data. - /// \param column_position[in] the position of the column, starting from 1. + /// \param column_position [in] the position of the column, starting from 1. /// \return the length in bytes. virtual size_t GetOctetLength(int column_position) = 0; /// \brief It returns the data type as a string. - /// \param column_position[in] the position of the column, starting from 1. + /// \param column_position [in] the position of the column, starting from 1. /// \return the data type string. virtual std::string GetTypeName(int column_position) = 0; /// \brief It returns a numeric values indicate the updatability of the /// column. - /// \param column_position[in] the position of the column, starting from 1. + /// \param column_position [in] the position of the column, starting from 1. /// \return the updatability of the column. virtual Updatability GetUpdatable(int column_position) = 0; /// \brief It returns a boolean value indicating if the column is /// autoincrementing. - /// \param column_position[in] the position of the column, starting from 1. + /// \param column_position [in] the position of the column, starting from 1. /// \return boolean values if column is auto incremental. virtual bool IsAutoUnique(int column_position) = 0; /// \brief It returns a boolean value indicating if the column is /// case sensitive. - /// \param column_position[in] the position of the column, starting from 1. + /// \param column_position [in] the position of the column, starting from 1. /// \return boolean values if column is case sensitive. virtual bool IsCaseSensitive(int column_position) = 0; /// \brief It returns a boolean value indicating if the column can be used /// in where clauses. - /// \param column_position[in] the position of the column, starting from 1. + /// \param column_position [in] the position of the column, starting from 1. /// \return boolean values if column can be used in where clauses. virtual Searchability IsSearchable(int column_position) = 0; /// \brief It checks if a numeric column is signed or unsigned. - /// \param column_position[in] the position of the column, starting from 1. + /// \param column_position [in] the position of the column, starting from 1. /// \return check if the column is signed or not. virtual bool IsUnsigned(int column_position) = 0; /// \brief It check if the columns has fixed precision and a nonzero /// scale. - /// \param column_position[in] the position of the column, starting from 1. + /// \param column_position [in] the position of the column, starting from 1. /// \return if column has a fixed precision and non zero scale. virtual bool IsFixedPrecScale(int column_position) = 0; }; diff --git a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/types.h b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/types.h index e5d206a2ca7c..8f16000daaa1 100644 --- a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/types.h +++ b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/types.h @@ -17,8 +17,8 @@ #pragma once -#include #include +#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/platform.h" namespace driver { namespace odbcabstraction { diff --git a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/utils.h b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/utils.h index 44669578cd3f..0fa8463b5464 100644 --- a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/utils.h +++ b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/utils.h @@ -17,10 +17,10 @@ #pragma once -#include -#include #include #include +#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/logger.h" +#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/spi/connection.h" namespace driver { namespace odbcabstraction { @@ -38,7 +38,7 @@ boost::optional AsBool(const std::string& value); /// \param property_name the name of the property that will be looked up. /// \return the parsed valued. boost::optional AsBool(const Connection::ConnPropertyMap& connPropertyMap, - const std::string& property_name); + const std::string_view& property_name); /// Looks up for a value inside the ConnPropertyMap and then try to parse it. /// In case it does not find or it cannot parse, the default value will be returned. @@ -46,11 +46,11 @@ boost::optional AsBool(const Connection::ConnPropertyMap& connPropertyMap, /// value is returned. \param connPropertyMap the map with the connection /// properties. \param property_name the name of the property that will be /// looked up. \return the parsed valued. \exception -/// std::invalid_argument exception from \link std::stoi \endlink \exception -/// std::out_of_range exception from \link std::stoi \endlink +/// std::invalid_argument exception from std::stoi \exception +/// std::out_of_range exception from std::stoi boost::optional AsInt32(int32_t min_value, const Connection::ConnPropertyMap& connPropertyMap, - const std::string& property_name); + const std::string_view& property_name); void ReadConfigFile(PropertyMap& properties, const std::string& configFileName); diff --git a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/logger.cc b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/logger.cc index edace64cf6ad..8b105a2f0b68 100644 --- a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/logger.cc +++ b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/logger.cc @@ -15,7 +15,7 @@ // specific language governing permissions and limitations // under the License. -#include +#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/logger.h" namespace driver { namespace odbcabstraction { diff --git a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/odbc_impl/odbc_connection.cc b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/odbc_impl/odbc_connection.cc index 0d3e772f55f2..4d5d4dc3656a 100644 --- a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/odbc_impl/odbc_connection.cc +++ b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/odbc_impl/odbc_connection.cc @@ -66,7 +66,7 @@ void loadPropertiesFromDSN(const std::string& dsn, // The output buffer holds the list of keys in a series of NUL-terminated strings. // The series is terminated with an empty string (eg a NUL-terminator terminating the // last key followed by a NUL terminator after). - std::vector keys; + std::vector keys; size_t pos = 0; while (pos < BUFFER_SIZE) { std::string key(&outputBuffer[pos]); @@ -85,8 +85,7 @@ void loadPropertiesFromDSN(const std::string& dsn, for (auto& key : keys) { outputBuffer.clear(); outputBuffer.resize(BUFFER_SIZE, '\0'); - - SQLGetPrivateProfileString(dsn.c_str(), key.c_str(), "", &outputBuffer[0], + SQLGetPrivateProfileString(dsn.c_str(), key.data(), "", &outputBuffer[0], BUFFER_SIZE, "odbc.ini"); std::string value = std::string(&outputBuffer[0]); @@ -118,7 +117,7 @@ const std::string& ODBCConnection::GetDSN() const { return m_dsn; } void ODBCConnection::connect(std::string dsn, const Connection::ConnPropertyMap& properties, - std::vector& missing_properties) { + std::vector& missing_properties) { if (m_isConnected) { throw DriverException("Already connected.", "HY010"); } diff --git a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/odbc_impl/odbc_environment.cc b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/odbc_impl/odbc_environment.cc index 7781235688fd..9d7a8223591c 100644 --- a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/odbc_impl/odbc_environment.cc +++ b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/odbc_impl/odbc_environment.cc @@ -15,12 +15,13 @@ // specific language governing permissions and limitations // under the License. -#include +#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_environment.h" + +#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_connection.h" +#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/spi/connection.h" +#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/spi/driver.h" +#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/types.h" -#include -#include -#include -#include #include #include #include diff --git a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/odbc_impl/odbc_statement.cc b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/odbc_impl/odbc_statement.cc index a5db0cc25dde..f6c06060d676 100644 --- a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/odbc_impl/odbc_statement.cc +++ b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/odbc_impl/odbc_statement.cc @@ -15,16 +15,17 @@ // specific language governing permissions and limitations // under the License. -#include - -#include -#include -#include -#include -#include -#include -#include -#include +#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_statement.h" + +#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/exceptions.h" +#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/attribute_utils.h" +#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_connection.h" +#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_descriptor.h" +#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/spi/result_set.h" +#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/spi/result_set_metadata.h" +#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/spi/statement.h" +#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/types.h" + #include #include #include diff --git a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/spd_logger.cc b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/spd_logger.cc index 9b6f481b3ddd..322ae5e5da13 100644 --- a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/spd_logger.cc +++ b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/spd_logger.cc @@ -27,16 +27,6 @@ namespace driver { namespace odbcabstraction { - -// clang-format off -const std::string SPDLogger::LOG_LEVEL = "LogLevel"; // NOLINT(runtime/string) -const std::string SPDLogger::LOG_PATH = "LogPath"; // NOLINT(runtime/string) -const std::string SPDLogger::MAXIMUM_FILE_SIZE = // NOLINT(runtime/string) - "MaximumFileSize"; -const std::string SPDLogger::FILE_QUANTITY = "FileQuantity"; // NOLINT(runtime/string) -const std::string SPDLogger::LOG_ENABLED = "LogEnabled"; // NOLINT(runtime/string) -// clang-format on - namespace { inline spdlog::level::level_enum ToSpdLogLevel(LogLevel level) { switch (level) { diff --git a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/utils.cc b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/utils.cc index fa93ea292cc4..f1d2d14744d3 100644 --- a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/utils.cc +++ b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/utils.cc @@ -15,8 +15,9 @@ // specific language governing permissions and limitations // under the License. +#include "arrow/vendored/whereami/whereami.h" + #include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/utils.h" -#include "arrow/flight/sql/odbc/odbcabstraction/whereami.h" #include #include @@ -40,7 +41,7 @@ boost::optional AsBool(const std::string& value) { } boost::optional AsBool(const Connection::ConnPropertyMap& connPropertyMap, - const std::string& property_name) { + const std::string_view& property_name) { auto extracted_property = connPropertyMap.find(property_name); if (extracted_property != connPropertyMap.end()) { @@ -52,7 +53,7 @@ boost::optional AsBool(const Connection::ConnPropertyMap& connPropertyMap, boost::optional AsInt32(int32_t min_value, const Connection::ConnPropertyMap& connPropertyMap, - const std::string& property_name) { + const std::string_view& property_name) { auto extracted_property = connPropertyMap.find(property_name); if (extracted_property != connPropertyMap.end()) { diff --git a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/whereami.cc b/cpp/src/arrow/vendored/whereami/whereami.cc similarity index 99% rename from cpp/src/arrow/flight/sql/odbc/odbcabstraction/whereami.cc rename to cpp/src/arrow/vendored/whereami/whereami.cc index ad5d08ef3107..945226193f99 100644 --- a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/whereami.cc +++ b/cpp/src/arrow/vendored/whereami/whereami.cc @@ -6,7 +6,7 @@ // in case you want to #include "whereami.c" in a larger compilation unit #if !defined(WHEREAMI_H) -# include "arrow/flight/sql/odbc/odbcabstraction/whereami.h" +# include "whereami.h" #endif #ifdef __cplusplus diff --git a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/whereami.h b/cpp/src/arrow/vendored/whereami/whereami.h similarity index 100% rename from cpp/src/arrow/flight/sql/odbc/odbcabstraction/whereami.h rename to cpp/src/arrow/vendored/whereami/whereami.h diff --git a/dev/release/rat_exclude_files.txt b/dev/release/rat_exclude_files.txt index d1e721ba9682..0c827421fe87 100644 --- a/dev/release/rat_exclude_files.txt +++ b/dev/release/rat_exclude_files.txt @@ -18,8 +18,6 @@ cpp/src/arrow/util/random.h cpp/src/arrow/status.cc cpp/src/arrow/status.h cpp/src/arrow/vendored/* -cpp/src/arrow/flight/sql/odbc/odbcabstraction/whereami.cc -cpp/src/arrow/flight/sql/odbc/odbcabstraction/whereami.h cpp/build-support/asan_symbolize.py cpp/build-support/cpplint.py cpp/build-support/lint_exclusions.txt