Skip to content

Commit 26ea37b

Browse files
committed
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.
1 parent 07de0ac commit 26ea37b

File tree

9 files changed

+63
-5
lines changed

9 files changed

+63
-5
lines changed

client/mysqltest.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4669,7 +4669,11 @@ void do_change_user(struct st_command *command)
46694669
handle_error(command, mysql_errno(mysql), mysql_error(mysql),
46704670
mysql_sqlstate(mysql), &ds_res);
46714671
else
4672+
{
4673+
if (display_session_track_info)
4674+
append_session_track_info(&ds_res, mysql);
46724675
handle_no_error(command);
4676+
}
46734677

46744678
dynstr_free(&ds_user);
46754679
dynstr_free(&ds_passwd);

mysql-test/main/change_user_notembedded.result

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,20 @@ ERROR 08S01: Unknown command
77
ERROR 08S01: Unknown command
88
disconnect test;
99
connection default;
10-
that's all
10+
# End of 10.0 tests
11+
#
12+
# MDEV-36405 Session tracking does not report changes from COM_CHANGE_USER
13+
#
14+
change_user
15+
-- Tracker : SESSION_TRACK_SYSTEM_VARIABLES
16+
-- autocommit: ON
17+
-- character_set_client: latin1
18+
-- character_set_connection: latin1
19+
-- character_set_results: latin1
20+
-- redirect_url:
21+
-- time_zone: SYSTEM
22+
23+
-- Tracker : SESSION_TRACK_SCHEMA
24+
-- test
25+
26+
# End of 12.0 tests

mysql-test/main/change_user_notembedded.test

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,14 @@ change_user;
2222
disconnect test;
2323
connection default;
2424

25-
--echo that's all
25+
--echo # End of 10.0 tests
2626

27+
--echo #
28+
--echo # MDEV-36405 Session tracking does not report changes from COM_CHANGE_USER
29+
--echo #
30+
enable_session_track_info;
31+
--echo change_user
32+
change_user;
33+
disable_session_track_info;
34+
35+
--echo # End of 12.0 tests

mysql-test/main/set_authorization.result

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,4 +133,19 @@ show global status like 'access_denied_errors';
133133
Variable_name Value
134134
Access_denied_errors 2
135135
drop user u1;
136-
# End of 11.8 tests
136+
#
137+
# MDEV-36405 Session tracking does not report changes from COM_CHANGE_USER
138+
#
139+
set session authorization root@localhost;
140+
-- Tracker : SESSION_TRACK_SYSTEM_VARIABLES
141+
-- autocommit: ON
142+
-- character_set_client: utf8mb4
143+
-- character_set_connection: utf8mb4
144+
-- character_set_results: utf8mb4
145+
-- redirect_url:
146+
-- time_zone: SYSTEM
147+
148+
-- Tracker : SESSION_TRACK_SCHEMA
149+
--
150+
151+
# End of 12.0 tests

mysql-test/main/set_authorization.test

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,4 +136,11 @@ connection default;
136136
show global status like 'access_denied_errors';
137137
drop user u1;
138138

139-
--echo # End of 11.8 tests
139+
--echo #
140+
--echo # MDEV-36405 Session tracking does not report changes from COM_CHANGE_USER
141+
--echo #
142+
enable_session_track_info;
143+
set session authorization root@localhost;
144+
disable_session_track_info;
145+
146+
--echo # End of 12.0 tests

mysql-test/suite/sys_vars/r/session_track_system_variables_basic.result

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,9 @@ connect foo,localhost,root;
163163
-- redirect_url:
164164
-- time_zone: SYSTEM
165165

166+
-- Tracker : SESSION_TRACK_SCHEMA
167+
--
168+
166169
connection default;
167170
disconnect foo;
168171
# End of tests 11.5

sql/session_tracker.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,7 @@ class Session_tracker
483483
{
484484
public:
485485
void mark_as_changed(THD *thd) {}
486+
void mark_all_as_changed(THD *thd) {}
486487
void mark_as_changed(THD *thd, const sys_var *var) {}
487488
};
488489
public:

sql/sql_acl.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12390,6 +12390,10 @@ static int set_privs_on_login(THD *thd, const ACL_USER *acl_user)
1239012390
thd->variables.max_statement_time=
1239112391
(ulonglong) (thd->variables.max_statement_time_double * 1e6 + 0.1);
1239212392
}
12393+
12394+
thd->session_tracker.sysvars.mark_all_as_changed(thd);
12395+
thd->session_tracker.current_schema.mark_as_changed(thd);
12396+
thd->session_tracker.state_change.mark_as_changed(thd);
1239312397
return 0;
1239412398
}
1239512399

sql/sql_connect.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1153,7 +1153,6 @@ static bool login_connection(THD *thd)
11531153
my_net_set_write_timeout(net, connect_timeout);
11541154

11551155
error= check_connection(thd);
1156-
thd->session_tracker.sysvars.mark_all_as_changed(thd);
11571156
thd->protocol->end_statement();
11581157

11591158
if (unlikely(error))

0 commit comments

Comments
 (0)