File: rename_myisam.result

package info (click to toggle)
mysql-8.0 8.0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,924 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,181; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,194; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (188 lines) | stat: -rw-r--r-- 6,200 bytes parent folder | download
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
188
#
# Bug#24807594 SDI FILE LOSTS AFTER ALTERING DATABASE
# Verify that .sdi files are cleaned up correctly
#
CREATE TABLE t1(i INT) ENGINE MYISAM;
RENAME TABLE t1 TO tt1;
# Should only see tt1_XXX.sdi
tt1_XXX.sdi
RENAME TABLE tt1 TO tt1tt1;
# Should only see tt1tt1_XXX.sdi
tt1tt1_XXX.sdi
RENAME TABLE tt1tt1 TO ttt1ttt1ttt1ttt1_xyz;
# Should only see ttt1ttt1ttt1ttt1_XXX.sdi
ttt1ttt1ttt1ttt1_XXX.sdi
RENAME TABLE ttt1ttt1ttt1ttt1_xyz TO tttttttttttttttt1_abc;
# Should only see tttttttttttttttt_XXX.sdi
tttttttttttttttt_XXX.sdi
RENAME TABLE tttttttttttttttt1_abc TO t1;
# Should only see t1_XXX.sdi
t1_XXX.sdi
DROP TABLE t1;
SET @old_lock_wait_timeout= @@lock_wait_timeout;
connect  con1, localhost, root,,;
SET @old_lock_wait_timeout= @@lock_wait_timeout;
connection default;
#
# Non-atomic RENAME TABLES which fails but is fully
# reverted should restore set of locked tables and
# state of metadata locks.
CREATE TABLE t0 (m INT) ENGINE=MyISAM;
CREATE TABLE t1 (i INT) ENGINE=InnoDB;
CREATE TABLE t2 (j INT) ENGINE=InnoDB;
CREATE TABLE t3 (k INT) ENGINE=InnoDB;
CREATE TABLE t4 (l INT) ENGINE=InnoDB;
LOCK TABLES t1 WRITE, t2 WRITE, t3 WRITE, t0 WRITE;
RENAME TABLES t0 TO t00, t1 TO t01, t2 TO t4;
ERROR 42S01: Table 't4' already exists
# Tables are available under old names.
SELECT * FROM t0;
m
SELECT * FROM t1;
i
SELECT * FROM t2;
j
# Including untouched table.
SELECT * FROM t3;
k
# And not under new names.
SELECT * FROM t00;
ERROR HY000: Table 't00' was not locked with LOCK TABLES
SELECT * FROM t01;
ERROR HY000: Table 't01' was not locked with LOCK TABLES
SELECT * FROM t4;
ERROR HY000: Table 't4' was not locked with LOCK TABLES
connection con1;
# Access by old names from other connections should be blocked.
SET @@lock_wait_timeout= 1;
SELECT * FROM t0;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
SELECT * FROM t1;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
SELECT * FROM t2;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
# And access to untouched table too.
SELECT * FROM t3;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
SET @@lock_wait_timeout= @old_lock_wait_timeout;
# New names should not be locked.
SELECT * FROM t00;
ERROR 42S02: Table 'test.t00' doesn't exist
SELECT * FROM t01;
ERROR 42S02: Table 'test.t01' doesn't exist
SELECT * FROM t4;
l
connection default;
UNLOCK TABLES;
DROP TABLES t0, t1, t2, t3, t4;
#
# 7) RENAME TABLES under LOCK TABLES which moves tables
#    between schemas.
#
# 7.1) RENAME TABLES under LOCK TABLES which moves table
#      to different schema acquires IX lock on it and keeps
#      it until UNLOCK TABLES.
CREATE TABLE t1 (i INT);
CREATE DATABASE mysqltest;
LOCK TABLES t1 WRITE;
RENAME TABLE t1 TO mysqltest.t1;
# Table is available in new schema!
INSERT INTO mysqltest.t1 VALUES (1);
# And not in the old one.
SELECT * FROM t1;
ERROR HY000: Table 't1' was not locked with LOCK TABLES
connection con1;
# Access in the new schema from other connections should be blocked.
SET @@lock_wait_timeout= 1;
SELECT * FROM mysqltest.t1;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
SET @@lock_wait_timeout= @old_lock_wait_timeout;
# But not when trying to find table in old schema.
SELECT * FROM test.t1;
ERROR 42S02: Table 'test.t1' doesn't exist
# Also IX metadata lock on new schema should be kept.
SET @@lock_wait_timeout= 1;
ALTER DATABASE mysqltest CHARACTER SET latin1;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
SET @@lock_wait_timeout= @old_lock_wait_timeout;
connection default;
UNLOCK TABLES;
DROP TABLE mysqltest.t1;
#
# 7.2) Atomic RENAME TABLES which moves table to different schema
#      and fails at late stage should be fully rolled back.
CREATE TABLE t1 (i INT) ENGINE=InnoDB;
CREATE TABLE t2 (j INT) ENGINE=InnoDB;
CREATE TABLE t3 (k INT);
CREATE TABLE t4 (l INT) ENGINE=MyISAM;
LOCK TABLES t1 WRITE, t2 WRITE;
RENAME TABLES t1 TO mysqltest.t1, t2 TO t3;
ERROR 42S01: Table 't3' already exists
# Tables are available under old names.
SELECT * FROM t1;
i
SELECT * FROM t2;
j
# And not under new names.
SELECT * FROM mysqltest.t1;
ERROR HY000: Table 't1' was not locked with LOCK TABLES
SELECT * FROM t3;
ERROR HY000: Table 't3' was not locked with LOCK TABLES
connection con1;
# Access by old names from other connections should be blocked.
SET @@lock_wait_timeout= 1;
SELECT * FROM t1;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
SELECT * FROM t2;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
SET @@lock_wait_timeout= @old_lock_wait_timeout;
# New names should not be locked.
SELECT * FROM mysqltest.t1;
ERROR 42S02: Table 'mysqltest.t1' doesn't exist
SELECT * FROM t3;
k
# There should be no IX metadata lock on new schema.
ALTER DATABASE mysqltest CHARACTER SET latin1;
connection default;
UNLOCK TABLES;
#
# 7.3) Non-atomic RENAME TABLES which moves table to different schema, fails
#      but is fully reverted should restore set of locked tables and
#      state of metadata locks too.
# This part of the test resides in rename_myisam.test.
LOCK TABLES t4 WRITE, t1 WRITE;
RENAME TABLES t4 TO mysqltest.t4, t1 TO t3;
ERROR 42S01: Table 't3' already exists
# Tables are available under old names.
SELECT * FROM t4;
l
SELECT * FROM t1;
i
# And not under new names.
SELECT * FROM mysqltest.t4;
ERROR HY000: Table 't4' was not locked with LOCK TABLES
SELECT * FROM t3;
ERROR HY000: Table 't3' was not locked with LOCK TABLES
connection con1;
# Access by old names from other connections should be blocked.
SET @@lock_wait_timeout= 1;
SELECT * FROM t4;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
SELECT * FROM t1;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
SET @@lock_wait_timeout= @old_lock_wait_timeout;
# New names should not be locked.
SELECT * FROM mysqltest.t4;
ERROR 42S02: Table 'mysqltest.t4' doesn't exist
SELECT * FROM t3;
k
# There should be no IX metadata lock on new schema.
ALTER DATABASE mysqltest CHARACTER SET latin1;
connection default;
UNLOCK TABLES;
DROP TABLES t1, t2, t3, t4;
DROP DATABASE mysqltest;
# Clean-up.
connection con1;
disconnect con1;
connection default;