Skip to content

Conversation

@alinaliBQ
Copy link

@alinaliBQ alinaliBQ commented Dec 11, 2025

Implement SQLError for macOS only, as macOS driver manager does not do the mapping for SQLError. On Windows we use the SQLError mapping by the driver manager.

Test command with tests passing on intel mac

arrow-flight-sql-odbc-test "--gtest_filter=*.TestConnect:*.*SQLError*"

Test `TestSQLErrorConnError` now passing locally

Disable `SQLGetConnectOption` on macOS. Still need to check if SQLGetConnectOption is needed on macOS Excel.

Move implementation to odbc_api.cc
verified on Windows
Comment on lines +500 to 502
// TODO: verify that `SQLGetConnectOption` is not required by Excel.
#ifndef __APPLE__
TYPED_TEST(ErrorsOdbcV2Test, TestSQLErrorConnError) {
Copy link
Author

Choose a reason for hiding this comment

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

Still need to verify if SQLGetConnectOption is required by latest version of Excel. Will remove this todo comment in future PRs.

For this PR, we are checking in the SQLErrors changes.

Comment on lines 488 to 496
// Function sequence error state from driver manager
EXPECT_EQ(std::wstring(L"S1010"), std::wstring(sql_state));
#ifdef _WIN32
// Windows Driver Manager returns S1010
EXPECT_EQ(SqlWcharToString(sql_state), kErrorStateS1010);
#else
// unix Driver Manager returns HY010
EXPECT_EQ(SqlWcharToString(sql_state), kErrorStateHY010);
#endif // _WIN32

Copy link
Author

Choose a reason for hiding this comment

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

I am surprised that Windows Driver Manager (DM) returns S1010, but I ran the original TestSQLErrorEnvErrorFromDriverManager test on windows and S1010 is what DM returns.

sql_state_size * GetSqlWCharSize(), &sql_state_length));

EXPECT_EQ(std::wstring(L"28000"), std::wstring(sql_state));
EXPECT_EQ(SqlWcharToString(sql_state), kErrorState28000);

Choose a reason for hiding this comment

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

Previously we had EXPECT_EQ(expected, actual) and now you've swapped the order around. Can we do EXPECT_EQ(kErrorState28000, SqlWcharToString(sql_state))?

Likewise for the rest of this PR.

Copy link
Author

Choose a reason for hiding this comment

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

Yes I have swapped back. The swap was accidental as I forgot the original intended order

return SQL_ERROR;
}

#if defined(__APPLE__)

Choose a reason for hiding this comment

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

Do we also need a windows version of SQLError?

Copy link
Author

Choose a reason for hiding this comment

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

We can rely on the driver manager for Windows to provide an implementation of SQLError, it is less error prone.

Driver Managers are supposed to handle ODBC 2.0 APIs like SQLError by mapping to ODBC 3.0 APIs, but macOS Driver Manager is missing on the functionality so we have to implement SQLError for macOS.

@alinaliBQ alinaliBQ merged commit 4ba23ef into apache-odbc Dec 12, 2025
24 checks passed
@alinaliBQ alinaliBQ deleted the sql-error-mac-os branch December 12, 2025 00:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants