1
############## mysql-test\t\auto_increment_offset_basic.test ###################
3
# Variable Name: auto_increment_offset #
4
# Scope: GLOBAL & SESSION #
5
# Access Type: Dynamic #
11
# Creation Date: 2008-02-07 #
12
# Author: Salman Rawala #
14
# Description: Test Cases of Dynamic System Variable "auto_increment_offset" #
15
# that checks behavior of this variable in the following ways #
17
# * Valid & Invalid values #
18
# * Scope & Access method #
21
# Reference: http://dev.mysql.com/doc/refman/5.1/en/ #
22
# server-system-variables.html#option_mysqld_auto-increment-offset #
24
################################################################################
26
--source include/load_sysvars.inc
28
#####################################################################
29
# START OF auto_increment_offset TESTS #
30
#####################################################################
32
#############################################################
33
# Save initial value #
34
#############################################################
36
SET @start_global_value = @@global.auto_increment_offset;
37
SELECT @start_global_value;
38
SET @start_session_value = @@session.auto_increment_offset;
39
SELECT @start_session_value;
42
--echo '#--------------------FN_DYNVARS_002_01-------------------------#'
43
#####################################################################
44
# Display the DEFAULT value of auto_increment_offset #
45
#####################################################################
47
SET @@global.auto_increment_offset = 100;
48
SET @@global.auto_increment_offset = DEFAULT;
49
SELECT @@global.auto_increment_offset;
51
SET @@session.auto_increment_offset = 200;
52
SET @@session.auto_increment_offset = DEFAULT;
53
SELECT @@session.auto_increment_offset;
56
--echo '#--------------------FN_DYNVARS_002_02-------------------------#'
57
#####################################################################
58
# Check the DEFAULT value of auto_increment_offset #
59
#####################################################################
61
SET @@global.auto_increment_offset = @start_global_value;
62
SELECT @@global.auto_increment_offset = 1;
63
SET @@session.auto_increment_offset = @start_session_value;
64
SELECT @@session.auto_increment_offset = 1;
67
--echo '#--------------------FN_DYNVARS_002_03-------------------------#'
68
###############################################################################
69
# Change the value of auto_increment_offset to a valid value for GLOBAL Scope #
70
###############################################################################
72
SET @@global.auto_increment_offset = 1;
73
SELECT @@global.auto_increment_offset;
74
SET @@global.auto_increment_offset = 60020;
75
SELECT @@global.auto_increment_offset;
76
SET @@global.auto_increment_offset = 65535;
77
SELECT @@global.auto_increment_offset;
80
--echo '#--------------------FN_DYNVARS_002_04-------------------------#'
81
###############################################################################
82
# Change the value of auto_increment_offset to a valid value for SESSION Scope#
83
###############################################################################
85
SET @@session.auto_increment_offset = 1;
86
SELECT @@session.auto_increment_offset;
87
SET @@session.auto_increment_offset = 50050;
88
SELECT @@session.auto_increment_offset;
89
SET @@session.auto_increment_offset = 65535;
90
SELECT @@session.auto_increment_offset;
93
--echo '#------------------FN_DYNVARS_002_05-----------------------#'
94
#################################################################
95
# Change the value of auto_increment_offset to an invalid value #
96
#################################################################
98
SET @@global.auto_increment_offset = 0;
99
SELECT @@global.auto_increment_offset;
100
SET @@global.auto_increment_offset = -1024;
101
SELECT @@global.auto_increment_offset;
102
SET @@global.auto_increment_offset = 65536;
103
SELECT @@global.auto_increment_offset;
104
--Error ER_WRONG_TYPE_FOR_VAR
105
SET @@global.auto_increment_offset = ON;
106
SELECT @@global.auto_increment_offset;
107
--Error ER_WRONG_TYPE_FOR_VAR
108
SET @@global.auto_increment_offset = OFF;
109
SELECT @@global.auto_increment_offset;
110
--Error ER_WRONG_TYPE_FOR_VAR
111
SET @@global.auto_increment_offset = test;
112
SELECT @@global.auto_increment_offset;
114
SET @@session.auto_increment_offset = 0;
115
SELECT @@session.auto_increment_offset;
116
SET @@session.auto_increment_offset = -2;
117
SELECT @@session.auto_increment_offset;
118
SET @@session.auto_increment_offset = 65550;
119
SELECT @@session.auto_increment_offset;
120
echo 'Bug # 34837: Errors are not coming on assigning invalid values to variable';
122
--Error ER_WRONG_TYPE_FOR_VAR
123
SET @@session.auto_increment_offset = ON;
124
SELECT @@session.auto_increment_offset;
125
--Error ER_WRONG_TYPE_FOR_VAR
126
SET @@session.auto_increment_offset = OFF;
127
SELECT @@session.auto_increment_offset;
128
--Error ER_WRONG_TYPE_FOR_VAR
129
SET @@session.auto_increment_offset = test;
130
SELECT @@session.auto_increment_offset;
134
--echo '#------------------FN_DYNVARS_002_06-----------------------#'
135
####################################################################
136
# Check if the value in GLOBAL Table matches value in variable #
137
####################################################################
139
SELECT @@global.auto_increment_offset = VARIABLE_VALUE
140
FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
141
WHERE VARIABLE_NAME='auto_increment_offset';
144
--echo '#------------------FN_DYNVARS_002_07-----------------------#'
145
####################################################################
146
# Check if the value in SESSION Table matches value in variable #
147
####################################################################
149
SELECT @@session.auto_increment_offset = VARIABLE_VALUE
150
FROM INFORMATION_SCHEMA.SESSION_VARIABLES
151
WHERE VARIABLE_NAME='auto_increment_offset';
154
--echo '#------------------FN_DYNVARS_002_08-----------------------#'
155
####################################################################
156
# Check if TRUE and FALSE values can be used on variable #
157
####################################################################
159
SET @@global.auto_increment_offset = TRUE;
160
SELECT @@global.auto_increment_offset;
161
SET @@global.auto_increment_offset = FALSE;
162
SELECT @@global.auto_increment_offset;
165
--echo '#---------------------FN_DYNVARS_001_09----------------------#'
166
###############################################################################
167
# Check if global and session variables are independant of each other #
168
###############################################################################
170
SET @@global.auto_increment_offset = 10;
171
SET @@session.auto_increment_offset = 11;
172
SELECT @@auto_increment_offset = @@global.auto_increment_offset;
175
--echo '#---------------------FN_DYNVARS_001_10----------------------#'
176
##############################################################################
177
# Check if accessing variable with SESSION,LOCAL and without SCOPE points #
178
# to same session variable #
179
##############################################################################
181
SET @@auto_increment_offset = 100;
182
SELECT @@auto_increment_offset = @@local.auto_increment_offset;
183
SELECT @@local.auto_increment_offset = @@session.auto_increment_offset;
186
--echo '#---------------------FN_DYNVARS_001_11----------------------#'
187
###############################################################################
188
# Check if auto_increment_offset can be accessed with and without @@ sign #
189
###############################################################################
191
SET auto_increment_offset = 1;
192
SELECT @@auto_increment_offset;
193
--Error ER_UNKNOWN_TABLE
194
SELECT local.auto_increment_offset;
195
--Error ER_UNKNOWN_TABLE
196
SELECT session.auto_increment_offset;
197
--Error ER_BAD_FIELD_ERROR
198
SELECT auto_increment_offset = @@session.auto_increment_offset;
201
####################################
202
# Restore initial value #
203
####################################
205
SET @@global.auto_increment_offset = @start_global_value;
206
SELECT @@global.auto_increment_offset;
207
SET @@session.auto_increment_offset = @start_session_value;
208
SELECT @@session.auto_increment_offset;
211
###################################################
212
# END OF auto_increment_offset TESTS #
213
###################################################