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

Method Fetch

cpp/src/arrow/flight/sql/odbc/odbc_impl/odbc_statement.cc:324–379  ·  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 if (i < current_ard_->GetRecords().size() &&
343 current_ard_->GetRecords()[i].is_bound) {
344 const DescriptorRecord& ard_record = current_ard_->GetRecords()[i];
345 current_result_->BindColumn(i + 1, ard_record.type, ard_record.precision,
346 ard_record.scale, ard_record.data_ptr,
347 GetLength(ard_record), ard_record.indicator_ptr);
348 } else {
349 current_result_->BindColumn(i + 1,
350 arrow::flight::sql::odbc::CDataType_CHAR
351 /* arbitrary type, not used */,
352 0, 0, nullptr, 0, nullptr);
353 }
354 }
355 current_ard_->NotifyBindingsHavePropagated();
356 }
357
358 uint16_t* array_status_ptr;
359 if (row_status_array) {
360 // For SQLExtendedFetch only
361 array_status_ptr = row_status_array;
362 } else {
363 array_status_ptr = ird_->GetArrayStatusPtr();
364 }
365
366 size_t rows_fetched =
367 current_result_->Move(rows, current_ard_->GetBindOffset(),
368 current_ard_->GetBoundStructOffset(), array_status_ptr);
369 ird_->SetRowsProcessed(static_cast<SQLULEN>(rows_fetched));
370
371 if (row_count_ptr) {
372 // For SQLExtendedFetch only
373 *row_count_ptr = rows_fetched;
374 }
375
376 row_number_ += rows_fetched;
377 has_reached_end_of_result_ = rows_fetched != rows;
378 return rows_fetched != 0;
379}
380
381void ODBCStatement::GetStmtAttr(SQLINTEGER statement_attribute, SQLPOINTER output,

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