~jlukas79/+junk/mysql-server

« back to all changes in this revision

Viewing changes to mysql-test/t/autocommit_func.test

manual merge 6.0-main --> 6.0-bka-review

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
############## mysql-test\t\auto_commit_func.test #############################
 
2
#                                                                              #
 
3
# Variable Name: autocommit                                                    #
 
4
# Scope: SESSION                                                               #
 
5
# Access Type: Dynamic                                                         #
 
6
# Data Type: Boolean                                                           #
 
7
# Default Value: NA                                                            #
 
8
# Range: NA                                                                    #
 
9
#                                                                              #
 
10
#                                                                              #
 
11
# Creation Date: 2008-03-07                                                    #
 
12
# Author:  Salman Rawala                                                       #
 
13
#                                                                              #
 
14
# Description: Test Cases of Dynamic System Variable "autocommit"              #
 
15
#              that checks functionality of this variable                      #
 
16
#                                                                              #
 
17
# Reference: (Not Mentioned on website)                                        #
 
18
#                                                                              #
 
19
################################################################################
 
20
 
 
21
--source include/have_innodb.inc
 
22
 
 
23
--disable_warnings
 
24
drop table if exists t1;
 
25
--enable_warnings
 
26
 
 
27
#########################
 
28
#   Creating new table  #
 
29
#########################
 
30
 
 
31
--echo ## Creating new table ##
 
32
CREATE TABLE t1
 
33
(
 
34
id INT NOT NULL auto_increment,
 
35
PRIMARY KEY (id),
 
36
name varchar(30)
 
37
) ENGINE = INNODB;
 
38
 
 
39
--echo '#--------------------FN_DYNVARS_003_01-------------------------#'
 
40
#####################################################
 
41
#    Setting initial value of auto_commit to zero   # 
 
42
#####################################################
 
43
 
 
44
--echo ## Setting variable's value to 0 i.e false ##
 
45
SET @@autocommit = 0;
 
46
 
 
47
 
 
48
--echo '#--------------------FN_DYNVARS_003_02-------------------------#'
 
49
######################################################################
 
50
#    Creating 2 different connections & testing behavior of autocommit
 
51
#    after updating record in 1st connection
 
52
######################################################################
 
53
 
 
54
--echo ## Creating new connection ## 
 
55
CONNECT (test_con1,localhost,root,,);
 
56
CONNECTION test_con1;
 
57
 
 
58
--echo ## Checking value of variable after opening new connection ##
 
59
 
 
60
SELECT @@autocommit;
 
61
 
 
62
--echo ## Setting value of variable to zero and inserting some rows ## 
 
63
SET @@autocommit = 0;
 
64
 
 
65
INSERT into t1(name) values('Record_1');
 
66
INSERT into t1(name) values('Record_2');
 
67
SELECT * from t1;
 
68
 
 
69
--echo ## Creating another connection and verifying records in table ## 
 
70
 
 
71
--echo ## New Connection test_con2 ##
 
72
CONNECT (test_con2,localhost,root,,);
 
73
CONNECTION test_con2;
 
74
SELECT * from t1;
 
75
 
 
76
 
 
77
--echo '#--------------------FN_DYNVARS_003_03-------------------------#'
 
78
######################################################################
 
79
#    Creating 2 different connections & testing behavior of autocommit
 
80
#    after updating record in 1st connection and using COMMIT in first
 
81
#    connection
 
82
######################################################################
 
83
 
 
84
--echo ## Verifying behavior of variable by commiting rows in test_con1 ##
 
85
--echo ## Connecting with connection # 01 ## 
 
86
CONNECTION test_con1;
 
87
SELECT * from t1;
 
88
COMMIT;
 
89
 
 
90
 
 
91
--echo ## New Connection test_con2 ##
 
92
--echo ## Now verifying records in table from connection # 02 ## 
 
93
CONNECTION test_con2;
 
94
SELECT * from t1;
 
95
 
 
96
--echo '#--------------------FN_DYNVARS_003_04-------------------------#'
 
97
######################################################################
 
98
#    Creating 2 different connections & testing behavior of autocommit
 
99
#    after updating record in 1st connection and using ROLLBACK in 
 
100
#    first connection
 
101
######################################################################
 
102
 
 
103
--echo ## Connecting to connection # 01 ##
 
104
CONNECTION test_con1;
 
105
SELECT * from t1;
 
106
 
 
107
--echo ## Updating value of first row ##
 
108
UPDATE t1 set name = 'Record_12' where name = 'Record_1';
 
109
SELECT * from t1;
 
110
 
 
111
--echo ## Connecting to connecting # 02 and verifying effect of update query ##
 
112
CONNECTION test_con2;
 
113
SELECT * from t1;
 
114
 
 
115
--echo ## Now connecting with connection # 01 and using ROLLBACK after it ##
 
116
CONNECTION test_con1;
 
117
ROLLBACK;
 
118
SELECT * from t1;
 
119
 
 
120
 
 
121
 
 
122
--echo '#--------------------FN_DYNVARS_003_05-------------------------#'
 
123
######################################################################
 
124
#    Creating 2 different connections & testing behavior of autocommit
 
125
#    after updating records in 1st connection and setting AUTOCOMMIT 
 
126
#    to 1 in second connection
 
127
######################################################################
 
128
 
 
129
 
 
130
--echo ## Connecting with connection # 01 ## 
 
131
CONNECTION test_con1;
 
132
INSERT into t1(name) values('Record_3');
 
133
 
 
134
 
 
135
--echo ## Connection test_con2 ##
 
136
--echo ## Now verifying records in table from connection # 02 and changing value  ## 
 
137
--echo ## of autocommit to true ## 
 
138
CONNECTION test_con2;
 
139
SELECT * from t1;
 
140
SET @@autocommit = 1;
 
141
INSERT into t1(name) values('Record_4');
 
142
INSERT into t1(name) values('Record_5');
 
143
SELECT * from t1;
 
144
 
 
145
--echo ## Connecting with connection # 01 and inserting few records ## 
 
146
CONNECTION test_con1;
 
147
SELECT * from t1;
 
148
--echo 'Bug#35373: Records donot get committed in transaction on switching connections'
 
149
INSERT into t1(name) values('Record_6');
 
150
SELECT * from t1;
 
151
 
 
152
--echo ## Now verifying the effect of these new records in second connection ## 
 
153
CONNECTION test_con2;
 
154
SELECT * from t1;
 
155
 
 
156
--echo ## Dropping table t1 ##
 
157
DROP table t1;
 
158
 
 
159
--echo ## Disconnecting both connections ##
 
160
DISCONNECT test_con1;
 
161
DISCONNECT test_con2;
 
162
 
 
163
 
 
164