diff --git a/ci/scripts/cpp_test.sh b/ci/scripts/cpp_test.sh index 5d6d5e099ab1..88239a0bd1e7 100755 --- a/ci/scripts/cpp_test.sh +++ b/ci/scripts/cpp_test.sh @@ -59,6 +59,7 @@ case "$(uname)" in ;; Darwin) n_jobs=$(sysctl -n hw.ncpu) + exclude_tests+=("arrow-flight-sql-odbc-test") # TODO: https://github.com/apache/arrow/issues/40410 exclude_tests+=("arrow-s3fs-test") ;; diff --git a/cpp/src/arrow/flight/sql/odbc/odbc_impl/CMakeLists.txt b/cpp/src/arrow/flight/sql/odbc/odbc_impl/CMakeLists.txt index 0897248f6cea..74c60cd91632 100644 --- a/cpp/src/arrow/flight/sql/odbc/odbc_impl/CMakeLists.txt +++ b/cpp/src/arrow/flight/sql/odbc/odbc_impl/CMakeLists.txt @@ -104,6 +104,8 @@ add_library(arrow_odbc_spi_impl STATIC spi/result_set.h spi/result_set_metadata.h spi/statement.h + system_dsn.cc + system_dsn.h system_trust_store.cc system_trust_store.h types.h @@ -125,9 +127,7 @@ if(WIN32) ui/dsn_configuration_window.h ui/window.cc ui/window.h - win_system_dsn.cc - system_dsn.cc - system_dsn.h) + win_system_dsn.cc) endif() if(APPLE) diff --git a/cpp/src/arrow/flight/sql/odbc/odbc_impl/system_dsn.cc b/cpp/src/arrow/flight/sql/odbc/odbc_impl/system_dsn.cc index 468f05e4cf4d..902b370ba181 100644 --- a/cpp/src/arrow/flight/sql/odbc/odbc_impl/system_dsn.cc +++ b/cpp/src/arrow/flight/sql/odbc/odbc_impl/system_dsn.cc @@ -17,23 +17,19 @@ #include "arrow/flight/sql/odbc/odbc_impl/system_dsn.h" -#include "arrow/flight/sql/odbc/odbc_impl/config/configuration.h" -#include "arrow/flight/sql/odbc/odbc_impl/flight_sql_connection.h" -#include "arrow/flight/sql/odbc/odbc_impl/ui/dsn_configuration_window.h" -#include "arrow/flight/sql/odbc/odbc_impl/ui/window.h" -#include "arrow/flight/sql/odbc/odbc_impl/util.h" #include "arrow/result.h" #include "arrow/util/utf8.h" -#include #include namespace arrow::flight::sql::odbc { using config::Configuration; -void PostError(DWORD error_code, LPCWSTR error_msg) { +void PostError(DWORD error_code, LPWSTR error_msg) { +#if defined _WIN32 MessageBox(NULL, error_msg, L"Error!", MB_ICONEXCLAMATION | MB_OK); +#endif // _WIN32 SQLPostInstallerError(error_code, error_msg); } @@ -42,7 +38,7 @@ void PostArrowUtilError(arrow::Status error_status) { std::wstring werror_msg = arrow::util::UTF8ToWideString(error_msg).ValueOr( L"Error during utf8 to wide string conversion"); - PostError(ODBC_ERROR_GENERAL_ERR, werror_msg.c_str()); + PostError(ODBC_ERROR_GENERAL_ERR, (LPWSTR)werror_msg.c_str()); } void PostLastInstallerError() { @@ -55,7 +51,7 @@ void PostLastInstallerError() { buf << L"Message: \"" << msg << L"\", Code: " << code; std::wstring error_msg = buf.str(); - PostError(code, error_msg.c_str()); + PostError(code, (LPWSTR)error_msg.c_str()); } /** diff --git a/cpp/src/arrow/flight/sql/odbc/odbc_impl/system_dsn.h b/cpp/src/arrow/flight/sql/odbc/odbc_impl/system_dsn.h index f1fee84fbd4e..59c8cc9601f0 100644 --- a/cpp/src/arrow/flight/sql/odbc/odbc_impl/system_dsn.h +++ b/cpp/src/arrow/flight/sql/odbc/odbc_impl/system_dsn.h @@ -19,8 +19,11 @@ #include "arrow/flight/sql/odbc/odbc_impl/platform.h" #include "arrow/flight/sql/odbc/odbc_impl/config/configuration.h" +#include "arrow/flight/sql/odbc/odbc_impl/flight_sql_connection.h" #include "arrow/status.h" +#include + namespace arrow::flight::sql::odbc { #if defined _WIN32 @@ -64,7 +67,7 @@ bool RegisterDsn(const config::Configuration& config, LPCWSTR driver); */ bool UnregisterDsn(const std::wstring& dsn); -void PostError(DWORD error_code, LPCWSTR error_msg); +void PostError(DWORD error_code, LPWSTR error_msg); void PostArrowUtilError(arrow::Status error_status); } // namespace arrow::flight::sql::odbc diff --git a/cpp/src/arrow/flight/sql/odbc/odbc_impl/win_system_dsn.cc b/cpp/src/arrow/flight/sql/odbc/odbc_impl/win_system_dsn.cc index 2ea9a2451c20..3140b9ade426 100644 --- a/cpp/src/arrow/flight/sql/odbc/odbc_impl/win_system_dsn.cc +++ b/cpp/src/arrow/flight/sql/odbc/odbc_impl/win_system_dsn.cc @@ -144,7 +144,7 @@ BOOL INSTAPI ConfigDSNW(HWND hwnd_parent, WORD req, LPCWSTR wdriver, std::wstring werror_msg = arrow::util::UTF8ToWideString(error_msg).ValueOr(L"Error during DSN load"); - PostError(err.GetNativeError(), werror_msg.c_str()); + PostError(err.GetNativeError(), (LPWSTR)werror_msg.c_str()); return FALSE; } diff --git a/cpp/src/arrow/flight/sql/odbc/tests/connection_test.cc b/cpp/src/arrow/flight/sql/odbc/tests/connection_test.cc index 3ca4a50ef769..57f6c9349bff 100644 --- a/cpp/src/arrow/flight/sql/odbc/tests/connection_test.cc +++ b/cpp/src/arrow/flight/sql/odbc/tests/connection_test.cc @@ -248,7 +248,6 @@ TYPED_TEST(ConnectionHandleTest, TestSQLDriverConnect) { << GetOdbcErrorMessage(SQL_HANDLE_DBC, this->conn); } -#if defined _WIN32 TYPED_TEST(ConnectionHandleTest, TestSQLDriverConnectDsn) { // Connect string std::string connect_str = this->GetConnectionString(); @@ -432,8 +431,6 @@ TEST_F(ConnectionRemoteTest, TestSQLConnectDSNPrecedence) { << GetOdbcErrorMessage(SQL_HANDLE_DBC, conn); } -#endif // _WIN32 - TEST_F(ConnectionRemoteTest, TestSQLDriverConnectInvalidUid) { // Invalid connect string std::string connect_str = GetInvalidConnectionString(); diff --git a/cpp/src/arrow/flight/sql/odbc/tests/odbc_test_suite.cc b/cpp/src/arrow/flight/sql/odbc/tests/odbc_test_suite.cc index 470a68b3beb3..d35713581cdb 100644 --- a/cpp/src/arrow/flight/sql/odbc/tests/odbc_test_suite.cc +++ b/cpp/src/arrow/flight/sql/odbc/tests/odbc_test_suite.cc @@ -463,9 +463,6 @@ std::string GetOdbcErrorMessage(SQLSMALLINT handle_type, SQLHANDLE handle) { return res; } -// GH-47822 TODO: once RegisterDsn is implemented in Mac and Linux, the following can be -// re-enabled. -#if defined _WIN32 bool WriteDSN(std::string connection_str) { Connection::ConnPropertyMap properties; @@ -490,7 +487,6 @@ bool WriteDSN(Connection::ConnPropertyMap properties) { std::wstring w_driver = arrow::util::UTF8ToWideString(driver).ValueOr(L""); return RegisterDsn(config, w_driver.c_str()); } -#endif std::wstring GetStringColumnW(SQLHSTMT stmt, int col_id) { SQLWCHAR buf[1024];