MCPcopy Create free account
hub / github.com/apache/arrow / SQLExtendedFetch

Function SQLExtendedFetch

cpp/src/arrow/flight/sql/odbc/odbc_api.cc:1108–1146  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1106}
1107
1108SQLRETURN SQLExtendedFetch(SQLHSTMT stmt, SQLUSMALLINT fetch_orientation,
1109 SQLLEN fetch_offset, SQLULEN* row_count_ptr,
1110 SQLUSMALLINT* row_status_array) {
1111 // GH-47110 TODO: SQLExtendedFetch should return SQL_SUCCESS_WITH_INFO for certain diag
1112 // states
1113 ARROW_LOG(DEBUG) << "SQLExtendedFetch called with stmt: " << stmt
1114 << ", fetch_orientation: " << fetch_orientation
1115 << ", fetch_offset: " << fetch_offset
1116 << ", row_count_ptr: " << static_cast<const void*>(row_count_ptr)
1117 << ", row_status_array: "
1118 << static_cast<const void*>(row_status_array);
1119
1120 using ODBC::ODBCDescriptor;
1121 using ODBC::ODBCStatement;
1122 return ODBCStatement::ExecuteWithDiagnostics(stmt, SQL_ERROR, [=]() {
1123 // Only SQL_FETCH_NEXT forward-only fetching orientation is supported,
1124 // meaning the behavior of SQLExtendedFetch is same as SQLFetch.
1125 if (fetch_orientation != SQL_FETCH_NEXT) {
1126 throw DriverException("Optional feature not supported.", "HYC00");
1127 }
1128 // Ignore fetch_offset as it's not applicable to SQL_FETCH_NEXT
1129 ARROW_UNUSED(fetch_offset);
1130
1131 ODBCStatement* statement = reinterpret_cast<ODBCStatement*>(stmt);
1132
1133 // The SQL_ROWSET_SIZE statement attribute specifies the number of rows in the
1134 // rowset. Retrieve it from GetRowsetSize.
1135 SQLULEN row_set_size = statement->GetRowsetSize();
1136 ARROW_LOG(DEBUG) << "SQL_ROWSET_SIZE value for SQLExtendedFetch: " << row_set_size;
1137
1138 if (statement->Fetch(static_cast<size_t>(row_set_size), row_count_ptr,
1139 row_status_array)) {
1140 return SQL_SUCCESS;
1141 } else {
1142 // Reached the end of rowset
1143 return SQL_NO_DATA;
1144 }
1145 });
1146}
1147
1148SQLRETURN SQLFetchScroll(SQLHSTMT stmt, SQLSMALLINT fetch_orientation,
1149 SQLLEN fetch_offset) {

Callers 2

TYPED_TESTFunction · 0.50
TEST_FFunction · 0.50

Calls 3

DriverExceptionClass · 0.85
GetRowsetSizeMethod · 0.80
FetchMethod · 0.80

Tested by 2

TYPED_TESTFunction · 0.40
TEST_FFunction · 0.40