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
|
# ==== Purpose ====
#
# Verify that a variable that is not defined in a scope cannot be
# accessed in that scope.
#
# ==== Requirements ====
#
# R1. SET should fail in all cases:
# R1.1. SET @@$scope.$variable = <VALUE>
# R1.2. SET @@$scope.$variable = DEFAULT
# R1.3. SET @@$variable = <VALUE>
# R1.4. SET @@$variable = DEFAULT
#
# R2. SELECT:
# R2.1. SELECT @@$scope.$variable should fail
# R2.2. if $scope is global, SELECT @@$variable should fail
# R2.3. if $scope is session, SELECT @@$variable should succeed
#
# R3. performance_schema:
# R3.1. if $scope is global, performance_schema.global_variables
# should not contain the variable
# R3.1. if $scope is session, performance_schema.session_variables
# should contain the variable
#
# ==== Usage ====
#
# --let $scope = {global|session}
# --let $name = NAME
# --let $values = JSON_ARRAY
# --let $global = {0|1}
# [--let $mask_value = 1]
# --source scenarios_for_dynamic_sysvar.inc
#
# Parameters:
#
# $scope
# The scope to test.
#
# All other parameters
# See json_sysvar_spec.inc
--echo ==== Testing SET @@$scope.$name [invalid scope] ====
if (!$dynamic) {
--let $error_code = ER_INCORRECT_GLOBAL_LOCAL_VAR
}
if ($dynamic) {
--let $error_code = ER_GLOBAL_VARIABLE
}
--error $error_code
eval SET @@$scope.$name = DEFAULT;
if ($scope == session) {
--error $error_code
eval SET @@$name = DEFAULT;
}
# Iterate over values, try to set the variable, and verify that it fails.
--let $json_array = $values
--source $json_value_start
while (!$json_value_done) {
if ($mask_value) {
--replace_result $json_value_value VALUE
}
--error $error_code
eval SET @@$scope.$name = $json_value_value;
if ($scope == session) {
if ($mask_value) {
--replace_result $json_value_value VALUE
}
--error $error_code
eval SET @@$name = $json_value_value;
}
--source $json_value_next
}
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
eval SELECT @@$scope.$name;
if ($scope == session) {
if ($mask_value) {
--disable_result_log
eval SELECT @@$name;
--enable_result_log
}
if (!$mask_value) {
eval SELECT @@$name;
}
}
--let $ps_table_name = _variables
--let $ps_table_name = performance_schema.$scope$ps_table_name
--let $actual_row_count = [SELECT COUNT(*) FROM $ps_table_name WHERE VARIABLE_NAME = '$name']
--let $expected_row_count = 0
--let $exist_text = not exist
if ($scope == session) {
if ($global) {
# Global variables always exist in performance_schema.session_variables
--let $expected_row_count = 1
--let $exist_text = exist
}
}
--let $assert_cond = $actual_row_count = $expected_row_count
--let $assert_text = Variable $name should $exist_text in $ps_table_name
--source include/assert.inc
|