| Home | Libraries | People | FAQ | More

###### any_connection::async_set_character_set (1 of 2 overloads)

Sets the connection's character set, as per SET NAMES.

###### Synopsis

    template<
        class CompletionToken = with_diagnostics_t<asio::deferred_t>>
    auto
    async_set_character_set(
        const character_set& charset,
        CompletionToken&& token = {});

###### Description

Sets the connection's character set by running a `SET NAMES` SQL statement, using the passed `character_set::name` as the charset name to set.

This function will also update the value returned by `current_character_set`, so prefer using this function over raw SQL statements.

If the server was unable to set the character set to the requested value (e.g. because the server does not support the requested charset), this function will fail, as opposed to how `connect` behaves when an unsupported collation is passed. This is a limitation of MySQL servers.

You need to perform connection establishment for this function to succeed, since it involves communicating with the server.

###### Object lifetimes

`charset` will be copied as required, and does not need to be kept alive.

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