MDEV-36405 Session tracking does not report changes from COM_CHANGE_USER

report all sysvar tracker changes, as for the new login.
also report db and other session state changes.
This commit is contained in:
Sergei Golubchik 2025-04-25 17:45:59 +02:00
parent 07de0ac69e
commit 26ea37be5d
9 changed files with 63 additions and 5 deletions

View File

@ -4669,7 +4669,11 @@ void do_change_user(struct st_command *command)
handle_error(command, mysql_errno(mysql), mysql_error(mysql),
mysql_sqlstate(mysql), &ds_res);
else
{
if (display_session_track_info)
append_session_track_info(&ds_res, mysql);
handle_no_error(command);
}
dynstr_free(&ds_user);
dynstr_free(&ds_passwd);

View File

@ -7,4 +7,20 @@ ERROR 08S01: Unknown command
ERROR 08S01: Unknown command
disconnect test;
connection default;
that's all
# End of 10.0 tests
#
# MDEV-36405 Session tracking does not report changes from COM_CHANGE_USER
#
change_user
-- Tracker : SESSION_TRACK_SYSTEM_VARIABLES
-- autocommit: ON
-- character_set_client: latin1
-- character_set_connection: latin1
-- character_set_results: latin1
-- redirect_url:
-- time_zone: SYSTEM
-- Tracker : SESSION_TRACK_SCHEMA
-- test
# End of 12.0 tests

View File

@ -22,5 +22,14 @@ change_user;
disconnect test;
connection default;
--echo that's all
--echo # End of 10.0 tests
--echo #
--echo # MDEV-36405 Session tracking does not report changes from COM_CHANGE_USER
--echo #
enable_session_track_info;
--echo change_user
change_user;
disable_session_track_info;
--echo # End of 12.0 tests

View File

@ -133,4 +133,19 @@ show global status like 'access_denied_errors';
Variable_name Value
Access_denied_errors 2
drop user u1;
# End of 11.8 tests
#
# MDEV-36405 Session tracking does not report changes from COM_CHANGE_USER
#
set session authorization root@localhost;
-- Tracker : SESSION_TRACK_SYSTEM_VARIABLES
-- autocommit: ON
-- character_set_client: utf8mb4
-- character_set_connection: utf8mb4
-- character_set_results: utf8mb4
-- redirect_url:
-- time_zone: SYSTEM
-- Tracker : SESSION_TRACK_SCHEMA
--
# End of 12.0 tests

View File

@ -136,4 +136,11 @@ connection default;
show global status like 'access_denied_errors';
drop user u1;
--echo # End of 11.8 tests
--echo #
--echo # MDEV-36405 Session tracking does not report changes from COM_CHANGE_USER
--echo #
enable_session_track_info;
set session authorization root@localhost;
disable_session_track_info;
--echo # End of 12.0 tests

View File

@ -163,6 +163,9 @@ connect foo,localhost,root;
-- redirect_url:
-- time_zone: SYSTEM
-- Tracker : SESSION_TRACK_SCHEMA
--
connection default;
disconnect foo;
# End of tests 11.5

View File

@ -483,6 +483,7 @@ class Session_tracker
{
public:
void mark_as_changed(THD *thd) {}
void mark_all_as_changed(THD *thd) {}
void mark_as_changed(THD *thd, const sys_var *var) {}
};
public:

View File

@ -12390,6 +12390,10 @@ static int set_privs_on_login(THD *thd, const ACL_USER *acl_user)
thd->variables.max_statement_time=
(ulonglong) (thd->variables.max_statement_time_double * 1e6 + 0.1);
}
thd->session_tracker.sysvars.mark_all_as_changed(thd);
thd->session_tracker.current_schema.mark_as_changed(thd);
thd->session_tracker.state_change.mark_as_changed(thd);
return 0;
}

View File

@ -1153,7 +1153,6 @@ static bool login_connection(THD *thd)
my_net_set_write_timeout(net, connect_timeout);
error= check_connection(thd);
thd->session_tracker.sysvars.mark_all_as_changed(thd);
thd->protocol->end_statement();
if (unlikely(error))