|
| 1 | +# |
| 2 | +# Variable name : session_track_system_variables |
| 3 | +# Scope : Global & Session |
| 4 | +# |
| 5 | +# Global - default |
| 6 | +SELECT @@global.session_track_system_variables; |
| 7 | +@@global.session_track_system_variables |
| 8 | +autocommit,character_set_client,character_set_connection,character_set_results,time_zone |
| 9 | +# Session - default |
| 10 | +SELECT @@session.session_track_system_variables; |
| 11 | +@@session.session_track_system_variables |
| 12 | +autocommit,character_set_client,character_set_connection,character_set_results,time_zone |
| 13 | + |
| 14 | +# via INFORMATION_SCHEMA.GLOBAL_VARIABLES |
| 15 | +SELECT * FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME LIKE 'session_track%' ORDER BY VARIABLE_NAME; |
| 16 | +VARIABLE_NAME VARIABLE_VALUE |
| 17 | +SESSION_TRACK_SCHEMA ON |
| 18 | +SESSION_TRACK_STATE_CHANGE OFF |
| 19 | +SESSION_TRACK_SYSTEM_VARIABLES autocommit,character_set_client,character_set_connection,character_set_results,time_zone |
| 20 | +# via INFORMATION_SCHEMA.SESSION_VARIABLES |
| 21 | +SELECT * FROM INFORMATION_SCHEMA.SESSION_VARIABLES WHERE VARIABLE_NAME LIKE 'session_track%' ORDER BY VARIABLE_NAME; |
| 22 | +VARIABLE_NAME VARIABLE_VALUE |
| 23 | +SESSION_TRACK_SCHEMA ON |
| 24 | +SESSION_TRACK_STATE_CHANGE OFF |
| 25 | +SESSION_TRACK_SYSTEM_VARIABLES autocommit,character_set_client,character_set_connection,character_set_results,time_zone |
| 26 | +SET @global_saved_tmp = @@global.session_track_system_variables; |
| 27 | + |
| 28 | +# Altering global variable's value |
| 29 | +SET @@global.session_track_system_variables='autocommit'; |
| 30 | +SELECT @@global.session_track_system_variables; |
| 31 | +@@global.session_track_system_variables |
| 32 | +autocommit |
| 33 | +SELECT @@session.session_track_system_variables; |
| 34 | +@@session.session_track_system_variables |
| 35 | +autocommit,character_set_client,character_set_connection,character_set_results,time_zone |
| 36 | + |
| 37 | +# Altering session variable's value |
| 38 | +SET @@session.session_track_system_variables='autocommit'; |
| 39 | +SELECT @@global.session_track_system_variables; |
| 40 | +@@global.session_track_system_variables |
| 41 | +autocommit |
| 42 | +SELECT @@session.session_track_system_variables; |
| 43 | +@@session.session_track_system_variables |
| 44 | +autocommit |
| 45 | + |
| 46 | +# Variables' values in a new session. |
| 47 | +connect con1,"127.0.0.1",root,,test,$MASTER_MYPORT,; |
| 48 | +# Global - expect "autocommit" |
| 49 | +SELECT @@global.session_track_system_variables; |
| 50 | +@@global.session_track_system_variables |
| 51 | +autocommit |
| 52 | + |
| 53 | +# Session - expect "autocommit" |
| 54 | +SELECT @@session.session_track_system_variables; |
| 55 | +@@session.session_track_system_variables |
| 56 | +autocommit |
| 57 | + |
| 58 | +# Switching to the default connection. |
| 59 | +connection default; |
| 60 | +SELECT @@global.session_track_system_variables; |
| 61 | +@@global.session_track_system_variables |
| 62 | +autocommit |
| 63 | +SELECT @@session.session_track_system_variables; |
| 64 | +@@session.session_track_system_variables |
| 65 | +autocommit |
| 66 | + |
| 67 | +# Test if DEFAULT is working as expected. |
| 68 | +SET @@global.session_track_system_variables = DEFAULT; |
| 69 | +SET @@session.session_track_system_variables = DEFAULT; |
| 70 | + |
| 71 | +SELECT @@global.session_track_system_variables; |
| 72 | +@@global.session_track_system_variables |
| 73 | +autocommit,character_set_client,character_set_connection,character_set_results,time_zone |
| 74 | +SELECT @@session.session_track_system_variables; |
| 75 | +@@session.session_track_system_variables |
| 76 | +autocommit,character_set_client,character_set_connection,character_set_results,time_zone |
| 77 | + |
| 78 | +# Variables' values in a new session (con2). |
| 79 | +connect con2,"127.0.0.1",root,,test,$MASTER_MYPORT,; |
| 80 | +SELECT @@global.session_track_system_variables; |
| 81 | +@@global.session_track_system_variables |
| 82 | +autocommit,character_set_client,character_set_connection,character_set_results,time_zone |
| 83 | +SELECT @@session.session_track_system_variables; |
| 84 | +@@session.session_track_system_variables |
| 85 | +autocommit,character_set_client,character_set_connection,character_set_results,time_zone |
| 86 | + |
| 87 | +# Altering session should not affect global. |
| 88 | +SET @@session.session_track_system_variables = 'sql_mode'; |
| 89 | +SELECT @@global.session_track_system_variables; |
| 90 | +@@global.session_track_system_variables |
| 91 | +autocommit,character_set_client,character_set_connection,character_set_results,time_zone |
| 92 | +SELECT @@session.session_track_system_variables; |
| 93 | +@@session.session_track_system_variables |
| 94 | +sql_mode |
| 95 | + |
| 96 | +# Variables' values in a new session (con3). |
| 97 | +connect con3,"127.0.0.1",root,,test,$MASTER_MYPORT,; |
| 98 | +# Altering global should not affect session. |
| 99 | +SET @@global.session_track_system_variables = 'sql_mode'; |
| 100 | +SELECT @@global.session_track_system_variables; |
| 101 | +@@global.session_track_system_variables |
| 102 | +sql_mode |
| 103 | +SELECT @@session.session_track_system_variables; |
| 104 | +@@session.session_track_system_variables |
| 105 | +autocommit,character_set_client,character_set_connection,character_set_results,time_zone |
| 106 | + |
| 107 | +# Switching to the default connection. |
| 108 | +connection default; |
| 109 | +# Testing NULL |
| 110 | +SET @@global.session_track_system_variables = NULL; |
| 111 | +SET @@session.session_track_system_variables = NULL; |
| 112 | +# Global - expect "" instead of NULL |
| 113 | +SELECT @@global.session_track_system_variables; |
| 114 | +@@global.session_track_system_variables |
| 115 | +NULL |
| 116 | +# Session - expect "" instead of NULL |
| 117 | +SELECT @@session.session_track_system_variables; |
| 118 | +@@session.session_track_system_variables |
| 119 | + |
| 120 | +# testing with duplicate entries. |
| 121 | +SET @@global.session_track_system_variables= "time_zone"; |
| 122 | +SET @@session.session_track_system_variables= "time_zone"; |
| 123 | +SET @@global.session_track_system_variables= "sql_mode,sql_mode"; |
| 124 | +SET @@session.session_track_system_variables= "sql_mode,sql_mode"; |
| 125 | +SELECT @@global.session_track_system_variables; |
| 126 | +@@global.session_track_system_variables |
| 127 | +sql_mode |
| 128 | +SELECT @@session.session_track_system_variables; |
| 129 | +@@session.session_track_system_variables |
| 130 | +sql_mode |
| 131 | + |
| 132 | +# testing ordering |
| 133 | +SET @@global.session_track_system_variables= "time_zone,sql_mode"; |
| 134 | +SET @@session.session_track_system_variables= "time_zone,sql_mode"; |
| 135 | +SELECT @@global.session_track_system_variables; |
| 136 | +@@global.session_track_system_variables |
| 137 | +sql_mode,time_zone |
| 138 | +SELECT @@session.session_track_system_variables; |
| 139 | +@@session.session_track_system_variables |
| 140 | +sql_mode,time_zone |
| 141 | + |
| 142 | +# special values |
| 143 | +SET @@global.session_track_system_variables= "*"; |
| 144 | +SET @@session.session_track_system_variables= "*"; |
| 145 | +SELECT @@global.session_track_system_variables; |
| 146 | +@@global.session_track_system_variables |
| 147 | +* |
| 148 | +SELECT @@session.session_track_system_variables; |
| 149 | +@@session.session_track_system_variables |
| 150 | +* |
| 151 | +SET @@global.session_track_system_variables= ""; |
| 152 | +SET @@session.session_track_system_variables= ""; |
| 153 | +SELECT @@global.session_track_system_variables; |
| 154 | +@@global.session_track_system_variables |
| 155 | + |
| 156 | +SELECT @@session.session_track_system_variables; |
| 157 | +@@session.session_track_system_variables |
| 158 | + |
| 159 | + |
| 160 | +# Restoring the original values. |
| 161 | +SET @@global.session_track_system_variables = @global_saved_tmp; |
| 162 | +# End of tests. |
0 commit comments