mirror of
https://github.com/boostorg/mysql.git
synced 2026-02-14 12:52:17 +00:00
Moved msgs into namespace detail
This commit is contained in:
1
TODO.txt
1
TODO.txt
@@ -5,7 +5,6 @@ MVP
|
||||
Add to readme
|
||||
Add travis
|
||||
Sanitize cmake
|
||||
GTest/GMock to be downloaded
|
||||
Namespacing for the exported library (how does export work anyway?)
|
||||
Building tests/examples conditionally
|
||||
Doxygen comments in interface
|
||||
|
||||
@@ -49,7 +49,7 @@ mysql::error_code mysql::detail::channel<AsyncStream>::process_header_read(
|
||||
std::uint32_t& size_to_read
|
||||
)
|
||||
{
|
||||
msgs::packet_header header;
|
||||
packet_header header;
|
||||
DeserializationContext ctx (boost::asio::buffer(header_buffer_), capabilities(0)); // unaffected by capabilities
|
||||
[[maybe_unused]] Error err = deserialize(header, ctx);
|
||||
assert(err == Error::ok); // this should always succeed
|
||||
@@ -66,7 +66,7 @@ void mysql::detail::channel<AsyncStream>::process_header_write(
|
||||
std::uint32_t size_to_write
|
||||
)
|
||||
{
|
||||
msgs::packet_header header;
|
||||
packet_header header;
|
||||
header.packet_size.value = size_to_write;
|
||||
header.sequence_number.value = next_sequence_number();
|
||||
SerializationContext ctx (capabilities(0), header_buffer_.data()); // capabilities not relevant here
|
||||
|
||||
@@ -21,7 +21,7 @@ inline std::uint8_t get_collation_first_byte(collation value)
|
||||
|
||||
inline error_code deserialize_handshake(
|
||||
boost::asio::const_buffer buffer,
|
||||
msgs::handshake& output
|
||||
handshake_packet& output
|
||||
)
|
||||
{
|
||||
std::uint8_t msg_type;
|
||||
@@ -84,7 +84,7 @@ public:
|
||||
handshake_processor(const handshake_params& params): params_(params) {};
|
||||
capabilities negotiated_capabilities() const { return negotiated_caps_; }
|
||||
|
||||
error_code process_capabilities(const msgs::handshake& handshake)
|
||||
error_code process_capabilities(const handshake_packet& handshake)
|
||||
{
|
||||
capabilities server_caps (handshake.capability_falgs.value);
|
||||
capabilities required_caps =
|
||||
@@ -100,7 +100,7 @@ public:
|
||||
}
|
||||
void compose_handshake_response(
|
||||
std::string_view auth_response,
|
||||
msgs::handshake_response& output
|
||||
handshake_response_packet& output
|
||||
)
|
||||
{
|
||||
output.client_flag.value = negotiated_caps_.get();
|
||||
@@ -112,8 +112,8 @@ public:
|
||||
output.client_plugin_name.value = mysql_native_password::plugin_name;
|
||||
}
|
||||
error_code compute_auth_switch_response(
|
||||
const msgs::auth_switch_request& request,
|
||||
msgs::auth_switch_response& output,
|
||||
const auth_switch_request_packet& request,
|
||||
auth_switch_response_packet& output,
|
||||
auth_response_calculator& calc
|
||||
)
|
||||
{
|
||||
@@ -131,7 +131,7 @@ public:
|
||||
error_code process_handshake(bytestring& buffer)
|
||||
{
|
||||
// Deserialize server greeting
|
||||
msgs::handshake handshake;
|
||||
handshake_packet handshake;
|
||||
auto err = deserialize_handshake(boost::asio::buffer(buffer), handshake);
|
||||
if (err) return err;
|
||||
|
||||
@@ -149,7 +149,7 @@ public:
|
||||
}
|
||||
|
||||
// Compose response
|
||||
msgs::handshake_response response;
|
||||
handshake_response_packet response;
|
||||
compose_handshake_response(auth_response, response);
|
||||
|
||||
// Serialize
|
||||
@@ -184,12 +184,12 @@ public:
|
||||
}
|
||||
|
||||
// We have received an auth switch request. Deserialize it
|
||||
msgs::auth_switch_request auth_sw;
|
||||
auth_switch_request_packet auth_sw;
|
||||
err = deserialize_message(auth_sw, ctx);
|
||||
if (err) return err;
|
||||
|
||||
// Compute response
|
||||
msgs::auth_switch_response auth_sw_res;
|
||||
auth_switch_response_packet auth_sw_res;
|
||||
auth_response_calculator calc;
|
||||
err = compute_auth_switch_response(auth_sw, auth_sw_res, calc);
|
||||
if (err) return err;
|
||||
|
||||
@@ -15,9 +15,6 @@ namespace mysql
|
||||
namespace detail
|
||||
{
|
||||
|
||||
namespace msgs
|
||||
{
|
||||
|
||||
struct packet_header
|
||||
{
|
||||
int3 packet_size;
|
||||
@@ -64,7 +61,7 @@ struct err_packet
|
||||
);
|
||||
};
|
||||
|
||||
struct handshake
|
||||
struct handshake_packet
|
||||
{
|
||||
// int<1> protocol version Always 10
|
||||
string_null server_version;
|
||||
@@ -78,17 +75,17 @@ struct handshake
|
||||
std::array<char, 8 + 0xff> auth_plugin_data_buffer; // not an actual protocol field, the merge of two fields
|
||||
|
||||
static constexpr auto fields = std::make_tuple(
|
||||
&handshake::server_version,
|
||||
&handshake::connection_id,
|
||||
&handshake::auth_plugin_data,
|
||||
&handshake::capability_falgs,
|
||||
&handshake::character_set,
|
||||
&handshake::status_flags,
|
||||
&handshake::auth_plugin_name
|
||||
&handshake_packet::server_version,
|
||||
&handshake_packet::connection_id,
|
||||
&handshake_packet::auth_plugin_data,
|
||||
&handshake_packet::capability_falgs,
|
||||
&handshake_packet::character_set,
|
||||
&handshake_packet::status_flags,
|
||||
&handshake_packet::auth_plugin_name
|
||||
);
|
||||
};
|
||||
|
||||
struct handshake_response
|
||||
struct handshake_response_packet
|
||||
{
|
||||
int4 client_flag; // capabilities
|
||||
int4 max_packet_size;
|
||||
@@ -101,37 +98,37 @@ struct handshake_response
|
||||
// TODO: CLIENT_CONNECT_ATTRS
|
||||
|
||||
static constexpr auto fields = std::make_tuple(
|
||||
&handshake_response::client_flag,
|
||||
&handshake_response::max_packet_size,
|
||||
&handshake_response::character_set,
|
||||
&handshake_response::username,
|
||||
&handshake_response::auth_response,
|
||||
&handshake_response::database,
|
||||
&handshake_response::client_plugin_name
|
||||
&handshake_response_packet::client_flag,
|
||||
&handshake_response_packet::max_packet_size,
|
||||
&handshake_response_packet::character_set,
|
||||
&handshake_response_packet::username,
|
||||
&handshake_response_packet::auth_response,
|
||||
&handshake_response_packet::database,
|
||||
&handshake_response_packet::client_plugin_name
|
||||
);
|
||||
};
|
||||
|
||||
struct auth_switch_request
|
||||
struct auth_switch_request_packet
|
||||
{
|
||||
string_null plugin_name;
|
||||
string_eof auth_plugin_data;
|
||||
|
||||
static constexpr auto fields = std::make_tuple(
|
||||
&auth_switch_request::plugin_name,
|
||||
&auth_switch_request::auth_plugin_data
|
||||
&auth_switch_request_packet::plugin_name,
|
||||
&auth_switch_request_packet::auth_plugin_data
|
||||
);
|
||||
};
|
||||
|
||||
struct auth_switch_response
|
||||
struct auth_switch_response_packet
|
||||
{
|
||||
string_eof auth_plugin_data;
|
||||
|
||||
static constexpr auto fields = std::make_tuple(
|
||||
&auth_switch_response::auth_plugin_data
|
||||
&auth_switch_response_packet::auth_plugin_data
|
||||
);
|
||||
};
|
||||
|
||||
struct column_definition
|
||||
struct column_definition_packet
|
||||
{
|
||||
string_lenenc catalog; // always "def"
|
||||
string_lenenc schema;
|
||||
@@ -146,40 +143,39 @@ struct column_definition
|
||||
int1 decimals; // max shown decimal digits. 0x00 for int/static strings; 0x1f for dynamic strings, double, float
|
||||
|
||||
static constexpr auto fields = std::make_tuple(
|
||||
&column_definition::catalog,
|
||||
&column_definition::schema,
|
||||
&column_definition::table,
|
||||
&column_definition::org_table,
|
||||
&column_definition::name,
|
||||
&column_definition::org_name,
|
||||
&column_definition::character_set,
|
||||
&column_definition::column_length,
|
||||
&column_definition::type,
|
||||
&column_definition::flags,
|
||||
&column_definition::decimals
|
||||
&column_definition_packet::catalog,
|
||||
&column_definition_packet::schema,
|
||||
&column_definition_packet::table,
|
||||
&column_definition_packet::org_table,
|
||||
&column_definition_packet::name,
|
||||
&column_definition_packet::org_name,
|
||||
&column_definition_packet::character_set,
|
||||
&column_definition_packet::column_length,
|
||||
&column_definition_packet::type,
|
||||
&column_definition_packet::flags,
|
||||
&column_definition_packet::decimals
|
||||
);
|
||||
};
|
||||
|
||||
// Commands
|
||||
struct com_query
|
||||
struct com_query_packet
|
||||
{
|
||||
string_eof query;
|
||||
|
||||
static constexpr std::uint8_t command_id = 3;
|
||||
static constexpr auto fields = std::make_tuple(
|
||||
&com_query::query
|
||||
&com_query_packet::query
|
||||
);
|
||||
};
|
||||
|
||||
} // msgs
|
||||
|
||||
// serialization functions
|
||||
inline Error deserialize(msgs::ok_packet& output, DeserializationContext& ctx) noexcept;
|
||||
inline Error deserialize(msgs::handshake& output, DeserializationContext& ctx) noexcept;
|
||||
inline std::size_t get_size(const msgs::handshake_response& value, const SerializationContext& ctx) noexcept;
|
||||
inline void serialize(const msgs::handshake_response& value, SerializationContext& ctx) noexcept;
|
||||
inline Error deserialize(msgs::auth_switch_request& output, DeserializationContext& ctx) noexcept;
|
||||
inline Error deserialize(msgs::column_definition& output, DeserializationContext& ctx) noexcept;
|
||||
inline Error deserialize(ok_packet& output, DeserializationContext& ctx) noexcept;
|
||||
inline Error deserialize(handshake_packet& output, DeserializationContext& ctx) noexcept;
|
||||
inline std::size_t get_size(const handshake_response_packet& value, const SerializationContext& ctx) noexcept;
|
||||
inline void serialize(const handshake_response_packet& value, SerializationContext& ctx) noexcept;
|
||||
inline Error deserialize(auth_switch_request_packet& output, DeserializationContext& ctx) noexcept;
|
||||
inline Error deserialize(column_definition_packet& output, DeserializationContext& ctx) noexcept;
|
||||
|
||||
// Helper to serialize top-level messages
|
||||
template <typename Serializable, typename Allocator>
|
||||
@@ -268,4 +264,4 @@ struct StmtClose
|
||||
#include "mysql/impl/messages.ipp"
|
||||
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include <cassert>
|
||||
|
||||
inline mysql::Error mysql::detail::deserialize(
|
||||
msgs::ok_packet& output,
|
||||
ok_packet& output,
|
||||
DeserializationContext& ctx
|
||||
) noexcept
|
||||
{
|
||||
@@ -24,7 +24,7 @@ inline mysql::Error mysql::detail::deserialize(
|
||||
}
|
||||
|
||||
inline mysql::Error mysql::detail::deserialize(
|
||||
msgs::handshake& output,
|
||||
handshake_packet& output,
|
||||
DeserializationContext& ctx
|
||||
) noexcept
|
||||
{
|
||||
@@ -87,7 +87,7 @@ inline mysql::Error mysql::detail::deserialize(
|
||||
}
|
||||
|
||||
std::size_t mysql::detail::get_size(
|
||||
const msgs::handshake_response& value,
|
||||
const handshake_response_packet& value,
|
||||
const SerializationContext& ctx
|
||||
) noexcept
|
||||
{
|
||||
@@ -107,7 +107,7 @@ std::size_t mysql::detail::get_size(
|
||||
}
|
||||
|
||||
inline void mysql::detail::serialize(
|
||||
const msgs::handshake_response& value,
|
||||
const handshake_response_packet& value,
|
||||
SerializationContext& ctx
|
||||
) noexcept
|
||||
{
|
||||
@@ -126,7 +126,7 @@ inline void mysql::detail::serialize(
|
||||
}
|
||||
|
||||
inline mysql::Error mysql::detail::deserialize(
|
||||
msgs::auth_switch_request& output,
|
||||
auth_switch_request_packet& output,
|
||||
DeserializationContext& ctx
|
||||
) noexcept
|
||||
{
|
||||
@@ -142,7 +142,7 @@ inline mysql::Error mysql::detail::deserialize(
|
||||
}
|
||||
|
||||
inline mysql::Error mysql::detail::deserialize(
|
||||
msgs::column_definition& output,
|
||||
column_definition_packet& output,
|
||||
DeserializationContext& ctx
|
||||
) noexcept
|
||||
{
|
||||
@@ -210,7 +210,7 @@ inline mysql::error_code mysql::detail::process_error_packet(
|
||||
DeserializationContext& ctx
|
||||
)
|
||||
{
|
||||
msgs::err_packet error_packet;
|
||||
err_packet error_packet;
|
||||
auto errc = deserialize_message(error_packet, ctx);
|
||||
if (errc) return errc;
|
||||
return make_error_code(static_cast<Error>(error_packet.error_code.value));
|
||||
|
||||
@@ -46,7 +46,7 @@ fetch_result fetch_text_row(
|
||||
const std::vector<field_metadata>& meta,
|
||||
bytestring& buffer,
|
||||
std::vector<value>& output_values,
|
||||
msgs::ok_packet& output_ok_packet,
|
||||
ok_packet& output_ok_packet,
|
||||
error_code& err
|
||||
);
|
||||
|
||||
@@ -57,7 +57,7 @@ async_fetch_text_row(
|
||||
const std::vector<field_metadata>& meta,
|
||||
bytestring& buffer,
|
||||
std::vector<value>& output_values,
|
||||
msgs::ok_packet& output_ok_packet,
|
||||
ok_packet& output_ok_packet,
|
||||
CompletionToken&& token
|
||||
);
|
||||
|
||||
@@ -67,4 +67,4 @@ async_fetch_text_row(
|
||||
|
||||
#include "mysql/impl/query.ipp"
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -26,7 +26,7 @@ public:
|
||||
)
|
||||
{
|
||||
// Compose a com_query message
|
||||
msgs::com_query query_msg;
|
||||
com_query_packet query_msg;
|
||||
query_msg.query.value = query;
|
||||
|
||||
// Serialize it
|
||||
@@ -52,7 +52,7 @@ public:
|
||||
if (err) return {};
|
||||
if (msg_type == ok_packet_header)
|
||||
{
|
||||
msgs::ok_packet ok_packet;
|
||||
ok_packet ok_packet;
|
||||
err = deserialize_message(ok_packet, ctx);
|
||||
if (err) return {};
|
||||
output = channel_resultset_type<ChannelType>(channel_, std::move(buffer_), ok_packet);
|
||||
@@ -83,7 +83,7 @@ public:
|
||||
|
||||
error_code process_field_definition()
|
||||
{
|
||||
msgs::column_definition field_definition;
|
||||
column_definition_packet field_definition;
|
||||
DeserializationContext ctx (boost::asio::buffer(buffer_), channel_.current_capabilities());
|
||||
auto err = deserialize_message(field_definition, ctx);
|
||||
if (err) return err;
|
||||
@@ -115,7 +115,7 @@ inline fetch_result process_fetch_message(
|
||||
const std::vector<field_metadata>& meta,
|
||||
const bytestring& buffer,
|
||||
std::vector<value>& output_values,
|
||||
msgs::ok_packet& output_ok_packet,
|
||||
ok_packet& output_ok_packet,
|
||||
error_code& err
|
||||
)
|
||||
{
|
||||
@@ -337,7 +337,7 @@ mysql::detail::fetch_result mysql::detail::fetch_text_row(
|
||||
const std::vector<field_metadata>& meta,
|
||||
bytestring& buffer,
|
||||
std::vector<value>& output_values,
|
||||
msgs::ok_packet& output_ok_packet,
|
||||
ok_packet& output_ok_packet,
|
||||
error_code& err
|
||||
)
|
||||
{
|
||||
@@ -363,7 +363,7 @@ mysql::detail::async_fetch_text_row(
|
||||
const std::vector<field_metadata>& meta,
|
||||
bytestring& buffer,
|
||||
std::vector<value>& output_values,
|
||||
msgs::ok_packet& output_ok_packet,
|
||||
ok_packet& output_ok_packet,
|
||||
CompletionToken&& token
|
||||
)
|
||||
{
|
||||
@@ -378,7 +378,7 @@ mysql::detail::async_fetch_text_row(
|
||||
const std::vector<field_metadata>& meta_;
|
||||
bytestring& buffer_;
|
||||
std::vector<value>& output_values_;
|
||||
msgs::ok_packet& output_ok_packet_;
|
||||
ok_packet& output_ok_packet_;
|
||||
|
||||
Op(
|
||||
HandlerType&& handler,
|
||||
@@ -386,7 +386,7 @@ mysql::detail::async_fetch_text_row(
|
||||
const std::vector<field_metadata>& meta,
|
||||
bytestring& buffer,
|
||||
std::vector<value>& output_values,
|
||||
msgs::ok_packet& output_ok_packet
|
||||
ok_packet& output_ok_packet
|
||||
):
|
||||
BaseType(std::move(handler), channel.next_layer().get_executor()),
|
||||
channel_(channel),
|
||||
@@ -447,4 +447,4 @@ mysql::detail::async_fetch_text_row(
|
||||
#include <boost/asio/unyield.hpp>
|
||||
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -10,13 +10,13 @@ namespace mysql
|
||||
|
||||
class field_metadata
|
||||
{
|
||||
detail::msgs::column_definition msg_;
|
||||
detail::column_definition_packet msg_;
|
||||
mutable field_type field_type_ { field_type::_not_computed };
|
||||
|
||||
bool flag_set(std::uint16_t flag) const noexcept { return msg_.flags.value & flag; }
|
||||
public:
|
||||
field_metadata() = default;
|
||||
field_metadata(const detail::msgs::column_definition& msg) noexcept: msg_(msg) {};
|
||||
field_metadata(const detail::column_definition_packet& msg) noexcept: msg_(msg) {};
|
||||
|
||||
std::string_view database() const noexcept { return msg_.schema.value; }
|
||||
std::string_view table() const noexcept { return msg_.table.value; }
|
||||
@@ -62,4 +62,4 @@ public:
|
||||
|
||||
#include "mysql/impl/metadata.hpp"
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -20,13 +20,13 @@ class resultset
|
||||
detail::resultset_metadata meta_;
|
||||
row current_row_;
|
||||
detail::bytestring buffer_;
|
||||
detail::msgs::ok_packet ok_packet_;
|
||||
detail::ok_packet ok_packet_;
|
||||
bool eof_received_ {false};
|
||||
public:
|
||||
resultset(): channel_(nullptr) {};
|
||||
resultset(channel_type& channel, detail::resultset_metadata&& meta):
|
||||
channel_(&channel), meta_(std::move(meta)) {};
|
||||
resultset(channel_type& channel, detail::bytestring&& buffer, const detail::msgs::ok_packet& ok_pack):
|
||||
resultset(channel_type& channel, detail::bytestring&& buffer, const detail::ok_packet& ok_pack):
|
||||
channel_(&channel), buffer_(std::move(buffer)), ok_packet_(ok_pack), eof_received_(true) {};
|
||||
|
||||
const row* fetch_one(error_code& err);
|
||||
|
||||
@@ -55,7 +55,7 @@ struct DeserializeTextValueTest : public TestWithParam<TextValueParam>
|
||||
|
||||
TEST_P(DeserializeTextValueTest, CorrectFormat_SetsOutputValueReturnsTrue)
|
||||
{
|
||||
msgs::column_definition coldef;
|
||||
column_definition_packet coldef;
|
||||
coldef.type = GetParam().type;
|
||||
coldef.decimals.value = static_cast<std::uint8_t>(GetParam().decimals);
|
||||
coldef.flags.value = GetParam().flags;
|
||||
@@ -296,7 +296,7 @@ INSTANTIATE_TEST_SUITE_P(YEAR, DeserializeTextValueTest, Values(
|
||||
struct DeserializeTextRowTest : public Test
|
||||
{
|
||||
std::vector<field_metadata> meta {
|
||||
msgs::column_definition {
|
||||
column_definition_packet {
|
||||
string_lenenc("def"),
|
||||
string_lenenc("awesome"),
|
||||
string_lenenc("test_table"),
|
||||
@@ -309,7 +309,7 @@ struct DeserializeTextRowTest : public Test
|
||||
int2(0),
|
||||
int1(0)
|
||||
},
|
||||
msgs::column_definition {
|
||||
column_definition_packet {
|
||||
string_lenenc("def"),
|
||||
string_lenenc("awesome"),
|
||||
string_lenenc("test_table"),
|
||||
@@ -322,7 +322,7 @@ struct DeserializeTextRowTest : public Test
|
||||
int2(0),
|
||||
int1(0)
|
||||
},
|
||||
msgs::column_definition {
|
||||
column_definition_packet {
|
||||
string_lenenc("def"),
|
||||
string_lenenc("awesome"),
|
||||
string_lenenc("test_table"),
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace
|
||||
|
||||
TEST(FieldMetadata, IntPrimaryKey)
|
||||
{
|
||||
msgs::column_definition msg {
|
||||
column_definition_packet msg {
|
||||
string_lenenc("def"),
|
||||
string_lenenc("awesome"),
|
||||
string_lenenc("test_table"),
|
||||
@@ -55,7 +55,7 @@ TEST(FieldMetadata, IntPrimaryKey)
|
||||
|
||||
TEST(FieldMetadata, VarcharWithAlias)
|
||||
{
|
||||
msgs::column_definition msg {
|
||||
column_definition_packet msg {
|
||||
string_lenenc("def"),
|
||||
string_lenenc("awesome"),
|
||||
string_lenenc("child"),
|
||||
@@ -92,7 +92,7 @@ TEST(FieldMetadata, VarcharWithAlias)
|
||||
|
||||
TEST(FieldMetadata, FloatField)
|
||||
{
|
||||
msgs::column_definition msg {
|
||||
column_definition_packet msg {
|
||||
string_lenenc("def"),
|
||||
string_lenenc("awesome"),
|
||||
string_lenenc("test_table"),
|
||||
|
||||
@@ -156,14 +156,14 @@ INSTANTIATE_TEST_SUITE_P(Enums, FullSerializationTest, ::testing::Values(
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(PacketHeader, FullSerializationTest, ::testing::Values(
|
||||
// packet header
|
||||
SerializeParams(msgs::packet_header{int3(3), int1(0)}, {0x03, 0x00, 0x00, 0x00}, "small packet, seqnum==0"),
|
||||
SerializeParams(msgs::packet_header{int3(9), int1(2)}, {0x09, 0x00, 0x00, 0x02}, "small packet, seqnum!=0"),
|
||||
SerializeParams(msgs::packet_header{int3(0xcacbcc), int1(0xfa)}, {0xcc, 0xcb, 0xca, 0xfa}, "big packet, seqnum!=0"),
|
||||
SerializeParams(msgs::packet_header{int3(0xffffff), int1(0xff)}, {0xff, 0xff, 0xff, 0xff}, "max packet, max seqnum")
|
||||
SerializeParams(packet_header{int3(3), int1(0)}, {0x03, 0x00, 0x00, 0x00}, "small packet, seqnum==0"),
|
||||
SerializeParams(packet_header{int3(9), int1(2)}, {0x09, 0x00, 0x00, 0x02}, "small packet, seqnum!=0"),
|
||||
SerializeParams(packet_header{int3(0xcacbcc), int1(0xfa)}, {0xcc, 0xcb, 0xca, 0xfa}, "big packet, seqnum!=0"),
|
||||
SerializeParams(packet_header{int3(0xffffff), int1(0xff)}, {0xff, 0xff, 0xff, 0xff}, "max packet, max seqnum")
|
||||
));
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(OkPacket, DeserializeTest, ::testing::Values(
|
||||
SerializeParams(msgs::ok_packet{
|
||||
SerializeParams(ok_packet{
|
||||
int_lenenc(4), // affected rows
|
||||
int_lenenc(0), // last insert ID
|
||||
int2(SERVER_STATUS_AUTOCOMMIT | SERVER_QUERY_NO_INDEX_USED), // server status
|
||||
@@ -176,7 +176,7 @@ INSTANTIATE_TEST_SUITE_P(OkPacket, DeserializeTest, ::testing::Values(
|
||||
0x73, 0x3a, 0x20, 0x30
|
||||
}, "successful UPDATE"),
|
||||
|
||||
SerializeParams(msgs::ok_packet{
|
||||
SerializeParams(ok_packet{
|
||||
int_lenenc(1), // affected rows
|
||||
int_lenenc(6), // last insert ID
|
||||
int2(SERVER_STATUS_AUTOCOMMIT), // server status
|
||||
@@ -186,7 +186,7 @@ INSTANTIATE_TEST_SUITE_P(OkPacket, DeserializeTest, ::testing::Values(
|
||||
0x01, 0x06, 0x02, 0x00, 0x00, 0x00
|
||||
}, "successful INSERT"),
|
||||
|
||||
SerializeParams(msgs::ok_packet{
|
||||
SerializeParams(ok_packet{
|
||||
int_lenenc(0), // affected rows
|
||||
int_lenenc(0), // last insert ID
|
||||
int2(SERVER_STATUS_AUTOCOMMIT), // server status
|
||||
@@ -198,7 +198,7 @@ INSTANTIATE_TEST_SUITE_P(OkPacket, DeserializeTest, ::testing::Values(
|
||||
));
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(ErrPacket, DeserializeTest, ::testing::Values(
|
||||
SerializeParams(msgs::err_packet{
|
||||
SerializeParams(err_packet{
|
||||
int2(1049), // eror code
|
||||
string_fixed<1>({0x23}), // sql state marker
|
||||
string_fixed<5>({'4', '2', '0', '0', '0'}), // sql state
|
||||
@@ -209,7 +209,7 @@ INSTANTIATE_TEST_SUITE_P(ErrPacket, DeserializeTest, ::testing::Values(
|
||||
0x61, 0x62, 0x61, 0x73, 0x65, 0x20, 0x27, 0x61, 0x27
|
||||
}, "Wrong USE database"),
|
||||
|
||||
SerializeParams(msgs::err_packet{
|
||||
SerializeParams(err_packet{
|
||||
int2(1146), // eror code
|
||||
string_fixed<1>({0x23}), // sql state marker
|
||||
string_fixed<5>({'4', '2', 'S', '0', '2'}), // sql state
|
||||
@@ -223,7 +223,7 @@ INSTANTIATE_TEST_SUITE_P(ErrPacket, DeserializeTest, ::testing::Values(
|
||||
0x65, 0x78, 0x69, 0x73, 0x74
|
||||
}, "Unknown table"),
|
||||
|
||||
SerializeParams(msgs::err_packet{
|
||||
SerializeParams(err_packet{
|
||||
int2(1045), // error code
|
||||
string_fixed<1>({0x23}), // SQL state marker
|
||||
string_fixed<5>({'2', '8', '0', '0', '0'}), // SQL state
|
||||
@@ -275,7 +275,7 @@ constexpr std::uint32_t hanshake_caps =
|
||||
CLIENT_REMEMBER_OPTIONS;
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(Handhsake, DeserializeSpaceTest, ::testing::Values(
|
||||
SerializeParams(msgs::handshake{
|
||||
SerializeParams(handshake_packet{
|
||||
string_null("5.7.27-0ubuntu0.19.04.1"), // server version
|
||||
int4(2), // connection ID
|
||||
string_lenenc(makesv(handshake_auth_plugin_data)),
|
||||
@@ -325,7 +325,7 @@ constexpr std::uint32_t handshake_response_caps =
|
||||
CLIENT_DEPRECATE_EOF;
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(HandhsakeResponse, SerializeTest, ::testing::Values(
|
||||
SerializeParams(msgs::handshake_response{
|
||||
SerializeParams(handshake_response_packet{
|
||||
int4(handshake_response_caps),
|
||||
int4(16777216), // max packet size
|
||||
int1(static_cast<std::uint8_t>(collation::utf8_general_ci)),
|
||||
@@ -346,7 +346,7 @@ INSTANTIATE_TEST_SUITE_P(HandhsakeResponse, SerializeTest, ::testing::Values(
|
||||
0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x00
|
||||
}, "without database", handshake_response_caps),
|
||||
|
||||
SerializeParams(msgs::handshake_response{
|
||||
SerializeParams(handshake_response_packet{
|
||||
int4(handshake_response_caps | CLIENT_CONNECT_WITH_DB),
|
||||
int4(16777216), // max packet size
|
||||
int1(static_cast<std::uint8_t>(collation::utf8_general_ci)),
|
||||
@@ -377,7 +377,7 @@ constexpr std::uint8_t auth_switch_request_auth_data [] = {
|
||||
};
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(AuthSwitchRequest, DeserializeTest, testing::Values(
|
||||
SerializeParams(msgs::auth_switch_request{
|
||||
SerializeParams(auth_switch_request_packet{
|
||||
string_null("mysql_native_password"),
|
||||
string_eof(makesv(auth_switch_request_auth_data))
|
||||
}, {
|
||||
@@ -397,7 +397,7 @@ constexpr std::uint8_t auth_switch_response_auth_data [] = {
|
||||
};
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(AuthSwitchResponse, SerializeTest, testing::Values(
|
||||
SerializeParams(msgs::auth_switch_response{
|
||||
SerializeParams(auth_switch_response_packet{
|
||||
string_eof(makesv(auth_switch_response_auth_data))
|
||||
}, {
|
||||
0xba, 0x55, 0x9c, 0xc5, 0x9c, 0xbf, 0xca, 0x06,
|
||||
@@ -408,7 +408,7 @@ INSTANTIATE_TEST_SUITE_P(AuthSwitchResponse, SerializeTest, testing::Values(
|
||||
|
||||
// Column definition
|
||||
INSTANTIATE_TEST_SUITE_P(ColumnDefinition, DeserializeSpaceTest, testing::Values(
|
||||
SerializeParams(msgs::column_definition{
|
||||
SerializeParams(column_definition_packet{
|
||||
string_lenenc("def"), //catalog
|
||||
string_lenenc("awesome"), // schema (database)
|
||||
string_lenenc("test_table"), // table
|
||||
@@ -434,7 +434,7 @@ INSTANTIATE_TEST_SUITE_P(ColumnDefinition, DeserializeSpaceTest, testing::Values
|
||||
0x0c, 0x3f, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x03,
|
||||
0x03, 0x42, 0x00, 0x00, 0x00
|
||||
}, "Numeric, auto-increment primary key"),
|
||||
SerializeParams(msgs::column_definition{
|
||||
SerializeParams(column_definition_packet{
|
||||
string_lenenc("def"), //catalog
|
||||
string_lenenc("awesome"), // schema (database)
|
||||
string_lenenc("child"), // table
|
||||
@@ -458,7 +458,7 @@ INSTANTIATE_TEST_SUITE_P(ColumnDefinition, DeserializeSpaceTest, testing::Values
|
||||
0x00, 0x00, 0x00, 0x00, 0x00
|
||||
}, "Varchar field, aliased field and table names (query with a JOIN)"),
|
||||
|
||||
SerializeParams(msgs::column_definition{
|
||||
SerializeParams(column_definition_packet{
|
||||
string_lenenc("def"), //catalog
|
||||
string_lenenc("awesome"), // schema (database)
|
||||
string_lenenc("test_table"), // table
|
||||
@@ -484,7 +484,7 @@ INSTANTIATE_TEST_SUITE_P(ColumnDefinition, DeserializeSpaceTest, testing::Values
|
||||
));
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(ComQuery, SerializeTest, testing::Values(
|
||||
SerializeParams(msgs::com_query{
|
||||
SerializeParams(com_query_packet{
|
||||
string_eof("show databases")
|
||||
}, {
|
||||
0x03, 0x73, 0x68, 0x6f, 0x77, 0x20, 0x64, 0x61,
|
||||
|
||||
Reference in New Issue
Block a user