Debian Codegraph @

mysql-test/suite/sys_vars/inc/scenarios_for_wrong_scope_sysvar.inc

raw
1 # ==== Purpose ====
2 #
3 # Verify that a variable that is not defined in a scope cannot be
4 # accessed in that scope.
5 #
6 # ==== Requirements ====
7 #
8 # R1. SET should fail in all cases:
9 # R1.1. SET @@$scope.$variable = <VALUE>
10 # R1.2. SET @@$scope.$variable = DEFAULT
11 # R1.3. SET @@$variable = <VALUE>
12 # R1.4. SET @@$variable = DEFAULT
13 #
14 # R2. SELECT:
15 # R2.1. SELECT @@$scope.$variable should fail
16 # R2.2. if $scope is global, SELECT @@$variable should fail
17 # R2.3. if $scope is session, SELECT @@$variable should succeed
18 #
19 # R3. performance_schema:
20 # R3.1. if $scope is global, performance_schema.global_variables
21 # should not contain the variable
22 # R3.1. if $scope is session, performance_schema.session_variables
23 # should contain the variable
24 #
25 # ==== Usage ====
26 #
27 # --let $scope = {global|session}
28 # --let $name = NAME
29 # --let $values = JSON_ARRAY
30 # --let $global = {0|1}
31 # [--let $mask_value = 1]
32 # --source scenarios_for_dynamic_sysvar.inc
33 #
34 # Parameters:
35 #
36 # $scope
37 # The scope to test.
38 #
39 # All other parameters
40 # See json_sysvar_spec.inc
41
42 --echo ==== Testing SET @@$scope.$name [invalid scope] ====
43
44 if (!$dynamic) {
45 --let $error_code = ER_INCORRECT_GLOBAL_LOCAL_VAR
46 }
47 if ($dynamic) {
48 --let $error_code = ER_GLOBAL_VARIABLE
49 }
50
51 --error $error_code
52 eval SET @@$scope.$name = DEFAULT;
53 if ($scope == session) {
54 --error $error_code
55 eval SET @@$name = DEFAULT;
56 }
57
58 # Iterate over values, try to set the variable, and verify that it fails.
59 --let $json_array = $values
60 --source $json_value_start
61 while (!$json_value_done) {
62
63 if ($mask_value) {
64 --replace_result $json_value_value VALUE
65 }
66 --error $error_code
67 eval SET @@$scope.$name = $json_value_value;
68 if ($scope == session) {
69 if ($mask_value) {
70 --replace_result $json_value_value VALUE
71 }
72 --error $error_code
73 eval SET @@$name = $json_value_value;
74 }
75
76 --source $json_value_next
77 }
78
79 --error ER_INCORRECT_GLOBAL_LOCAL_VAR
80 eval SELECT @@$scope.$name;
81 if ($scope == session) {
82 if ($mask_value) {
83 --disable_result_log
84 eval SELECT @@$name;
85 --enable_result_log
86 }
87 if (!$mask_value) {
88 eval SELECT @@$name;
89 }
90 }
91
92 --let $ps_table_name = _variables
93 --let $ps_table_name = performance_schema.$scope$ps_table_name
94 --let $actual_row_count = [SELECT COUNT(*) FROM $ps_table_name WHERE VARIABLE_NAME = '$name']
95 --let $expected_row_count = 0
96 --let $exist_text = not exist
97 if ($scope == session) {
98 if ($global) {
99 # Global variables always exist in performance_schema.session_variables
100 --let $expected_row_count = 1
101 --let $exist_text = exist
102 }
103 }
104
105 --let $assert_cond = $actual_row_count = $expected_row_count
106 --let $assert_text = Variable $name should $exist_text in $ps_table_name
107 --source include/assert.inc