Skip to content

Commit fda980c

Browse files
committed
Per-user session variable default values
Summary: This diff introduces per-user session variable default values. This is for MyRocks and MySQL production debugging. A new global variable 'per-user-session-var-default-val' with type of string is introduced, it defines the default values of multiple session variables for multiple users, e.g. --per-user-session-var-default-val="user1:user2:user3:tx_isolation=read-committed,gap_lock_raise_error=0,user4:user5:big_tables=1,auto_increment_increment=12345,long_query_time=123.45" In this example, the default values of session variables tx_isolation and gap_lock_raise_error for user1, user2, and user3 are defined, the default values of session variables big_tables, auto_increment_increment, and long_query_time for user4 and user 5 are defined. When these users connect to server, the corresponding session variables will be set with these values so that these users don't have to execute SET command to set these session variables before executing queries. The cost of an extra round trip is saved. (1) This global variable is dynamic so it can be set at runtime. (2) Sys-vars have many types. The per-user session variables supported types are enum/bool/int/uint/double, which are the most common types for session variables. Other types like string(charptr)/proxy_user/external_user/key_cache/plugin/struct etc are *not* supported. (3) The users won't be validated when per-user-session-var-default-val is set since users can be changed any time after the global is set (4) The session variables will be validated when per-user-session-var-default-val is set. Invalid command line value will cause server fail to start. Invalid value in SET command will fail the command. Test Plan: New tests added: sys_vars.per_user_session_var_default_val_basic.test sys_vars.per_user_session_var_default_val_null.test sys_vars.per_user_session_var_default_val_empty.test sys_vars.per_user_session_var_default_val.test sys_vars.per_user_session_var_default_validation.test Reviewers: santoshb, jkedgar Reviewed By: jkedgar Subscribers: webscalesql-eng Differential Revision: https://reviews.facebook.net/D55791
1 parent c5a7b3b commit fda980c

24 files changed

+3554
-8
lines changed

include/my_getopt.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,13 @@ extern my_bool my_getopt_print_errors;
107107
extern my_bool my_getopt_skip_unknown;
108108
extern my_error_reporter my_getopt_error_reporter;
109109

110+
extern my_bool my_get_bool_argument(const struct my_option *opts,
111+
const char *argument,
112+
int *error);
113+
extern longlong getopt_ll(char *arg, const struct my_option *optp, int *err);
114+
extern ulonglong getopt_ull(char *, const struct my_option *, int *);
115+
extern double getopt_double(char *arg, const struct my_option *optp, int *err);
116+
110117
extern int handle_options (int *argc, char ***argv,
111118
const struct my_option *longopts, my_get_one_option);
112119
extern int handle_options_with_logging (int *argc, char ***argv,

mysql-test/r/mysqld--help-notwin-profiling.result

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,8 @@ The following options may be given as the first argument:
673673
The rate of sampling replayed events on slave to
674674
determine the peak replication lag over some period.
675675
--peak-lag-time=# The time frame peak lag is measured within, in seconds.
676+
--per-user-session-var-default-val[=name]
677+
Per user session variable default value
676678
--performance-schema
677679
Enable the performance schema.
678680
(Defaults to on; use --skip-performance-schema to disable.)
@@ -1684,6 +1686,7 @@ optimizer-trace-offset -1
16841686
part-scan-max 10
16851687
peak-lag-sample-rate 100
16861688
peak-lag-time 60
1689+
per-user-session-var-default-val (No default value)
16871690
performance-schema TRUE
16881691
performance-schema-accounts-size -1
16891692
performance-schema-consumer-events-stages-current FALSE

mysql-test/r/mysqld--help-notwin.result

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,8 @@ The following options may be given as the first argument:
673673
The rate of sampling replayed events on slave to
674674
determine the peak replication lag over some period.
675675
--peak-lag-time=# The time frame peak lag is measured within, in seconds.
676+
--per-user-session-var-default-val[=name]
677+
Per user session variable default value
676678
--performance-schema
677679
Enable the performance schema.
678680
(Defaults to on; use --skip-performance-schema to disable.)
@@ -1682,6 +1684,7 @@ optimizer-trace-offset -1
16821684
part-scan-max 10
16831685
peak-lag-sample-rate 100
16841686
peak-lag-time 60
1687+
per-user-session-var-default-val (No default value)
16851688
performance-schema TRUE
16861689
performance-schema-accounts-size -1
16871690
performance-schema-consumer-events-stages-current FALSE

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

Lines changed: 2354 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
SET @original_val = @@global.per_user_session_var_default_val;
2+
SELECT @original_val;
3+
@original_val
4+
NULL
5+
SELECT @@GLOBAL.per_user_session_var_default_val = VARIABLE_VALUE
6+
FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
7+
WHERE VARIABLE_NAME='per_user_session_var_default_val';
8+
@@GLOBAL.per_user_session_var_default_val = VARIABLE_VALUE
9+
NULL
10+
SELECT @@SESSION.per_user_session_var_default_val;
11+
ERROR HY000: Variable 'per_user_session_var_default_val' is a GLOBAL variable
12+
SET SESSION per_user_session_var_default_val = "";
13+
ERROR HY000: Variable 'per_user_session_var_default_val' is a GLOBAL variable and should be set with SET GLOBAL
14+
SELECT @@GLOBAL.per_user_session_var_default_val;
15+
@@GLOBAL.per_user_session_var_default_val
16+
NULL
17+
## default value is NULL
18+
SET GLOBAL per_user_session_var_default_val = DEFAULT;
19+
SELECT @@GLOBAL.per_user_session_var_default_val;
20+
@@GLOBAL.per_user_session_var_default_val
21+
NULL
22+
## NULL is a valid value
23+
SET GLOBAL per_user_session_var_default_val = NULL;
24+
SELECT @@GLOBAL.per_user_session_var_default_val;
25+
@@GLOBAL.per_user_session_var_default_val
26+
NULL
27+
## "" is a valid value
28+
SET GLOBAL per_user_session_var_default_val = "";
29+
SELECT @@GLOBAL.per_user_session_var_default_val;
30+
@@GLOBAL.per_user_session_var_default_val
31+
32+
SET @@global.per_user_session_var_default_val = @original_val;
33+
SELECT @@global.per_user_session_var_default_val;
34+
@@global.per_user_session_var_default_val
35+
NULL
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# empty string is a valid value
2+
SELECT @@GLOBAL.per_user_session_var_default_val;
3+
@@GLOBAL.per_user_session_var_default_val
4+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# default value is NULL ptr
2+
SELECT @@GLOBAL.per_user_session_var_default_val;
3+
@@GLOBAL.per_user_session_var_default_val
4+
NULL
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
flush privileges;
2+
create user usr1@localhost;
3+
grant all privileges on *.* to admin1@localhost identified by password '' with grant option;
4+
flush user_resources;
5+
SET @original_val = @@global.per_user_session_var_default_val;
6+
SELECT @original_val;
7+
@original_val
8+
NULL
9+
## default value is NULL
10+
SET GLOBAL per_user_session_var_default_val = DEFAULT;
11+
SELECT @@GLOBAL.per_user_session_var_default_val;
12+
@@GLOBAL.per_user_session_var_default_val
13+
NULL
14+
## NULL is a valid value
15+
SET GLOBAL per_user_session_var_default_val = NULL;
16+
SELECT @@GLOBAL.per_user_session_var_default_val;
17+
@@GLOBAL.per_user_session_var_default_val
18+
NULL
19+
## "" is a valid value
20+
SET GLOBAL per_user_session_var_default_val = "";
21+
SELECT @@GLOBAL.per_user_session_var_default_val;
22+
@@GLOBAL.per_user_session_var_default_val
23+
24+
##
25+
## Invalid values. SET command will fail
26+
##
27+
SET GLOBAL per_user_session_var_default_val = " ";
28+
ERROR 42000: Variable 'per_user_session_var_default_val' can't be set to the value of ' '
29+
SET GLOBAL per_user_session_var_default_val = " ";
30+
ERROR 42000: Variable 'per_user_session_var_default_val' can't be set to the value of ' '
31+
SET GLOBAL per_user_session_var_default_val = ":";
32+
ERROR 42000: Variable 'per_user_session_var_default_val' can't be set to the value of ':'
33+
SET GLOBAL per_user_session_var_default_val = "=";
34+
ERROR 42000: Variable 'per_user_session_var_default_val' can't be set to the value of '='
35+
SET GLOBAL per_user_session_var_default_val = ",";
36+
ERROR 42000: Variable 'per_user_session_var_default_val' can't be set to the value of ','
37+
SET GLOBAL per_user_session_var_default_val = ";";
38+
ERROR 42000: Variable 'per_user_session_var_default_val' can't be set to the value of ';'
39+
SET GLOBAL per_user_session_var_default_val = "\"";
40+
ERROR 42000: Variable 'per_user_session_var_default_val' can't be set to the value of '"'
41+
SET GLOBAL per_user_session_var_default_val = "'";
42+
ERROR 42000: Variable 'per_user_session_var_default_val' can't be set to the value of '''
43+
SET GLOBAL per_user_session_var_default_val = "\\";
44+
ERROR 42000: Variable 'per_user_session_var_default_val' can't be set to the value of '\'
45+
SET GLOBAL per_user_session_var_default_val = "/";
46+
ERROR 42000: Variable 'per_user_session_var_default_val' can't be set to the value of '/'
47+
SET GLOBAL per_user_session_var_default_val = "u";
48+
ERROR 42000: Variable 'per_user_session_var_default_val' can't be set to the value of 'u'
49+
SET GLOBAL per_user_session_var_default_val = "gap_lock_raise_error=0";
50+
ERROR 42000: Variable 'per_user_session_var_default_val' can't be set to the value of 'gap_lock_raise_error=0'
51+
SET GLOBAL per_user_session_var_default_val = "gap_lock_raise_error=0,u2:gap_lock_raise_error=1";
52+
ERROR 42000: Variable 'per_user_session_var_default_val' can't be set to the value of 'gap_lock_raise_error=0,u2:gap_lock_raise_error=1'
53+
SET GLOBAL per_user_session_var_default_val = " u";
54+
ERROR 42000: Variable 'per_user_session_var_default_val' can't be set to the value of ' u'
55+
SET GLOBAL per_user_session_var_default_val = "u ";
56+
ERROR 42000: Variable 'per_user_session_var_default_val' can't be set to the value of 'u '
57+
SET GLOBAL per_user_session_var_default_val = "u :";
58+
ERROR 42000: Variable 'per_user_session_var_default_val' can't be set to the value of 'u :'
59+
SET GLOBAL per_user_session_var_default_val = "u:gap_lock_raise_error";
60+
ERROR 42000: Variable 'per_user_session_var_default_val' can't be set to the value of 'u:gap_lock_raise_error'
61+
SET GLOBAL per_user_session_var_default_val = "u: ";
62+
ERROR 42000: Variable 'per_user_session_var_default_val' can't be set to the value of 'u: '
63+
SET GLOBAL per_user_session_var_default_val = " u:gap_lock_raise_error";
64+
ERROR 42000: Variable 'per_user_session_var_default_val' can't be set to the value of ' u:gap_lock_raise_error'
65+
SET GLOBAL per_user_session_var_default_val = "u:v:";
66+
ERROR 42000: Variable 'per_user_session_var_default_val' can't be set to the value of 'u:v:'
67+
SET GLOBAL per_user_session_var_default_val = "u:gap_lock_raise_error=";
68+
ERROR 42000: Variable 'per_user_session_var_default_val' can't be set to the value of 'u:gap_lock_raise_error='
69+
SET GLOBAL per_user_session_var_default_val = "u:gap_lock_raise_error=0:";
70+
ERROR 42000: Variable 'per_user_session_var_default_val' can't be set to the value of 'u:gap_lock_raise_error=0:'
71+
SET GLOBAL per_user_session_var_default_val = "u:gap_lock_raise_error=0=";
72+
ERROR 42000: Variable 'per_user_session_var_default_val' can't be set to the value of 'u:gap_lock_raise_error=0='
73+
SET GLOBAL per_user_session_var_default_val = "u:gap_lock_raise_error=0=1";
74+
ERROR 42000: Variable 'per_user_session_var_default_val' can't be set to the value of 'u:gap_lock_raise_error=0=1'
75+
SET GLOBAL per_user_session_var_default_val = "u:gap_lock_raise_error=0,u:gap_lock_write_log=0";
76+
ERROR 42000: Variable 'per_user_session_var_default_val' can't be set to the value of 'u:gap_lock_raise_error=0,u:gap_lock_write_log=0'
77+
SET GLOBAL per_user_session_var_default_val = "u:= 0";
78+
ERROR 42000: Variable 'per_user_session_var_default_val' can't be set to the value of 'u:= 0'
79+
SET GLOBAL per_user_session_var_default_val = "u:gap_lock_raise_error= 0";
80+
ERROR 42000: Variable 'per_user_session_var_default_val' can't be set to the value of 'u:gap_lock_raise_error= 0'
81+
SET GLOBAL per_user_session_var_default_val = "u:gap_lock_raise_error= ";
82+
ERROR 42000: Variable 'per_user_session_var_default_val' can't be set to the value of 'u:gap_lock_raise_error= '
83+
SET GLOBAL per_user_session_var_default_val = "u:gap_lock_raise_error=0,";
84+
ERROR 42000: Variable 'per_user_session_var_default_val' can't be set to the value of 'u:gap_lock_raise_error=0,'
85+
SET GLOBAL per_user_session_var_default_val = "u:gap_lock_raise_error=0;";
86+
ERROR 42000: Variable 'per_user_session_var_default_val' can't be set to the value of 'u:gap_lock_raise_error=0;'
87+
SET GLOBAL per_user_session_var_default_val = "u1:u2:gap_lock_raise_error=0,gap_lock_write_log=0,,u3:big_tables=1";
88+
ERROR 42000: Variable 'per_user_session_var_default_val' can't be set to the value of 'u1:u2:gap_lock_raise_error=0,gap_lock_write_log=0,,u3:big_tables=1'
89+
SET GLOBAL per_user_session_var_default_val = "u1::u2:gap_lock_raise_error=0,gap_lock_write_log=0,u3:big_tables=1";
90+
ERROR 42000: Variable 'per_user_session_var_default_val' can't be set to the value of 'u1::u2:gap_lock_raise_error=0,gap_lock_write_log=0,u3:big_tables=1'
91+
SET GLOBAL per_user_session_var_default_val = "u1:gap_lock_raise_error=0,gap_lock_write_log=0,u3:big_tables=1 ";
92+
ERROR 42000: Variable 'per_user_session_var_default_val' can't be set to the value of 'u1:gap_lock_raise_error=0,gap_lock_write_log=0,u3:big_tables=1 '
93+
SET GLOBAL per_user_session_var_default_val = "u1:gap_lock_raise_error=0,gap_lock_write_log=0,u3:big_tables=1,";
94+
ERROR 42000: Variable 'per_user_session_var_default_val' can't be set to the value of 'u1:gap_lock_raise_error=0,gap_lock_write_log=0,u3:big_tables=1,'
95+
SET GLOBAL per_user_session_var_default_val = "u1:gap_lock_raise_error=0,gap_lock_write_log=0,u3:big_tables=1'";
96+
ERROR 42000: Variable 'per_user_session_var_default_val' can't be set to the value of 'u1:gap_lock_raise_error=0,gap_lock_write_log=0,u3:big_tables=1''
97+
SET GLOBAL per_user_session_var_default_val = "u1:gap_lock_raise_error=0,gap_lock_write_log=0,u3:big_tables='1'";
98+
ERROR 42000: Variable 'per_user_session_var_default_val' can't be set to the value of 'u1:gap_lock_raise_error=0,gap_lock_write_log=0,u3:big_tables='1''
99+
SET GLOBAL per_user_session_var_default_val = "u1:gap_lock_raise_error=0,gap_lock_write_log=0,u3:big_tables=\"1\"";
100+
ERROR 42000: Variable 'per_user_session_var_default_val' can't be set to the value of 'u1:gap_lock_raise_error=0,gap_lock_write_log=0,u3:big_tables="1"'
101+
SET GLOBAL per_user_session_var_default_val = "u1:time_zone=\'+10:00\'";
102+
ERROR 42000: Variable 'per_user_session_var_default_val' can't be set to the value of 'u1:time_zone='+10:00''
103+
## Syntax error
104+
SET GLOBAL per_user_session_var_default_val = "u1:optimizer_switch=index_merge=on";
105+
ERROR 42000: Variable 'per_user_session_var_default_val' can't be set to the value of 'u1:optimizer_switch=index_merge=on'
106+
## Unsupported type 'flagset'
107+
SET GLOBAL per_user_session_var_default_val = "u1:optimizer_switch=xyz";
108+
ERROR 42000: Variable 'per_user_session_var_default_val' can't be set to the value of 'u1:optimizer_switch=xyz'
109+
##
110+
## root privilege is required to set session variable binglog_format
111+
## root privilege will be granted to usr1 temporarily to get this done
112+
##
113+
SET GLOBAL per_user_session_var_default_val = "usr1:binlog_format=MIXED";
114+
SELECT @@GLOBAL.binlog_format, @@SESSION.binlog_format;
115+
@@GLOBAL.binlog_format @@SESSION.binlog_format
116+
STATEMENT MIXED
117+
SET GLOBAL per_user_session_var_default_val = "usr1:binlog_format=ROW";
118+
SELECT @@GLOBAL.binlog_format, @@SESSION.binlog_format;
119+
@@GLOBAL.binlog_format @@SESSION.binlog_format
120+
STATEMENT ROW
121+
SET GLOBAL per_user_session_var_default_val = "admin1:binlog_format=MIXED";
122+
SELECT @@GLOBAL.binlog_format, @@SESSION.binlog_format;
123+
@@GLOBAL.binlog_format @@SESSION.binlog_format
124+
STATEMENT MIXED
125+
SET GLOBAL per_user_session_var_default_val = "admin1:binlog_format=ROW";
126+
SELECT @@GLOBAL.binlog_format, @@SESSION.binlog_format;
127+
@@GLOBAL.binlog_format @@SESSION.binlog_format
128+
STATEMENT ROW
129+
drop user usr1@localhost;
130+
drop user admin1@localhost;
131+
SET @@global.per_user_session_var_default_val = @original_val;
132+
SELECT @@global.per_user_session_var_default_val;
133+
@@global.per_user_session_var_default_val
134+
NULL
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
--echo ## create connection batch $i
2+
let $j=1;
3+
while ($j<=5) {
4+
connect (con_tao_$i$j,localhost,tao$j,,);
5+
connect (con_tao_ssl_$i$j,localhost,tao$j,,,,,SSL);
6+
inc $j;
7+
}
8+
connect (con_root_$i,localhost,root,,);
9+
connect (con_root_ssl_$i,localhost,root,,,,,SSL);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--per-user-session-var-default-val="tao2:tao3:root:tx_isolation=read-committed,gap_lock_raise_error=0,gap_lock_write_log=0,big_tables=1,tao1:bulk_insert_buffer_size=16M,gap_lock_raise_error=0,gap_lock_write_log=0,auto_increment_increment=12345,long_query_time=123.45"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--per-user-session-var-default-val="tao2:tao3:root:tx_isolation=read-committed,gap_lock_raise_error=0,gap_lock_write_log=0,big_tables=1,tao1:bulk_insert_buffer_size=16M,gap_lock_raise_error=0,gap_lock_write_log=0,auto_increment_increment=12345,long_query_time=123.45"
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
--source include/load_sysvars.inc
2+
3+
# Wait for all the connections from previous tests except
4+
# the default one to be completedly disconnected
5+
let $count_sessions= 1;
6+
--source include/wait_until_count_sessions.inc
7+
8+
flush privileges;
9+
10+
--source include/master-slave.inc
11+
connection master;
12+
13+
let $original_val = query_get_value(select @@GLOBAL.per_user_session_var_default_val as val, val, 1);
14+
--echo $original_val
15+
SELECT @@GLOBAL.per_user_session_var_default_val;
16+
17+
--echo ## create non-super users tao1, tao2, and tao3
18+
create user tao1@localhost;
19+
create user tao2@localhost;
20+
create user tao3@localhost;
21+
22+
--echo ## create super users tao4 and tao5
23+
grant all privileges on *.* to tao4@localhost identified by password '' with grant option;
24+
grant all privileges on *.* to tao5@localhost identified by password '' with grant option;
25+
26+
flush user_resources;
27+
28+
let $i=1;
29+
--echo ## ($i) Initial non-empty value
30+
--source per_user_session_var_conn_create.inc
31+
32+
inc $i;
33+
--echo ## ($i) DEFAULT value
34+
SET GLOBAL per_user_session_var_default_val = DEFAULT;
35+
SELECT @@GLOBAL.per_user_session_var_default_val;
36+
--source per_user_session_var_conn_create.inc
37+
38+
inc $i;
39+
--echo ## ($i) Non-empty value
40+
SET GLOBAL per_user_session_var_default_val="tao1:tao2:tao3:tao4:tx_isolation=serializable,big_tables=1,auto_increment_increment=12345,long_query_time=123.45,bulk_insert_buffer_size=1G,tao5:root:binlog_format=row";
41+
SELECT @@GLOBAL.per_user_session_var_default_val;
42+
--source per_user_session_var_conn_create.inc
43+
44+
inc $i;
45+
--echo ## ($i) NULL value
46+
SET GLOBAL per_user_session_var_default_val = NULL;
47+
SELECT @@GLOBAL.per_user_session_var_default_val;
48+
--source per_user_session_var_conn_create.inc
49+
50+
inc $i;
51+
--echo ## ($i) Non-empty value
52+
SET GLOBAL per_user_session_var_default_val="tao1:tx_isolation=READ-UNCOMMITTED,tao2:tao3:gap_lock_raise_error=FALSE,root:gap_lock_write_log=off,tao4:big_tables=1,auto_increment_increment=12345,long_query_time=123.45,tao5:binlog_format=MIXED,bulk_insert_buffer_size=32M";
53+
SELECT @@GLOBAL.per_user_session_var_default_val;
54+
--source per_user_session_var_conn_create.inc
55+
56+
inc $i;
57+
--echo ## ($i) Empty value
58+
SET GLOBAL per_user_session_var_default_val = "";
59+
SELECT @@GLOBAL.per_user_session_var_default_val;
60+
--source per_user_session_var_conn_create.inc
61+
62+
inc $i;
63+
--echo ## ($i) Restored initial non-empty value
64+
eval SET @@global.per_user_session_var_default_val = "$original_val";
65+
SELECT @@global.per_user_session_var_default_val;
66+
--source per_user_session_var_conn_create.inc
67+
68+
--echo ##
69+
--echo ## Session variables of all the connnections
70+
--echo ##
71+
72+
let $k=1;
73+
while ($k<=$i) {
74+
--echo ##
75+
--echo ## ($k) Connection batch $k
76+
--echo ##
77+
78+
let $j=1;
79+
while ($j<=5) {
80+
--echo ##
81+
--echo ## Connection con_tao_$k$j for user tao$j
82+
--echo ##
83+
connection con_tao_$k$j;
84+
--source per_user_session_var_print.inc
85+
disconnect con_tao_$k$j;
86+
87+
--echo ##
88+
--echo ## SSL connection con_tao_ssl_$k$j for user tao$j
89+
--echo ##
90+
connection con_tao_ssl_$k$j;
91+
--source per_user_session_var_print.inc
92+
disconnect con_tao_ssl_$k$j;
93+
94+
inc $j;
95+
}
96+
--echo ##
97+
--echo ## Connection con_root_$k for user root
98+
--echo ##
99+
connection con_root_$k;
100+
--source per_user_session_var_print.inc
101+
disconnect con_root_$k;
102+
103+
--echo ##
104+
--echo ## SSL connection con_root_ssl_$k for user root
105+
--echo ##
106+
connection con_root_ssl_$k;
107+
--source per_user_session_var_print.inc
108+
disconnect con_root_ssl_$k;
109+
110+
inc $k;
111+
}
112+
113+
connection default;
114+
115+
drop user tao1@localhost;
116+
drop user tao2@localhost;
117+
drop user tao3@localhost;
118+
drop user tao4@localhost;
119+
drop user tao5@localhost;
120+
121+
--source include/rpl_end.inc
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
--source include/load_sysvars.inc
2+
3+
SET @original_val = @@global.per_user_session_var_default_val;
4+
SELECT @original_val;
5+
6+
SELECT @@GLOBAL.per_user_session_var_default_val = VARIABLE_VALUE
7+
FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
8+
WHERE VARIABLE_NAME='per_user_session_var_default_val';
9+
10+
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
11+
SELECT @@SESSION.per_user_session_var_default_val;
12+
13+
--error ER_GLOBAL_VARIABLE
14+
SET SESSION per_user_session_var_default_val = "";
15+
16+
SELECT @@GLOBAL.per_user_session_var_default_val;
17+
18+
--echo ## default value is NULL
19+
SET GLOBAL per_user_session_var_default_val = DEFAULT;
20+
SELECT @@GLOBAL.per_user_session_var_default_val;
21+
22+
--echo ## NULL is a valid value
23+
SET GLOBAL per_user_session_var_default_val = NULL;
24+
SELECT @@GLOBAL.per_user_session_var_default_val;
25+
26+
--echo ## "" is a valid value
27+
SET GLOBAL per_user_session_var_default_val = "";
28+
SELECT @@GLOBAL.per_user_session_var_default_val;
29+
30+
SET @@global.per_user_session_var_default_val = @original_val;
31+
SELECT @@global.per_user_session_var_default_val;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--per-user-session-var-default-val=""

0 commit comments

Comments
 (0)