diff --git a/include/mysql/connection.hpp b/include/mysql/connection.hpp index 85dfd004..f9bb16b4 100644 --- a/include/mysql/connection.hpp +++ b/include/mysql/connection.hpp @@ -3,7 +3,6 @@ #include "mysql/impl/channel.hpp" #include "mysql/impl/handshake.hpp" -#include "mysql/impl/capabilities.hpp" #include "mysql/error.hpp" #include @@ -17,7 +16,6 @@ class connection { Stream next_level_; detail::channel channel_; - detail::capabilities caps_; std::vector buffer_; public: template diff --git a/include/mysql/impl/channel.hpp b/include/mysql/impl/channel.hpp index f2f695ba..b6656fe0 100644 --- a/include/mysql/impl/channel.hpp +++ b/include/mysql/impl/channel.hpp @@ -3,6 +3,7 @@ #include "mysql/error.hpp" #include "mysql/impl/basic_types.hpp" +#include "mysql/impl/capabilities.hpp" #include #include #include @@ -20,6 +21,7 @@ class channel AsyncStream& next_layer_; std::uint8_t sequence_number_ {0}; std::array header_buffer_ {}; // for async ops + capabilities current_caps_; bool process_sequence_number(std::uint8_t got); std::uint8_t next_sequence_number() { return sequence_number_++; } @@ -47,6 +49,9 @@ public: using stream_type = AsyncStream; stream_type& next_layer() { return next_layer_; } + + capabilities current_capabilities() const noexcept { return current_caps_; } + void set_current_capabilities(capabilities value) noexcept { current_caps_ = value; } }; } diff --git a/include/mysql/impl/connection_impl.hpp b/include/mysql/impl/connection_impl.hpp index ac2dad40..24c8c608 100644 --- a/include/mysql/impl/connection_impl.hpp +++ b/include/mysql/impl/connection_impl.hpp @@ -10,7 +10,7 @@ void mysql::connection::handshake( error_code& errc ) { - detail::hanshake(channel_, params, buffer_, caps_, errc); + detail::hanshake(channel_, params, buffer_, errc); // TODO: should we close() the stream in case of error? } @@ -36,7 +36,6 @@ mysql::connection::async_handshake( channel_, params, buffer_, - caps_, std::forward(token) ); } diff --git a/include/mysql/impl/handshake.hpp b/include/mysql/impl/handshake.hpp index 8f604d3e..f9ce65ee 100644 --- a/include/mysql/impl/handshake.hpp +++ b/include/mysql/impl/handshake.hpp @@ -4,7 +4,6 @@ #include #include #include "mysql/impl/channel.hpp" -#include "mysql/impl/capabilities.hpp" #include "mysql/impl/constants.hpp" #include "mysql/impl/basic_types.hpp" #include "mysql/collation.hpp" @@ -27,7 +26,6 @@ void hanshake( ChannelType& channel, const handshake_params& params, bytestring& buffer, - capabilities& output_capabilities, error_code& err ); @@ -37,7 +35,6 @@ async_handshake( ChannelType& channel, const handshake_params& params, bytestring& buffer, - capabilities& output_capabilities, CompletionToken&& token ); diff --git a/include/mysql/impl/handshake_impl.hpp b/include/mysql/impl/handshake_impl.hpp index edc5b01c..ff5a5390 100644 --- a/include/mysql/impl/handshake_impl.hpp +++ b/include/mysql/impl/handshake_impl.hpp @@ -234,7 +234,6 @@ void mysql::detail::hanshake( ChannelType& channel, const handshake_params& params, bytestring& buffer, - capabilities& output_capabilities, error_code& err ) { @@ -279,7 +278,7 @@ void mysql::detail::hanshake( err = processor.process_auth_switch_response(boost::asio::buffer(buffer)); if (err) return; - output_capabilities = processor.negotiated_capabilities(); + channel.set_current_capabilities(processor.negotiated_capabilities()); } template @@ -288,7 +287,6 @@ mysql::detail::async_handshake( ChannelType& channel, const handshake_params& params, bytestring& buffer, - capabilities& output_capabilities, CompletionToken&& token ) { @@ -304,26 +302,23 @@ mysql::detail::async_handshake( ChannelType& channel_; bytestring& buffer_; handshake_processor processor_; - capabilities* output_capabilities_; Op( HandlerType&& handler, ChannelType& channel, bytestring& buffer, - const handshake_params& params, - capabilities* output_capabilities + const handshake_params& params ): BaseType(std::move(handler), channel.next_layer().get_executor()), channel_(channel), buffer_(buffer), - processor_(params), - output_capabilities_(output_capabilities) + processor_(params) { } void complete(bool cont, error_code errc) { - *output_capabilities_ = processor_.negotiated_capabilities(); + channel_.set_current_capabilities(processor_.negotiated_capabilities()); BaseType::complete(cont, errc); } @@ -409,8 +404,7 @@ mysql::detail::async_handshake( std::move(initiator.completion_handler), channel, buffer, - params, - &output_capabilities + params )(error_code(), false); return initiator.result.get(); } diff --git a/include/mysql/impl/messages.hpp b/include/mysql/impl/messages.hpp index a028d4b3..c9114784 100644 --- a/include/mysql/impl/messages.hpp +++ b/include/mysql/impl/messages.hpp @@ -37,7 +37,7 @@ struct ok_packet int_lenenc last_insert_id; int2 status_flags; // server_status_flags int2 warnings; - // TODO: CLIENT_SESSION_TRACK. This may require separate serialization functions + // TODO: CLIENT_SESSION_TRACK string_lenenc info; static constexpr auto fields = std::make_tuple( diff --git a/include/mysql/metadata.hpp b/include/mysql/metadata.hpp index 609254aa..b74af77d 100644 --- a/include/mysql/metadata.hpp +++ b/include/mysql/metadata.hpp @@ -50,7 +50,7 @@ public: }; template -class dataset_metadata +class resultset_metadata { std::vector> fields_; public: diff --git a/include/mysql/row.hpp b/include/mysql/row.hpp index 4e77d34f..edab92f5 100644 --- a/include/mysql/row.hpp +++ b/include/mysql/row.hpp @@ -13,10 +13,11 @@ class row { detail::bytestring buffer_; std::vector values_; - const dataset_metadata* metadata_; + const resultset_metadata* metadata_; public: + row(): metadata_(nullptr) {}; row(detail::bytestring&& buffer, std::vector&& values, - const dataset_metadata& meta): + const resultset_metadata& meta): buffer_(std::move(buffer)), values_(std::move(values)), metadata_(&meta) {}; row(const row&) = delete; row(row&&) = default; @@ -26,6 +27,10 @@ public: const std::vector& values() const noexcept { return values_; } const auto& metadata() const noexcept { return *metadata_; } + + // TODO: can we make these private? accessed by resultset + auto& buffer() { return buffer_; } + auto& values() { return values_; } }; }