From fa6f177e0fcae6b4d33407912fdf99aa9eef2fc1 Mon Sep 17 00:00:00 2001 From: Ruben Perez Date: Mon, 8 Mar 2021 18:56:25 +0100 Subject: [PATCH] Added support for the BIT type - Moved socket_connection to a separate include file. - Clarified Stream requirements. - Made make_error_code public. - Updated include styles to match Boost's. - Moved to to match conventions. - Added support for the BIT type. closes #13 closes #21 --- .appveyor.yml | 23 +- doc/qbk/helpers/SocketStream.qbk | 14 ++ doc/qbk/helpers/Stream.qbk | 15 ++ doc/qbk/helpers/quickref.xml | 2 + doc/qbk/main.qbk | 5 +- doc/qbk/types.qbk | 4 +- doc/xsl/emphasized-types.xsl | 1 + example/default_completion_tokens.cpp | 3 +- example/metadata.cpp | 2 +- example/prepared_statements.cpp | 2 +- example/query_async_callbacks.cpp | 2 +- example/query_async_coroutines.cpp | 3 +- example/query_async_coroutinescpp20.cpp | 3 +- example/query_async_futures.cpp | 3 +- example/query_sync.cpp | 2 +- example/ssl.cpp | 4 +- example/tutorial.cpp | 2 +- example/unix_socket.cpp | 2 +- example/value.cpp | 2 +- include/boost/{mysql => }/mysql.hpp | 7 +- include/boost/mysql/connection.hpp | 200 +---------------- include/boost/mysql/connection_params.hpp | 2 +- .../mysql/detail/auth/auth_calculator.hpp | 6 +- .../detail/auth/caching_sha2_password.hpp | 4 +- .../detail/auth/impl/auth_calculator.ipp | 6 +- .../auth/impl/caching_sha2_password.ipp | 2 +- .../detail/auth/mysql_native_password.hpp | 4 +- .../detail/auxiliar/value_type_traits.hpp | 2 +- .../network_algorithms/close_connection.hpp | 12 +- .../network_algorithms/close_statement.hpp | 4 +- .../detail/network_algorithms/common.hpp | 8 +- .../detail/network_algorithms/connect.hpp | 6 +- .../network_algorithms/execute_generic.hpp | 6 +- .../network_algorithms/execute_query.hpp | 6 +- .../network_algorithms/execute_statement.hpp | 8 +- .../detail/network_algorithms/handshake.hpp | 12 +- .../impl/close_connection.hpp | 18 +- .../impl/close_statement.hpp | 2 +- .../network_algorithms/impl/connect.hpp | 2 +- .../network_algorithms/impl/execute_query.hpp | 6 +- .../impl/execute_statement.hpp | 6 +- .../network_algorithms/impl/handshake.hpp | 8 +- .../network_algorithms/impl/read_row.hpp | 2 +- .../network_algorithms/prepare_statement.hpp | 6 +- .../network_algorithms/quit_connection.hpp | 4 +- .../detail/network_algorithms/read_row.hpp | 8 +- .../protocol/binary_deserialization.hpp | 10 +- .../detail/protocol/binary_serialization.hpp | 6 +- .../detail/protocol/bit_deserialization.hpp | 46 ++++ .../boost/mysql/detail/protocol/channel.hpp | 8 +- .../mysql/detail/protocol/common_messages.hpp | 8 +- .../boost/mysql/detail/protocol/constants.hpp | 4 +- include/boost/mysql/detail/protocol/date.hpp | 2 +- .../protocol/deserialization_context.hpp | 4 +- .../detail/protocol/handshake_messages.hpp | 6 +- .../protocol/impl/binary_deserialization.ipp | 25 ++- .../protocol/impl/binary_serialization.ipp | 4 +- .../mysql/detail/protocol/impl/channel.hpp | 6 +- .../boost/mysql/detail/protocol/impl/date.hpp | 2 +- .../impl/prepared_statement_messages.hpp | 4 +- .../protocol/impl/text_deserialization.ipp | 8 +- .../protocol/prepared_statement_messages.hpp | 8 +- .../mysql/detail/protocol/query_messages.hpp | 2 +- .../mysql/detail/protocol/serialization.hpp | 16 +- .../detail/protocol/serialization_context.hpp | 2 +- .../detail/protocol/text_deserialization.hpp | 10 +- include/boost/mysql/error.hpp | 7 +- include/boost/mysql/execute_params.hpp | 4 +- include/boost/mysql/impl/connection.hpp | 94 +------- include/boost/mysql/impl/error.hpp | 14 +- .../boost/mysql/impl/error_descriptions.hpp | 2 +- .../boost/mysql/impl/prepared_statement.hpp | 8 +- include/boost/mysql/impl/resultset.hpp | 2 +- .../boost/mysql/impl/socket_connection.hpp | 97 ++++++++ include/boost/mysql/impl/value.hpp | 4 +- include/boost/mysql/metadata.hpp | 8 +- include/boost/mysql/prepared_statement.hpp | 12 +- include/boost/mysql/resultset.hpp | 14 +- include/boost/mysql/row.hpp | 8 +- include/boost/mysql/socket_connection.hpp | 207 ++++++++++++++++++ include/boost/mysql/value.hpp | 6 +- test/CMakeLists.txt | 1 + test/common/test_common.hpp | 8 +- test/integration/connection.cpp | 2 +- test/integration/database_types.cpp | 42 +++- test/integration/db_setup.sql | 23 +- test/integration/execute_statement.cpp | 2 +- test/integration/handshake.cpp | 6 +- test/integration/integration_test_common.hpp | 2 +- test/integration/metadata_validator.hpp | 2 +- test/integration/network_functions.hpp | 4 +- .../network_functions/async_callback.cpp | 2 +- .../network_functions/async_coroutine.cpp | 4 +- test/integration/network_functions/sync.cpp | 2 +- test/integration/prepare_statement.cpp | 2 +- test/integration/query.cpp | 7 +- test/integration/resultset.cpp | 4 +- test/unit/connection.cpp | 14 +- test/unit/detail/auth/auth_calculator.cpp | 2 +- test/unit/detail/auxiliar/static_string.cpp | 2 +- .../detail/auxiliar/value_type_traits.cpp | 2 +- .../protocol/binary_deserialization_error.cpp | 17 +- .../protocol/binary_deserialization_value.cpp | 34 ++- test/unit/detail/protocol/capabilities.cpp | 2 +- test/unit/detail/protocol/date.cpp | 2 +- .../detail/protocol/null_bitmap_traits.cpp | 2 +- .../detail/protocol/row_deserialization.cpp | 6 +- .../detail/protocol/serialization_test.hpp | 4 +- .../basic_types.hpp | 2 +- .../binary_serialization.hpp | 2 +- .../common_messages.hpp | 2 +- .../handshake_messages.hpp | 2 +- .../prepared_statement_messages.hpp | 2 +- .../query_messages.hpp | 2 +- .../protocol/text_deserialization_error.cpp | 11 +- .../protocol/text_deserialization_value.cpp | 25 ++- test/unit/error.cpp | 9 +- test/unit/execute_params.cpp | 4 +- test/unit/metadata.cpp | 2 +- test/unit/prepared_statement.cpp | 4 +- test/unit/resultset.cpp | 4 +- test/unit/row.cpp | 8 +- test/unit/socket_connection.cpp | 28 +++ test/unit/value.cpp | 2 +- test/unit/value_constexpr.cpp | 2 +- tools/build_windows_b2.bat | 4 +- tools/file_headers.py | 2 +- 127 files changed, 853 insertions(+), 583 deletions(-) create mode 100644 doc/qbk/helpers/SocketStream.qbk create mode 100644 doc/qbk/helpers/Stream.qbk rename include/boost/{mysql => }/mysql.hpp (65%) create mode 100644 include/boost/mysql/detail/protocol/bit_deserialization.hpp create mode 100644 include/boost/mysql/impl/socket_connection.hpp create mode 100644 include/boost/mysql/socket_connection.hpp create mode 100644 test/unit/socket_connection.cpp diff --git a/.appveyor.yml b/.appveyor.yml index 64cbacc5..b4072602 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -23,6 +23,17 @@ environment: B2_VARIANT: release,debug B2_CXXSTD: 11,14,17 matrix: + # Boost.Build + - FLAVOR: Visual Studio 2019 + APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 + PLATFORM: x64 + B2_TOOLSET: msvc-14.2 + B2_CXXSTD: 11,14,17 + - FLAVOR: Visual Studio 2019 + APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 + PLATFORM: x86 + B2_TOOLSET: msvc-14.2 + B2_CXXSTD: 11,14,17 # CMake - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 CMAKE_BUILD_TYPE: Debug @@ -36,14 +47,4 @@ environment: - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 CMAKE_BUILD_TYPE: Release PLATFORM: x86 - # Boost.Build - - FLAVOR: Visual Studio 2019 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 - PLATFORM: x86 - B2_TOOLSET: msvc-14.2 - B2_CXXSTD: 11,14 # Hitting an internal compiler error under C++17, can't reproduce locally - - FLAVOR: Visual Studio 2019 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 - PLATFORM: x64 - B2_TOOLSET: msvc-14.2 - B2_CXXSTD: 14,17 # Hitting an internal compiler error under C++11, can't reproduce locally + \ No newline at end of file diff --git a/doc/qbk/helpers/SocketStream.qbk b/doc/qbk/helpers/SocketStream.qbk new file mode 100644 index 00000000..a2a13881 --- /dev/null +++ b/doc/qbk/helpers/SocketStream.qbk @@ -0,0 +1,14 @@ +[/ + Copyright (c) 2019-2021 Ruben Perez Hidalgo (rubenperez038 at gmail dot com) + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +] + +[section:boost__mysql__SocketStream SocketStream concept] + +`SocketStream` should meet the [reflink Stream] requirements. +Additionally, it should inherit from an instantiation of +[asioreflink basic_socket basic_socket]. + +[endsect] \ No newline at end of file diff --git a/doc/qbk/helpers/Stream.qbk b/doc/qbk/helpers/Stream.qbk new file mode 100644 index 00000000..a014bf03 --- /dev/null +++ b/doc/qbk/helpers/Stream.qbk @@ -0,0 +1,15 @@ +[/ + Copyright (c) 2019-2021 Ruben Perez Hidalgo (rubenperez038 at gmail dot com) + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +] + +[section:boost__mysql__Stream Stream concept] + +`Stream` should meet both the `AsyncStream` and `SyncStream` requirements, +[@boost:/libs/beast/doc/html/beast/concepts/streams.html as defined by Boost.Beast here]. +Additionally, the type `boost::asio::ssl::stream` should be valid and usable +to both read and write data over SSL. + +[endsect] \ No newline at end of file diff --git a/doc/qbk/helpers/quickref.xml b/doc/qbk/helpers/quickref.xml index 5e13c5b7..4a9f734d 100644 --- a/doc/qbk/helpers/quickref.xml +++ b/doc/qbk/helpers/quickref.xml @@ -68,6 +68,8 @@ Concepts + Stream + SocketStream ValueCollection ValueForwardIterator diff --git a/doc/qbk/main.qbk b/doc/qbk/main.qbk index dc8111a3..5f783d09 100644 --- a/doc/qbk/main.qbk +++ b/doc/qbk/main.qbk @@ -32,7 +32,8 @@ [template asioreflink[id term][@boost:/doc/html/boost_asio/reference/[id].html [^boost::asio::[term]]]] [template mysqllink[id text][@https://dev.mysql.com/doc/refman/8.0/en/[id] [text]]] -[def __Stream__ [@boost:/libs/beast/doc/html/beast/concepts/streams.html ['Stream]]] +[def __Stream__ [reflink2 Stream ['Stream]]] +[def __SocketStream__ [reflink2 SocketStream ['SocketStream]]] [def __Executor__ [@boost:/doc/html/boost_asio/reference/Executor1.html ['Executor]]] [def __CompletionToken__ [@boost:/doc/html/boost_asio/reference/asynchronous_operations.html#boost_asio.reference.asynchronous_operations.completion_tokens_and_handlers ['CompletionToken]]] [def __ValueCollection__ [reflink2 ValueCollection ['ValueCollection]]] @@ -101,6 +102,8 @@ [block'''This Page Intentionally Left Blank 1/2'''] [section:ref This Page Intentionally Left Blank 2/2] [include reference.qbk] +[include helpers/Stream.qbk] +[include helpers/SocketStream.qbk] [include helpers/ValueCollection.qbk] [include helpers/ValueForwardIterator.qbk] [endsect] diff --git a/doc/qbk/types.qbk b/doc/qbk/types.qbk index 390b812d..c1d0099a 100644 --- a/doc/qbk/types.qbk +++ b/doc/qbk/types.qbk @@ -37,6 +37,8 @@ for each one. \[`1901`, `2155`\], plus zero. Zero is often employed to represent invalid year values. We represent zero year here as a numeric 0. YEAR is represented as a `std::uint64_t`. + * __BIT__. A bitset between 1 and 64 bits wide. Represented here as + a `std::uint64_t` ranging between `0` and `0xffffffffffffffff`. * Floating point types: * __FLOAT__. 4 byte floating point type. Represented as `float`. * __DOUBLE__. 8 byte floating point type. Represented as `double`. @@ -113,8 +115,6 @@ for each one. * __DECIMAL__ and __NUMERIC__ (equivalent). A fixed precision numeric value. In this case, the string will contain the textual representation of the number (e.g. the string `"20.52"` for `20.52`). - * __BIT__. A bitset between 1 and 64 bits wide. In this case, the string will contain - the binary representation of the bitset. * __GEOMETRY__. In this case, the string will contain the binary representation of the geometry type. diff --git a/doc/xsl/emphasized-types.xsl b/doc/xsl/emphasized-types.xsl index 57292b7e..fb720fb8 100644 --- a/doc/xsl/emphasized-types.xsl +++ b/doc/xsl/emphasized-types.xsl @@ -13,6 +13,7 @@ #include #include #include diff --git a/example/metadata.cpp b/example/metadata.cpp index ebf3529a..181bd2f8 100644 --- a/example/metadata.cpp +++ b/example/metadata.cpp @@ -7,7 +7,7 @@ //[example_metadata -#include "boost/mysql/mysql.hpp" +#include #include #include #include diff --git a/example/prepared_statements.cpp b/example/prepared_statements.cpp index 384e1262..ea178e3a 100644 --- a/example/prepared_statements.cpp +++ b/example/prepared_statements.cpp @@ -7,7 +7,7 @@ //[example_prepared_statements -#include "boost/mysql/mysql.hpp" +#include #include #include #include diff --git a/example/query_async_callbacks.cpp b/example/query_async_callbacks.cpp index 7108cf09..f6e93522 100644 --- a/example/query_async_callbacks.cpp +++ b/example/query_async_callbacks.cpp @@ -7,7 +7,7 @@ //[example_query_async_callbacks -#include "boost/mysql/mysql.hpp" +#include #include #include #include diff --git a/example/query_async_coroutines.cpp b/example/query_async_coroutines.cpp index 47ec1814..5c825c67 100644 --- a/example/query_async_coroutines.cpp +++ b/example/query_async_coroutines.cpp @@ -7,8 +7,7 @@ //[example_query_async_coroutines -#include "boost/mysql/mysql.hpp" -#include "boost/mysql/row.hpp" +#include #include #include #include diff --git a/example/query_async_coroutinescpp20.cpp b/example/query_async_coroutinescpp20.cpp index 1c8b684e..50808fc0 100644 --- a/example/query_async_coroutinescpp20.cpp +++ b/example/query_async_coroutinescpp20.cpp @@ -7,8 +7,7 @@ //[example_query_async_coroutinescpp20 -#include "boost/mysql/mysql.hpp" -#include "boost/mysql/row.hpp" +#include #include #include #include diff --git a/example/query_async_futures.cpp b/example/query_async_futures.cpp index b9fa3514..5d8ca5e4 100644 --- a/example/query_async_futures.cpp +++ b/example/query_async_futures.cpp @@ -7,8 +7,7 @@ //[example_query_async_futures -#include "boost/mysql/mysql.hpp" -#include "boost/mysql/row.hpp" +#include #include #include #include diff --git a/example/query_sync.cpp b/example/query_sync.cpp index 5cb371de..30b63f7b 100644 --- a/example/query_sync.cpp +++ b/example/query_sync.cpp @@ -6,7 +6,7 @@ // //[example_query_sync -#include "boost/mysql/mysql.hpp" +#include #include #include #include diff --git a/example/ssl.cpp b/example/ssl.cpp index 646da72b..9cc8804f 100644 --- a/example/ssl.cpp +++ b/example/ssl.cpp @@ -6,9 +6,7 @@ // //[example_ssl -#include "boost/mysql/collation.hpp" -#include "boost/mysql/connection_params.hpp" -#include "boost/mysql/mysql.hpp" +#include #include #include #include diff --git a/example/tutorial.cpp b/example/tutorial.cpp index ec366901..7e939ba7 100644 --- a/example/tutorial.cpp +++ b/example/tutorial.cpp @@ -5,7 +5,7 @@ // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // -#include "boost/mysql/mysql.hpp" +#include #include #include #include diff --git a/example/unix_socket.cpp b/example/unix_socket.cpp index cd188e83..bdfb7040 100644 --- a/example/unix_socket.cpp +++ b/example/unix_socket.cpp @@ -7,7 +7,7 @@ //[example_unix_socket -#include "boost/mysql/mysql.hpp" +#include #include #include #include diff --git a/example/value.cpp b/example/value.cpp index f58d1868..40021e99 100644 --- a/example/value.cpp +++ b/example/value.cpp @@ -5,7 +5,7 @@ // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // -#include "boost/mysql/value.hpp" +#include #include #define ASSERT(expr) \ diff --git a/include/boost/mysql/mysql.hpp b/include/boost/mysql.hpp similarity index 65% rename from include/boost/mysql/mysql.hpp rename to include/boost/mysql.hpp index 00cd639b..a6a10bbc 100644 --- a/include/boost/mysql/mysql.hpp +++ b/include/boost/mysql.hpp @@ -5,9 +5,10 @@ // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // -#ifndef BOOST_MYSQL_MYSQL_HPP -#define BOOST_MYSQL_MYSQL_HPP +#ifndef BOOST_MYSQL_HPP +#define BOOST_MYSQL_HPP -#include "boost/mysql/connection.hpp" +#include +#include #endif diff --git a/include/boost/mysql/connection.hpp b/include/boost/mysql/connection.hpp index 0af7779c..f0534323 100644 --- a/include/boost/mysql/connection.hpp +++ b/include/boost/mysql/connection.hpp @@ -11,15 +11,13 @@ #include #include #ifndef BOOST_MYSQL_DOXYGEN // For some arcane reason, Doxygen fails to expand Asio macros without this -#include "boost/mysql/detail/protocol/channel.hpp" -#include "boost/mysql/detail/protocol/protocol_types.hpp" -#include "boost/mysql/detail/network_algorithms/handshake.hpp" -#include "boost/mysql/error.hpp" -#include "boost/mysql/resultset.hpp" -#include "boost/mysql/prepared_statement.hpp" -#include "boost/mysql/connection_params.hpp" -#include -#include +#include +#include +#include +#include +#include +#include +#include #endif /// The Boost libraries namespace. @@ -453,194 +451,12 @@ public: }; }; -/** - * \brief A connection to a MySQL server over a socket. - * \details Extends [reflink connection] with additional - * functions that require Stream to be a socket. Stream should - * inherit from an instantiation of [asioreflink basic_socket basic_socket]. - * - * In general, prefer this class over [reflink connection]. - * See also [reflink tcp_connection] and [reflink unix_connection] for - * the most common instantiations of this template class. - * See [link mysql.other_streams this section] for more info. - * - * The same considerations for copy and move operations as for - * [reflink connection] apply. - */ -template< -class Stream -> -class socket_connection : public connection -{ -public: - using connection::connection; - - /// The executor type associated to this object. - using executor_type = typename Stream::executor_type; - - /// The endpoint type associated to this connection. - using endpoint_type = typename Stream::endpoint_type; - - /** - * \brief Performs a connection to the MySQL server (sync with error code version). - * \details Connects the underlying socket and then performs the handshake - * with the server. The underlying socket is closed in case of error. Prefer - * this function to [refmem connection handshake]. - * - * If SSL certificate validation was configured (by providing a custom SSL context - * to this class' constructor) and fails, this function will fail. - */ - void connect(const endpoint_type& endpoint, const connection_params& params, - error_code& ec, error_info& info); - - /** - * \brief Performs a connection to the MySQL server (sync with exceptions version). - * \details Connects the underlying socket and then performs the handshake - * with the server. The underlying socket is closed in case of error. Prefer - * this function to [refmem connection handshake]. - * - * If SSL certificate validation was configured (by providing a custom SSL context - * to this class' constructor) and fails, this function will fail. - */ - void connect(const endpoint_type& endpoint, const connection_params& params); - - /** - * \brief Performs a connection to the MySQL server - * (async without [reflink error_info] version). - * \details - * Connects the underlying socket and then performs the handshake - * with the server. The underlying socket is closed in case of error. Prefer - * this function to [refmem connection async_handshake]. - * - * The strings pointed to by params should be kept alive by the caller - * until the operation completes, as no copy is made by the library. - * - * If SSL certificate validation was configured (by providing a custom SSL context - * to this class' constructor) and fails, this function will fail. - * - * The handler signature for this operation is `void(boost::mysql::error_code)`. - */ - template < - BOOST_ASIO_COMPLETION_TOKEN_FOR(void(error_code)) - CompletionToken - BOOST_ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(executor_type) - > - BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(CompletionToken, void(error_code)) - async_connect( - const endpoint_type& endpoint, - const connection_params& params, - CompletionToken&& token BOOST_ASIO_DEFAULT_COMPLETION_TOKEN(executor_type) - ) - { - return async_connect(endpoint, params, this->shared_info(), std::forward(token)); - } - - /** - * \brief Performs a connection to the MySQL server - * (async with [reflink error_info] version). - * \details - * Connects the underlying socket and then performs the handshake - * with the server. The underlying socket is closed in case of error. Prefer - * this function to [refmem connection async_handshake]. - * - * The strings pointed to by params should be kept alive by the caller - * until the operation completes, as no copy is made by the library. - * - * If SSL certificate validation was configured (by providing a custom SSL context - * to this class' constructor) and fails, this function will fail. - * - * The handler signature for this operation is `void(boost::mysql::error_code)`. - */ - template < - BOOST_ASIO_COMPLETION_TOKEN_FOR(void(error_code)) - CompletionToken - BOOST_ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(executor_type) - > - BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(CompletionToken, void(error_code)) - async_connect( - const endpoint_type& endpoint, - const connection_params& params, - error_info& output_info, - CompletionToken&& token BOOST_ASIO_DEFAULT_COMPLETION_TOKEN(executor_type) - ); - - /** - * \brief Closes the connection (sync with error code version). - * \details Sends a quit request and closes the underlying socket. - * Prefer this function to [refmem connection quit]. - */ - void close(error_code&, error_info&); - - /** - * \brief Closes the connection (sync with exceptions version). - * \details Sends a quit request and closes the underlying socket. - * Prefer this function to [refmem connection quit]. - */ - void close(); - - /** - * \brief Closes the connection (async without [reflink error_info] version). - * \details Sends a quit request and closes the underlying socket. - * Prefer this function to [refmem connection async_quit]. - * - * The handler signature for this operation is `void(boost::mysql::error_code)`. - */ - template < - BOOST_ASIO_COMPLETION_TOKEN_FOR(void(error_code)) - CompletionToken - BOOST_ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(executor_type) - > - BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(CompletionToken, void(error_code)) - async_close(CompletionToken&& token BOOST_ASIO_DEFAULT_COMPLETION_TOKEN(executor_type)) - { - return async_close(this->shared_info(), std::forward(token)); - } - - /** - * \brief Closes the connection (async with [reflink error_info] version). - * \details Sends a quit request and closes the underlying socket. - * Prefer this function to [refmem connection async_quit]. - * - * The handler signature for this operation is `void(boost::mysql::error_code)`. - */ - template < - BOOST_ASIO_COMPLETION_TOKEN_FOR(void(error_code)) - CompletionToken - BOOST_ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(executor_type) - > - BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(CompletionToken, void(error_code)) - async_close( - error_info& output_info, - CompletionToken&& token BOOST_ASIO_DEFAULT_COMPLETION_TOKEN(executor_type) - ); - - /// Rebinds the connection type to another executor. - template - struct rebind_executor - { - /// The connection type when rebound to the specified executor. - using other = socket_connection< - typename Stream:: template rebind_executor::other - >; - }; -}; - -/// A connection to MySQL over a TCP socket. -using tcp_connection = socket_connection; - -#if defined(BOOST_ASIO_HAS_LOCAL_SOCKETS) || defined(BOOST_MYSQL_DOXYGEN) - -/// A connection to MySQL over a UNIX domain socket. -using unix_connection = socket_connection; - -#endif - /// The default TCP port for the MySQL protocol. constexpr unsigned short default_port = 3306; } // mysql } // boost -#include "boost/mysql/impl/connection.hpp" +#include #endif diff --git a/include/boost/mysql/connection_params.hpp b/include/boost/mysql/connection_params.hpp index 5afe81ee..376a335e 100644 --- a/include/boost/mysql/connection_params.hpp +++ b/include/boost/mysql/connection_params.hpp @@ -9,7 +9,7 @@ #define BOOST_MYSQL_CONNECTION_PARAMS_HPP #include -#include "boost/mysql/collation.hpp" +#include namespace boost { namespace mysql { diff --git a/include/boost/mysql/detail/auth/auth_calculator.hpp b/include/boost/mysql/detail/auth/auth_calculator.hpp index e2923d47..08805d5c 100644 --- a/include/boost/mysql/detail/auth/auth_calculator.hpp +++ b/include/boost/mysql/detail/auth/auth_calculator.hpp @@ -8,8 +8,8 @@ #ifndef BOOST_MYSQL_DETAIL_AUTH_AUTH_CALCULATOR_HPP #define BOOST_MYSQL_DETAIL_AUTH_AUTH_CALCULATOR_HPP -#include "boost/mysql/error.hpp" -#include "boost/mysql/detail/auxiliar/bytestring.hpp" +#include +#include #include #include #include @@ -59,6 +59,6 @@ public: } // mysql } // boost -#include "boost/mysql/detail/auth/impl/auth_calculator.ipp" +#include #endif /* INCLUDE_BOOST_MYSQL_DETAIL_AUTH_AUTH_CALCULATOR_HPP_ */ diff --git a/include/boost/mysql/detail/auth/caching_sha2_password.hpp b/include/boost/mysql/detail/auth/caching_sha2_password.hpp index 5357ef5e..e49c3821 100644 --- a/include/boost/mysql/detail/auth/caching_sha2_password.hpp +++ b/include/boost/mysql/detail/auth/caching_sha2_password.hpp @@ -10,7 +10,7 @@ #include #include -#include "boost/mysql/error.hpp" +#include namespace boost { namespace mysql { @@ -38,6 +38,6 @@ inline error_code compute_response( } // mysql } // boost -#include "boost/mysql/detail/auth/impl/caching_sha2_password.ipp" +#include #endif /* INCLUDE_BOOST_MYSQL_DETAIL_AUTH_CACHING_SHA2_PASSWORD_HPP_ */ diff --git a/include/boost/mysql/detail/auth/impl/auth_calculator.ipp b/include/boost/mysql/detail/auth/impl/auth_calculator.ipp index 4e3351ca..22da872b 100644 --- a/include/boost/mysql/detail/auth/impl/auth_calculator.ipp +++ b/include/boost/mysql/detail/auth/impl/auth_calculator.ipp @@ -8,9 +8,9 @@ #ifndef BOOST_MYSQL_DETAIL_AUTH_IMPL_AUTH_CALCULATOR_IPP #define BOOST_MYSQL_DETAIL_AUTH_IMPL_AUTH_CALCULATOR_IPP -#include "boost/mysql/detail/auth/mysql_native_password.hpp" -#include "boost/mysql/detail/auth/caching_sha2_password.hpp" -#include "boost/mysql/detail/auxiliar/make_string_view.hpp" +#include +#include +#include namespace boost { namespace mysql { diff --git a/include/boost/mysql/detail/auth/impl/caching_sha2_password.ipp b/include/boost/mysql/detail/auth/impl/caching_sha2_password.ipp index 41816e82..8fe34578 100644 --- a/include/boost/mysql/detail/auth/impl/caching_sha2_password.ipp +++ b/include/boost/mysql/detail/auth/impl/caching_sha2_password.ipp @@ -10,7 +10,7 @@ #include #include -#include "boost/mysql/detail/auxiliar/make_string_view.hpp" +#include namespace boost { namespace mysql { diff --git a/include/boost/mysql/detail/auth/mysql_native_password.hpp b/include/boost/mysql/detail/auth/mysql_native_password.hpp index ad074ee8..5748a368 100644 --- a/include/boost/mysql/detail/auth/mysql_native_password.hpp +++ b/include/boost/mysql/detail/auth/mysql_native_password.hpp @@ -10,7 +10,7 @@ #include #include -#include "boost/mysql/error.hpp" +#include namespace boost { namespace mysql { @@ -32,6 +32,6 @@ inline error_code compute_response( } // mysql } // boost -#include "boost/mysql/detail/auth/impl/mysql_native_password.ipp" +#include #endif diff --git a/include/boost/mysql/detail/auxiliar/value_type_traits.hpp b/include/boost/mysql/detail/auxiliar/value_type_traits.hpp index 924ee015..9dc4857f 100644 --- a/include/boost/mysql/detail/auxiliar/value_type_traits.hpp +++ b/include/boost/mysql/detail/auxiliar/value_type_traits.hpp @@ -8,7 +8,7 @@ #ifndef BOOST_MYSQL_DETAIL_AUXILIAR_VALUE_TYPE_TRAITS_HPP #define BOOST_MYSQL_DETAIL_AUXILIAR_VALUE_TYPE_TRAITS_HPP -#include "boost/mysql/value.hpp" +#include #include #include #include diff --git a/include/boost/mysql/detail/network_algorithms/close_connection.hpp b/include/boost/mysql/detail/network_algorithms/close_connection.hpp index 3b42b00e..c8c37647 100644 --- a/include/boost/mysql/detail/network_algorithms/close_connection.hpp +++ b/include/boost/mysql/detail/network_algorithms/close_connection.hpp @@ -8,23 +8,23 @@ #ifndef BOOST_MYSQL_DETAIL_NETWORK_ALGORITHMS_CLOSE_CONNECTION_HPP #define BOOST_MYSQL_DETAIL_NETWORK_ALGORITHMS_CLOSE_CONNECTION_HPP -#include "boost/mysql/detail/network_algorithms/common.hpp" +#include namespace boost { namespace mysql { namespace detail { -template +template void close_connection( - channel& chan, + channel& chan, error_code& code, error_info& info ); -template +template BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(CompletionToken, void(error_code)) async_close_connection( - channel& chan, + channel& chan, CompletionToken&& token, error_info& info ); @@ -33,7 +33,7 @@ async_close_connection( } // mysql } // boost -#include "boost/mysql/detail/network_algorithms/impl/close_connection.hpp" +#include #endif /* INCLUDE_BOOST_MYSQL_DETAIL_NETWORK_ALGORITHMS_CLOSE_CONNECTION_HPP_ */ diff --git a/include/boost/mysql/detail/network_algorithms/close_statement.hpp b/include/boost/mysql/detail/network_algorithms/close_statement.hpp index 996e5396..6b17946c 100644 --- a/include/boost/mysql/detail/network_algorithms/close_statement.hpp +++ b/include/boost/mysql/detail/network_algorithms/close_statement.hpp @@ -8,7 +8,7 @@ #ifndef BOOST_MYSQL_DETAIL_NETWORK_ALGORITHMS_CLOSE_STATEMENT_HPP #define BOOST_MYSQL_DETAIL_NETWORK_ALGORITHMS_CLOSE_STATEMENT_HPP -#include "boost/mysql/detail/network_algorithms/common.hpp" +#include namespace boost { namespace mysql { @@ -35,6 +35,6 @@ async_close_statement( } // mysql } // boost -#include "boost/mysql/detail/network_algorithms/impl/close_statement.hpp" +#include #endif /* INCLUDE_BOOST_MYSQL_DETAIL_NETWORK_ALGORITHMS_CLOSE_STATEMENT_HPP_ */ diff --git a/include/boost/mysql/detail/network_algorithms/common.hpp b/include/boost/mysql/detail/network_algorithms/common.hpp index eee24f1d..9446acfb 100644 --- a/include/boost/mysql/detail/network_algorithms/common.hpp +++ b/include/boost/mysql/detail/network_algorithms/common.hpp @@ -8,10 +8,10 @@ #ifndef BOOST_MYSQL_DETAIL_NETWORK_ALGORITHMS_COMMON_HPP #define BOOST_MYSQL_DETAIL_NETWORK_ALGORITHMS_COMMON_HPP -#include "boost/mysql/error.hpp" -#include "boost/mysql/metadata.hpp" -#include "boost/mysql/detail/protocol/channel.hpp" -#include "boost/mysql/detail/protocol/common_messages.hpp" +#include +#include +#include +#include namespace boost { namespace mysql { diff --git a/include/boost/mysql/detail/network_algorithms/connect.hpp b/include/boost/mysql/detail/network_algorithms/connect.hpp index d3bd7237..d5a1b836 100644 --- a/include/boost/mysql/detail/network_algorithms/connect.hpp +++ b/include/boost/mysql/detail/network_algorithms/connect.hpp @@ -8,8 +8,8 @@ #ifndef BOOST_MYSQL_DETAIL_NETWORK_ALGORITHMS_CONNECT_HPP #define BOOST_MYSQL_DETAIL_NETWORK_ALGORITHMS_CONNECT_HPP -#include "boost/mysql/detail/network_algorithms/common.hpp" -#include "boost/mysql/connection_params.hpp" +#include +#include namespace boost { namespace mysql { @@ -38,6 +38,6 @@ async_connect( } // mysql } // boost -#include "boost/mysql/detail/network_algorithms/impl/connect.hpp" +#include #endif /* INCLUDE_BOOST_MYSQL_DETAIL_NETWORK_ALGORITHMS_CONNECT_HPP_ */ diff --git a/include/boost/mysql/detail/network_algorithms/execute_generic.hpp b/include/boost/mysql/detail/network_algorithms/execute_generic.hpp index 3b9ff98d..54ab2e00 100644 --- a/include/boost/mysql/detail/network_algorithms/execute_generic.hpp +++ b/include/boost/mysql/detail/network_algorithms/execute_generic.hpp @@ -8,8 +8,8 @@ #ifndef BOOST_MYSQL_DETAIL_NETWORK_ALGORITHMS_EXECUTE_GENERIC_HPP #define BOOST_MYSQL_DETAIL_NETWORK_ALGORITHMS_EXECUTE_GENERIC_HPP -#include "boost/mysql/detail/network_algorithms/common.hpp" -#include "boost/mysql/resultset.hpp" +#include +#include #include namespace boost { @@ -40,6 +40,6 @@ async_execute_generic( } // mysql } // boost -#include "boost/mysql/detail/network_algorithms/impl/execute_generic.hpp" +#include #endif /* INCLUDE_MYSQL_IMPL_NETWORK_ALGORITHMS_READ_RESULTSET_HEAD_HPP_ */ diff --git a/include/boost/mysql/detail/network_algorithms/execute_query.hpp b/include/boost/mysql/detail/network_algorithms/execute_query.hpp index 63c0afa5..cd4186a0 100644 --- a/include/boost/mysql/detail/network_algorithms/execute_query.hpp +++ b/include/boost/mysql/detail/network_algorithms/execute_query.hpp @@ -8,8 +8,8 @@ #ifndef BOOST_MYSQL_DETAIL_NETWORK_ALGORITHMS_EXECUTE_QUERY_HPP #define BOOST_MYSQL_DETAIL_NETWORK_ALGORITHMS_EXECUTE_QUERY_HPP -#include "boost/mysql/detail/network_algorithms/common.hpp" -#include "boost/mysql/resultset.hpp" +#include +#include #include namespace boost { @@ -38,6 +38,6 @@ async_execute_query( } } -#include "boost/mysql/detail/network_algorithms/impl/execute_query.hpp" +#include #endif /* INCLUDE_BOOST_MYSQL_DETAIL_NETWORK_ALGORITHMS_EXECUTE_QUERY_HPP_ */ diff --git a/include/boost/mysql/detail/network_algorithms/execute_statement.hpp b/include/boost/mysql/detail/network_algorithms/execute_statement.hpp index 06b0372f..37f1c124 100644 --- a/include/boost/mysql/detail/network_algorithms/execute_statement.hpp +++ b/include/boost/mysql/detail/network_algorithms/execute_statement.hpp @@ -8,9 +8,9 @@ #ifndef BOOST_MYSQL_DETAIL_NETWORK_ALGORITHMS_EXECUTE_STATEMENT_HPP #define BOOST_MYSQL_DETAIL_NETWORK_ALGORITHMS_EXECUTE_STATEMENT_HPP -#include "boost/mysql/detail/network_algorithms/common.hpp" -#include "boost/mysql/resultset.hpp" -#include "boost/mysql/value.hpp" +#include +#include +#include namespace boost { namespace mysql { @@ -42,6 +42,6 @@ async_execute_statement( } // mysql } // boost -#include "boost/mysql/detail/network_algorithms/impl/execute_statement.hpp" +#include #endif /* INCLUDE_BOOST_MYSQL_DETAIL_NETWORK_ALGORITHMS_EXECUTE_STATEMENT_HPP_ */ diff --git a/include/boost/mysql/detail/network_algorithms/handshake.hpp b/include/boost/mysql/detail/network_algorithms/handshake.hpp index 1d005d62..c68b55b6 100644 --- a/include/boost/mysql/detail/network_algorithms/handshake.hpp +++ b/include/boost/mysql/detail/network_algorithms/handshake.hpp @@ -9,11 +9,11 @@ #define BOOST_MYSQL_DETAIL_NETWORK_ALGORITHMS_HANDSHAKE_HPP #include -#include "boost/mysql/detail/network_algorithms/common.hpp" -#include "boost/mysql/detail/protocol/channel.hpp" -#include "boost/mysql/detail/protocol/protocol_types.hpp" -#include "boost/mysql/connection_params.hpp" -#include "boost/mysql/collation.hpp" +#include +#include +#include +#include +#include namespace boost { namespace mysql { @@ -40,7 +40,7 @@ async_handshake( } // mysql } // boost -#include "boost/mysql/detail/network_algorithms/impl/handshake.hpp" +#include #endif diff --git a/include/boost/mysql/detail/network_algorithms/impl/close_connection.hpp b/include/boost/mysql/detail/network_algorithms/impl/close_connection.hpp index 587d6cab..e2727996 100644 --- a/include/boost/mysql/detail/network_algorithms/impl/close_connection.hpp +++ b/include/boost/mysql/detail/network_algorithms/impl/close_connection.hpp @@ -8,11 +8,11 @@ #ifndef BOOST_MYSQL_DETAIL_NETWORK_ALGORITHMS_IMPL_CLOSE_CONNECTION_HPP #define BOOST_MYSQL_DETAIL_NETWORK_ALGORITHMS_IMPL_CLOSE_CONNECTION_HPP -#include "boost/mysql/detail/network_algorithms/quit_connection.hpp" +#include -template +template void boost::mysql::detail::close_connection( - channel& chan, + channel& chan, error_code& code, error_info& info ) @@ -33,13 +33,13 @@ namespace boost { namespace mysql { namespace detail { -template +template struct close_connection_op : boost::asio::coroutine { - channel& chan_; + channel& chan_; error_info& output_info_; - close_connection_op(channel& chan, error_info& output_info) : + close_connection_op(channel& chan, error_info& output_info) : chan_(chan), output_info_(output_info) { @@ -78,13 +78,13 @@ struct close_connection_op : boost::asio::coroutine } } -template +template BOOST_ASIO_INITFN_AUTO_RESULT_TYPE( CompletionToken, void(boost::mysql::error_code) ) boost::mysql::detail::async_close_connection( - channel& chan, + channel& chan, CompletionToken&& token, error_info& info ) @@ -92,7 +92,7 @@ boost::mysql::detail::async_close_connection( return boost::asio::async_compose< CompletionToken, void(boost::mysql::error_code) - >(close_connection_op{chan, info}, token, chan); + >(close_connection_op{chan, info}, token, chan); } diff --git a/include/boost/mysql/detail/network_algorithms/impl/close_statement.hpp b/include/boost/mysql/detail/network_algorithms/impl/close_statement.hpp index 7aca0cac..587f857b 100644 --- a/include/boost/mysql/detail/network_algorithms/impl/close_statement.hpp +++ b/include/boost/mysql/detail/network_algorithms/impl/close_statement.hpp @@ -8,7 +8,7 @@ #ifndef BOOST_MYSQL_DETAIL_NETWORK_ALGORITHMS_IMPL_CLOSE_STATEMENT_HPP #define BOOST_MYSQL_DETAIL_NETWORK_ALGORITHMS_IMPL_CLOSE_STATEMENT_HPP -#include "boost/mysql/detail/protocol/prepared_statement_messages.hpp" +#include template void boost::mysql::detail::close_statement( diff --git a/include/boost/mysql/detail/network_algorithms/impl/connect.hpp b/include/boost/mysql/detail/network_algorithms/impl/connect.hpp index e9f692dd..d84f8e67 100644 --- a/include/boost/mysql/detail/network_algorithms/impl/connect.hpp +++ b/include/boost/mysql/detail/network_algorithms/impl/connect.hpp @@ -8,7 +8,7 @@ #ifndef BOOST_MYSQL_DETAIL_NETWORK_ALGORITHMS_IMPL_CONNECT_HPP #define BOOST_MYSQL_DETAIL_NETWORK_ALGORITHMS_IMPL_CONNECT_HPP -#include "boost/mysql/detail/network_algorithms/handshake.hpp" +#include namespace boost { namespace mysql { diff --git a/include/boost/mysql/detail/network_algorithms/impl/execute_query.hpp b/include/boost/mysql/detail/network_algorithms/impl/execute_query.hpp index a7b91685..b8fa26f0 100644 --- a/include/boost/mysql/detail/network_algorithms/impl/execute_query.hpp +++ b/include/boost/mysql/detail/network_algorithms/impl/execute_query.hpp @@ -8,9 +8,9 @@ #ifndef BOOST_MYSQL_DETAIL_NETWORK_ALGORITHMS_IMPL_EXECUTE_QUERY_HPP #define BOOST_MYSQL_DETAIL_NETWORK_ALGORITHMS_IMPL_EXECUTE_QUERY_HPP -#include "boost/mysql/detail/protocol/text_deserialization.hpp" -#include "boost/mysql/detail/protocol/query_messages.hpp" -#include "boost/mysql/detail/network_algorithms/execute_generic.hpp" +#include +#include +#include template void boost::mysql::detail::execute_query( diff --git a/include/boost/mysql/detail/network_algorithms/impl/execute_statement.hpp b/include/boost/mysql/detail/network_algorithms/impl/execute_statement.hpp index c4c89ee3..b5c92d44 100644 --- a/include/boost/mysql/detail/network_algorithms/impl/execute_statement.hpp +++ b/include/boost/mysql/detail/network_algorithms/impl/execute_statement.hpp @@ -8,9 +8,9 @@ #ifndef BOOST_MYSQL_DETAIL_NETWORK_ALGORITHMS_IMPL_EXECUTE_STATEMENT_HPP #define BOOST_MYSQL_DETAIL_NETWORK_ALGORITHMS_IMPL_EXECUTE_STATEMENT_HPP -#include "boost/mysql/detail/protocol/binary_deserialization.hpp" -#include "boost/mysql/detail/protocol/prepared_statement_messages.hpp" -#include "boost/mysql/detail/network_algorithms/execute_generic.hpp" +#include +#include +#include namespace boost { namespace mysql { diff --git a/include/boost/mysql/detail/network_algorithms/impl/handshake.hpp b/include/boost/mysql/detail/network_algorithms/impl/handshake.hpp index 7d9fd6ea..effa69b7 100644 --- a/include/boost/mysql/detail/network_algorithms/impl/handshake.hpp +++ b/include/boost/mysql/detail/network_algorithms/impl/handshake.hpp @@ -8,10 +8,10 @@ #ifndef BOOST_MYSQL_DETAIL_NETWORK_ALGORITHMS_IMPL_HANDSHAKE_HPP #define BOOST_MYSQL_DETAIL_NETWORK_ALGORITHMS_IMPL_HANDSHAKE_HPP -#include "boost/mysql/detail/network_algorithms/common.hpp" -#include "boost/mysql/detail/protocol/capabilities.hpp" -#include "boost/mysql/detail/protocol/handshake_messages.hpp" -#include "boost/mysql/detail/auth/auth_calculator.hpp" +#include +#include +#include +#include namespace boost { namespace mysql { diff --git a/include/boost/mysql/detail/network_algorithms/impl/read_row.hpp b/include/boost/mysql/detail/network_algorithms/impl/read_row.hpp index 171344ff..7630d6f9 100644 --- a/include/boost/mysql/detail/network_algorithms/impl/read_row.hpp +++ b/include/boost/mysql/detail/network_algorithms/impl/read_row.hpp @@ -8,7 +8,7 @@ #ifndef BOOST_MYSQL_DETAIL_NETWORK_ALGORITHMS_IMPL_READ_ROW_HPP #define BOOST_MYSQL_DETAIL_NETWORK_ALGORITHMS_IMPL_READ_ROW_HPP -#include "boost/mysql/detail/protocol/text_deserialization.hpp" +#include namespace boost { namespace mysql { diff --git a/include/boost/mysql/detail/network_algorithms/prepare_statement.hpp b/include/boost/mysql/detail/network_algorithms/prepare_statement.hpp index 3fbbdf04..0384ceb6 100644 --- a/include/boost/mysql/detail/network_algorithms/prepare_statement.hpp +++ b/include/boost/mysql/detail/network_algorithms/prepare_statement.hpp @@ -8,8 +8,8 @@ #ifndef BOOST_MYSQL_DETAIL_NETWORK_ALGORITHMS_PREPARE_STATEMENT_HPP #define BOOST_MYSQL_DETAIL_NETWORK_ALGORITHMS_PREPARE_STATEMENT_HPP -#include "boost/mysql/detail/network_algorithms/common.hpp" -#include "boost/mysql/prepared_statement.hpp" +#include +#include namespace boost { namespace mysql { @@ -37,6 +37,6 @@ async_prepare_statement( } // mysql } // boost -#include "boost/mysql/detail/network_algorithms/impl/prepare_statement.hpp" +#include #endif /* INCLUDE_BOOST_MYSQL_DETAIL_NETWORK_ALGORITHMS_PREPARE_STATEMENT_HPP_ */ diff --git a/include/boost/mysql/detail/network_algorithms/quit_connection.hpp b/include/boost/mysql/detail/network_algorithms/quit_connection.hpp index 01934f56..4ad296b5 100644 --- a/include/boost/mysql/detail/network_algorithms/quit_connection.hpp +++ b/include/boost/mysql/detail/network_algorithms/quit_connection.hpp @@ -8,7 +8,7 @@ #ifndef BOOST_MYSQL_DETAIL_NETWORK_ALGORITHMS_QUIT_CONNECTION_HPP #define BOOST_MYSQL_DETAIL_NETWORK_ALGORITHMS_QUIT_CONNECTION_HPP -#include "boost/mysql/detail/network_algorithms/common.hpp" +#include namespace boost { namespace mysql { @@ -33,6 +33,6 @@ async_quit_connection( } // mysql } // boost -#include "boost/mysql/detail/network_algorithms/impl/quit_connection.hpp" +#include #endif /* INCLUDE_BOOST_MYSQL_DETAIL_NETWORK_ALGORITHMS_QUIT_CONNECTION_HPP_ */ diff --git a/include/boost/mysql/detail/network_algorithms/read_row.hpp b/include/boost/mysql/detail/network_algorithms/read_row.hpp index fd1c2584..8f6a3b1d 100644 --- a/include/boost/mysql/detail/network_algorithms/read_row.hpp +++ b/include/boost/mysql/detail/network_algorithms/read_row.hpp @@ -8,9 +8,9 @@ #ifndef BOOST_MYSQL_DETAIL_NETWORK_ALGORITHMS_READ_ROW_HPP #define BOOST_MYSQL_DETAIL_NETWORK_ALGORITHMS_READ_ROW_HPP -#include "boost/mysql/detail/network_algorithms/common.hpp" -#include "boost/mysql/metadata.hpp" -#include "boost/mysql/row.hpp" +#include +#include +#include #include #include @@ -55,7 +55,7 @@ async_read_row( } // mysql } // boost -#include "boost/mysql/detail/network_algorithms/impl/read_row.hpp" +#include diff --git a/include/boost/mysql/detail/protocol/binary_deserialization.hpp b/include/boost/mysql/detail/protocol/binary_deserialization.hpp index 8763f652..c0af9ba2 100644 --- a/include/boost/mysql/detail/protocol/binary_deserialization.hpp +++ b/include/boost/mysql/detail/protocol/binary_deserialization.hpp @@ -8,10 +8,10 @@ #ifndef BOOST_MYSQL_DETAIL_PROTOCOL_BINARY_DESERIALIZATION_HPP #define BOOST_MYSQL_DETAIL_PROTOCOL_BINARY_DESERIALIZATION_HPP -#include "boost/mysql/detail/protocol/serialization.hpp" -#include "boost/mysql/error.hpp" -#include "boost/mysql/value.hpp" -#include "boost/mysql/metadata.hpp" +#include +#include +#include +#include #include namespace boost { @@ -34,6 +34,6 @@ inline error_code deserialize_binary_row( } // mysql } // boost -#include "boost/mysql/detail/protocol/impl/binary_deserialization.ipp" +#include #endif /* INCLUDE_BOOST_MYSQL_DETAIL_PROTOCOL_BINARY_DESERIALIZATION_HPP_ */ diff --git a/include/boost/mysql/detail/protocol/binary_serialization.hpp b/include/boost/mysql/detail/protocol/binary_serialization.hpp index a2b5c538..ba516f55 100644 --- a/include/boost/mysql/detail/protocol/binary_serialization.hpp +++ b/include/boost/mysql/detail/protocol/binary_serialization.hpp @@ -8,8 +8,8 @@ #ifndef BOOST_MYSQL_DETAIL_PROTOCOL_BINARY_SERIALIZATION_HPP #define BOOST_MYSQL_DETAIL_PROTOCOL_BINARY_SERIALIZATION_HPP -#include "boost/mysql/value.hpp" -#include "boost/mysql/detail/protocol/serialization.hpp" +#include +#include namespace boost { namespace mysql { @@ -30,6 +30,6 @@ struct serialization_traits : } // mysql } // boost -#include "boost/mysql/detail/protocol/impl/binary_serialization.ipp" +#include #endif diff --git a/include/boost/mysql/detail/protocol/bit_deserialization.hpp b/include/boost/mysql/detail/protocol/bit_deserialization.hpp new file mode 100644 index 00000000..fbcb251a --- /dev/null +++ b/include/boost/mysql/detail/protocol/bit_deserialization.hpp @@ -0,0 +1,46 @@ +// +// Copyright (c) 2019-2021 Ruben Perez Hidalgo (rubenperez038 at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_MYSQL_DETAIL_PROTOCOL_BIT_DESERIALIZATION_HPP +#define BOOST_MYSQL_DETAIL_PROTOCOL_BIT_DESERIALIZATION_HPP + +#include +#include +#include +#include + +namespace boost { +namespace mysql { +namespace detail { + +// All BIT values come as binary values between 1 and 8 bytes length packed in string_lenenc's, +// for both the text and the binary protocols. As the text protocol already unpacks the string_lenenc layer, +// this function is in charge of just parsing the binary payload. +// The length of the BIT value depends on how the type was defined in the table (e.g. BIT(14) will send +// a 2 byte value; BIT(54) will send a 7 byte one). Values are sent as big-endian. +inline errc deserialize_bit( + boost::string_view from, + value& to +) noexcept +{ + std::size_t num_bytes = from.size(); + if (num_bytes < 1 || num_bytes > 8) + { + return errc::protocol_value_error; + } + unsigned char temp [8] {}; + unsigned char* dest = temp + sizeof(temp) - num_bytes; + std::memcpy(dest, from.data(), num_bytes); + to = value(boost::endian::load_big_u64(temp)); + return errc::ok; +} + +} // detail +} // mysql +} // boost + +#endif \ No newline at end of file diff --git a/include/boost/mysql/detail/protocol/channel.hpp b/include/boost/mysql/detail/protocol/channel.hpp index 2ad475e5..45bf4861 100644 --- a/include/boost/mysql/detail/protocol/channel.hpp +++ b/include/boost/mysql/detail/protocol/channel.hpp @@ -8,9 +8,9 @@ #ifndef BOOST_MYSQL_DETAIL_PROTOCOL_CHANNEL_HPP #define BOOST_MYSQL_DETAIL_PROTOCOL_CHANNEL_HPP -#include "boost/mysql/error.hpp" -#include "boost/mysql/detail/auxiliar/bytestring.hpp" -#include "boost/mysql/detail/protocol/capabilities.hpp" +#include +#include +#include #include #include #include @@ -145,6 +145,6 @@ using channel_observer_ptr = std::unique_ptr, null_channel_delet } // mysql } // boost -#include "boost/mysql/detail/protocol/impl/channel.hpp" +#include #endif diff --git a/include/boost/mysql/detail/protocol/common_messages.hpp b/include/boost/mysql/detail/protocol/common_messages.hpp index 39be1407..b48664cb 100644 --- a/include/boost/mysql/detail/protocol/common_messages.hpp +++ b/include/boost/mysql/detail/protocol/common_messages.hpp @@ -8,9 +8,9 @@ #ifndef BOOST_MYSQL_DETAIL_PROTOCOL_COMMON_MESSAGES_HPP #define BOOST_MYSQL_DETAIL_PROTOCOL_COMMON_MESSAGES_HPP -#include "boost/mysql/detail/protocol/serialization.hpp" -#include "boost/mysql/detail/protocol/constants.hpp" -#include "boost/mysql/collation.hpp" +#include +#include +#include #include namespace boost { @@ -145,6 +145,6 @@ inline error_code process_error_packet(deserialization_context& ctx, error_info& } // mysql } // boost -#include "boost/mysql/detail/protocol/impl/common_messages.ipp" +#include #endif /* INCLUDE_BOOST_MYSQL_DETAIL_PROTOCOL_COMMON_MESSAGES_HPP_ */ diff --git a/include/boost/mysql/detail/protocol/constants.hpp b/include/boost/mysql/detail/protocol/constants.hpp index f5df0741..9da1176f 100644 --- a/include/boost/mysql/detail/protocol/constants.hpp +++ b/include/boost/mysql/detail/protocol/constants.hpp @@ -8,8 +8,8 @@ #ifndef BOOST_MYSQL_DETAIL_PROTOCOL_CONSTANTS_HPP #define BOOST_MYSQL_DETAIL_PROTOCOL_CONSTANTS_HPP -#include "boost/mysql/detail/protocol/protocol_types.hpp" -#include "boost/mysql/detail/auxiliar/make_string_view.hpp" +#include +#include namespace boost { namespace mysql { diff --git a/include/boost/mysql/detail/protocol/date.hpp b/include/boost/mysql/detail/protocol/date.hpp index 2cfaec18..a50bc4ef 100644 --- a/include/boost/mysql/detail/protocol/date.hpp +++ b/include/boost/mysql/detail/protocol/date.hpp @@ -33,6 +33,6 @@ BOOST_CXX14_CONSTEXPR inline year_month_day days_to_ymd(int num_days) noexcept; } // mysql } // boost -#include "boost/mysql/detail/protocol/impl/date.hpp" +#include #endif diff --git a/include/boost/mysql/detail/protocol/deserialization_context.hpp b/include/boost/mysql/detail/protocol/deserialization_context.hpp index 8fa4cc8d..fe888c43 100644 --- a/include/boost/mysql/detail/protocol/deserialization_context.hpp +++ b/include/boost/mysql/detail/protocol/deserialization_context.hpp @@ -8,8 +8,8 @@ #ifndef BOOST_MYSQL_DETAIL_PROTOCOL_DESERIALIZATION_CONTEXT_HPP #define BOOST_MYSQL_DETAIL_PROTOCOL_DESERIALIZATION_CONTEXT_HPP -#include "boost/mysql/detail/protocol/capabilities.hpp" -#include "boost/mysql/error.hpp" +#include +#include #include #include #include diff --git a/include/boost/mysql/detail/protocol/handshake_messages.hpp b/include/boost/mysql/detail/protocol/handshake_messages.hpp index a03f852a..581bdb91 100644 --- a/include/boost/mysql/detail/protocol/handshake_messages.hpp +++ b/include/boost/mysql/detail/protocol/handshake_messages.hpp @@ -8,8 +8,8 @@ #ifndef BOOST_MYSQL_DETAIL_PROTOCOL_HANDSHAKE_MESSAGES_HPP #define BOOST_MYSQL_DETAIL_PROTOCOL_HANDSHAKE_MESSAGES_HPP -#include "boost/mysql/detail/protocol/serialization.hpp" -#include "boost/mysql/detail/auxiliar/static_string.hpp" +#include +#include namespace boost { namespace mysql { @@ -165,6 +165,6 @@ struct auth_more_data_packet } // mysql } // boost -#include "boost/mysql/detail/protocol/impl/handshake_messages.ipp" +#include #endif /* INCLUDE_BOOST_MYSQL_DETAIL_PROTOCOL_HANDSHAKE_MESSAGES_HPP_ */ diff --git a/include/boost/mysql/detail/protocol/impl/binary_deserialization.ipp b/include/boost/mysql/detail/protocol/impl/binary_deserialization.ipp index 4bd28844..016204cf 100644 --- a/include/boost/mysql/detail/protocol/impl/binary_deserialization.ipp +++ b/include/boost/mysql/detail/protocol/impl/binary_deserialization.ipp @@ -8,10 +8,11 @@ #ifndef BOOST_MYSQL_DETAIL_PROTOCOL_IMPL_BINARY_DESERIALIZATION_IPP #define BOOST_MYSQL_DETAIL_PROTOCOL_IMPL_BINARY_DESERIALIZATION_IPP -#include "boost/mysql/detail/protocol/serialization.hpp" -#include "boost/mysql/detail/protocol/null_bitmap_traits.hpp" -#include "boost/mysql/detail/protocol/constants.hpp" -#include "boost/mysql/detail/protocol/date.hpp" +#include +#include +#include +#include +#include namespace boost { namespace mysql { @@ -63,6 +64,19 @@ errc deserialize_binary_value_int( std::int64_t, DeserializableTypeSigned>(ctx, output); } +// Bits. These come as a binary value between 1 and 8 bytes, +// packed in a string +inline errc deserialize_binary_value_bit( + deserialization_context& ctx, + value& output +) noexcept +{ + string_lenenc buffer; + auto err = deserialize(ctx, buffer); + if (err != errc::ok) return err; + return deserialize_bit(buffer.value, output); +} + // Floats template errc deserialize_binary_value_float( @@ -316,6 +330,8 @@ inline boost::mysql::errc boost::mysql::detail::deserialize_binary_value( return deserialize_binary_value_int(meta, ctx, output); case protocol_field_type::longlong: return deserialize_binary_value_int(meta, ctx, output); + case protocol_field_type::bit: + return deserialize_binary_value_bit(ctx, output); case protocol_field_type::float_: return deserialize_binary_value_float(ctx, output); case protocol_field_type::double_: @@ -339,7 +355,6 @@ inline boost::mysql::errc boost::mysql::detail::deserialize_binary_value( case protocol_field_type::set: // Anything else that we do not know how to interpret, we return as a binary string case protocol_field_type::decimal: - case protocol_field_type::bit: case protocol_field_type::newdecimal: case protocol_field_type::geometry: default: diff --git a/include/boost/mysql/detail/protocol/impl/binary_serialization.ipp b/include/boost/mysql/detail/protocol/impl/binary_serialization.ipp index f4155132..d9906d11 100644 --- a/include/boost/mysql/detail/protocol/impl/binary_serialization.ipp +++ b/include/boost/mysql/detail/protocol/impl/binary_serialization.ipp @@ -8,8 +8,8 @@ #ifndef BOOST_MYSQL_DETAIL_PROTOCOL_IMPL_BINARY_SERIALIZATION_IPP #define BOOST_MYSQL_DETAIL_PROTOCOL_IMPL_BINARY_SERIALIZATION_IPP -#include "boost/mysql/detail/protocol/constants.hpp" -#include "boost/mysql/detail/protocol/date.hpp" +#include +#include namespace boost { namespace mysql { diff --git a/include/boost/mysql/detail/protocol/impl/channel.hpp b/include/boost/mysql/detail/protocol/impl/channel.hpp index aab08c1f..8b6af225 100644 --- a/include/boost/mysql/detail/protocol/impl/channel.hpp +++ b/include/boost/mysql/detail/protocol/impl/channel.hpp @@ -12,9 +12,9 @@ #include #include #include -#include "boost/mysql/detail/protocol/common_messages.hpp" -#include "boost/mysql/detail/protocol/constants.hpp" -#include "boost/mysql/detail/auxiliar/valgrind.hpp" +#include +#include +#include namespace boost { namespace mysql { diff --git a/include/boost/mysql/detail/protocol/impl/date.hpp b/include/boost/mysql/detail/protocol/impl/date.hpp index 8548e511..a10ef2c1 100644 --- a/include/boost/mysql/detail/protocol/impl/date.hpp +++ b/include/boost/mysql/detail/protocol/impl/date.hpp @@ -8,7 +8,7 @@ #ifndef BOOST_MYSQL_DETAIL_PROTOCOL_IMPL_DATE_HPP #define BOOST_MYSQL_DETAIL_PROTOCOL_IMPL_DATE_HPP -#include "boost/mysql/detail/protocol/constants.hpp" +#include #include namespace boost { diff --git a/include/boost/mysql/detail/protocol/impl/prepared_statement_messages.hpp b/include/boost/mysql/detail/protocol/impl/prepared_statement_messages.hpp index fccae8d7..2b2a3d9d 100644 --- a/include/boost/mysql/detail/protocol/impl/prepared_statement_messages.hpp +++ b/include/boost/mysql/detail/protocol/impl/prepared_statement_messages.hpp @@ -8,8 +8,8 @@ #ifndef BOOST_MYSQL_DETAIL_PROTOCOL_IMPL_PREPARED_STATEMENT_MESSAGES_HPP #define BOOST_MYSQL_DETAIL_PROTOCOL_IMPL_PREPARED_STATEMENT_MESSAGES_HPP -#include "boost/mysql/detail/protocol/null_bitmap_traits.hpp" -#include "boost/mysql/detail/protocol/binary_serialization.hpp" +#include +#include namespace boost { namespace mysql { diff --git a/include/boost/mysql/detail/protocol/impl/text_deserialization.ipp b/include/boost/mysql/detail/protocol/impl/text_deserialization.ipp index 5fc836c2..cd823206 100644 --- a/include/boost/mysql/detail/protocol/impl/text_deserialization.ipp +++ b/include/boost/mysql/detail/protocol/impl/text_deserialization.ipp @@ -13,8 +13,9 @@ #include #include #include -#include "boost/mysql/detail/protocol/constants.hpp" -#include "boost/mysql/detail/protocol/date.hpp" +#include +#include +#include #ifdef BOOST_MSVC #pragma warning( push ) @@ -317,6 +318,8 @@ inline boost::mysql::errc boost::mysql::detail::deserialize_text_value( case protocol_field_type::year: case protocol_field_type::longlong: return deserialize_text_value_int(from, output, meta); + case protocol_field_type::bit: + return deserialize_bit(from, output); case protocol_field_type::float_: return deserialize_text_value_float(from, output); case protocol_field_type::double_: @@ -340,7 +343,6 @@ inline boost::mysql::errc boost::mysql::detail::deserialize_text_value( case protocol_field_type::set: // Anything else that we do not know how to interpret, we return as a binary string case protocol_field_type::decimal: - case protocol_field_type::bit: case protocol_field_type::newdecimal: case protocol_field_type::geometry: default: diff --git a/include/boost/mysql/detail/protocol/prepared_statement_messages.hpp b/include/boost/mysql/detail/protocol/prepared_statement_messages.hpp index 9363dd75..08526d6a 100644 --- a/include/boost/mysql/detail/protocol/prepared_statement_messages.hpp +++ b/include/boost/mysql/detail/protocol/prepared_statement_messages.hpp @@ -8,9 +8,9 @@ #ifndef BOOST_MYSQL_DETAIL_PROTOCOL_PREPARED_STATEMENT_MESSAGES_HPP #define BOOST_MYSQL_DETAIL_PROTOCOL_PREPARED_STATEMENT_MESSAGES_HPP -#include "boost/mysql/detail/protocol/serialization.hpp" -#include "boost/mysql/detail/protocol/constants.hpp" -#include "boost/mysql/value.hpp" +#include +#include +#include namespace boost { namespace mysql { @@ -137,6 +137,6 @@ struct com_stmt_close_packet } // mysql } // boost -#include "boost/mysql/detail/protocol/impl/prepared_statement_messages.hpp" +#include #endif /* INCLUDE_BOOST_MYSQL_DETAIL_PROTOCOL_PREPARED_STATEMENT_MESSAGES_HPP_ */ diff --git a/include/boost/mysql/detail/protocol/query_messages.hpp b/include/boost/mysql/detail/protocol/query_messages.hpp index 405de136..e517c762 100644 --- a/include/boost/mysql/detail/protocol/query_messages.hpp +++ b/include/boost/mysql/detail/protocol/query_messages.hpp @@ -8,7 +8,7 @@ #ifndef BOOST_MYSQL_DETAIL_PROTOCOL_QUERY_MESSAGES_HPP #define BOOST_MYSQL_DETAIL_PROTOCOL_QUERY_MESSAGES_HPP -#include "boost/mysql/detail/protocol/serialization.hpp" +#include #include namespace boost { diff --git a/include/boost/mysql/detail/protocol/serialization.hpp b/include/boost/mysql/detail/protocol/serialization.hpp index 349fa9f0..9dd14d7c 100644 --- a/include/boost/mysql/detail/protocol/serialization.hpp +++ b/include/boost/mysql/detail/protocol/serialization.hpp @@ -11,12 +11,12 @@ #include #include #include -#include "boost/mysql/detail/protocol/protocol_types.hpp" -#include "boost/mysql/detail/protocol/serialization_context.hpp" -#include "boost/mysql/detail/protocol/deserialization_context.hpp" -#include "boost/mysql/detail/auxiliar/bytestring.hpp" -#include "boost/mysql/value.hpp" -#include "boost/mysql/error.hpp" +#include +#include +#include +#include +#include +#include namespace boost { namespace mysql { @@ -232,7 +232,7 @@ void serialize_fields(serialization_context& ctx, const Types&... fields) noexce } // mysql } // boost -#include "boost/mysql/detail/protocol/impl/serialization.hpp" -#include "boost/mysql/detail/protocol/impl/serialization.ipp" +#include +#include #endif diff --git a/include/boost/mysql/detail/protocol/serialization_context.hpp b/include/boost/mysql/detail/protocol/serialization_context.hpp index b5e86b12..56384c8c 100644 --- a/include/boost/mysql/detail/protocol/serialization_context.hpp +++ b/include/boost/mysql/detail/protocol/serialization_context.hpp @@ -8,7 +8,7 @@ #ifndef BOOST_MYSQL_DETAIL_PROTOCOL_SERIALIZATION_CONTEXT_HPP #define BOOST_MYSQL_DETAIL_PROTOCOL_SERIALIZATION_CONTEXT_HPP -#include "boost/mysql/detail/protocol/capabilities.hpp" +#include #include #include #include diff --git a/include/boost/mysql/detail/protocol/text_deserialization.hpp b/include/boost/mysql/detail/protocol/text_deserialization.hpp index 284098e2..acf7611a 100644 --- a/include/boost/mysql/detail/protocol/text_deserialization.hpp +++ b/include/boost/mysql/detail/protocol/text_deserialization.hpp @@ -8,10 +8,10 @@ #ifndef BOOST_MYSQL_DETAIL_PROTOCOL_TEXT_DESERIALIZATION_HPP #define BOOST_MYSQL_DETAIL_PROTOCOL_TEXT_DESERIALIZATION_HPP -#include "boost/mysql/detail/protocol/serialization.hpp" -#include "boost/mysql/error.hpp" -#include "boost/mysql/value.hpp" -#include "boost/mysql/metadata.hpp" +#include +#include +#include +#include #include namespace boost { @@ -34,6 +34,6 @@ inline error_code deserialize_text_row( } // mysql } // boost -#include "boost/mysql/detail/protocol/impl/text_deserialization.ipp" +#include #endif diff --git a/include/boost/mysql/error.hpp b/include/boost/mysql/error.hpp index 366ca1bc..05f9fd94 100644 --- a/include/boost/mysql/error.hpp +++ b/include/boost/mysql/error.hpp @@ -11,7 +11,7 @@ #include #include #include -#include "boost/mysql/errc.hpp" +#include namespace boost { namespace mysql { @@ -19,6 +19,9 @@ namespace mysql { /// An alias for boost::system error codes. using error_code = boost::system::error_code; +/// Creates an [reflink error_code] from an [reflink errc]. +inline error_code make_error_code(errc error); + /** * \brief Additional information about error conditions * \details Contains an error message describing what happened. Not all error @@ -66,6 +69,6 @@ inline std::ostream& operator<<(std::ostream& os, const error_info& v) { return } // mysql } // boost -#include "boost/mysql/impl/error.hpp" +#include #endif diff --git a/include/boost/mysql/execute_params.hpp b/include/boost/mysql/execute_params.hpp index 08a002cb..fc7a0991 100644 --- a/include/boost/mysql/execute_params.hpp +++ b/include/boost/mysql/execute_params.hpp @@ -8,8 +8,8 @@ #ifndef BOOST_MYSQL_EXECUTE_PARAMS_HPP #define BOOST_MYSQL_EXECUTE_PARAMS_HPP -#include "boost/mysql/value.hpp" -#include "boost/mysql/detail/auxiliar/value_type_traits.hpp" +#include +#include #include #include diff --git a/include/boost/mysql/impl/connection.hpp b/include/boost/mysql/impl/connection.hpp index 49da0c5a..79ff49ae 100644 --- a/include/boost/mysql/impl/connection.hpp +++ b/include/boost/mysql/impl/connection.hpp @@ -8,12 +8,10 @@ #ifndef BOOST_MYSQL_IMPL_CONNECTION_HPP #define BOOST_MYSQL_IMPL_CONNECTION_HPP -#include "boost/mysql/detail/network_algorithms/handshake.hpp" -#include "boost/mysql/detail/network_algorithms/execute_query.hpp" -#include "boost/mysql/detail/network_algorithms/prepare_statement.hpp" -#include "boost/mysql/detail/network_algorithms/quit_connection.hpp" -#include "boost/mysql/detail/network_algorithms/close_connection.hpp" -#include "boost/mysql/detail/network_algorithms/connect.hpp" +#include +#include +#include +#include #include template @@ -190,88 +188,4 @@ boost::mysql::connection::async_quit( ); } -// socket_connection: connect -template -void boost::mysql::socket_connection::connect( - const endpoint_type& endpoint, - const connection_params& params, - error_code& ec, - error_info& info -) -{ - detail::clear_errors(ec, info); - detail::connect(this->get_channel(), endpoint, params, ec, info); -} - -template -void boost::mysql::socket_connection::connect( - const endpoint_type& endpoint, - const connection_params& params -) -{ - detail::error_block blk; - detail::connect(this->get_channel(), endpoint, params, blk.err, blk.info); - blk.check(); -} - -template -template -BOOST_ASIO_INITFN_AUTO_RESULT_TYPE( - CompletionToken, - void(boost::mysql::error_code) -) -boost::mysql::socket_connection::async_connect( - const endpoint_type& endpoint, - const connection_params& params, - error_info& output_info, - CompletionToken&& token -) -{ - output_info.clear(); - return detail::async_connect( - this->get_channel(), - endpoint, - params, - std::forward(token), - output_info - ); -} - -template -void boost::mysql::socket_connection::close( - error_code& err, - error_info& info -) -{ - detail::clear_errors(err, info); - detail::close_connection(this->get_channel(), err, info); -} - -template -void boost::mysql::socket_connection::close() -{ - detail::error_block blk; - detail::close_connection(this->get_channel(), blk.err, blk.info); - blk.check(); -} - -template -template -BOOST_ASIO_INITFN_AUTO_RESULT_TYPE( - CompletionToken, - void(boost::mysql::error_code) -) -boost::mysql::socket_connection::async_close( - error_info& output_info, - CompletionToken&& token -) -{ - output_info.clear(); - return detail::async_close_connection( - this->get_channel(), - std::forward(token), - output_info - ); -} - #endif diff --git a/include/boost/mysql/impl/error.hpp b/include/boost/mysql/impl/error.hpp index ec67b0bf..a0a9dbdc 100644 --- a/include/boost/mysql/impl/error.hpp +++ b/include/boost/mysql/impl/error.hpp @@ -11,7 +11,7 @@ #include #include #include -#include "boost/mysql/impl/error_descriptions.hpp" +#include namespace boost { namespace system { @@ -66,11 +66,6 @@ inline mysql_error_category_t& get_mysql_error_category() noexcept #endif -inline boost::system::error_code make_error_code(errc error) -{ - return boost::system::error_code(static_cast(error), get_mysql_error_category()); -} - inline void check_error_code(const error_code& code, const error_info& info) { if (code) @@ -106,5 +101,12 @@ inline std::ostream& boost::mysql::operator<<( return os << detail::error_to_string(value); } +inline boost::mysql::error_code boost::mysql::make_error_code( + errc error +) +{ + return boost::system::error_code(static_cast(error), detail::get_mysql_error_category()); +} + #endif diff --git a/include/boost/mysql/impl/error_descriptions.hpp b/include/boost/mysql/impl/error_descriptions.hpp index 0abde7dc..11eb4994 100644 --- a/include/boost/mysql/impl/error_descriptions.hpp +++ b/include/boost/mysql/impl/error_descriptions.hpp @@ -8,7 +8,7 @@ #ifndef BOOST_MYSQL_IMPL_ERROR_DESCRIPTIONS_HPP #define BOOST_MYSQL_IMPL_ERROR_DESCRIPTIONS_HPP -#include "boost/mysql/errc.hpp" +#include namespace boost { namespace mysql { diff --git a/include/boost/mysql/impl/prepared_statement.hpp b/include/boost/mysql/impl/prepared_statement.hpp index b5c81950..fd210977 100644 --- a/include/boost/mysql/impl/prepared_statement.hpp +++ b/include/boost/mysql/impl/prepared_statement.hpp @@ -8,9 +8,9 @@ #ifndef BOOST_MYSQL_IMPL_PREPARED_STATEMENT_HPP #define BOOST_MYSQL_IMPL_PREPARED_STATEMENT_HPP -#include "boost/mysql/detail/network_algorithms/execute_statement.hpp" -#include "boost/mysql/detail/network_algorithms/close_statement.hpp" -#include "boost/mysql/detail/auxiliar/stringize.hpp" +#include +#include +#include #include @@ -26,7 +26,7 @@ void boost::mysql::prepared_statement::check_num_params( auto param_count = std::distance(first, last); if (param_count != num_params()) { - err = detail::make_error_code(errc::wrong_num_params); + err = make_error_code(errc::wrong_num_params); info.set_message(detail::stringize( "prepared_statement::execute: expected ", num_params(), " params, but got ", param_count)); } diff --git a/include/boost/mysql/impl/resultset.hpp b/include/boost/mysql/impl/resultset.hpp index 03d1d287..c6e4a97c 100644 --- a/include/boost/mysql/impl/resultset.hpp +++ b/include/boost/mysql/impl/resultset.hpp @@ -8,7 +8,7 @@ #ifndef BOOST_MYSQL_IMPL_RESULTSET_HPP #define BOOST_MYSQL_IMPL_RESULTSET_HPP -#include "boost/mysql/detail/network_algorithms/read_row.hpp" +#include #include #include #include diff --git a/include/boost/mysql/impl/socket_connection.hpp b/include/boost/mysql/impl/socket_connection.hpp new file mode 100644 index 00000000..8e51bffc --- /dev/null +++ b/include/boost/mysql/impl/socket_connection.hpp @@ -0,0 +1,97 @@ +// +// Copyright (c) 2019-2021 Ruben Perez Hidalgo (rubenperez038 at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_MYSQL_IMPL_SOCKET_CONNECTION_HPP +#define BOOST_MYSQL_IMPL_SOCKET_CONNECTION_HPP + +#include +#include + +template +void boost::mysql::socket_connection::connect( + const endpoint_type& endpoint, + const connection_params& params, + error_code& ec, + error_info& info +) +{ + detail::clear_errors(ec, info); + detail::connect(this->get_channel(), endpoint, params, ec, info); +} + +template +void boost::mysql::socket_connection::connect( + const endpoint_type& endpoint, + const connection_params& params +) +{ + detail::error_block blk; + detail::connect(this->get_channel(), endpoint, params, blk.err, blk.info); + blk.check(); +} + +template +template +BOOST_ASIO_INITFN_AUTO_RESULT_TYPE( + CompletionToken, + void(boost::mysql::error_code) +) +boost::mysql::socket_connection::async_connect( + const endpoint_type& endpoint, + const connection_params& params, + error_info& output_info, + CompletionToken&& token +) +{ + output_info.clear(); + return detail::async_connect( + this->get_channel(), + endpoint, + params, + std::forward(token), + output_info + ); +} + +template +void boost::mysql::socket_connection::close( + error_code& err, + error_info& info +) +{ + detail::clear_errors(err, info); + detail::close_connection(this->get_channel(), err, info); +} + +template +void boost::mysql::socket_connection::close() +{ + detail::error_block blk; + detail::close_connection(this->get_channel(), blk.err, blk.info); + blk.check(); +} + +template +template +BOOST_ASIO_INITFN_AUTO_RESULT_TYPE( + CompletionToken, + void(boost::mysql::error_code) +) +boost::mysql::socket_connection::async_close( + error_info& output_info, + CompletionToken&& token +) +{ + output_info.clear(); + return detail::async_close_connection( + this->get_channel(), + std::forward(token), + output_info + ); +} + +#endif \ No newline at end of file diff --git a/include/boost/mysql/impl/value.hpp b/include/boost/mysql/impl/value.hpp index 0bd11666..54e0e78f 100644 --- a/include/boost/mysql/impl/value.hpp +++ b/include/boost/mysql/impl/value.hpp @@ -8,8 +8,8 @@ #ifndef BOOST_MYSQL_IMPL_VALUE_HPP #define BOOST_MYSQL_IMPL_VALUE_HPP -#include "boost/mysql/detail/auxiliar/container_equals.hpp" -#include "boost/mysql/detail/protocol/date.hpp" +#include +#include #include namespace boost { diff --git a/include/boost/mysql/metadata.hpp b/include/boost/mysql/metadata.hpp index fea6e493..25c0d6a2 100644 --- a/include/boost/mysql/metadata.hpp +++ b/include/boost/mysql/metadata.hpp @@ -8,9 +8,9 @@ #ifndef BOOST_MYSQL_METADATA_HPP #define BOOST_MYSQL_METADATA_HPP -#include "boost/mysql/detail/protocol/common_messages.hpp" -#include "boost/mysql/detail/auxiliar/bytestring.hpp" -#include "boost/mysql/field_type.hpp" +#include +#include +#include namespace boost { namespace mysql { @@ -139,6 +139,6 @@ public: } // mysql } // boost -#include "boost/mysql/impl/metadata.ipp" +#include #endif diff --git a/include/boost/mysql/prepared_statement.hpp b/include/boost/mysql/prepared_statement.hpp index 0840c90f..87885943 100644 --- a/include/boost/mysql/prepared_statement.hpp +++ b/include/boost/mysql/prepared_statement.hpp @@ -8,11 +8,11 @@ #ifndef BOOST_MYSQL_PREPARED_STATEMENT_HPP #define BOOST_MYSQL_PREPARED_STATEMENT_HPP -#include "boost/mysql/resultset.hpp" -#include "boost/mysql/execute_params.hpp" -#include "boost/mysql/detail/protocol/channel.hpp" -#include "boost/mysql/detail/protocol/prepared_statement_messages.hpp" -#include "boost/mysql/detail/auxiliar/value_type_traits.hpp" +#include +#include +#include +#include +#include #include #include #include @@ -386,6 +386,6 @@ using unix_prepared_statement = prepared_statement #endif /* INCLUDE_BOOST_MYSQL_PREPARED_STATEMENT_HPP_ */ diff --git a/include/boost/mysql/resultset.hpp b/include/boost/mysql/resultset.hpp index bb0946da..e8ba3294 100644 --- a/include/boost/mysql/resultset.hpp +++ b/include/boost/mysql/resultset.hpp @@ -8,12 +8,12 @@ #ifndef BOOST_MYSQL_RESULTSET_HPP #define BOOST_MYSQL_RESULTSET_HPP -#include "boost/mysql/row.hpp" -#include "boost/mysql/metadata.hpp" -#include "boost/mysql/detail/protocol/common_messages.hpp" -#include "boost/mysql/detail/protocol/channel.hpp" -#include "boost/mysql/detail/auxiliar/bytestring.hpp" -#include "boost/mysql/detail/network_algorithms/common.hpp" // deserialize_row_fn +#include +#include +#include +#include +#include +#include // deserialize_row_fn #include #include #include @@ -335,6 +335,6 @@ using unix_resultset = resultset; } // mysql } // boost -#include "boost/mysql/impl/resultset.hpp" +#include #endif diff --git a/include/boost/mysql/row.hpp b/include/boost/mysql/row.hpp index 1cca90d4..db2aa116 100644 --- a/include/boost/mysql/row.hpp +++ b/include/boost/mysql/row.hpp @@ -8,10 +8,10 @@ #ifndef BOOST_MYSQL_ROW_HPP #define BOOST_MYSQL_ROW_HPP -#include "boost/mysql/detail/auxiliar/bytestring.hpp" -#include "boost/mysql/detail/auxiliar/container_equals.hpp" -#include "boost/mysql/value.hpp" -#include "boost/mysql/metadata.hpp" +#include +#include +#include +#include #include namespace boost { diff --git a/include/boost/mysql/socket_connection.hpp b/include/boost/mysql/socket_connection.hpp new file mode 100644 index 00000000..fe0fbf99 --- /dev/null +++ b/include/boost/mysql/socket_connection.hpp @@ -0,0 +1,207 @@ +// +// Copyright (c) 2019-2021 Ruben Perez Hidalgo (rubenperez038 at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_MYSQL_SOCKET_CONNECTION_HPP +#define BOOST_MYSQL_SOCKET_CONNECTION_HPP + +#ifndef BOOST_MYSQL_DOXYGEN // For some arcane reason, Doxygen fails to expand Asio macros without this +#include +#include +#include +#include +#endif + +namespace boost { +namespace mysql { + +/** + * \brief A connection to a MySQL server over a socket. + * \details Extends [reflink connection] with additional + * functions that require the undrlying stream to be a socket. + * + * In general, prefer this class over [reflink connection]. + * See also [reflink tcp_connection] and [reflink unix_connection] for + * the most common instantiations of this template class. + * See [link mysql.other_streams this section] for more info. + * + * The same considerations for copy and move operations as for + * [reflink connection] apply. + */ +template< + class SocketStream +> +class socket_connection : public connection +{ +public: + using connection::connection; + + /// The executor type associated to this object. + using executor_type = typename SocketStream::executor_type; + + /// The endpoint type associated to this connection. + using endpoint_type = typename SocketStream::endpoint_type; + + /** + * \brief Performs a connection to the MySQL server (sync with error code version). + * \details Connects the underlying socket and then performs the handshake + * with the server. The underlying socket is closed in case of error. Prefer + * this function to [refmem connection handshake]. + * + * If SSL certificate validation was configured (by providing a custom SSL context + * to this class' constructor) and fails, this function will fail. + */ + void connect(const endpoint_type& endpoint, const connection_params& params, + error_code& ec, error_info& info); + + /** + * \brief Performs a connection to the MySQL server (sync with exceptions version). + * \details Connects the underlying socket and then performs the handshake + * with the server. The underlying socket is closed in case of error. Prefer + * this function to [refmem connection handshake]. + * + * If SSL certificate validation was configured (by providing a custom SSL context + * to this class' constructor) and fails, this function will fail. + */ + void connect(const endpoint_type& endpoint, const connection_params& params); + + /** + * \brief Performs a connection to the MySQL server + * (async without [reflink error_info] version). + * \details + * Connects the underlying socket and then performs the handshake + * with the server. The underlying socket is closed in case of error. Prefer + * this function to [refmem connection async_handshake]. + * + * The strings pointed to by params should be kept alive by the caller + * until the operation completes, as no copy is made by the library. + * + * If SSL certificate validation was configured (by providing a custom SSL context + * to this class' constructor) and fails, this function will fail. + * + * The handler signature for this operation is `void(boost::mysql::error_code)`. + */ + template < + BOOST_ASIO_COMPLETION_TOKEN_FOR(void(error_code)) + CompletionToken + BOOST_ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(executor_type) + > + BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(CompletionToken, void(error_code)) + async_connect( + const endpoint_type& endpoint, + const connection_params& params, + CompletionToken&& token BOOST_ASIO_DEFAULT_COMPLETION_TOKEN(executor_type) + ) + { + return async_connect(endpoint, params, this->shared_info(), std::forward(token)); + } + + /** + * \brief Performs a connection to the MySQL server + * (async with [reflink error_info] version). + * \details + * Connects the underlying socket and then performs the handshake + * with the server. The underlying socket is closed in case of error. Prefer + * this function to [refmem connection async_handshake]. + * + * The strings pointed to by params should be kept alive by the caller + * until the operation completes, as no copy is made by the library. + * + * If SSL certificate validation was configured (by providing a custom SSL context + * to this class' constructor) and fails, this function will fail. + * + * The handler signature for this operation is `void(boost::mysql::error_code)`. + */ + template < + BOOST_ASIO_COMPLETION_TOKEN_FOR(void(error_code)) + CompletionToken + BOOST_ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(executor_type) + > + BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(CompletionToken, void(error_code)) + async_connect( + const endpoint_type& endpoint, + const connection_params& params, + error_info& output_info, + CompletionToken&& token BOOST_ASIO_DEFAULT_COMPLETION_TOKEN(executor_type) + ); + + /** + * \brief Closes the connection (sync with error code version). + * \details Sends a quit request and closes the underlying socket. + * Prefer this function to [refmem connection quit]. + */ + void close(error_code&, error_info&); + + /** + * \brief Closes the connection (sync with exceptions version). + * \details Sends a quit request and closes the underlying socket. + * Prefer this function to [refmem connection quit]. + */ + void close(); + + /** + * \brief Closes the connection (async without [reflink error_info] version). + * \details Sends a quit request and closes the underlying socket. + * Prefer this function to [refmem connection async_quit]. + * + * The handler signature for this operation is `void(boost::mysql::error_code)`. + */ + template < + BOOST_ASIO_COMPLETION_TOKEN_FOR(void(error_code)) + CompletionToken + BOOST_ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(executor_type) + > + BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(CompletionToken, void(error_code)) + async_close(CompletionToken&& token BOOST_ASIO_DEFAULT_COMPLETION_TOKEN(executor_type)) + { + return async_close(this->shared_info(), std::forward(token)); + } + + /** + * \brief Closes the connection (async with [reflink error_info] version). + * \details Sends a quit request and closes the underlying socket. + * Prefer this function to [refmem connection async_quit]. + * + * The handler signature for this operation is `void(boost::mysql::error_code)`. + */ + template < + BOOST_ASIO_COMPLETION_TOKEN_FOR(void(error_code)) + CompletionToken + BOOST_ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(executor_type) + > + BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(CompletionToken, void(error_code)) + async_close( + error_info& output_info, + CompletionToken&& token BOOST_ASIO_DEFAULT_COMPLETION_TOKEN(executor_type) + ); + + /// Rebinds the connection type to another executor. + template + struct rebind_executor + { + /// The connection type when rebound to the specified executor. + using other = socket_connection< + typename SocketStream:: template rebind_executor::other + >; + }; +}; + +/// A connection to MySQL over a TCP socket. +using tcp_connection = socket_connection; + +#if defined(BOOST_ASIO_HAS_LOCAL_SOCKETS) || defined(BOOST_MYSQL_DOXYGEN) + +/// A connection to MySQL over a UNIX domain socket. +using unix_connection = socket_connection; + +#endif + +} // mysql +} // boost + +#include + +#endif \ No newline at end of file diff --git a/include/boost/mysql/value.hpp b/include/boost/mysql/value.hpp index f123f473..51daf5e5 100644 --- a/include/boost/mysql/value.hpp +++ b/include/boost/mysql/value.hpp @@ -72,8 +72,8 @@ public: using variant_type = boost::variant2::variant< null_t, // Any of the below when the value is NULL std::int64_t, // signed TINYINT, SMALLINT, MEDIUMINT, INT, BIGINT - std::uint64_t, // unsigned TINYINT, SMALLINT, MEDIUMINT, INT, BIGINT, YEAR - boost::string_view,// CHAR, VARCHAR, BINARY, VARBINARY, TEXT (all sizes), BLOB (all sizes), ENUM, SET, DECIMAL, BIT, GEOMTRY + std::uint64_t, // unsigned TINYINT, SMALLINT, MEDIUMINT, INT, BIGINT, YEAR, BIT + boost::string_view,// CHAR, VARCHAR, BINARY, VARBINARY, TEXT (all sizes), BLOB (all sizes), ENUM, SET, DECIMAL, GEOMTRY float, // FLOAT double, // DOUBLE date, // DATE @@ -265,7 +265,7 @@ constexpr time max_time = std::chrono::hours(839); } // mysql } // boost -#include "boost/mysql/impl/value.hpp" +#include #endif diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 2986bfc2..1620926d 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -50,6 +50,7 @@ add_executable( unit/prepared_statement.cpp unit/resultset.cpp unit/connection.cpp + unit/socket_connection.cpp unit/entry_point.cpp ) target_link_libraries( diff --git a/test/common/test_common.hpp b/test/common/test_common.hpp index 6c052238..9d01a6fe 100644 --- a/test/common/test_common.hpp +++ b/test/common/test_common.hpp @@ -8,10 +8,10 @@ #ifndef BOOST_MYSQL_TEST_COMMON_TEST_COMMON_HPP #define BOOST_MYSQL_TEST_COMMON_TEST_COMMON_HPP -#include "boost/mysql/value.hpp" -#include "boost/mysql/row.hpp" -#include "boost/mysql/connection_params.hpp" -#include "boost/mysql/detail/auxiliar/stringize.hpp" +#include +#include +#include +#include #include #include #include diff --git a/test/integration/connection.cpp b/test/integration/connection.cpp index f111fcd3..eb9951a0 100644 --- a/test/integration/connection.cpp +++ b/test/integration/connection.cpp @@ -5,7 +5,7 @@ // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // -#include "boost/mysql/connection.hpp" +#include #include "integration_test_common.hpp" #include "get_endpoint.hpp" diff --git a/test/integration/database_types.cpp b/test/integration/database_types.cpp index c4dddfe8..225e3283 100644 --- a/test/integration/database_types.cpp +++ b/test/integration/database_types.cpp @@ -10,6 +10,7 @@ #include "test_common.hpp" #include #include +#include #include #include @@ -110,6 +111,34 @@ void add_int_samples(std::vector& output) -0x7fffffffffffffff - 1, 0x7fffffffffffffff, 0xffffffffffffffff, output); } +// BIT cases +void add_bit_samples_helper( + std::vector& output, + const char* field_name, + std::uint64_t regular_value, + std::uint64_t max_value +) +{ + output.emplace_back("types_bit", field_name, "min", std::uint64_t(0), field_type::bit, flags_unsigned); + output.emplace_back("types_bit", field_name, "regular", regular_value, field_type::bit, flags_unsigned); + output.emplace_back("types_bit", field_name, "max", max_value, field_type::bit, flags_unsigned); +} + +void add_bit_samples(std::vector& output) +{ + add_bit_samples_helper(output, "field_1", 0x01, 0x01); + add_bit_samples_helper(output, "field_8", 0x9e, 0xff); + add_bit_samples_helper(output, "field_14", 0x1e2a, 0x3fff); + add_bit_samples_helper(output, "field_16", 0x1234, 0xffff); + add_bit_samples_helper(output, "field_24", 0x123456, 0xffffff); + add_bit_samples_helper(output, "field_25", 0x154abe0, 0x1ffffff); + add_bit_samples_helper(output, "field_32", 0x12345678, 0xffffffff); + add_bit_samples_helper(output, "field_40", 0x123456789a, 0xffffffffff); + add_bit_samples_helper(output, "field_48", 0x123456789abc, 0xffffffffffff); + add_bit_samples_helper(output, "field_56", 0x123456789abcde, 0xffffffffffffff); + add_bit_samples_helper(output, "field_64", 0x1234567812345678, 0xffffffffffffffff); +} + // Floating point cases void add_float_samples(std::vector& output) { @@ -533,8 +562,6 @@ std::uint8_t geometry_value [] = { void add_not_implemented_samples(std::vector& output) { - output.emplace_back("types_not_implemented", "field_bit", "regular", - "\xfe", field_type::bit, flags_unsigned); output.emplace_back("types_not_implemented", "field_decimal", "regular", "300", field_type::decimal); output.emplace_back("types_not_implemented", "field_geometry", "regular", @@ -563,6 +590,7 @@ std::vector make_all_samples() { std::vector res; add_int_samples(res); + add_bit_samples(res); add_float_samples(res); add_double_samples(res); add_date_samples(res); @@ -625,10 +653,9 @@ BOOST_DATA_TEST_CASE_F(database_types_fixture, prepared_statement, data::make(al } // The prepared statement param tests binary serialization. -// This test is not applicable (yet) to nullptr values or bit values. -// Doing "field = ?" where ? is nullptr never matches anything. -// Bit values are returned as strings bit need to be sent as integers in -// prepared statements. Filter the cases to remove the ones that +// This test is not applicable (yet) to NULL values. +// Doing "field = ?" where ? is NULL never matches anything. +// Filter the cases to remove the ones that // are not applicable std::vector make_prepared_stmt_param_samples() @@ -637,8 +664,7 @@ make_prepared_stmt_param_samples() res.reserve(all_samples.size()); for (const auto& test : all_samples) { - if (!test.expected_value.is_null() && - test.mvalid.type() != field_type::bit) + if (!test.expected_value.is_null()) { res.push_back(test); } diff --git a/test/integration/db_setup.sql b/test/integration/db_setup.sql index ebc03b6a..68e9a1f2 100644 --- a/test/integration/db_setup.sql +++ b/test/integration/db_setup.sql @@ -404,14 +404,33 @@ INSERT INTO types_binary VALUES ("empty", "", "", "", "", "", "") ; +CREATE TABLE types_bit( + id VARCHAR(50) NOT NULL PRIMARY KEY, + field_1 BIT(1), + field_8 BIT(8), + field_14 BIT(14), + field_16 BIT(16), + field_24 BIT(24), + field_25 BIT(25), + field_32 BIT(32), + field_40 BIT(40), + field_48 BIT(48), + field_56 BIT(56), + field_64 BIT(64) +); +INSERT INTO types_bit VALUES + ("min", 0, 0x00, 0x0000, 0x0000, 0x000000, 0x0000000, 0x00000000, 0x0000000000, 0x000000000000, 0x00000000000000, 0x0000000000000000), + ("regular", 1, 0x9e, 0x1e2a, 0x1234, 0x123456, 0x154abe0, 0x12345678, 0x123456789a, 0x123456789abc, 0x123456789abcde, 0x1234567812345678), + ("max", 1, 0xff, 0x3fff, 0xffff, 0xffffff, 0x1ffffff, 0xffffffff, 0xffffffffff, 0xffffffffffff, 0xffffffffffffff, 0xffffffffffffffff) +; + CREATE TABLE types_not_implemented( id VARCHAR(50) NOT NULL PRIMARY KEY, - field_bit BIT(8), field_decimal DECIMAL, field_geometry GEOMETRY ); INSERT INTO types_not_implemented VALUES - ("regular", 0xfe, 300, POINT(1, 2)) + ("regular", 300, POINT(1, 2)) ; CREATE TABLE types_flags( diff --git a/test/integration/execute_statement.cpp b/test/integration/execute_statement.cpp index 3fd57e73..4a976b02 100644 --- a/test/integration/execute_statement.cpp +++ b/test/integration/execute_statement.cpp @@ -5,7 +5,7 @@ // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // -#include "boost/mysql/execute_params.hpp" +#include #include "integration_test_common.hpp" #include diff --git a/test/integration/handshake.cpp b/test/integration/handshake.cpp index 42f0e633..23a93ce3 100644 --- a/test/integration/handshake.cpp +++ b/test/integration/handshake.cpp @@ -5,8 +5,8 @@ // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // -#include "boost/mysql/connection.hpp" -#include "boost/mysql/connection_params.hpp" +#include +#include #include "integration_test_common.hpp" #include "network_functions.hpp" #include "test_common.hpp" @@ -50,7 +50,7 @@ void do_handshake_ok( ssl_mode ssl ) { - auto result = do_handshake(conn, params, net, ssl); + network_result result = do_handshake(conn, params, net, ssl); result.validate_no_error(); validate_ssl(conn, ssl); } diff --git a/test/integration/integration_test_common.hpp b/test/integration/integration_test_common.hpp index db9aff27..0edfd331 100644 --- a/test/integration/integration_test_common.hpp +++ b/test/integration/integration_test_common.hpp @@ -8,7 +8,7 @@ #ifndef BOOST_MYSQL_TEST_INTEGRATION_INTEGRATION_TEST_COMMON_HPP #define BOOST_MYSQL_TEST_INTEGRATION_INTEGRATION_TEST_COMMON_HPP -#include "boost/mysql/connection.hpp" +#include #include #include #include diff --git a/test/integration/metadata_validator.hpp b/test/integration/metadata_validator.hpp index 58092efd..4df26119 100644 --- a/test/integration/metadata_validator.hpp +++ b/test/integration/metadata_validator.hpp @@ -8,7 +8,7 @@ #ifndef BOOST_MYSQL_TEST_INTEGRATION_METADATA_VALIDATOR_HPP #define BOOST_MYSQL_TEST_INTEGRATION_METADATA_VALIDATOR_HPP -#include "boost/mysql/metadata.hpp" +#include #include namespace boost { diff --git a/test/integration/network_functions.hpp b/test/integration/network_functions.hpp index 77aef3ec..42dd291b 100644 --- a/test/integration/network_functions.hpp +++ b/test/integration/network_functions.hpp @@ -8,7 +8,7 @@ #ifndef BOOST_MYSQL_TEST_INTEGRATION_NETWORK_FUNCTIONS_HPP #define BOOST_MYSQL_TEST_INTEGRATION_NETWORK_FUNCTIONS_HPP -#include "boost/mysql/connection.hpp" +#include #include "tcp_future_socket.hpp" #include #include @@ -61,7 +61,7 @@ struct network_result_base const std::vector& expected_msg ) const { - validate_error(detail::make_error_code(expected_errc), expected_msg); + validate_error(make_error_code(expected_errc), expected_msg); } }; diff --git a/test/integration/network_functions/async_callback.cpp b/test/integration/network_functions/async_callback.cpp index cddad195..79c68944 100644 --- a/test/integration/network_functions/async_callback.cpp +++ b/test/integration/network_functions/async_callback.cpp @@ -6,7 +6,7 @@ // -#include "boost/mysql/execute_params.hpp" +#include #include "network_functions_impl.hpp" #include #include diff --git a/test/integration/network_functions/async_coroutine.cpp b/test/integration/network_functions/async_coroutine.cpp index 448c28ad..af635f55 100644 --- a/test/integration/network_functions/async_coroutine.cpp +++ b/test/integration/network_functions/async_coroutine.cpp @@ -39,7 +39,7 @@ class async_coroutine_errinfo : public network_functions std::promise> prom; boost::asio::spawn(obj.get_executor(), [&](yield_context yield) { - error_code ec = boost::mysql::detail::make_error_code(errc::no); + error_code ec = boost::mysql::make_error_code(errc::no); error_info info ("error_info not cleared properly"); R result = cb(yield[ec], info); prom.set_value(network_result(ec, std::move(info), std::move(result))); @@ -185,7 +185,7 @@ class async_coroutine_noerrinfo : public network_functions std::promise> prom; boost::asio::spawn(obj.get_executor(), [&](yield_context yield) { - error_code ec = boost::mysql::detail::make_error_code(errc::no); + error_code ec = boost::mysql::make_error_code(errc::no); R result = cb(yield[ec]); prom.set_value(network_result(ec, std::move(result))); }); diff --git a/test/integration/network_functions/sync.cpp b/test/integration/network_functions/sync.cpp index eb3b8f98..2f726e66 100644 --- a/test/integration/network_functions/sync.cpp +++ b/test/integration/network_functions/sync.cpp @@ -35,7 +35,7 @@ class sync_errc : public network_functions static network_result> impl(Callable&& cb) { network_result> res ( - boost::mysql::detail::make_error_code(errc::no), + boost::mysql::make_error_code(errc::no), error_info("error_info not cleared properly") ); res.value = cb(res.err, *res.info); diff --git a/test/integration/prepare_statement.cpp b/test/integration/prepare_statement.cpp index 47e152cc..6fdfc640 100644 --- a/test/integration/prepare_statement.cpp +++ b/test/integration/prepare_statement.cpp @@ -5,7 +5,7 @@ // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // -#include "boost/mysql/prepared_statement.hpp" +#include #include "integration_test_common.hpp" #include diff --git a/test/integration/query.cpp b/test/integration/query.cpp index 5d9e28ca..3c1f2cd8 100644 --- a/test/integration/query.cpp +++ b/test/integration/query.cpp @@ -5,18 +5,13 @@ // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // -#include "boost/mysql/connection.hpp" +#include #include "metadata_validator.hpp" #include "integration_test_common.hpp" #include "test_common.hpp" -namespace net = boost::asio; using namespace boost::mysql::test; -using boost::mysql::detail::make_error_code; -using boost::mysql::field_metadata; -using boost::mysql::field_type; using boost::mysql::errc; -using boost::mysql::resultset; BOOST_AUTO_TEST_SUITE(test_query) diff --git a/test/integration/resultset.cpp b/test/integration/resultset.cpp index 64f11a2d..ccb21159 100644 --- a/test/integration/resultset.cpp +++ b/test/integration/resultset.cpp @@ -5,8 +5,8 @@ // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // -#include "boost/mysql/resultset.hpp" -#include "boost/mysql/row.hpp" +#include +#include #include "integration_test_common.hpp" #include "test_common.hpp" #include diff --git a/test/unit/connection.cpp b/test/unit/connection.cpp index f38fe2cd..29bdf73a 100644 --- a/test/unit/connection.cpp +++ b/test/unit/connection.cpp @@ -5,7 +5,7 @@ // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // -#include "boost/mysql/connection.hpp" +#include #include "test_stream.hpp" #include #include @@ -95,16 +95,4 @@ BOOST_AUTO_TEST_CASE(connection_rebind_executor) BOOST_TEST((std::is_same::value)); } -BOOST_AUTO_TEST_CASE(socket_connection_rebind_executor) -{ - using rebound_type = boost::mysql::tcp_connection::rebind_executor::other; - using expected_type = boost::mysql::socket_connection< - boost::asio::basic_stream_socket< - boost::asio::ip::tcp, - other_executor - > - >; - BOOST_TEST((std::is_same::value)); -} - BOOST_AUTO_TEST_SUITE_END() // test_connection diff --git a/test/unit/detail/auth/auth_calculator.cpp b/test/unit/detail/auth/auth_calculator.cpp index 987090d5..6c44757c 100644 --- a/test/unit/detail/auth/auth_calculator.cpp +++ b/test/unit/detail/auth/auth_calculator.cpp @@ -5,7 +5,7 @@ // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // -#include "boost/mysql/detail/auth/auth_calculator.hpp" +#include #include "test_common.hpp" using namespace boost::mysql::detail; diff --git a/test/unit/detail/auxiliar/static_string.cpp b/test/unit/detail/auxiliar/static_string.cpp index 67c10072..c991b7ec 100644 --- a/test/unit/detail/auxiliar/static_string.cpp +++ b/test/unit/detail/auxiliar/static_string.cpp @@ -5,7 +5,7 @@ // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // -#include "boost/mysql/detail/auxiliar/static_string.hpp" +#include #include using boost::mysql::detail::static_string; diff --git a/test/unit/detail/auxiliar/value_type_traits.cpp b/test/unit/detail/auxiliar/value_type_traits.cpp index 16efc8be..f65dd1b7 100644 --- a/test/unit/detail/auxiliar/value_type_traits.cpp +++ b/test/unit/detail/auxiliar/value_type_traits.cpp @@ -10,7 +10,7 @@ #include #include #include -#include "boost/mysql/detail/auxiliar/value_type_traits.hpp" +#include #include #include #include diff --git a/test/unit/detail/protocol/binary_deserialization_error.cpp b/test/unit/detail/protocol/binary_deserialization_error.cpp index d258e48b..30d6cdbd 100644 --- a/test/unit/detail/protocol/binary_deserialization_error.cpp +++ b/test/unit/detail/protocol/binary_deserialization_error.cpp @@ -7,7 +7,8 @@ // Test deserialize_binary_value(), only error cases -#include "boost/mysql/detail/protocol/binary_deserialization.hpp" +#include +#include #include "test_common.hpp" #include #include @@ -70,6 +71,19 @@ void add_int_samples( bytestring(num_bytes, 0x0a), type, column_flags::unsigned_, errc::incomplete_message)); } +void add_bit_samples( + std::vector& output +) +{ + output.emplace_back(binary_value_err_sample("bit_error_deserializing_string_view", + {0x01}, protocol_field_type::bit, column_flags::unsigned_, errc::incomplete_message)); + output.emplace_back(binary_value_err_sample("bit_string_view_too_short", + {0x00}, protocol_field_type::bit, column_flags::unsigned_)); + output.emplace_back(binary_value_err_sample("bit_string_view_too_long", + {0x09, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09}, + protocol_field_type::bit, column_flags::unsigned_)); +} + void add_float_samples(std::vector& output) { output.push_back(binary_value_err_sample("not_enough_space", {0x01, 0x02, 0x03}, @@ -238,6 +252,7 @@ std::vector make_all_samples() add_int_samples(protocol_field_type::long_, 3, res); add_int_samples(protocol_field_type::longlong, 7, res); add_int_samples(protocol_field_type::year, 1, res); + add_bit_samples(res); add_float_samples(res); add_double_samples(res); add_date_samples(res); diff --git a/test/unit/detail/protocol/binary_deserialization_value.cpp b/test/unit/detail/protocol/binary_deserialization_value.cpp index 4cdd6745..a7b1ec52 100644 --- a/test/unit/detail/protocol/binary_deserialization_value.cpp +++ b/test/unit/detail/protocol/binary_deserialization_value.cpp @@ -5,7 +5,7 @@ // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // -#include "boost/mysql/detail/protocol/binary_deserialization.hpp" +#include #include "test_common.hpp" #include #include @@ -70,8 +70,6 @@ void add_string_samples(std::vector& output) {0x04, 0x74, 0x65, 0x73, 0x74}, "test", protocol_field_type::string, column_flags::enum_)); output.push_back(binary_value_sample("set", {0x04, 0x74, 0x65, 0x73, 0x74}, "test", protocol_field_type::string, column_flags::set)); - output.push_back(binary_value_sample("bit", - {0x02, 0x02, 0x01}, "\2\1", protocol_field_type::bit)); output.push_back(binary_value_sample("decimal", {0x02, 0x31, 0x30}, "10", protocol_field_type::newdecimal)); output.push_back(binary_value_sample("geomtry", @@ -121,6 +119,35 @@ void add_int_samples(std::vector& output) protocol_field_type::year, column_flags::unsigned_)); } +// bit +void add_bit_types(std::vector& output) +{ + output.push_back(binary_value_sample("bit_8", + {0x01, 0x12}, std::uint64_t(0x12), + protocol_field_type::bit, column_flags::unsigned_)); + output.push_back(binary_value_sample("bit_16", + {0x02, 0x12, 0x34}, std::uint64_t(0x1234), + protocol_field_type::bit, column_flags::unsigned_)); + output.push_back(binary_value_sample("bit_24", + {0x03, 0x12, 0x34, 0x56}, std::uint64_t(0x123456), + protocol_field_type::bit, column_flags::unsigned_)); + output.push_back(binary_value_sample("bit_32", + {0x04, 0x12, 0x34, 0x56, 0x78}, std::uint64_t(0x12345678), + protocol_field_type::bit, column_flags::unsigned_)); + output.push_back(binary_value_sample("bit_40", + {0x05, 0x12, 0x34, 0x56, 0x78, 0x9a}, std::uint64_t(0x123456789a), + protocol_field_type::bit, column_flags::unsigned_)); + output.push_back(binary_value_sample("bit_48", + {0x06, 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc}, std::uint64_t(0x123456789abc), + protocol_field_type::bit, column_flags::unsigned_)); + output.push_back(binary_value_sample("bit_56", + {0x07, 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde}, std::uint64_t(0x123456789abcde), + protocol_field_type::bit, column_flags::unsigned_)); + output.push_back(binary_value_sample("bit_64", + {0x08, 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0}, std::uint64_t(0x123456789abcdef0), + protocol_field_type::bit, column_flags::unsigned_)); +} + void add_float_samples(std::vector& output) { output.push_back(binary_value_sample("fractional_negative", {0x66, 0x66, 0x86, 0xc0}, @@ -317,6 +344,7 @@ std::vector make_all_samples() std::vector res; add_string_samples(res); add_int_samples(res); + add_bit_types(res); add_float_samples(res); add_double_samples(res); add_date_samples(res); diff --git a/test/unit/detail/protocol/capabilities.cpp b/test/unit/detail/protocol/capabilities.cpp index 09c2f162..8081f636 100644 --- a/test/unit/detail/protocol/capabilities.cpp +++ b/test/unit/detail/protocol/capabilities.cpp @@ -5,7 +5,7 @@ // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // -#include "boost/mysql/detail/protocol/capabilities.hpp" +#include #include using namespace boost::mysql::detail; diff --git a/test/unit/detail/protocol/date.cpp b/test/unit/detail/protocol/date.cpp index 2d597819..386c8392 100644 --- a/test/unit/detail/protocol/date.cpp +++ b/test/unit/detail/protocol/date.cpp @@ -5,7 +5,7 @@ // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // -#include "boost/mysql/detail/protocol/date.hpp" +#include #include "test_common.hpp" #include #include diff --git a/test/unit/detail/protocol/null_bitmap_traits.cpp b/test/unit/detail/protocol/null_bitmap_traits.cpp index 91152d89..45160735 100644 --- a/test/unit/detail/protocol/null_bitmap_traits.cpp +++ b/test/unit/detail/protocol/null_bitmap_traits.cpp @@ -5,7 +5,7 @@ // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // -#include "boost/mysql/detail/protocol/null_bitmap_traits.hpp" +#include #include "test_common.hpp" #include #include diff --git a/test/unit/detail/protocol/row_deserialization.cpp b/test/unit/detail/protocol/row_deserialization.cpp index 7c0c660c..53b67b09 100644 --- a/test/unit/detail/protocol/row_deserialization.cpp +++ b/test/unit/detail/protocol/row_deserialization.cpp @@ -7,9 +7,9 @@ // Tests for both deserialize_binary_row() and deserialize_text_row() -#include "boost/mysql/detail/protocol/text_deserialization.hpp" -#include "boost/mysql/detail/protocol/binary_deserialization.hpp" -#include "boost/mysql/detail/network_algorithms/common.hpp" // for deserialize_row_fn +#include +#include +#include // for deserialize_row_fn #include "test_common.hpp" #include #include diff --git a/test/unit/detail/protocol/serialization_test.hpp b/test/unit/detail/protocol/serialization_test.hpp index 03220f29..41b7d482 100644 --- a/test/unit/detail/protocol/serialization_test.hpp +++ b/test/unit/detail/protocol/serialization_test.hpp @@ -8,8 +8,8 @@ #ifndef BOOST_MYSQL_TEST_UNIT_DETAIL_PROTOCOL_SERIALIZATION_TEST_HPP #define BOOST_MYSQL_TEST_UNIT_DETAIL_PROTOCOL_SERIALIZATION_TEST_HPP -#include "boost/mysql/detail/protocol/serialization.hpp" -#include "boost/mysql/detail/protocol/constants.hpp" +#include +#include #include #include #include "test_common.hpp" diff --git a/test/unit/detail/protocol/serialization_test_samples/basic_types.hpp b/test/unit/detail/protocol/serialization_test_samples/basic_types.hpp index 9306aee0..75b7298d 100644 --- a/test/unit/detail/protocol/serialization_test_samples/basic_types.hpp +++ b/test/unit/detail/protocol/serialization_test_samples/basic_types.hpp @@ -8,7 +8,7 @@ #ifndef BOOST_MYSQL_TEST_UNIT_DETAIL_PROTOCOL_SERIALIZATION_TEST_SAMPLES_BASIC_TYPES_HPP #define BOOST_MYSQL_TEST_UNIT_DETAIL_PROTOCOL_SERIALIZATION_TEST_SAMPLES_BASIC_TYPES_HPP -#include "boost/mysql/detail/protocol/serialization.hpp" +#include #include "../serialization_test.hpp" diff --git a/test/unit/detail/protocol/serialization_test_samples/binary_serialization.hpp b/test/unit/detail/protocol/serialization_test_samples/binary_serialization.hpp index 8383f636..1ea27b22 100644 --- a/test/unit/detail/protocol/serialization_test_samples/binary_serialization.hpp +++ b/test/unit/detail/protocol/serialization_test_samples/binary_serialization.hpp @@ -9,7 +9,7 @@ #define BOOST_MYSQL_TEST_UNIT_DETAIL_PROTOCOL_SERIALIZATION_TEST_SAMPLES_BINARY_SERIALIZATION_HPP -#include "boost/mysql/detail/protocol/binary_serialization.hpp" +#include #include "../serialization_test.hpp" namespace boost { diff --git a/test/unit/detail/protocol/serialization_test_samples/common_messages.hpp b/test/unit/detail/protocol/serialization_test_samples/common_messages.hpp index 690508bc..1cd0acef 100644 --- a/test/unit/detail/protocol/serialization_test_samples/common_messages.hpp +++ b/test/unit/detail/protocol/serialization_test_samples/common_messages.hpp @@ -8,7 +8,7 @@ #ifndef BOOST_MYSQL_TEST_UNIT_DETAIL_PROTOCOL_SERIALIZATION_TEST_SAMPLES_COMMON_MESSAGES_HPP #define BOOST_MYSQL_TEST_UNIT_DETAIL_PROTOCOL_SERIALIZATION_TEST_SAMPLES_COMMON_MESSAGES_HPP -#include "boost/mysql/detail/protocol/common_messages.hpp" +#include #include "../serialization_test.hpp" namespace boost { diff --git a/test/unit/detail/protocol/serialization_test_samples/handshake_messages.hpp b/test/unit/detail/protocol/serialization_test_samples/handshake_messages.hpp index 0b0705e8..54df56b3 100644 --- a/test/unit/detail/protocol/serialization_test_samples/handshake_messages.hpp +++ b/test/unit/detail/protocol/serialization_test_samples/handshake_messages.hpp @@ -8,7 +8,7 @@ #ifndef BOOST_MYSQL_TEST_UNIT_DETAIL_PROTOCOL_SERIALIZATION_TEST_SAMPLES_HANDSHAKE_MESSAGES_HPP #define BOOST_MYSQL_TEST_UNIT_DETAIL_PROTOCOL_SERIALIZATION_TEST_SAMPLES_HANDSHAKE_MESSAGES_HPP -#include "boost/mysql/detail/protocol/handshake_messages.hpp" +#include #include "../serialization_test.hpp" diff --git a/test/unit/detail/protocol/serialization_test_samples/prepared_statement_messages.hpp b/test/unit/detail/protocol/serialization_test_samples/prepared_statement_messages.hpp index 55a0ad54..7f1b7b4b 100644 --- a/test/unit/detail/protocol/serialization_test_samples/prepared_statement_messages.hpp +++ b/test/unit/detail/protocol/serialization_test_samples/prepared_statement_messages.hpp @@ -8,7 +8,7 @@ #ifndef BOOST_MYSQL_TEST_UNIT_DETAIL_PROTOCOL_SERIALIZATION_TEST_SAMPLES_PREPARED_STATEMENT_MESSAGES_HPP #define BOOST_MYSQL_TEST_UNIT_DETAIL_PROTOCOL_SERIALIZATION_TEST_SAMPLES_PREPARED_STATEMENT_MESSAGES_HPP -#include "boost/mysql/detail/protocol/prepared_statement_messages.hpp" +#include #include "../serialization_test.hpp" #include #include diff --git a/test/unit/detail/protocol/serialization_test_samples/query_messages.hpp b/test/unit/detail/protocol/serialization_test_samples/query_messages.hpp index 9d5981c5..4cd0c7c4 100644 --- a/test/unit/detail/protocol/serialization_test_samples/query_messages.hpp +++ b/test/unit/detail/protocol/serialization_test_samples/query_messages.hpp @@ -8,7 +8,7 @@ #ifndef BOOST_MYSQL_TEST_UNIT_DETAIL_PROTOCOL_SERIALIZATION_TEST_SAMPLES_QUERY_MESSAGES_HPP #define BOOST_MYSQL_TEST_UNIT_DETAIL_PROTOCOL_SERIALIZATION_TEST_SAMPLES_QUERY_MESSAGES_HPP -#include "boost/mysql/detail/protocol/query_messages.hpp" +#include #include "../serialization_test.hpp" namespace boost { diff --git a/test/unit/detail/protocol/text_deserialization_error.cpp b/test/unit/detail/protocol/text_deserialization_error.cpp index e380595f..3b39272f 100644 --- a/test/unit/detail/protocol/text_deserialization_error.cpp +++ b/test/unit/detail/protocol/text_deserialization_error.cpp @@ -7,7 +7,7 @@ // Test deserialize_text_value(), only error cases -#include "boost/mysql/detail/protocol/text_deserialization.hpp" +#include #include "test_common.hpp" #include #include @@ -72,6 +72,14 @@ void add_int_samples( output.emplace_back("unsigned_gt_max", "18446744073709551616", t, column_flags::unsigned_); } +void add_bit_samples( + std::vector& output +) +{ + output.emplace_back("bit_string_view_too_short", "", protocol_field_type::bit, column_flags::unsigned_); + output.emplace_back("bit_string_view_too_long", "123456789", protocol_field_type::bit, column_flags::unsigned_); +} + void add_float_samples( protocol_field_type t, boost::string_view lt_min, @@ -237,6 +245,7 @@ std::vector make_all_samples() add_int_samples(protocol_field_type::long_, res); add_int_samples(protocol_field_type::longlong, res); add_int_samples(protocol_field_type::year, res); + add_bit_samples(res); add_float_samples(protocol_field_type::float_, "-2e90", "2e90", res); add_float_samples(protocol_field_type::double_, "-2e9999", "2e9999", res); add_date_samples(res); diff --git a/test/unit/detail/protocol/text_deserialization_value.cpp b/test/unit/detail/protocol/text_deserialization_value.cpp index 7adc67b5..228962b9 100644 --- a/test/unit/detail/protocol/text_deserialization_value.cpp +++ b/test/unit/detail/protocol/text_deserialization_value.cpp @@ -7,7 +7,7 @@ // Test deserialize_text_value(), just positive cases -#include "boost/mysql/detail/protocol/text_deserialization.hpp" +#include #include "test_common.hpp" #include #include @@ -69,7 +69,6 @@ void add_string_samples(std::vector& output) output.emplace_back("enum", "value", "value", protocol_field_type::string, column_flags::enum_); output.emplace_back("set", "value1,value2", "value1,value2", protocol_field_type::string, column_flags::set); - output.emplace_back("bit", "\1", "\1", protocol_field_type::bit); output.emplace_back("decimal", "\1", "\1", protocol_field_type::newdecimal); output.emplace_back("geometry", "\1", "\1", protocol_field_type::geometry, column_flags::binary | column_flags::blob); @@ -162,6 +161,27 @@ void add_int_samples(std::vector& output) output.emplace_back("zero", "0000", std::uint64_t(0), protocol_field_type::year, column_flags::unsigned_); } +// bit +void add_bit_types(std::vector& output) +{ + output.emplace_back("bit_8", "\x12", std::uint64_t(0x12), + protocol_field_type::bit, column_flags::unsigned_); + output.emplace_back("bit_16", "\x12\x34", std::uint64_t(0x1234), + protocol_field_type::bit, column_flags::unsigned_); + output.emplace_back("bit_24", "\x12\x34\x56", std::uint64_t(0x123456), + protocol_field_type::bit, column_flags::unsigned_); + output.emplace_back("bit_32", "\x12\x34\x56\x78", std::uint64_t(0x12345678), + protocol_field_type::bit, column_flags::unsigned_); + output.emplace_back("bit_40", "\x12\x34\x56\x78\x9a", std::uint64_t(0x123456789a), + protocol_field_type::bit, column_flags::unsigned_); + output.emplace_back("bit_48", "\x12\x34\x56\x78\x9a\xbc", std::uint64_t(0x123456789abc), + protocol_field_type::bit, column_flags::unsigned_); + output.emplace_back("bit_56", "\x12\x34\x56\x78\x9a\xbc\xde", std::uint64_t(0x123456789abcde), + protocol_field_type::bit, column_flags::unsigned_); + output.emplace_back("bit_64", "\x12\x34\x56\x78\x9a\xbc\xde\xf0", std::uint64_t(0x123456789abcdef0), + protocol_field_type::bit, column_flags::unsigned_); +} + template void add_float_samples( protocol_field_type type, @@ -350,6 +370,7 @@ std::vector make_all_samples() std::vector res; add_string_samples(res); add_int_samples(res); + add_bit_types(res); add_float_samples(protocol_field_type::float_, res); add_float_samples(protocol_field_type::double_, res); add_date_samples(res); diff --git a/test/unit/error.cpp b/test/unit/error.cpp index 7cad6ee2..6d44ea4c 100644 --- a/test/unit/error.cpp +++ b/test/unit/error.cpp @@ -5,7 +5,7 @@ // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // -#include "boost/mysql/error.hpp" +#include #include "test_common.hpp" using boost::mysql::errc; @@ -82,4 +82,11 @@ BOOST_AUTO_TEST_CASE(operator_stream) BOOST_AUTO_TEST_SUITE_END() // test_error_info +// error_code construction from errc +BOOST_AUTO_TEST_CASE(error_code_from_errc) +{ + boost::mysql::error_code code (errc::protocol_value_error); + BOOST_TEST(code.value() == static_cast(errc::protocol_value_error)); +} + BOOST_AUTO_TEST_SUITE_END() // test_error diff --git a/test/unit/execute_params.cpp b/test/unit/execute_params.cpp index dc6ad77c..d658d244 100644 --- a/test/unit/execute_params.cpp +++ b/test/unit/execute_params.cpp @@ -5,8 +5,8 @@ // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // -#include "boost/mysql/execute_params.hpp" -#include "boost/mysql/value.hpp" +#include +#include #include "test_common.hpp" #include "assert_type_equals.hpp" #include diff --git a/test/unit/metadata.cpp b/test/unit/metadata.cpp index 47605ec9..0aa7e7d5 100644 --- a/test/unit/metadata.cpp +++ b/test/unit/metadata.cpp @@ -5,7 +5,7 @@ // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // -#include "boost/mysql/metadata.hpp" +#include #include "test_common.hpp" using namespace boost::mysql::detail; diff --git a/test/unit/prepared_statement.cpp b/test/unit/prepared_statement.cpp index ad472aaa..91c4de64 100644 --- a/test/unit/prepared_statement.cpp +++ b/test/unit/prepared_statement.cpp @@ -5,10 +5,10 @@ // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // -#include "boost/mysql/detail/protocol/channel.hpp" +#include #include "test_common.hpp" #include "test_stream.hpp" -#include "boost/mysql/prepared_statement.hpp" +#include #include #include #include diff --git a/test/unit/resultset.cpp b/test/unit/resultset.cpp index 76ab5cc7..347a6955 100644 --- a/test/unit/resultset.cpp +++ b/test/unit/resultset.cpp @@ -5,8 +5,8 @@ // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // -#include "boost/mysql/resultset.hpp" -#include "boost/mysql/detail/protocol/channel.hpp" +#include +#include #include #include #include diff --git a/test/unit/row.cpp b/test/unit/row.cpp index 952e4a56..8f540c84 100644 --- a/test/unit/row.cpp +++ b/test/unit/row.cpp @@ -5,10 +5,10 @@ // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // -#include "boost/mysql/row.hpp" -#include "boost/mysql/connection.hpp" -#include "boost/mysql/detail/auxiliar/bytestring.hpp" -#include "boost/mysql/value.hpp" +#include +#include +#include +#include #include "test_common.hpp" #include #include diff --git a/test/unit/socket_connection.cpp b/test/unit/socket_connection.cpp new file mode 100644 index 00000000..84ca7d4b --- /dev/null +++ b/test/unit/socket_connection.cpp @@ -0,0 +1,28 @@ +// +// Copyright (c) 2019-2021 Ruben Perez Hidalgo (rubenperez038 at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include +#include +#include + +BOOST_AUTO_TEST_SUITE(test_socket_connection) + +using other_executor = boost::asio::strand; + +BOOST_AUTO_TEST_CASE(socket_connection_rebind_executor) +{ + using rebound_type = boost::mysql::tcp_connection::rebind_executor::other; + using expected_type = boost::mysql::socket_connection< + boost::asio::basic_stream_socket< + boost::asio::ip::tcp, + other_executor + > + >; + BOOST_TEST((std::is_same::value)); +} + +BOOST_AUTO_TEST_SUITE_END() // test_socket_connection \ No newline at end of file diff --git a/test/unit/value.cpp b/test/unit/value.cpp index 28afbb52..e7762d2e 100644 --- a/test/unit/value.cpp +++ b/test/unit/value.cpp @@ -5,7 +5,7 @@ // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // -#include "boost/mysql/value.hpp" +#include #include "test_common.hpp" #include #include diff --git a/test/unit/value_constexpr.cpp b/test/unit/value_constexpr.cpp index 60d95603..eb28cc30 100644 --- a/test/unit/value_constexpr.cpp +++ b/test/unit/value_constexpr.cpp @@ -5,7 +5,7 @@ // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // -#include "boost/mysql/value.hpp" +#include #include "test_common.hpp" #include #include diff --git a/tools/build_windows_b2.bat b/tools/build_windows_b2.bat index 0f0d9967..5fcdca65 100644 --- a/tools/build_windows_b2.bat +++ b/tools/build_windows_b2.bat @@ -33,7 +33,7 @@ IF DEFINED SCRIPT ( ) ELSE ( set SELF_S=%SELF:\=/% REM Echo the complete build command to the build log - ECHO b2 --abbreviate-paths libs/!SELF_S!/test %B2_TOOLCXX% %B2_CXXSTD% %B2_CXXFLAGS% %B2_DEFINES% %B2_THREADING% %B2_ADDRESS_MODEL% %B2_LINK% %B2_VARIANT% -j3 %* + ECHO b2 --abbreviate-paths libs/!SELF_S!/test %B2_TOOLCXX% %B2_CXXSTD% %B2_CXXFLAGS% %B2_DEFINES% %B2_THREADING% %B2_ADDRESS_MODEL% %B2_LINK% %B2_VARIANT% -j4 %* REM Now go build... - b2 --abbreviate-paths libs/!SELF_S!/test %B2_TOOLCXX% %B2_CXXSTD% %B2_CXXFLAGS% %B2_DEFINES% %B2_THREADING% %B2_ADDRESS_MODEL% %B2_LINK% %B2_VARIANT% -j3 %* + b2 --abbreviate-paths libs/!SELF_S!/test %B2_TOOLCXX% %B2_CXXSTD% %B2_CXXFLAGS% %B2_DEFINES% %B2_THREADING% %B2_ADDRESS_MODEL% %B2_LINK% %B2_VARIANT% -j4 %* ) diff --git a/tools/file_headers.py b/tools/file_headers.py index 1cdd5c6d..dcbc2c30 100644 --- a/tools/file_headers.py +++ b/tools/file_headers.py @@ -216,7 +216,7 @@ DESCRIPTIONS_TEMPLATE=''' #ifndef BOOST_MYSQL_IMPL_ERROR_DESCRIPTIONS_HPP #define BOOST_MYSQL_IMPL_ERROR_DESCRIPTIONS_HPP -#include "boost/mysql/errc.hpp" +#include namespace boost {{ namespace mysql {{