| Home | Libraries | People | FAQ | More

###### connection::async_reset_connection (2 of 2 overloads)

Resets server-side session state, like variables and prepared statements.

###### Synopsis

    template<
        class CompletionToken>
    auto
    async_reset_connection(
        diagnostics& diag,
        CompletionToken&& token);

###### Description

Resets all server-side state for the current session:

- Rolls back any active transactions and resets autocommit mode.
- Releases all table locks.
- Drops all temporary tables.
- Resets all session system variables to their default values (including the ones set by `SET NAMES`) and clears all user-defined variables.
- Closes all prepared statements.

A full reference on the affected session state can be found here.

This function will not reset the current physical connection and won't cause re-authentication. It is faster than closing and re-opening a connection.

The connection must be connected and authenticated before calling this function. This function involves communication with the server, and thus may fail.

###### Warning on character sets

This function will restore the connection's character set and collation to the server's default, and not to the one specified during connection establishment. Some servers have `latin1` as their default character set, which is not usually what you want. Use a `SET NAMES` statement after using this function to be sure.

You can find the character set that your server will use after reset by running:

    "SELECT @@global.character_set_client, @@global.character_set_results;"

###### Handler signature

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

###### 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.