| Home | Libraries | People | FAQ | More

###### connection::async_read_some_rows (3 of 4 overloads)

Reads a batch of rows.

###### Synopsis

    template<
        class SpanElementType,
        class... StaticRow,
        class CompletionToken>
    auto
    async_read_some_rows(
        static_execution_state< StaticRow... >& st,
        span< SpanElementType > output,
        CompletionToken&& token);

###### Description

Reads a batch of rows of unspecified size into the storage given by `output`. At most `output.size()` rows will be read. If the operation represented by `st` has still rows to read, and `output.size() > 0`, at least one row will be read.

Returns the number of read rows.

If there are no more rows, or `st.should_read_rows() == false`, this function is a no-op and returns zero.

The number of rows that will be read depends on the connection's buffer size. The bigger the buffer, the greater the batch size (up to a maximum). You can set the initial buffer size in `connection`'s constructor, using `buffer_params::initial_read_size`. The buffer may be grown bigger by other read operations, if required.

Rows read by this function are owning objects, and don't hold any reference to the connection's internal buffers (contrary what happens with the dynamic interface's counterpart).

The type `SpanElementType` must be the underlying row type for one of the types in the `StaticRow` parameter pack (i.e., one of the types in `underlying_row_t<StaticRow>...`). The type must match the resultset that is currently being processed by `st`. For instance, given `static_execution_state<T1, T2>`, when reading rows for the second resultset, `SpanElementType` must exactly be `underlying_row_t<T2>`. If this is not the case, a runtime error will be issued.

This function can report schema mismatches.

###### Handler signature

The handler signature for this operation is `void(boost::mysql::error_code, std::size_t)`.

###### Executor

Intermediate completion handlers, as well as the final handler, are executed using `token`'s associated executor, or `this->get_executor()` if the token doesn't have an associated executor.

If the final handler has an associated immediate executor, and the operation completes immediately, the final handler is dispatched to it. Otherwise, the final handler is called as if it was submitted using `asio::post`, and is never be called inline from within this function.

###### Object lifetimes

The storage that `output` references must be kept alive until the operation completes.