1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206
|
call mtr.add_suppression("duplicate variable name");
# Simple load test
INSTALL COMPONENT "file://component_test_sys_var_service";
# Testing integer and bool type variable
SELECT @@test_component.int_sys_var;
@@test_component.int_sys_var
8
SELECT @@global.test_component.int_sys_var;
@@global.test_component.int_sys_var
8
SELECT @@global.test_component.bool_sys_var;
@@global.test_component.bool_sys_var
1
SELECT @@test_component.int_sys_var, @@test_component.bool_sys_var;
@@test_component.int_sys_var @@test_component.bool_sys_var
8 1
SET test_component.bool_sys_var=1;
ERROR HY000: Variable 'test_component.bool_sys_var' is a GLOBAL variable and should be set with SET GLOBAL
SET GLOBAL test_component.int_sys_var=7;
SET GLOBAL test_component.int_sys_var=1234567;
Warnings:
Warning 1292 Truncated incorrect test_component.int_sys_var value: '1234567'
SELECT @@test_component.int_sys_var;
@@test_component.int_sys_var
1024
SET GLOBAL test_component.int_sys_var=-1;
Warnings:
Warning 1292 Truncated incorrect test_component.int_sys_var value: '-1'
SELECT @@test_component.int_sys_var;
@@test_component.int_sys_var
0
SET GLOBAL test_component.int_sys_var=1.25;
ERROR 42000: Incorrect argument type to variable 'test_component.int_sys_var'
SET GLOBAL test_component.int_sys_var="hello";
ERROR 42000: Incorrect argument type to variable 'test_component.int_sys_var'
SET GLOBAL test_component.int_sys_var=123, test_component.bool_sys_var=0;
SELECT @@test_component.int_sys_var, @@test_component.bool_sys_var;
@@test_component.int_sys_var @@test_component.bool_sys_var
123 0
SET SESSION test_component.int_sys_var=123;
ERROR HY000: Variable 'test_component.int_sys_var' is a GLOBAL variable and should be set with SET GLOBAL
# Testing enum type variable
SELECT @@test_component.enum_sys_var;
@@test_component.enum_sys_var
MEDIUM
SET GLOBAL test_component.enum_sys_var="LOW";
SELECT @@test_component.enum_sys_var;
@@test_component.enum_sys_var
LOW
# Testing string type variable
SELECT @@test_component.str_sys_var;
@@test_component.str_sys_var
NULL
SET GLOBAL test_component.str_sys_var="dictionary.txt";
SELECT @@test_component.str_sys_var;
@@test_component.str_sys_var
dictionary.txt
SET GLOBAL test_component.str_sys_var=default;
SELECT @@test_component.str_sys_var;
@@test_component.str_sys_var
NULL
# Testing string type variable with default value
SELECT @@test_component.str_sys_var_default;
@@test_component.str_sys_var_default
default
SET GLOBAL test_component.str_sys_var_default="dictionary.txt";
SELECT @@test_component.str_sys_var_default;
@@test_component.str_sys_var_default
dictionary.txt
SET GLOBAL test_component.str_sys_var_default=something;
SELECT @@test_component.str_sys_var_default;
@@test_component.str_sys_var_default
something
# Testing unsigned integer type variable
SELECT @@test_component.uint_sys_var;
@@test_component.uint_sys_var
1024
SET GLOBAL test_component.uint_sys_var=12345678;
Warnings:
Warning 1292 Truncated incorrect test_component.uint_sys_var value: '12345678'
SELECT @@test_component.uint_sys_var;
@@test_component.uint_sys_var
10241024
SET GLOBAL test_component.uint_sys_var=default;
SELECT @@test_component.uint_sys_var;
@@test_component.uint_sys_var
1024
# Testing long type variable
SELECT @@test_component.long_sys_var;
@@test_component.long_sys_var
100
SET GLOBAL test_component.long_sys_var=1234567890;
Warnings:
Warning 1292 Truncated incorrect test_component.long_sys_var value: '1234567890'
SELECT @@test_component.long_sys_var;
@@test_component.long_sys_var
100
SET GLOBAL test_component.long_sys_var=default;
SELECT @@test_component.long_sys_var;
@@test_component.long_sys_var
100
# Testing unsigned long type variable
SELECT @@test_component.ulong_sys_var;
@@test_component.ulong_sys_var
8192
SET GLOBAL test_component.ulong_sys_var=1234567890;
Warnings:
Warning 1292 Truncated incorrect test_component.ulong_sys_var value: '1234567890'
SELECT @@test_component.ulong_sys_var;
@@test_component.ulong_sys_var
81928192
SET GLOBAL test_component.ulong_sys_var=default;
SELECT @@test_component.ulong_sys_var;
@@test_component.ulong_sys_var
8192
# Testing long long type variable
SELECT @@test_component.longlong_sys_var;
@@test_component.longlong_sys_var
8192
SET GLOBAL test_component.longlong_sys_var=1234567890;
SELECT @@test_component.longlong_sys_var;
@@test_component.longlong_sys_var
1234567890
SET GLOBAL test_component.longlong_sys_var=default;
SELECT @@test_component.longlong_sys_var;
@@test_component.longlong_sys_var
8192
# Testing unsigned long long type variable
SELECT @@test_component.ulonglong_sys_var;
@@test_component.ulonglong_sys_var
8192
SET GLOBAL test_component.ulonglong_sys_var=1234567890;
SELECT @@test_component.ulonglong_sys_var;
@@test_component.ulonglong_sys_var
1234567890
SET GLOBAL test_component.ulonglong_sys_var=default;
SELECT @@test_component.ulonglong_sys_var;
@@test_component.ulonglong_sys_var
8192
# Testing PERSIST for component system variables
SET PERSIST test_component.int_sys_var=7;
SELECT @@test_component.int_sys_var;
@@test_component.int_sys_var
7
SELECT * FROM performance_schema.persisted_variables;
VARIABLE_NAME VARIABLE_VALUE
test_component.int_sys_var 7
RESET PERSIST `test_component.int_sys_var`;
SELECT * FROM performance_schema.persisted_variables;
VARIABLE_NAME VARIABLE_VALUE
UNINSTALL COMPONENT "file://component_test_sys_var_service";
########## test_component_sys_var_service.log:
test_component_sys_var init:
int register_variable failed.
variable value : 8
variable value : 1024
variable value : 100
variable value : 8192
variable value : 8192
variable value : 8192
variable value : ON
variable value : MEDIUM
variable value :
test_component_sys_var end of init:
test_component_sys_var deinit:
test_component_sys_var end of deinit:
#
# Coverage/regression tests for component & SP interations
#
CREATE PROCEDURE p(x VARCHAR(32)) SET @@GLOBAL.test_component.str_sys_var = x;
ERROR HY000: Unknown system variable 'test_component.str_sys_var'
CREATE PROCEDURE p() SELECT @@test_component.str_sys_var;
ERROR HY000: Unknown system variable 'test_component.str_sys_var'
INSTALL COMPONENT "file://component_test_sys_var_service";
CREATE PROCEDURE p1(x VARCHAR(32)) SET @@GLOBAL.test_component.str_sys_var = x;
CREATE PROCEDURE p2() SELECT @@test_component.str_sys_var;
CALL p2();
@@test_component.str_sys_var
NULL
CALL p1('test');
CALL p2();
@@test_component.str_sys_var
test
# Try to uninstall the component and fail with a warning since its busy
UNINSTALL COMPONENT "file://component_test_sys_var_service";
# Check that the component has been uninstalled
UNINSTALL COMPONENT "file://component_test_sys_var_service";
ERROR HY000: Component specified by URN 'file://component_test_sys_var_service' to unload has not been loaded before.
# Variable is not available any more: the component is uninstalling
CALL p1('test');
ERROR HY000: Unknown system variable 'test_component.str_sys_var'
CALL p2();
ERROR HY000: Unknown system variable 'test_component.str_sys_var'
# Check that the component is uninstalled
INSTALL COMPONENT "file://component_test_sys_var_service";
# Variable is available again
CALL p2();
@@test_component.str_sys_var
NULL
CALL p1('test');
CALL p2();
@@test_component.str_sys_var
test
UNINSTALL COMPONENT "file://component_test_sys_var_service";
DROP PROCEDURE p1;
DROP PROCEDURE p2;
|