Skip to content

Commit a23a2af

Browse files
committed
Merge branch 'mysql-8.4' into mysql-trunk
Change-Id: Ie82c40386c39358ce971cf87b7c801f7920a27ab
2 parents ca6cdd2 + 5ab76ce commit a23a2af

File tree

2 files changed

+32
-18
lines changed

2 files changed

+32
-18
lines changed

router/src/mysql_protocol/include/mysqlrouter/classic_protocol_codec_message.h

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -388,13 +388,16 @@ class Codec<borrowable::message::server::Ok<Borrowed>>
388388
}
389389
}
390390

391-
if (this->caps().test(capabilities::pos::session_track)) {
391+
// if there is only empty "message" or "session-data", skip the rest.
392+
const bool has_session_track_cap =
393+
this->caps().test(capabilities::pos::session_track);
394+
395+
if (!v_.message().empty() || has_session_track_cap) {
392396
accu.step(bw::VarString<Borrowed>(v_.message()));
393-
if (v_.status_flags().test(status::pos::session_state_changed)) {
397+
if (has_session_track_cap &&
398+
v_.status_flags().test(status::pos::session_state_changed)) {
394399
accu.step(bw::VarString<Borrowed>(v_.session_changes()));
395400
}
396-
} else {
397-
accu.step(bw::String<Borrowed>(v_.message()));
398401
}
399402

400403
return accu.result();
@@ -460,24 +463,20 @@ class Codec<borrowable::message::server::Ok<Borrowed>>
460463
}
461464
}
462465

463-
stdx::expected<bw::String<Borrowed>, std::error_code> message_res;
464466
stdx::expected<bw::VarString<Borrowed>, std::error_code>
465467
session_changes_res;
466-
if (caps[capabilities::pos::session_track]) {
467-
// if there is more data.
468-
const auto var_message_res =
469-
accu.template try_step<bw::VarString<Borrowed>>();
470-
if (var_message_res) {
471-
// set the message from the var-string
472-
message_res = var_message_res.value();
473-
}
474-
475-
if (status_flags_res->value() &
476-
status::session_state_changed.to_ulong()) {
477-
session_changes_res = accu.template step<bw::VarString<Borrowed>>();
468+
// if there is more data.
469+
auto message_res = accu.template try_step<bw::VarString<Borrowed>>();
470+
if (message_res) {
471+
if (caps[capabilities::pos::session_track]) {
472+
if (status_flags_res->value() &
473+
status::session_state_changed.to_ulong()) {
474+
session_changes_res = accu.template step<bw::VarString<Borrowed>>();
475+
}
478476
}
479477
} else {
480-
message_res = accu.template step<bw::String<Borrowed>>();
478+
// no message field == empty message.
479+
message_res = {};
481480
}
482481

483482
if (!accu.result()) return stdx::unexpected(accu.result().error());

router/src/mysql_protocol/tests/test_classic_protocol_message.cc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,21 @@ const CodecParam<classic_protocol::message::server::Ok>
138138
{1, 3, classic_protocol::status::autocommit, 4},
139139
classic_protocol::capabilities::protocol_41,
140140
{0x00, 0x01, 0x03, 0x02, 0x00, 0x04, 0x00}},
141+
{"with_message",
142+
{
143+
0x01, // affected
144+
0x00, // last-insert-id
145+
classic_protocol::status::autocommit, // status
146+
4, // warning-count
147+
"Rows matched: 1 Changed: 0 Warnings: 0", // message
148+
{}, // no session-info
149+
},
150+
classic_protocol::capabilities::protocol_41,
151+
{0x00, 0x01, 0x00, 0x02, 0x00, 0x04, 0x00, 0x28, 0x52, 0x6f,
152+
0x77, 0x73, 0x20, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x65, 0x64,
153+
0x3a, 0x20, 0x31, 0x20, 0x20, 0x43, 0x68, 0x61, 0x6e, 0x67,
154+
0x65, 0x64, 0x3a, 0x20, 0x30, 0x20, 0x20, 0x57, 0x61, 0x72,
155+
0x6e, 0x69, 0x6e, 0x67, 0x73, 0x3a, 0x20, 0x30}},
141156
{"with_session_state_info",
142157
{1,
143158
3,

0 commit comments

Comments
 (0)