forked from apache/arrow
-
Notifications
You must be signed in to change notification settings - Fork 0
SQLError implementation in macOS #142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -47,6 +47,8 @@ using TestTypesHandle = ::testing::Types<FlightSQLOdbcEnvConnHandleMockTestBase, | |
| FlightSQLOdbcEnvConnHandleRemoteTestBase>; | ||
| TYPED_TEST_SUITE(ErrorsHandleTest, TestTypesHandle); | ||
|
|
||
| using ODBC::SqlWcharToString; | ||
|
|
||
| TYPED_TEST(ErrorsHandleTest, TestSQLGetDiagFieldWForConnectFailure) { | ||
| // Invalid connect string | ||
| std::string connect_str = this->GetInvalidConnectionString(); | ||
|
|
@@ -119,7 +121,7 @@ TYPED_TEST(ErrorsHandleTest, TestSQLGetDiagFieldWForConnectFailure) { | |
| SQLGetDiagField(SQL_HANDLE_DBC, this->conn, RECORD_1, SQL_DIAG_SQLSTATE, sql_state, | ||
| sql_state_size * GetSqlWCharSize(), &sql_state_length)); | ||
|
|
||
| EXPECT_EQ(std::wstring(L"28000"), std::wstring(sql_state)); | ||
| EXPECT_EQ(kErrorState28000, SqlWcharToString(sql_state)); | ||
| } | ||
|
|
||
| TYPED_TEST(ErrorsHandleTest, DISABLED_TestSQLGetDiagFieldWForConnectFailureNTS) { | ||
|
|
@@ -218,7 +220,7 @@ TYPED_TEST(ErrorsTest, TestSQLGetDiagFieldWForDescriptorFailureFromDriverManager | |
| SQLGetDiagField(SQL_HANDLE_DESC, descriptor, RECORD_1, SQL_DIAG_SQLSTATE, sql_state, | ||
| sql_state_size * GetSqlWCharSize(), &sql_state_length)); | ||
|
|
||
| EXPECT_EQ(std::wstring(L"IM001"), std::wstring(sql_state)); | ||
| EXPECT_EQ(kErrorStateIM001, SqlWcharToString(sql_state)); | ||
|
|
||
| // Free descriptor handle | ||
| EXPECT_EQ(SQL_SUCCESS, SQLFreeHandle(SQL_HANDLE_DESC, descriptor)); | ||
|
|
@@ -247,7 +249,7 @@ TYPED_TEST(ErrorsTest, TestSQLGetDiagRecForDescriptorFailureFromDriverManager) { | |
| EXPECT_EQ(0, native_error); | ||
|
|
||
| // API not implemented error from driver manager | ||
| EXPECT_EQ(std::wstring(L"IM001"), std::wstring(sql_state)); | ||
| EXPECT_EQ(kErrorStateIM001, SqlWcharToString(sql_state)); | ||
|
|
||
| EXPECT_FALSE(std::wstring(message).empty()); | ||
|
|
||
|
|
@@ -284,7 +286,7 @@ TYPED_TEST(ErrorsHandleTest, TestSQLGetDiagRecForConnectFailure) { | |
|
|
||
| EXPECT_EQ(200, native_error); | ||
|
|
||
| EXPECT_EQ(std::wstring(L"28000"), std::wstring(sql_state)); | ||
| EXPECT_EQ(kErrorState28000, SqlWcharToString(sql_state)); | ||
|
|
||
| EXPECT_FALSE(std::wstring(message).empty()); | ||
| } | ||
|
|
@@ -358,12 +360,12 @@ TYPED_TEST(ErrorsTest, TestSQLErrorEnvErrorFromDriverManager) { | |
| ASSERT_EQ(SQL_SUCCESS, SQLError(this->env, nullptr, nullptr, sql_state, &native_error, | ||
| message, SQL_MAX_MESSAGE_LENGTH, &message_length)); | ||
|
|
||
| EXPECT_GT(message_length, 50); | ||
| EXPECT_GT(message_length, 40); | ||
|
|
||
| EXPECT_EQ(0, native_error); | ||
|
|
||
| // Function sequence error state from driver manager | ||
| EXPECT_EQ(std::wstring(L"HY010"), std::wstring(sql_state)); | ||
| EXPECT_EQ(kErrorStateHY010, SqlWcharToString(sql_state)); | ||
|
|
||
| EXPECT_FALSE(std::wstring(message).empty()); | ||
| } | ||
|
|
@@ -390,7 +392,7 @@ TYPED_TEST(ErrorsTest, TestSQLErrorConnError) { | |
| EXPECT_EQ(100, native_error); | ||
|
|
||
| // optional feature not supported error state | ||
| EXPECT_EQ(std::wstring(L"HYC00"), std::wstring(sql_state)); | ||
| EXPECT_EQ(kErrorStateHYC00, SqlWcharToString(sql_state)); | ||
|
|
||
| EXPECT_FALSE(std::wstring(message).empty()); | ||
| } | ||
|
|
@@ -420,7 +422,7 @@ TYPED_TEST(ErrorsTest, TestSQLErrorStmtError) { | |
|
|
||
| EXPECT_EQ(100, native_error); | ||
|
|
||
| EXPECT_EQ(std::wstring(L"HY000"), std::wstring(sql_state)); | ||
| EXPECT_EQ(kErrorStateHY000, SqlWcharToString(sql_state)); | ||
|
|
||
| EXPECT_FALSE(std::wstring(message).empty()); | ||
| } | ||
|
|
@@ -457,7 +459,7 @@ TYPED_TEST(ErrorsTest, TestSQLErrorStmtWarning) { | |
| EXPECT_EQ(1000100, native_error); | ||
|
|
||
| // Verify string truncation warning is reported | ||
| EXPECT_EQ(std::wstring(L"01004"), std::wstring(sql_state)); | ||
| EXPECT_EQ(kErrorState01004, SqlWcharToString(sql_state)); | ||
|
|
||
| EXPECT_FALSE(std::wstring(message).empty()); | ||
| } | ||
|
|
@@ -479,22 +481,35 @@ TYPED_TEST(ErrorsOdbcV2Test, TestSQLErrorEnvErrorFromDriverManager) { | |
| ASSERT_EQ(SQL_SUCCESS, SQLError(this->env, nullptr, nullptr, sql_state, &native_error, | ||
| message, SQL_MAX_MESSAGE_LENGTH, &message_length)); | ||
|
|
||
| EXPECT_GT(message_length, 50); | ||
| EXPECT_GT(message_length, 40); | ||
|
|
||
| EXPECT_EQ(0, native_error); | ||
|
|
||
| // 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(kErrorStateS1010, SqlWcharToString(sql_state)); | ||
| #else | ||
| // unix Driver Manager returns HY010 | ||
| EXPECT_EQ(kErrorStateHY010, SqlWcharToString(sql_state)); | ||
| #endif // _WIN32 | ||
|
|
||
| EXPECT_FALSE(std::wstring(message).empty()); | ||
| } | ||
|
|
||
| // TODO: verify that `SQLGetConnectOption` is not required by Excel. | ||
| #ifndef __APPLE__ | ||
| TYPED_TEST(ErrorsOdbcV2Test, TestSQLErrorConnError) { | ||
|
Comment on lines
+500
to
502
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Still need to verify if For this PR, we are checking in the SQLErrors changes. |
||
| // Test ODBC 2.0 API SQLError with ODBC ver 2. | ||
| // Known Windows Driver Manager (DM) behavior: | ||
| // When application passes buffer length greater than SQL_MAX_MESSAGE_LENGTH (512), | ||
| // DM passes 512 as buffer length to SQLError. | ||
|
|
||
| // Known macOS Driver Manager (DM) behavior: | ||
| // Attempts to call SQLGetConnectOption without redirecting the API call to | ||
| // SQLGetConnectAttr. SQLGetConnectOption is not implemented as it is not required by | ||
| // macOS Excel. | ||
|
|
||
| // Attempt to set unsupported attribute | ||
| ASSERT_EQ(SQL_ERROR, | ||
| SQLGetConnectAttr(this->conn, SQL_ATTR_TXN_ISOLATION, 0, 0, nullptr)); | ||
|
|
@@ -511,10 +526,11 @@ TYPED_TEST(ErrorsOdbcV2Test, TestSQLErrorConnError) { | |
| EXPECT_EQ(100, native_error); | ||
|
|
||
| // optional feature not supported error state. Driver Manager maps state to S1C00 | ||
| EXPECT_EQ(std::wstring(L"S1C00"), std::wstring(sql_state)); | ||
| EXPECT_EQ(kErrorStateS1C00, SqlWcharToString(sql_state)); | ||
|
|
||
| EXPECT_FALSE(std::wstring(message).empty()); | ||
| } | ||
| #endif // __APPLE__ | ||
|
|
||
| TYPED_TEST(ErrorsOdbcV2Test, TestSQLErrorStmtError) { | ||
| // Test ODBC 2.0 API SQLError with ODBC ver 2. | ||
|
|
@@ -540,7 +556,7 @@ TYPED_TEST(ErrorsOdbcV2Test, TestSQLErrorStmtError) { | |
| EXPECT_EQ(100, native_error); | ||
|
|
||
| // Driver Manager maps error state to S1000 | ||
| EXPECT_EQ(std::wstring(L"S1000"), std::wstring(sql_state)); | ||
| EXPECT_EQ(kErrorStateS1000, SqlWcharToString(sql_state)); | ||
|
|
||
| EXPECT_FALSE(std::wstring(message).empty()); | ||
| } | ||
|
|
@@ -577,7 +593,7 @@ TYPED_TEST(ErrorsOdbcV2Test, TestSQLErrorStmtWarning) { | |
| EXPECT_EQ(1000100, native_error); | ||
|
|
||
| // Verify string truncation warning is reported | ||
| EXPECT_EQ(std::wstring(L"01004"), std::wstring(sql_state)); | ||
| EXPECT_EQ(kErrorState01004, SqlWcharToString(sql_state)); | ||
|
|
||
| EXPECT_FALSE(std::wstring(message).empty()); | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.