| 1 |
# Base test for registration of system variables by components. |
| 2 |
|
| 3 |
--source ../include/have_component_test_sys_var_service.inc |
| 4 |
|
| 5 |
call mtr.add_suppression("duplicate variable name"); |
| 6 |
--echo # Simple load test |
| 7 |
INSTALL COMPONENT "file://component_test_sys_var_service"; |
| 8 |
|
| 9 |
--echo # Testing integer and bool type variable |
| 10 |
SELECT @@test_component.int_sys_var; |
| 11 |
SELECT @@global.test_component.int_sys_var; |
| 12 |
SELECT @@global.test_component.bool_sys_var; |
| 13 |
SELECT @@test_component.int_sys_var, @@test_component.bool_sys_var; |
| 14 |
--error ER_GLOBAL_VARIABLE |
| 15 |
SET test_component.bool_sys_var=1; |
| 16 |
SET GLOBAL test_component.int_sys_var=7; |
| 17 |
# The max value for the test_component.int_sys_var is 1024. Hence below SET |
| 18 |
# stmt will set the value to 1024. |
| 19 |
SET GLOBAL test_component.int_sys_var=1234567; |
| 20 |
SELECT @@test_component.int_sys_var; |
| 21 |
# The min value for the test_component.int_sys_var is 0. Hence below SET stmt |
| 22 |
# will set the value to 0. |
| 23 |
SET GLOBAL test_component.int_sys_var=-1; |
| 24 |
SELECT @@test_component.int_sys_var; |
| 25 |
--error ER_WRONG_TYPE_FOR_VAR |
| 26 |
SET GLOBAL test_component.int_sys_var=1.25; |
| 27 |
--error ER_WRONG_TYPE_FOR_VAR |
| 28 |
SET GLOBAL test_component.int_sys_var="hello"; |
| 29 |
SET GLOBAL test_component.int_sys_var=123, test_component.bool_sys_var=0; |
| 30 |
SELECT @@test_component.int_sys_var, @@test_component.bool_sys_var; |
| 31 |
--error ER_GLOBAL_VARIABLE |
| 32 |
SET SESSION test_component.int_sys_var=123; |
| 33 |
|
| 34 |
--echo # Testing enum type variable |
| 35 |
SELECT @@test_component.enum_sys_var; |
| 36 |
SET GLOBAL test_component.enum_sys_var="LOW"; |
| 37 |
SELECT @@test_component.enum_sys_var; |
| 38 |
|
| 39 |
--echo # Testing string type variable |
| 40 |
SELECT @@test_component.str_sys_var; |
| 41 |
SET GLOBAL test_component.str_sys_var="dictionary.txt"; |
| 42 |
SELECT @@test_component.str_sys_var; |
| 43 |
SET GLOBAL test_component.str_sys_var=default; |
| 44 |
SELECT @@test_component.str_sys_var; |
| 45 |
|
| 46 |
--echo # Testing string type variable with default value |
| 47 |
SELECT @@test_component.str_sys_var_default; |
| 48 |
SET GLOBAL test_component.str_sys_var_default="dictionary.txt"; |
| 49 |
SELECT @@test_component.str_sys_var_default; |
| 50 |
SET GLOBAL test_component.str_sys_var_default=something; |
| 51 |
SELECT @@test_component.str_sys_var_default; |
| 52 |
|
| 53 |
--echo # Testing unsigned integer type variable |
| 54 |
SELECT @@test_component.uint_sys_var; |
| 55 |
SET GLOBAL test_component.uint_sys_var=12345678; |
| 56 |
SELECT @@test_component.uint_sys_var; |
| 57 |
SET GLOBAL test_component.uint_sys_var=default; |
| 58 |
SELECT @@test_component.uint_sys_var; |
| 59 |
|
| 60 |
--echo # Testing long type variable |
| 61 |
SELECT @@test_component.long_sys_var; |
| 62 |
SET GLOBAL test_component.long_sys_var=1234567890; |
| 63 |
SELECT @@test_component.long_sys_var; |
| 64 |
SET GLOBAL test_component.long_sys_var=default; |
| 65 |
SELECT @@test_component.long_sys_var; |
| 66 |
|
| 67 |
--echo # Testing unsigned long type variable |
| 68 |
SELECT @@test_component.ulong_sys_var; |
| 69 |
SET GLOBAL test_component.ulong_sys_var=1234567890; |
| 70 |
SELECT @@test_component.ulong_sys_var; |
| 71 |
SET GLOBAL test_component.ulong_sys_var=default; |
| 72 |
SELECT @@test_component.ulong_sys_var; |
| 73 |
|
| 74 |
--echo # Testing long long type variable |
| 75 |
SELECT @@test_component.longlong_sys_var; |
| 76 |
SET GLOBAL test_component.longlong_sys_var=1234567890; |
| 77 |
SELECT @@test_component.longlong_sys_var; |
| 78 |
SET GLOBAL test_component.longlong_sys_var=default; |
| 79 |
SELECT @@test_component.longlong_sys_var; |
| 80 |
|
| 81 |
--echo # Testing unsigned long long type variable |
| 82 |
SELECT @@test_component.ulonglong_sys_var; |
| 83 |
SET GLOBAL test_component.ulonglong_sys_var=1234567890; |
| 84 |
SELECT @@test_component.ulonglong_sys_var; |
| 85 |
SET GLOBAL test_component.ulonglong_sys_var=default; |
| 86 |
SELECT @@test_component.ulonglong_sys_var; |
| 87 |
|
| 88 |
--echo # Testing PERSIST for component system variables |
| 89 |
SET PERSIST test_component.int_sys_var=7; |
| 90 |
SELECT @@test_component.int_sys_var; |
| 91 |
SELECT * FROM performance_schema.persisted_variables; |
| 92 |
RESET PERSIST `test_component.int_sys_var`; |
| 93 |
SELECT * FROM performance_schema.persisted_variables; |
| 94 |
|
| 95 |
UNINSTALL COMPONENT "file://component_test_sys_var_service"; |
| 96 |
|
| 97 |
# Write the test results in "test_component_sys_var_service.log" into the |
| 98 |
# result file of this test |
| 99 |
--echo ########## test_component_sys_var_service.log: |
| 100 |
let $MYSQLD_DATADIR= `select @@datadir`; |
| 101 |
cat_file $MYSQLD_DATADIR/test_component_sys_var_service.log; |
| 102 |
remove_file $MYSQLD_DATADIR/test_component_sys_var_service.log; |
| 103 |
|
| 104 |
--echo # |
| 105 |
--echo # Coverage/regression tests for component & SP interations |
| 106 |
--echo # |
| 107 |
|
| 108 |
--error ER_UNKNOWN_SYSTEM_VARIABLE |
| 109 |
CREATE PROCEDURE p(x VARCHAR(32)) SET @@GLOBAL.test_component.str_sys_var = x; |
| 110 |
|
| 111 |
--error ER_UNKNOWN_SYSTEM_VARIABLE |
| 112 |
CREATE PROCEDURE p() SELECT @@test_component.str_sys_var; |
| 113 |
|
| 114 |
INSTALL COMPONENT "file://component_test_sys_var_service"; |
| 115 |
|
| 116 |
CREATE PROCEDURE p1(x VARCHAR(32)) SET @@GLOBAL.test_component.str_sys_var = x; |
| 117 |
CREATE PROCEDURE p2() SELECT @@test_component.str_sys_var; |
| 118 |
|
| 119 |
CALL p2(); |
| 120 |
CALL p1('test'); |
| 121 |
CALL p2(); |
| 122 |
|
| 123 |
--echo # Try to uninstall the component and fail with a warning since its busy |
| 124 |
UNINSTALL COMPONENT "file://component_test_sys_var_service"; |
| 125 |
|
| 126 |
--echo # Check that the component has been uninstalled |
| 127 |
--error ER_COMPONENTS_UNLOAD_NOT_LOADED |
| 128 |
UNINSTALL COMPONENT "file://component_test_sys_var_service"; |
| 129 |
|
| 130 |
--echo # Variable is not available any more: the component is uninstalling |
| 131 |
--error ER_UNKNOWN_SYSTEM_VARIABLE |
| 132 |
CALL p1('test'); |
| 133 |
--error ER_UNKNOWN_SYSTEM_VARIABLE |
| 134 |
CALL p2(); |
| 135 |
|
| 136 |
--echo # Check that the component is uninstalled |
| 137 |
--replace_regex /\.dll/.so/ |
| 138 |
eval INSTALL COMPONENT "file://component_test_sys_var_service"; |
| 139 |
|
| 140 |
--echo # Variable is available again |
| 141 |
CALL p2(); |
| 142 |
CALL p1('test'); |
| 143 |
CALL p2(); |
| 144 |
|
| 145 |
UNINSTALL COMPONENT "file://component_test_sys_var_service"; |
| 146 |
|
| 147 |
DROP PROCEDURE p1; |
| 148 |
DROP PROCEDURE p2; |