Skip to content

Commit 53cf1c9

Browse files
committed
Attempt to fix segfault error
Iirc, there is segfault error associated with `SQLGetStmtAttrW` Attempt to fix segfault error by adding impl for `SQLSetConnectAttr` Part-fix remove `using` that isn't needed
1 parent fc95da6 commit 53cf1c9

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

cpp/src/arrow/flight/sql/odbc/odbc_api.cc

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -723,8 +723,15 @@ SQLRETURN SQLSetConnectAttr(SQLHDBC conn, SQLINTEGER attr, SQLPOINTER value_ptr,
723723
ARROW_LOG(DEBUG) << "SQLSetConnectAttrW called with conn: " << conn
724724
<< ", attr: " << attr << ", value_ptr: " << value_ptr
725725
<< ", value_len: " << value_len;
726-
// GH-47708 TODO: Implement SQLSetConnectAttr
727-
return SQL_INVALID_HANDLE;
726+
// GH-47708 TODO: Add tests for SQLSetConnectAttr
727+
using ODBC::ODBCConnection;
728+
729+
return ODBCConnection::ExecuteWithDiagnostics(conn, SQL_ERROR, [=]() {
730+
const bool is_unicode = true;
731+
ODBCConnection* connection = reinterpret_cast<ODBCConnection*>(conn);
732+
connection->SetConnectAttr(attr, value_ptr, value_len, is_unicode);
733+
return SQL_SUCCESS;
734+
});
728735
}
729736

730737
// Load properties from the given DSN. The properties loaded do _not_ overwrite existing
@@ -766,8 +773,6 @@ SQLRETURN SQLDriverConnect(SQLHDBC conn, SQLHWND window_handle,
766773
// GH-46560 TODO: Copy connection string properly in SQLDriverConnect according to the
767774
// spec
768775

769-
using arrow::flight::sql::odbc::Connection;
770-
using arrow::flight::sql::odbc::DriverException;
771776
using ODBC::ODBCConnection;
772777

773778
return ODBCConnection::ExecuteWithDiagnostics(conn, SQL_ERROR, [=]() {
@@ -840,8 +845,6 @@ SQLRETURN SQLConnect(SQLHDBC conn, SQLWCHAR* dsn_name, SQLSMALLINT dsn_name_len,
840845
<< ", password: " << static_cast<const void*>(password)
841846
<< ", password_len: " << password_len;
842847

843-
using arrow::flight::sql::odbc::FlightSqlConnection;
844-
using arrow::flight::sql::odbc::config::Configuration;
845848
using ODBC::ODBCConnection;
846849

847850
using ODBC::SqlWcharToString;

cpp/src/arrow/flight/sql/odbc/tests/odbc_test_suite.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,13 @@ void ODBCRemoteTestBase::ConnectWithString(std::string connect_str) {
6161
kOdbcBufferSize, &out_str_len, SQL_DRIVER_NOPROMPT))
6262
<< GetOdbcErrorMessage(SQL_HANDLE_DBC, conn);
6363

64-
// Allocate a statement using alloc handle
65-
ASSERT_EQ(SQL_SUCCESS, SQLAllocHandle(SQL_HANDLE_STMT, conn, &stmt));
64+
// GH-47710: TODO Allocate a statement using alloc handle
65+
// ASSERT_EQ(SQL_SUCCESS, SQLAllocHandle(SQL_HANDLE_STMT, conn, &stmt));
6666
}
6767

6868
void ODBCRemoteTestBase::Disconnect() {
69-
// Close statement
70-
EXPECT_EQ(SQL_SUCCESS, SQLFreeHandle(SQL_HANDLE_STMT, stmt));
69+
// GH-47710: TODO Close statement
70+
// EXPECT_EQ(SQL_SUCCESS, SQLFreeHandle(SQL_HANDLE_STMT, stmt));
7171

7272
// Disconnect from ODBC
7373
EXPECT_EQ(SQL_SUCCESS, SQLDisconnect(conn))

0 commit comments

Comments
 (0)