Skip to content
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
4516e4c
Implement SQLGetStmtAttr and SQLSetStmtAttr
rscales Jul 3, 2025
12a059f
Reformat files
rscales Jul 4, 2025
04962f3
Add initial version of statement attr tests
rscales Jul 8, 2025
a5735bf
Change order to have log as first line in method
rscales Jul 8, 2025
6f3e58a
Fix outstanding issues from test cases
rscales Jul 8, 2025
22469a0
Revert back to use void return for ODBCStatement GetStmtAttr and SetS…
rscales Jul 9, 2025
e5cdd2b
Fix formatting issues
rscales Jul 9, 2025
bbbdedf
Fix additional test case issues
rscales Jul 9, 2025
570fa28
Fix issue with expected returned value for SQL_ATTR_ROW_NUMBER test
rscales Jul 9, 2025
87800d5
Revert to use null SQLPOINTER for SQL_ATTR_FETCH_BOOKMARK_PTR default…
rscales Jul 9, 2025
403a53b
Update tests that require use of SQLPOINTER data
rscales Jul 11, 2025
44c331c
Fix copy and paste error for SQL_ATTR_PARAM_STATUS_PTR test case
rscales Jul 11, 2025
413723e
Merge branch 'apache-odbc' into sql-get-stmt-attr
rscales Jul 11, 2025
6cdff25
Update to address comments from review
rscales Jul 11, 2025
b192397
Merge branch 'sql-get-stmt-attr' of https://github.com/Bit-Quill/arro…
rscales Jul 11, 2025
17f2e16
Add SQLPOINTER static casts where missing
rscales Jul 11, 2025
599ffec
Empty commit to force running workflows
rscales Jul 11, 2025
61af11d
Empty commit to force running workflows
rscales Jul 11, 2025
db63cdb
Reformat entry points file due to line added by merge
rscales Jul 11, 2025
dfbf53b
Add missing this reference for statement instance
rscales Jul 14, 2025
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
7 changes: 2 additions & 5 deletions cpp/src/arrow/flight/sql/odbc/entry_points.cc
Original file line number Diff line number Diff line change
Expand Up @@ -279,11 +279,8 @@ SQLRETURN SQL_API SQLPrimaryKeys(SQLHSTMT stmt, SQLWCHAR* catalogName,

SQLRETURN SQL_API SQLSetStmtAttr(SQLHSTMT stmt, SQLINTEGER attribute, SQLPOINTER valuePtr,
SQLINTEGER stringLength) {
LOG_DEBUG(
"SQLSetStmtAttrW called with stmt: {}, attribute: {}, valuePtr: {}, "
"stringLength: {}",
stmt, attribute, valuePtr, stringLength);
return SQL_ERROR;

return arrow::SQLSetStmtAttr(stmt, attribute, valuePtr, stringLength);
}

SQLRETURN SQL_API SQLTables(SQLHSTMT stmt, SQLWCHAR* catalogName,
Expand Down
27 changes: 23 additions & 4 deletions cpp/src/arrow/flight/sql/odbc/odbc_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -873,19 +873,38 @@ SQLRETURN SQLGetInfo(SQLHDBC conn, SQLUSMALLINT infoType, SQLPOINTER infoValuePt

SQLRETURN SQLGetStmtAttr(SQLHSTMT stmt, SQLINTEGER attribute, SQLPOINTER valuePtr,
SQLINTEGER bufferLength, SQLINTEGER* stringLengthPtr) {
using ODBC::ODBCStatement;
// TODO: complete implementation of SQLGetStmtAttrW and write tests
LOG_DEBUG(
"SQLGetStmtAttrW called with stmt: {}, attribute: {}, valuePtr: {}, "
"bufferLength: {}, stringLengthPtr: {}",
stmt, attribute, valuePtr, bufferLength, fmt::ptr(stringLengthPtr));
using ODBC::ODBCStatement;

return ODBCStatement::ExecuteWithDiagnostics(stmt, SQL_ERROR, [=]() {
ODBCStatement* statement = reinterpret_cast<ODBCStatement*>(stmt);

bool isUnicode = true;

statement->GetStmtAttr(attribute, valuePtr, bufferLength, stringLengthPtr, isUnicode);
// TODO: change GetStmtAttr to return SQLRETURN instead of void,
// and return value from GetStmtAttr instead

return SQL_SUCCESS;
});
}

SQLRETURN SQLSetStmtAttr(SQLHSTMT stmt, SQLINTEGER attribute, SQLPOINTER valuePtr,
SQLINTEGER stringLength) {
LOG_DEBUG(
"SQLSetStmtAttrW called with stmt: {}, attribute: {}, valuePtr: {}, "
"stringLength: {}",
stmt, attribute, valuePtr, stringLength);
using ODBC::ODBCStatement;

return ODBCStatement::ExecuteWithDiagnostics(stmt, SQL_ERROR, [=]() {
ODBCStatement* statement = reinterpret_cast<ODBCStatement*>(stmt);

bool isUnicode = true;

statement->SetStmtAttr(attribute, valuePtr, stringLength, isUnicode);

return SQL_SUCCESS;
});
}
Expand Down
2 changes: 2 additions & 0 deletions cpp/src/arrow/flight/sql/odbc/odbc_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ SQLRETURN SQLGetInfo(SQLHDBC conn, SQLUSMALLINT infoType, SQLPOINTER infoValuePt
SQLSMALLINT bufLen, SQLSMALLINT* length);
SQLRETURN SQLGetStmtAttr(SQLHSTMT stmt, SQLINTEGER attribute, SQLPOINTER valuePtr,
SQLINTEGER bufferLength, SQLINTEGER* stringLengthPtr);
SQLRETURN SQLSetStmtAttr(SQLHSTMT stmt, SQLINTEGER attribute, SQLPOINTER valuePtr,
SQLINTEGER stringLength);
SQLRETURN SQLExecDirect(SQLHSTMT stmt, SQLWCHAR* queryText, SQLINTEGER textLength);
SQLRETURN SQLPrepare(SQLHSTMT stmt, SQLWCHAR* queryText, SQLINTEGER textLength);
SQLRETURN SQLExecute(SQLHSTMT stmt);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ void ODBCStatement::SetStmtAttr(SQLINTEGER statementAttribute, SQLPOINTER value,
CheckIfAttributeIsSetToOnlyValidValue(value, static_cast<SQLULEN>(SQL_UB_OFF));
return;
case SQL_ATTR_RETRIEVE_DATA:
CheckIfAttributeIsSetToOnlyValidValue(value, static_cast<SQLULEN>(SQL_TRUE));
CheckIfAttributeIsSetToOnlyValidValue(value, static_cast<SQLULEN>(SQL_RD_ON));
Comment thread
rscales marked this conversation as resolved.
return;
case SQL_ROWSET_SIZE:
SetAttribute(value, m_rowsetSize);
Expand Down
1 change: 1 addition & 0 deletions cpp/src/arrow/flight/sql/odbc/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ add_arrow_test(flight_sql_odbc_test
SOURCES
connection_attr_test.cc
connection_info_test.cc
statement_attr_test.cc
statement_test.cc
# Connection test needs to be put last to resolve segfault issue
connection_test.cc
Expand Down
1 change: 1 addition & 0 deletions cpp/src/arrow/flight/sql/odbc/tests/odbc_test_suite.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ static constexpr std::string_view error_state_HY024 = "HY024";
static constexpr std::string_view error_state_HY092 = "HY092";
static constexpr std::string_view error_state_HYC00 = "HYC00";
static constexpr std::string_view error_state_HY114 = "HY114";
static constexpr std::string_view error_state_HY017 = "HY017";
static constexpr std::string_view error_state_HY118 = "HY118";

/// Verify ODBC Error State
Expand Down
Loading
Loading