mirror of
https://github.com/boostorg/mysql.git
synced 2026-02-15 01:02:17 +00:00
Moved capabilities from connection to channel
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
|
||||
#include "mysql/impl/channel.hpp"
|
||||
#include "mysql/impl/handshake.hpp"
|
||||
#include "mysql/impl/capabilities.hpp"
|
||||
#include "mysql/error.hpp"
|
||||
#include <vector>
|
||||
|
||||
@@ -17,7 +16,6 @@ class connection
|
||||
{
|
||||
Stream next_level_;
|
||||
detail::channel<Stream> channel_;
|
||||
detail::capabilities caps_;
|
||||
std::vector<std::uint8_t> buffer_;
|
||||
public:
|
||||
template <typename... Args>
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include "mysql/error.hpp"
|
||||
#include "mysql/impl/basic_types.hpp"
|
||||
#include "mysql/impl/capabilities.hpp"
|
||||
#include <boost/asio/buffer.hpp>
|
||||
#include <boost/asio/async_result.hpp>
|
||||
#include <array>
|
||||
@@ -20,6 +21,7 @@ class channel
|
||||
AsyncStream& next_layer_;
|
||||
std::uint8_t sequence_number_ {0};
|
||||
std::array<std::uint8_t, 4> 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; }
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ void mysql::connection<Stream>::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<Stream>::async_handshake(
|
||||
channel_,
|
||||
params,
|
||||
buffer_,
|
||||
caps_,
|
||||
std::forward<CompletionToken>(token)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#include <string_view>
|
||||
#include <boost/asio/async_result.hpp>
|
||||
#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<Allocator>& buffer,
|
||||
capabilities& output_capabilities,
|
||||
error_code& err
|
||||
);
|
||||
|
||||
@@ -37,7 +35,6 @@ async_handshake(
|
||||
ChannelType& channel,
|
||||
const handshake_params& params,
|
||||
bytestring<Allocator>& buffer,
|
||||
capabilities& output_capabilities,
|
||||
CompletionToken&& token
|
||||
);
|
||||
|
||||
|
||||
@@ -234,7 +234,6 @@ void mysql::detail::hanshake(
|
||||
ChannelType& channel,
|
||||
const handshake_params& params,
|
||||
bytestring<Allocator>& 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 <typename ChannelType, typename Allocator, typename CompletionToken>
|
||||
@@ -288,7 +287,6 @@ mysql::detail::async_handshake(
|
||||
ChannelType& channel,
|
||||
const handshake_params& params,
|
||||
bytestring<Allocator>& buffer,
|
||||
capabilities& output_capabilities,
|
||||
CompletionToken&& token
|
||||
)
|
||||
{
|
||||
@@ -304,26 +302,23 @@ mysql::detail::async_handshake(
|
||||
ChannelType& channel_;
|
||||
bytestring<Allocator>& buffer_;
|
||||
handshake_processor processor_;
|
||||
capabilities* output_capabilities_;
|
||||
|
||||
Op(
|
||||
HandlerType&& handler,
|
||||
ChannelType& channel,
|
||||
bytestring<Allocator>& 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();
|
||||
}
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -50,7 +50,7 @@ public:
|
||||
};
|
||||
|
||||
template <typename Allocator>
|
||||
class dataset_metadata
|
||||
class resultset_metadata
|
||||
{
|
||||
std::vector<field_metadata<Allocator>> fields_;
|
||||
public:
|
||||
|
||||
@@ -13,10 +13,11 @@ class row
|
||||
{
|
||||
detail::bytestring<Allocator> buffer_;
|
||||
std::vector<value> values_;
|
||||
const dataset_metadata<Allocator>* metadata_;
|
||||
const resultset_metadata<Allocator>* metadata_;
|
||||
public:
|
||||
row(): metadata_(nullptr) {};
|
||||
row(detail::bytestring<Allocator>&& buffer, std::vector<value>&& values,
|
||||
const dataset_metadata<Allocator>& meta):
|
||||
const resultset_metadata<Allocator>& 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<value>& 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_; }
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user