Debian Codegraph @

mysql-test/suite/sys_vars/t/immediate_server_version_basic.test

raw
1 #
2 # ==== Purpose ====
3 #
4 # In this test we check that the variable immediate_server_version can be
5 # correctly set and accessed.
6 #
7 #
8 # ==== References ====
9 #
10 # WL#11879 replicate original server version
11
12 --let $default_value = 999999
13 --let $max_value = 999999
14
15 --error ER_INCORRECT_GLOBAL_LOCAL_VAR
16 SELECT @@GLOBAL.immediate_server_version;
17
18 --let $ISV = `SELECT @@SESSION.immediate_server_version;`
19 --let $assert_text = immediate_server_version must be accessible and have the default value
20 --let $assert_cond = $ISV = $default_value
21 --source include/assert.inc
22
23 # Verify that SHOW VARIABLES works
24 SHOW VARIABLES LIKE 'immediate_server_version';
25
26 # Check if value can set
27 --error ER_LOCAL_VARIABLE
28 SET @@GLOBAL.immediate_server_version = 123456;
29
30 SET @@SESSION.immediate_server_version = 123456;
31 --let $ISV = `SELECT @@SESSION.immediate_server_version;`
32 --let $assert_text = immediate_server_version must be equal to the set value
33 --let $assert_cond = $ISV = 123456
34 --source include/assert.inc
35
36 # Check errors for wrong values (different type or not in the range of allowed
37 # values)
38
39 # This will generate a warning
40 SET @@SESSION.immediate_server_version = -123456;
41 --let $ISV = `SELECT @@SESSION.immediate_server_version;`
42 --let $assert_text = immediate_server_version must be 0
43 --let $assert_cond = $ISV = 0
44 --source include/assert.inc
45
46 # Should be accepted
47 SET @@SESSION.immediate_server_version = 0;
48 --let $ISV = `SELECT @@SESSION.immediate_server_version;`
49 --let $assert_text = immediate_server_version must be 0
50 --let $assert_cond = $ISV = 0
51 --source include/assert.inc
52
53 --error ER_WRONG_TYPE_FOR_VAR
54 SET @@SESSION.immediate_server_version = 123456789012345678901;
55 --let $ISV = `SELECT @@SESSION.immediate_server_version;`
56 --let $assert_text = immediate_server_version must be 0
57 --let $assert_cond = $ISV = 0
58 --source include/assert.inc
59
60 --error ER_WRONG_TYPE_FOR_VAR
61 SET @@SESSION.immediate_server_version = 'xyz';
62 --let $ISV = `SELECT @@SESSION.immediate_server_version;`
63 --let $assert_text = immediate_server_version must be 0
64 --let $assert_cond = $ISV = 0
65 --source include/assert.inc
66
67 --error ER_WRONG_TYPE_FOR_VAR
68 SET @@SESSION.immediate_server_version = xyz;
69 --let $ISV = `SELECT @@SESSION.immediate_server_version;`
70 --let $assert_text = immediate_server_version must be 0
71 --let $assert_cond = $ISV = 0
72 --source include/assert.inc
73
74 # Should give a warning and truncate the value and set it to the maximum value
75 SET @@SESSION.immediate_server_version = 36028797018963969;
76 --let $ISV = `SELECT @@SESSION.immediate_server_version;`
77 --let $assert_text = immediate_server_version must be equal to the maximum value
78 --let $assert_cond = $ISV = $max_value
79 --source include/assert.inc
80
81 # Should give a warning and truncate the value and set it to the maximum value
82 SET @@SESSION.immediate_server_version = 18446744073709551615;
83 --let $ISV = `SELECT @@SESSION.immediate_server_version;`
84 --let $assert_text = immediate_server_version must be equal to the maximum value
85 --let $assert_cond = $ISV = $max_value
86 --source include/assert.inc
87
88 # Should give a error
89 --error ER_WRONG_TYPE_FOR_VAR
90 SET @@SESSION.immediate_server_version = 18446744073709551616;
91 --let $ISV = `SELECT @@SESSION.immediate_server_version;`
92 --let $assert_text = immediate_server_version must be equal to the maximum value
93 --let $assert_cond = $ISV = $max_value
94 --source include/assert.inc
95
96
97 # Check if the value in SESSION Table matches value in variable
98
99 --let $count =`SELECT @@SESSION.immediate_server_version = VARIABLE_VALUE FROM performance_schema.session_variables WHERE VARIABLE_NAME='immediate_server_version';`
100 --let $assert_text = The value in session table matches the one in the variable
101 --let $assert_cond = $count = 1
102 --source include/assert.inc
103
104 --let $count = `SELECT COUNT(@@SESSION.immediate_server_version);`
105 --let $assert_text = There is only one variable with this name
106 --let $assert_cond = $count = 1
107 --source include/assert.inc
108
109 --let $count = `SELECT COUNT(VARIABLE_VALUE) FROM performance_schema.session_variables WHERE VARIABLE_NAME='immediate_server_version';`
110 --let $assert_text = There is only one variable with this name in the performance schema table
111 --let $assert_cond = $count = 1
112 --source include/assert.inc
113
114 # Check if immediate_server_version can be accessed with @@ sign
115
116 --let $count = `SELECT COUNT(@@immediate_server_version);`
117 --let $assert_text = The variable can be accessed with @@ sign
118 --let $assert_cond = $count = 1
119 --source include/assert.inc
120
121 # Check that it's read-only to a NON super privileged
122
123 # Create new user without super privilege
124 CREATE USER nosuper;
125 connect (conn_nosuper,localhost,nosuper,,);
126 --error ER_SPECIFIC_ACCESS_DENIED_ERROR
127 SET SESSION immediate_server_version = 0;
128 --disconnect conn_nosuper
129 --connection default
130 DROP USER nosuper;