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

Function SQLExtendedFetch

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

Source from the content-addressed store, hash-verified

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