5#include <userver/storages/mysql/statement_result_set.hpp>
9namespace storages::
mysql {
16class CursorResultSet final {
18 explicit CursorResultSet(StatementResultSet&& result_set);
21 CursorResultSet(
const CursorResultSet& other) =
delete;
22 CursorResultSet(CursorResultSet&& other)
noexcept;
30 template <
typename RowCallback>
31 void ForEach(RowCallback&& row_callback, engine::Deadline deadline) &&;
34 StatementResultSet result_set_;
38CursorResultSet<T>::CursorResultSet(StatementResultSet&& result_set) : result_set_{std::move(result_set)} {}
41CursorResultSet<T>::~CursorResultSet() =
default;
44CursorResultSet<T>::CursorResultSet(CursorResultSet<T>&& other)
noexcept =
default;
47template <
typename RowCallback>
49 RowCallback&& row_callback,
53 using IntermediateStorage = std::vector<T>;
55 bool keep_going =
true;
56 auto extractor = impl::io::TypedExtractor<IntermediateStorage, T, RowTag>{};
60 keep_going = result_set_.FetchResult(extractor);
62 fetch
.Reset(impl::tracing::kForEachScope);
63 IntermediateStorage data{extractor.ExtractData()};
64 for (
auto&& row : data) {
65 row_callback(std::move(row));