Debian Codegraph @

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

raw
1 ############## mysql-test\t\identity_basic.test ###############
2 # #
3 # Variable Name: identity #
4 # Scope: SESSION #
5 # Access Type: Dynamic #
6 # Data Type: numeric #
7 # Default Value: - #
8 # Range: - #
9 # #
10 # #
11 # Creation Date: 2008-02-07 #
12 # Author: Salman #
13 # #
14 # Description: Test Cases of Dynamic System Variable identity #
15 # that checks the behavior of this variable in the following ways#
16 # * Default Value #
17 # * Valid & Invalid values #
18 # * Scope & Access method #
19 # * Data Integrity #
20 # #
21 # Reference: http://dev.mysql.com/doc/refman/5.1/en/ #
22 # server-system-variables.html #
23 # #
24 ###############################################################################
25
26 --source include/load_sysvars.inc
27
28 ################################################################
29 # START OF identity TESTS #
30 ################################################################
31
32
33 ################################################################
34 # Saving initial value of identity in a temporary variable #
35 ################################################################
36
37 SET @start_value = @@session.identity;
38 SELECT @start_value;
39
40
41 --echo '#--------------------FN_DYNVARS_035_01------------------------#'
42 ########################################################################
43 # Display the DEFAULT value of identity #
44 ########################################################################
45
46 SET @@session.identity = 99;
47 # SET @@session.identity = DEFAULT;
48 --echo 'Variable is giving error on assigning Default value';
49 SELECT @@session.identity;
50
51
52 --echo '#---------------------FN_DYNVARS_035_02-------------------------#'
53 ###############################################
54 # Verify default value of variable #
55 ###############################################
56
57 SET @@session.identity = @start_value;
58 SELECT @@session.identity = 0;
59
60
61 --echo '#--------------------FN_DYNVARS_035_03------------------------#'
62 ########################################################################
63 # Change the value of identity to a valid value #
64 ########################################################################
65
66 SET @@session.identity = 0;
67 SELECT @@session.identity;
68 SET @@session.identity = 1099;
69 SELECT @@session.identity;
70 SET @@session.identity = 1800;
71 SELECT @@session.identity;
72 SET @@session.identity = 65535;
73 SELECT @@session.identity;
74
75
76 --echo '#--------------------FN_DYNVARS_035_04-------------------------#'
77 ###########################################################################
78 # Change the value of identity to invalid value #
79 ###########################################################################
80
81 SET @@session.identity = -1;
82 SELECT @@session.identity;
83 SET @@session.identity = 100000000000;
84 SELECT @@session.identity;
85 --Error ER_WRONG_TYPE_FOR_VAR
86 SET @@session.identity = 10000.01;
87 SELECT @@session.identity;
88 SET @@session.identity = -1024;
89 SELECT @@session.identity;
90 SET @@session.identity = 42949672950;
91 SELECT @@session.identity;
92 --Error ER_WRONG_TYPE_FOR_VAR
93 SET @@session.identity = " ";
94 SELECT @@session.identity;
95 --Error ER_WRONG_TYPE_FOR_VAR
96 SET @@session.identity = ' ';
97 SELECT @@session.identity;
98
99 --Error ER_WRONG_TYPE_FOR_VAR
100 SET @@session.identity = ON;
101 SELECT @@session.identity;
102 --Error ER_WRONG_TYPE_FOR_VAR
103 SET @@session.identity = 'test';
104 SELECT @@session.identity;
105
106
107 --echo '#-------------------FN_DYNVARS_035_05----------------------------#'
108 ###########################################################################
109 # Test if accessing global identity gives error #
110 ###########################################################################
111
112 --Error ER_LOCAL_VARIABLE
113 SET @@global.identity = 0;
114 --Error ER_INCORRECT_GLOBAL_LOCAL_VAR
115 SELECT @@global.identity;
116
117
118 --echo '#----------------------FN_DYNVARS_035_06------------------------#'
119 ##############################################################################
120 # Check if the value in GLOBAL & SESSION Tables matches values in variable #
121 ##############################################################################
122
123 --Error ER_INCORRECT_GLOBAL_LOCAL_VAR
124 SELECT @@global.identity = VARIABLE_VALUE
125 FROM performance_schema.global_variables
126 WHERE VARIABLE_NAME='identity';
127
128 --disable_warnings
129 SELECT @@session.identity = VARIABLE_VALUE
130 FROM performance_schema.session_variables
131 WHERE VARIABLE_NAME='identity';
132 --enable_warnings
133
134
135 --echo '#-------------------FN_DYNVARS_035_07----------------------------#'
136 ######################################################################
137 # Test if accessing GLOBAL identity gives error #
138 ######################################################################
139
140 --Error ER_LOCAL_VARIABLE
141 SET @@global.identity = 0;
142 --Error ER_INCORRECT_GLOBAL_LOCAL_VAR
143 SELECT @@global.identity;
144
145 --echo '#---------------------FN_DYNVARS_035_08----------------------#'
146 ###################################################################
147 # Check if TRUE and FALSE values can be used on variable #
148 ###################################################################
149
150 SET @@session.identity = TRUE;
151 SELECT @@session.identity;
152 SET @@session.identity = FALSE;
153 SELECT @@session.identity;
154
155
156 --echo '#---------------------FN_DYNVARS_035_09----------------------#'
157 ########################################################################################################
158 # Check if accessing variable with SESSION,LOCAL and without SCOPE points to same session variable #
159 ########################################################################################################
160
161 SET @@session.identity = 1;
162 SELECT @@identity = @@session.identity;
163 SELECT @@session.identity = @@local.identity;
164
165
166 --echo '#---------------------FN_DYNVARS_035_10----------------------#'
167 ##########################################################################
168 # Check if identity can be accessed with and without @@ sign #
169 ##########################################################################
170
171
172 SET identity = 1;
173 SELECT @@identity;
174 --Error ER_PARSE_ERROR
175 SET local.identity = 1;
176 --Error ER_UNKNOWN_TABLE
177 SELECT local.identity;
178 --Error ER_PARSE_ERROR
179 SET session.identity = 1;
180 --Error ER_UNKNOWN_TABLE
181 SELECT session.identity;
182 --Error ER_BAD_FIELD_ERROR
183 SELECT identity = @@session.identity;
184
185
186 ##############################
187 # Restore initial value #
188 ##############################
189
190 SET @@session.identity = @start_value;
191 SELECT @@session.identity;
192
193
194 ########################################################################
195 # END OF identity TESTS #
196 ########################################################################