Commit d062b690 authored by Diego Dupin's avatar Diego Dupin Committed by Oleksandr Byelkin

MDEV-26868: Session tracking flag in OK_PACKET

Take into account client capabilities.
parent 1f70e4b0
...@@ -218,8 +218,6 @@ net_send_ok(THD *thd, ...@@ -218,8 +218,6 @@ net_send_ok(THD *thd,
NET *net= &thd->net; NET *net= &thd->net;
StringBuffer<MYSQL_ERRMSG_SIZE + 10> store; StringBuffer<MYSQL_ERRMSG_SIZE + 10> store;
bool state_changed= false;
bool error= FALSE; bool error= FALSE;
DBUG_ENTER("net_send_ok"); DBUG_ENTER("net_send_ok");
...@@ -246,6 +244,11 @@ net_send_ok(THD *thd, ...@@ -246,6 +244,11 @@ net_send_ok(THD *thd,
/* last insert id */ /* last insert id */
store.q_net_store_length(id); store.q_net_store_length(id);
/* if client has not session tracking capability, don't send state change flag*/
if (!(thd->client_capabilities & CLIENT_SESSION_TRACK)) {
server_status &= ~SERVER_SESSION_STATE_CHANGED;
}
if (thd->client_capabilities & CLIENT_PROTOCOL_41) if (thd->client_capabilities & CLIENT_PROTOCOL_41)
{ {
DBUG_PRINT("info", DBUG_PRINT("info",
...@@ -266,21 +269,17 @@ net_send_ok(THD *thd, ...@@ -266,21 +269,17 @@ net_send_ok(THD *thd,
} }
thd->get_stmt_da()->set_overwrite_status(true); thd->get_stmt_da()->set_overwrite_status(true);
state_changed= if ((server_status & SERVER_SESSION_STATE_CHANGED) || (message && message[0]))
(thd->client_capabilities & CLIENT_SESSION_TRACK) &&
(server_status & SERVER_SESSION_STATE_CHANGED);
if (state_changed || (message && message[0]))
{ {
DBUG_ASSERT(safe_strlen(message) <= MYSQL_ERRMSG_SIZE); DBUG_ASSERT(safe_strlen(message) <= MYSQL_ERRMSG_SIZE);
store.q_net_store_data((uchar*) safe_str(message), safe_strlen(message)); store.q_net_store_data((uchar*) safe_str(message), safe_strlen(message));
} }
if (unlikely(state_changed)) if (unlikely(server_status & SERVER_SESSION_STATE_CHANGED))
{ {
store.set_charset(thd->variables.collation_database); store.set_charset(thd->variables.collation_database);
thd->session_tracker.store(thd, &store); thd->session_tracker.store(thd, &store);
thd->server_status&= ~SERVER_SESSION_STATE_CHANGED;
} }
DBUG_ASSERT(store.length() <= MAX_PACKET_LENGTH); DBUG_ASSERT(store.length() <= MAX_PACKET_LENGTH);
...@@ -289,8 +288,6 @@ net_send_ok(THD *thd, ...@@ -289,8 +288,6 @@ net_send_ok(THD *thd,
if (!error && (!skip_flush || is_eof)) if (!error && (!skip_flush || is_eof))
error= net_flush(net); error= net_flush(net);
thd->server_status&= ~SERVER_SESSION_STATE_CHANGED;
thd->get_stmt_da()->set_overwrite_status(false); thd->get_stmt_da()->set_overwrite_status(false);
DBUG_PRINT("info", ("OK sent, so no more error sending allowed")); DBUG_PRINT("info", ("OK sent, so no more error sending allowed"));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment