~ubuntu-branches/ubuntu/maverick/mysql-5.1/maverick-proposed

« back to all changes in this revision

Viewing changes to mysql-test/suite/innodb/t/innodb_bug53756.test

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2012-02-22 14:16:05 UTC
  • mto: This revision was merged to the branch mainline in revision 20.
  • Revision ID: package-import@ubuntu.com-20120222141605-nxlu9yzc6attylc2
Tags: upstream-5.1.61
ImportĀ upstreamĀ versionĀ 5.1.61

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# This is the test case for bug #53756. Alter table operation could
 
2
# leave a deleted record for the temp table (later renamed to the altered
 
3
# table) in the SYS_TABLES secondary index, we should ignore this row and
 
4
# find the first non-deleted row for the specified table_id when load table
 
5
# metadata in the function dict_load_table_on_id() during crash recovery.
 
6
 
 
7
#
 
8
# innobackup needs to connect to the server. Not supported in embedded.
 
9
--source include/not_embedded.inc
 
10
#
 
11
# This test case needs to crash the server. Needs a debug server.
 
12
--source include/have_debug.inc
 
13
#
 
14
# Don't test this under valgrind, memory leaks will occur.
 
15
--source include/not_valgrind.inc
 
16
#
 
17
# This test case needs InnoDB.
 
18
--source include/have_innodb.inc
 
19
 
 
20
# Avoid CrashReporter popup on Mac
 
21
--source include/not_crashrep.inc
 
22
 
 
23
#
 
24
# Precautionary clean up.
 
25
#
 
26
--disable_warnings
 
27
DROP TABLE IF EXISTS bug_53756 ;
 
28
--enable_warnings
 
29
 
 
30
#
 
31
# Create test data.
 
32
#
 
33
CREATE TABLE bug_53756 (pk INT, c1 INT) ENGINE=InnoDB;
 
34
ALTER TABLE bug_53756 ADD PRIMARY KEY (pk);
 
35
INSERT INTO bug_53756 VALUES(1, 11), (2, 22), (3, 33), (4, 44);
 
36
 
 
37
--echo
 
38
--echo # Select a less restrictive isolation level.
 
39
# Don't use user variables. They won't survive server crash.
 
40
--let $global_isolation= `SELECT @@global.tx_isolation`
 
41
--let $session_isolation= `SELECT @@session.tx_isolation`
 
42
SET GLOBAL TRANSACTION ISOLATION LEVEL READ COMMITTED;
 
43
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
 
44
COMMIT;
 
45
 
 
46
--echo
 
47
--echo # Start a transaction in the default connection for isolation.
 
48
START TRANSACTION;
 
49
SELECT @@tx_isolation;
 
50
SELECT * FROM bug_53756;
 
51
 
 
52
--echo
 
53
--echo # connection con1 deletes row 1
 
54
--connect (con1,localhost,root,,)
 
55
START TRANSACTION;
 
56
SELECT @@tx_isolation;
 
57
DELETE FROM bug_53756 WHERE pk=1;
 
58
 
 
59
--echo
 
60
--echo # connection con2 deletes row 2
 
61
--connect (con2,localhost,root,,)
 
62
START TRANSACTION;
 
63
SELECT @@tx_isolation;
 
64
DELETE FROM bug_53756 WHERE pk=2;
 
65
 
 
66
--echo
 
67
--echo # connection con3 updates row 3
 
68
--connect (con3,localhost,root,,)
 
69
START TRANSACTION;
 
70
SELECT @@tx_isolation;
 
71
UPDATE bug_53756 SET c1=77 WHERE pk=3;
 
72
 
 
73
--echo
 
74
--echo # connection con4 updates row 4
 
75
--connect (con4,localhost,root,,)
 
76
START TRANSACTION;
 
77
SELECT @@tx_isolation;
 
78
UPDATE bug_53756 SET c1=88 WHERE pk=4;
 
79
 
 
80
--echo
 
81
--echo # connection con5 inserts row 5
 
82
--connect (con5,localhost,root,,)
 
83
START TRANSACTION;
 
84
SELECT @@tx_isolation;
 
85
INSERT INTO bug_53756 VALUES(5, 55);
 
86
 
 
87
--echo
 
88
--echo # connection con6 inserts row 6
 
89
--connect (con6,localhost,root,,)
 
90
START TRANSACTION;
 
91
SELECT @@tx_isolation;
 
92
INSERT INTO bug_53756 VALUES(6, 66);
 
93
 
 
94
--echo
 
95
--echo # connection con1 commits.
 
96
--connection con1
 
97
COMMIT;
 
98
 
 
99
--echo
 
100
--echo # connection con3 commits.
 
101
--connection con3
 
102
COMMIT;
 
103
 
 
104
--echo
 
105
--echo # connection con4 rolls back.
 
106
--connection con4
 
107
ROLLBACK;
 
108
 
 
109
--echo
 
110
--echo # connection con6 rolls back.
 
111
--connection con6
 
112
ROLLBACK;
 
113
 
 
114
--echo
 
115
--echo # The connections 2 and 5 stay open.
 
116
 
 
117
--echo
 
118
--echo # connection default selects resulting data.
 
119
--echo # Delete of row 1 was committed.
 
120
--echo # Update of row 3 was committed.
 
121
--echo # Due to isolation level read committed, these should be included.
 
122
--echo # All other changes should not be included.
 
123
--connection default
 
124
SELECT * FROM bug_53756;
 
125
 
 
126
--echo
 
127
--echo # connection default
 
128
--connection default
 
129
--echo #
 
130
--echo # Crash server.
 
131
#
 
132
# Write file to make mysql-test-run.pl expect the "crash", but don't start
 
133
# it until it's told to
 
134
--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
 
135
#
 
136
START TRANSACTION;
 
137
INSERT INTO bug_53756 VALUES (666,666);
 
138
#
 
139
# Request a crash on next execution of commit.
 
140
SET SESSION debug="+d,crash_commit_before";
 
141
#
 
142
# Execute the statement that causes the crash.
 
143
--error 2013
 
144
COMMIT;
 
145
--echo
 
146
--echo #
 
147
--echo # disconnect con1, con2, con3, con4, con5, con6.
 
148
--disconnect con1
 
149
--disconnect con2
 
150
--disconnect con3
 
151
--disconnect con4
 
152
--disconnect con5
 
153
--disconnect con6
 
154
--echo #
 
155
--echo # Restart server.
 
156
#
 
157
# Write file to make mysql-test-run.pl start up the server again
 
158
--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
 
159
#
 
160
# Turn on reconnect
 
161
--enable_reconnect
 
162
#
 
163
# Call script that will poll the server waiting for it to be back online again
 
164
--source include/wait_until_connected_again.inc
 
165
#
 
166
# Turn off reconnect again
 
167
--disable_reconnect
 
168
--echo
 
169
 
 
170
--echo #
 
171
--echo # Select recovered data.
 
172
--echo # Delete of row 1 was committed.
 
173
--echo # Update of row 3 was committed.
 
174
--echo # These should be included.
 
175
--echo # All other changes should not be included.
 
176
--echo # Delete of row 2 and insert of row 5 should be rolled back
 
177
SELECT * FROM bug_53756;
 
178
 
 
179
--echo
 
180
--echo # Clean up.
 
181
DROP TABLE bug_53756;
 
182
 
 
183
--disable_query_log
 
184
eval SET GLOBAL tx_isolation= '$global_isolation';
 
185
eval SET SESSION tx_isolation= '$session_isolation';
 
186
--enable_query_log
 
187