summaryrefslogtreecommitdiff
path: root/mysql-test/suite/sys_vars/t/autocommit_basic.test
blob: fa6654ae37c98215adbfd26690c5695e678d6de2 (plain)
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
############## mysql-test\t\auto_commit_basic.test #############################
#                                                                              #
# Variable Name: autocommit                                                    #
# Scope: SESSION                                                               #
# Access Type: Dynamic                                                         #
# Data Type: Boolean                                                           #
# Default Value: NA                                                            #
# Range: NA                                                                    #
#                                                                              #
#                                                                              #
# Creation Date: 2008-02-07                                                    #
# Author:  Salman Rawala                                                       #
#                                                                              #
# Description: Test Cases of Dynamic System Variable "autocommit"              #
#              that checks behavior of this variable in the following ways     #
#              * Default Value                                                 #
#              * Valid & Invalid values                                        #
#              * Scope & Access method                                         #
#              * Data Integrity                                                #
#                                                                              #
# Reference: (Not Mentioned on website)                                        #
#                                                                              #
################################################################################

--source include/load_sysvars.inc

######################################################################## 
#                    START OF autocommit TESTS                         #
######################################################################## 


######################################################################## 
#      Saving initial value of autocommit in a temporary variable      #
######################################################################## 

SET @start_value = @@global.autocommit;
SELECT @start_value;


--echo '#--------------------FN_DYNVARS_003_01------------------------#'
######################################################################## 
#                    Display the DEFAULT value of autocommit           #
######################################################################## 

SET @@autocommit = 0;
SET @@autocommit = DEFAULT;
SELECT @@autocommit;

--echo '#---------------------FN_DYNVARS_003_02-------------------------#'
############################################### 
#      Check default value of variable        #
############################################### 

SET @@autocommit = @start_value;
SELECT @@autocommit = 1;


--echo '#--------------------FN_DYNVARS_003_03------------------------#'
######################################################################## 
#              Change the value of autocommit to a valid value         #
######################################################################## 
SET @@autocommit = 0;
SELECT @@autocommit;
SET @@autocommit = 1;
SELECT @@autocommit;


--echo '#--------------------FN_DYNVARS_003_04-------------------------#'
########################################################################### 
#               Change the value of autocommit to invalid value           #
########################################################################### 

--Error ER_WRONG_VALUE_FOR_VAR
SET @@autocommit = 2;
--Error ER_WRONG_VALUE_FOR_VAR
SET @@autocommit = -1;
--Error ER_WRONG_VALUE_FOR_VAR
SET @@autocommit = TRUEF;
--Error ER_WRONG_VALUE_FOR_VAR
SET @@autocommit = TRUE_F;
--Error ER_WRONG_VALUE_FOR_VAR
SET @@autocommit = FALSE0;
--Error ER_WRONG_VALUE_FOR_VAR
SET @@autocommit = OON;
--Error ER_WRONG_VALUE_FOR_VAR
SET @@autocommit = ONN;
--Error ER_WRONG_VALUE_FOR_VAR
SET @@autocommit = OOFF;
--Error ER_WRONG_VALUE_FOR_VAR
SET @@autocommit = 0FF;
--Error ER_WRONG_VALUE_FOR_VAR
SET @@autocommit = ' ';
--Error ER_WRONG_VALUE_FOR_VAR
SET @@autocommit = " ";
--Error ER_WRONG_VALUE_FOR_VAR
SET @@autocommit = '';


--echo '#-------------------FN_DYNVARS_003_05----------------------------#'
########################################################################### 
#              Test if accessing global autocommit gives error            #
########################################################################### 

SET @@global.autocommit = 0;
SELECT @@global.autocommit;
SET @@global.autocommit = 1;


--echo '#----------------------FN_DYNVARS_003_06------------------------#'
######################################################################### 
#     Check if the value in SESSION Table matches value in variable     #
#########################################################################

SELECT IF(@@session.autocommit, "ON", "OFF") = VARIABLE_VALUE 
FROM INFORMATION_SCHEMA.SESSION_VARIABLES 
WHERE VARIABLE_NAME='autocommit';

--echo '#----------------------FN_DYNVARS_003_07------------------------#'
######################################################################### 
#     Check if the value in GLOBAL Table matches value in variable      #
#########################################################################

SET @@autocommit = 1;
SELECT IF(@@autocommit, "ON", "OFF") = VARIABLE_VALUE
FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES 
WHERE VARIABLE_NAME='autocommit';

--echo '#---------------------FN_DYNVARS_003_08-------------------------#'
################################################################### 
#        Check if ON and OFF values can be used on variable       #
################################################################### 

SET @@autocommit = OFF;
SELECT @@autocommit;
SET @@autocommit = ON;
SELECT @@autocommit;

--echo '#---------------------FN_DYNVARS_003_09----------------------#'
################################################################### 
#      Check if TRUE and FALSE values can be used on variable     #
################################################################### 

SET @@autocommit = TRUE;
SELECT @@autocommit;
SET @@autocommit = FALSE;
SELECT @@autocommit;


--echo '#---------------------FN_DYNVARS_003_10----------------------#'
##############################################################################
#    Check if accessing variable with SESSION,LOCAL and without SCOPE points #
#    to same session variable                                                #
##############################################################################

SET @@autocommit = 0;
SELECT @@autocommit = @@local.autocommit;
SELECT @@local.autocommit = @@session.autocommit;
SET @@autocommit = 1;
SELECT @@autocommit = @@local.autocommit;
SELECT @@session.autocommit = @@autocommit;


--echo '#---------------------FN_DYNVARS_003_11----------------------#'
#####################################################################  
#   Check if autocommit can be accessed with and without @@ sign    #
#####################################################################

SET autocommit = 1;
SELECT @@autocommit;
--Error ER_UNKNOWN_TABLE
SELECT local.autocommit;
--Error ER_UNKNOWN_TABLE
SELECT session.autocommit;
--Error ER_BAD_FIELD_ERROR
SELECT autocommit = @@session.autocommit;


##############################  
#   Restore initial value    #
##############################

SET @@global.autocommit = @start_value;
SELECT @@global.autocommit;

######################################################################## 
#                    END OF autocommit TESTS                           #
########################################################################