Skip to content

Commit d062b69

Browse files
rushersanja-byelkin
authored andcommitted
MDEV-26868: Session tracking flag in OK_PACKET
Take into account client capabilities.
1 parent 1f70e4b commit d062b69

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

sql/protocol.cc

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,6 @@ net_send_ok(THD *thd,
218218
NET *net= &thd->net;
219219
StringBuffer<MYSQL_ERRMSG_SIZE + 10> store;
220220

221-
bool state_changed= false;
222-
223221
bool error= FALSE;
224222
DBUG_ENTER("net_send_ok");
225223

@@ -246,6 +244,11 @@ net_send_ok(THD *thd,
246244
/* last insert id */
247245
store.q_net_store_length(id);
248246

247+
/* if client has not session tracking capability, don't send state change flag*/
248+
if (!(thd->client_capabilities & CLIENT_SESSION_TRACK)) {
249+
server_status &= ~SERVER_SESSION_STATE_CHANGED;
250+
}
251+
249252
if (thd->client_capabilities & CLIENT_PROTOCOL_41)
250253
{
251254
DBUG_PRINT("info",
@@ -266,21 +269,17 @@ net_send_ok(THD *thd,
266269
}
267270
thd->get_stmt_da()->set_overwrite_status(true);
268271

269-
state_changed=
270-
(thd->client_capabilities & CLIENT_SESSION_TRACK) &&
271-
(server_status & SERVER_SESSION_STATE_CHANGED);
272-
273-
if (state_changed || (message && message[0]))
272+
if ((server_status & SERVER_SESSION_STATE_CHANGED) || (message && message[0]))
274273
{
275274
DBUG_ASSERT(safe_strlen(message) <= MYSQL_ERRMSG_SIZE);
276275
store.q_net_store_data((uchar*) safe_str(message), safe_strlen(message));
277276
}
278277

279-
if (unlikely(state_changed))
278+
if (unlikely(server_status & SERVER_SESSION_STATE_CHANGED))
280279
{
281280
store.set_charset(thd->variables.collation_database);
282-
283281
thd->session_tracker.store(thd, &store);
282+
thd->server_status&= ~SERVER_SESSION_STATE_CHANGED;
284283
}
285284

286285
DBUG_ASSERT(store.length() <= MAX_PACKET_LENGTH);
@@ -289,8 +288,6 @@ net_send_ok(THD *thd,
289288
if (!error && (!skip_flush || is_eof))
290289
error= net_flush(net);
291290

292-
thd->server_status&= ~SERVER_SESSION_STATE_CHANGED;
293-
294291
thd->get_stmt_da()->set_overwrite_status(false);
295292
DBUG_PRINT("info", ("OK sent, so no more error sending allowed"));
296293

0 commit comments

Comments
 (0)