Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions cpp/src/arrow/flight/sql/odbc/odbc_impl/win_system_dsn.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,11 @@
#include <sstream>

namespace arrow::flight::sql::odbc {

using config::Configuration;
using config::ConnectionStringParser;
using config::DsnConfigurationWindow;
using config::Result;
using config::Window;

bool DisplayConnectionWindow(void* window_parent, Configuration& config) {
HWND hwnd_parent = (HWND)window_parent;

Expand Down Expand Up @@ -93,9 +91,20 @@ bool DisplayConnectionWindow(void* window_parent, Configuration& config,
return false;
}
}
} // namespace arrow::flight::sql::odbc

BOOL INSTAPI ConfigDSNW(HWND hwnd_parent, WORD req, LPCWSTR wdriver,

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If ConfigDSNW is under namespace arrow::flight::sql::odbc, then ConfigDSNW is defined as arrow::flight::sql::odbc::ConfigDSNW which is not recognized by stricted compilers. So ConfigDSNW needs to be defined on its own without any namespace

LPCWSTR wattributes) {
using arrow::flight::sql::odbc::DisplayConnectionWindow;
using arrow::flight::sql::odbc::DriverException;
using arrow::flight::sql::odbc::FlightSqlConnection;
using arrow::flight::sql::odbc::PostArrowUtilError;
using arrow::flight::sql::odbc::PostError;
using arrow::flight::sql::odbc::RegisterDsn;
using arrow::flight::sql::odbc::UnregisterDsn;
using arrow::flight::sql::odbc::config::Configuration;
using arrow::flight::sql::odbc::config::ConnectionStringParser;

Configuration config;
ConnectionStringParser parser(config);

Expand Down Expand Up @@ -165,4 +174,3 @@ BOOL INSTAPI ConfigDSNW(HWND hwnd_parent, WORD req, LPCWSTR wdriver,

return TRUE;
}
} // namespace arrow::flight::sql::odbc
12 changes: 8 additions & 4 deletions cpp/src/arrow/flight/sql/odbc/tests/connection_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -101,16 +101,20 @@ TEST(ODBCHandles, TestSQLAllocAndFreeConnect) {
ASSERT_EQ(SQL_SUCCESS, SQLFreeEnv(env));
}

TYPED_TEST(ConnectionTest, TestFreeNullHandles) {
TEST(SQLFreeHandle, TestFreeNullHandles) {
SQLHENV env = NULL;
SQLHDBC conn = NULL;
SQLHSTMT stmt = NULL;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this change necessary?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The TestFreeNullHandles test was failing for me, ConnectionTest fixture sets up the handles, so the this->... handles will not be null at the beginning of test. I think originally TestFreeNullHandles wasn't a part of the ConnectionTest fixture.


// Verifies attempt to free invalid handle does not cause segfault
// Attempt to free null statement handle
ASSERT_EQ(SQL_INVALID_HANDLE, SQLFreeHandle(SQL_HANDLE_STMT, this->stmt));
ASSERT_EQ(SQL_INVALID_HANDLE, SQLFreeHandle(SQL_HANDLE_STMT, stmt));

// Attempt to free null connection handle
ASSERT_EQ(SQL_INVALID_HANDLE, SQLFreeHandle(SQL_HANDLE_DBC, this->conn));
ASSERT_EQ(SQL_INVALID_HANDLE, SQLFreeHandle(SQL_HANDLE_DBC, conn));

// Attempt to free null environment handle
ASSERT_EQ(SQL_INVALID_HANDLE, SQLFreeHandle(SQL_HANDLE_ENV, this->env));
ASSERT_EQ(SQL_INVALID_HANDLE, SQLFreeHandle(SQL_HANDLE_ENV, env));
}

TEST(SQLGetEnvAttr, TestSQLGetEnvAttrODBCVersion) {
Expand Down
Loading