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