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

Method Fetch

cpp/src/arrow/flight/sql/odbc/odbc_impl/odbc_statement.cc:324–380  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

322}
323
324bool ODBCStatement::Fetch(size_t rows, SQLULEN* row_count_ptr,
325 SQLUSMALLINT* row_status_array) {
326 if (has_reached_end_of_result_) {
327 ird_->SetRowsProcessed(0);
328 return false;
329 }
330
331 if (max_rows_) {
332 rows = std::min(rows, max_rows_ - row_number_);
333 }
334
335 if (current_ard_->HaveBindingsChanged()) {
336 // TODO: Deal handle when offset != buffer_length.
337
338 // Wipe out all bindings in the ResultSet.
339 // Note that the number of ARD records can both be more or less
340 // than the number of columns.
341 for (size_t i = 0; i < ird_->GetRecords().size(); i++) {
342 const int column_number = static_cast<int>(i + 1);
343 if (i < current_ard_->GetRecords().size() &&
344 current_ard_->GetRecords()[i].is_bound) {
345 const DescriptorRecord& ard_record = current_ard_->GetRecords()[i];
346 current_result_->BindColumn(column_number, ard_record.type, ard_record.precision,
347 ard_record.scale, ard_record.data_ptr,
348 GetLength(ard_record), ard_record.indicator_ptr);
349 } else {
350 current_result_->BindColumn(column_number,
351 arrow::flight::sql::odbc::CDataType_CHAR
352 /* arbitrary type, not used */,
353 0, 0, nullptr, 0, nullptr);
354 }
355 }
356 current_ard_->NotifyBindingsHavePropagated();
357 }
358
359 uint16_t* array_status_ptr;
360 if (row_status_array) {
361 // For SQLExtendedFetch only
362 array_status_ptr = row_status_array;
363 } else {
364 array_status_ptr = ird_->GetArrayStatusPtr();
365 }
366
367 size_t rows_fetched =
368 current_result_->Move(rows, current_ard_->GetBindOffset(),
369 current_ard_->GetBoundStructOffset(), array_status_ptr);
370 ird_->SetRowsProcessed(static_cast<SQLULEN>(rows_fetched));
371
372 if (row_count_ptr) {
373 // For SQLExtendedFetch only
374 *row_count_ptr = rows_fetched;
375 }
376
377 row_number_ += rows_fetched;
378 has_reached_end_of_result_ = rows_fetched != rows;
379 return rows_fetched != 0;
380}
381

Callers 3

SQLFetchFunction · 0.80
SQLExtendedFetchFunction · 0.80
SQLFetchScrollFunction · 0.80

Calls 10

SetRowsProcessedMethod · 0.80
HaveBindingsChangedMethod · 0.80
BindColumnMethod · 0.80
GetArrayStatusPtrMethod · 0.80
GetBindOffsetMethod · 0.80
GetBoundStructOffsetMethod · 0.80
GetLengthFunction · 0.70
sizeMethod · 0.45
MoveMethod · 0.45

Tested by

no test coverage detected