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
93 --Error ER_WRONG_TYPE_FOR_VAR
94 SET @@session.identity = ON;
95 SELECT @@session.identity;
96 --Error ER_WRONG_TYPE_FOR_VAR
97 SET @@session.identity = 'test';
98 SELECT @@session.identity;
99
100
101 --echo '#-------------------FN_DYNVARS_035_05----------------------------#'
102 ###########################################################################
103 # Test if accessing global identity gives error #
104 ###########################################################################
105
106 --Error ER_LOCAL_VARIABLE
107 SET @@global.identity = 0;
108 --Error ER_INCORRECT_GLOBAL_LOCAL_VAR
109 SELECT @@global.identity;
110
111
112 --echo '#----------------------FN_DYNVARS_035_06------------------------#'
113 ##############################################################################
114 # Check if the value in GLOBAL & SESSION Tables matches values in variable #
115 ##############################################################################
116
117 --Error ER_INCORRECT_GLOBAL_LOCAL_VAR
118 SELECT @@global.identity = VARIABLE_VALUE
119 FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
120 WHERE VARIABLE_NAME='identity';
121
122 SELECT @@session.identity = VARIABLE_VALUE
123 FROM INFORMATION_SCHEMA.SESSION_VARIABLES
124 WHERE VARIABLE_NAME='identity';
125
126
127 --echo '#-------------------FN_DYNVARS_035_07----------------------------#'
128 ######################################################################
129 # Test if accessing GLOBAL identity gives error #
130 ######################################################################
131
132 --Error ER_LOCAL_VARIABLE
133 SET @@global.identity = 0;
134 --Error ER_INCORRECT_GLOBAL_LOCAL_VAR
135 SELECT @@global.identity;
136
137 --echo '#---------------------FN_DYNVARS_035_08----------------------#'
138 ###################################################################
139 # Check if TRUE and FALSE values can be used on variable #
140 ###################################################################
141
142 SET @@session.identity = TRUE;
143 SELECT @@session.identity;
144 SET @@session.identity = FALSE;
145 SELECT @@session.identity;
146
147
148 --echo '#---------------------FN_DYNVARS_035_09----------------------#'
149 ########################################################################################################
150 # Check if accessing variable with SESSION,LOCAL and without SCOPE points to same session variable #
151 ########################################################################################################
152
153 SET @@session.identity = 1;
154 SELECT @@identity = @@session.identity;
155 SELECT @@session.identity = @@local.identity;
156
157
158 --echo '#---------------------FN_DYNVARS_035_10----------------------#'
159 ##########################################################################
160 # Check if identity can be accessed with and without @@ sign #
161 ##########################################################################
162
163
164 SET identity = 1;
165 SELECT @@identity;
166 --Error ER_UNKNOWN_TABLE
167 SELECT local.identity;
168 --Error ER_UNKNOWN_TABLE
169 SELECT session.identity;
170 --Error ER_BAD_FIELD_ERROR
171 SELECT identity = @@session.identity;
172
173
174 ##############################
175 # Restore initial value #
176 ##############################
177
178 SET @@session.identity = @start_value;
179 SELECT @@session.identity;
180
181
182 ########################################################################
183 # END OF identity TESTS #
184 ########################################################################