Skip to content

Commit a03f981

Browse files
author
Aditya A
committed
Bug #29627690 NOT ABLE TO IMPORT PARTITIONED TABLESPACE FROM VERSIONS 8.0.14-16
PROBLEM ------- This bug is a regression after the fix for <Bug26925260 ERROR 1030 (HY000): GOT ERROR 44 - 'INNODB ERROR' FROM STORAGE ENGINE> During import we first try to open the cfg file corresponding to the tablename. To search for a cfg file,we first try to build the path to cfg with the data directory and the tablename ,but because of the above bug the partition table ibd file as well as the cfg file are built in lower cases where as in version <=8.0.13 we build it in upper cases. This is the reason we are unable to get the path to the cfg and ibd file FIX --- If we don't find the cfg/cfp file ,we search it after converting table name to lower cases and if found we rename the cfg/cfp and ibd file according to previous convention. Approved by: Mayank Prasad <[email protected]>
1 parent ee3d9a0 commit a03f981

File tree

10 files changed

+613
-14
lines changed

10 files changed

+613
-14
lines changed

mysql-test/include/innodb-util.inc

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,24 @@ sub ib_backup_cfg_file {
3333
my $tmpd = $ENV{'MYSQLTEST_VARDIR'} . "/tmp";
3434

3535
my @args = (File::Spec->catfile($datadir, $db, $cfg_file),
36-
File::Spec->catfile($tmpd, $cfg_file));
36+
File::Spec->catfile($tmpd, $cfg_file));
3737

3838
copy(@args) or die "copy @args failed: $!";
3939
}
4040

41+
sub ib_backup_cfp_file {
42+
my ($db, $table) = @_;
43+
my $datadir = $ENV{'MYSQLD_DATADIR'};
44+
my $cfp_file = sprintf("%s.cfp", $table);
45+
my $tmpd = $ENV{'MYSQLTEST_VARDIR'} . "/tmp";
46+
47+
my @args = (File::Spec->catfile($datadir, $db, $cfp_file),
48+
File::Spec->catfile($tmpd, $cfp_file));
49+
50+
copy(@args) or die "copy @args failed: $!";
51+
}
52+
53+
4154
sub ib_backup_tablespace {
4255
my ($db, $table) = @_;
4356

@@ -101,6 +114,21 @@ sub ib_restore_ibd_file {
101114
copy(@args) or die "copy @args failed: $!";
102115
}
103116

117+
118+
sub ib_restore_cfp_file {
119+
my ($db, $table) = @_;
120+
my $datadir = $ENV{'MYSQLD_DATADIR'};
121+
my $cfp_file = sprintf("%s.cfp", $table);
122+
my $tmpd = $ENV{'MYSQLTEST_VARDIR'} . "/tmp";
123+
124+
my @args = (File::Spec->catfile($tmpd, $cfp_file),
125+
File::Spec->catfile($datadir, "$db", $cfp_file));
126+
127+
copy(@args) or die "copy @args failed: $!";
128+
}
129+
130+
131+
104132
sub ib_restore_tablespace {
105133
my ($db, $table) = @_;
106134
my $datadir = $ENV{'MYSQLD_DATADIR'};

mysql-test/std_data/8.0.15_cfg.zip

4.84 KB
Binary file not shown.

mysql-test/std_data/8.0.17_cfg.zip

7.35 KB
Binary file not shown.
Lines changed: 231 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,231 @@
1+
#
2+
# Bug #29627690 NOT ABLE TO IMPORT PARTITIONED TABLESPACE OLDER THAN 8.0.14
3+
#
4+
select @lower_case_table_names;
5+
@lower_case_table_names
6+
NULL
7+
# Test 1: With Hash partitions
8+
SET SESSION debug="+d,induce_lowercase_part_names";
9+
CREATE TABLE t1 (c1 INT) ENGINE = InnoDB
10+
PARTITION BY HASH (c1) PARTITIONS 3;
11+
INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6);
12+
SELECT c1 FROM t1 ORDER BY c1;
13+
c1
14+
1
15+
2
16+
3
17+
4
18+
5
19+
6
20+
FLUSH TABLES t1 FOR EXPORT;
21+
SET debug="-d,induce_lowercase_part_names";
22+
backup: t1#p#p0
23+
backup: t1#p#p1
24+
backup: t1#p#p2
25+
UNLOCK TABLES;
26+
DROP TABLE t1;
27+
CREATE TABLE t1 (c1 INT) ENGINE = InnoDB
28+
PARTITION BY HASH (c1) PARTITIONS 3;
29+
ALTER TABLE t1 DISCARD TABLESPACE;
30+
restore: t1#p#p0 .ibd and .cfg files
31+
restore: t1#p#p1 .ibd and .cfg files
32+
restore: t1#p#p2 .ibd and .cfg files
33+
ALTER TABLE t1 IMPORT TABLESPACE;
34+
SELECT * FROM t1 ORDER BY c1;
35+
c1
36+
1
37+
2
38+
3
39+
4
40+
5
41+
6
42+
DROP TABLE t1;
43+
# Test 2 With range partitions/subpartitions with mixed cases partiton names
44+
SET SESSION debug="+d,induce_lowercase_part_names";
45+
create table t1 (f1 int ,f2 int) partition by range (f1)
46+
subpartition by key (f2)
47+
(
48+
partition ABCdef values less than (10) (
49+
subpartition SUB_ABCdef0,
50+
subpartition SUB_abcdef1
51+
),
52+
partition ABC values less than (50) (
53+
subpartition SUB_ABC0,
54+
subpartition SUB_abc1
55+
) ,
56+
partition def values less than (100) (
57+
subpartition sub_def0,
58+
subpartition SUB_DEF1
59+
));
60+
insert into t1 values (90,10) ,(40,78) ,(5,76);
61+
SELECT * from t1 order by f1;
62+
f1 f2
63+
5 76
64+
40 78
65+
90 10
66+
FLUSH TABLES t1 FOR EXPORT;
67+
SET debug="-d,induce_lowercase_part_names";
68+
backup: t1#p#abcdef#sp#sub_abcdef0
69+
backup: t1#p#abcdef#sp#sub_abcdef1
70+
backup: t1#p#abc#sp#sub_abc0
71+
backup: t1#p#abc#sp#sub_abc1
72+
backup: t1#p#def#sp#sub_def0
73+
backup: t1#p#def#sp#sub_def1
74+
unlock tables;
75+
drop table t1;
76+
create table t1 (f1 int ,f2 int) partition by range (f1)
77+
subpartition by key (f2)
78+
(
79+
partition ABCdef values less than (10) (
80+
subpartition SUB_ABCdef0,
81+
subpartition SUB_abcdef1
82+
),
83+
partition ABC values less than (50) (
84+
subpartition SUB_ABC0,
85+
subpartition SUB_abc1
86+
) ,
87+
partition def values less than (100) (
88+
subpartition sub_def0,
89+
subpartition SUB_DEF1
90+
));
91+
ALTER TABLE t1 DISCARD TABLESPACE;
92+
restore: t1#p#abcdef#sp#sub_abcdef0 .ibd and .cfg files
93+
restore: t1#p#abcdef#sp#sub_abcdef1 .ibd and .cfg files
94+
restore: t1#p#abc#sp#sub_abc0 .ibd and .cfg files
95+
restore: t1#p#abc#sp#sub_abc1 .ibd and .cfg files
96+
restore: t1#p#def#sp#sub_def0 .ibd and .cfg files
97+
restore: t1#p#def#sp#sub_def1 .ibd and .cfg files
98+
ALTER TABLE t1 IMPORT TABLESPACE;
99+
SELECT * FROM t1 ORDER BY f1;
100+
f1 f2
101+
5 76
102+
40 78
103+
90 10
104+
DROP TABLE t1;
105+
# Test 3 : With encryption
106+
# restart: --early-plugin-load=keyring_file=keyring_file.so --loose-keyring_file_data=MYSQL_TMP_DIR/mysecret_keyring --plugin-dir=KEYRING_PLUGIN_PATH
107+
SET SESSION debug="+d,induce_lowercase_part_names";
108+
CREATE TABLE t1 (c1 INT) ENGINE = InnoDB ENCRYPTION='Y'
109+
PARTITION BY RANGE (c1) ( PARTITION ABC VALUES LESS THAN (10));
110+
INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6);
111+
SELECT c1 FROM t1 ORDER BY c1;
112+
c1
113+
1
114+
2
115+
3
116+
4
117+
5
118+
6
119+
FLUSH TABLES t1 FOR EXPORT;
120+
SET debug="-d,induce_lowercase_part_names";
121+
backup: t1#p#abc
122+
UNLOCK TABLES;
123+
DROP TABLE t1;
124+
CREATE TABLE t1 (c1 INT) ENGINE = InnoDB ENCRYPTION='Y'
125+
PARTITION BY RANGE (c1) ( PARTITION ABC VALUES LESS THAN (10));
126+
ALTER TABLE t1 DISCARD TABLESPACE;
127+
restore: t1#p#abc .ibd and .cfg files
128+
ALTER TABLE t1 IMPORT TABLESPACE;
129+
SELECT * FROM t1 ORDER BY c1;
130+
c1
131+
1
132+
2
133+
3
134+
4
135+
5
136+
6
137+
DROP TABLE t1;
138+
# Restarting server without keyring to restore server state
139+
# restart:
140+
Test 4 : Missing cfg file
141+
SET SESSION debug="+d,induce_lowercase_part_names";
142+
CREATE TABLE t1 (c1 INT) ENGINE = InnoDB
143+
PARTITION BY RANGE (c1) ( PARTITION ABCD VALUES LESS THAN (10));
144+
INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(8);
145+
SELECT c1 FROM t1 ORDER BY c1;
146+
c1
147+
1
148+
2
149+
3
150+
4
151+
5
152+
8
153+
FLUSH TABLES t1 FOR EXPORT;
154+
SET debug="-d,induce_lowercase_part_names";
155+
UNLOCK TABLES;
156+
DROP TABLE t1;
157+
CREATE TABLE t1 (c1 INT) ENGINE = InnoDB
158+
PARTITION BY RANGE (c1) ( PARTITION ABCD VALUES LESS THAN (10));
159+
ALTER TABLE t1 DISCARD TABLESPACE;
160+
restore: t1#p#abcd .ibd file
161+
ALTER TABLE t1 IMPORT TABLESPACE;
162+
Warnings:
163+
Warning 1810 InnoDB: IO Read error: (2, No such file or directory) Error opening './test/t1#P#ABCD.cfg', will attempt to import without schema verification
164+
SELECT * FROM t1 ORDER BY c1;
165+
c1
166+
1
167+
2
168+
3
169+
4
170+
5
171+
8
172+
DROP TABLE t1;
173+
Test 5:-
174+
# 1. Create table in 8.0.13 version
175+
# 2. Upgrade the table to 8.0.15 version
176+
# 3. Add another partition (PART_two)
177+
# 4. Do flush table and generate cfg files
178+
# 5. These ibd and cfg files are present in 8.0.15_cfg.zip
179+
# 6. Do import from the cfg file and ibd from 8.0.15_cfg.zip.
180+
CREATE DATABASE db1;
181+
use db1;
182+
CREATE TABLE t1 (
183+
f1 int
184+
) ENGINE=InnoDB
185+
PARTITION BY RANGE (f1)
186+
(PARTITION PART_one VALUES LESS THAN (10),
187+
PARTITION PART_two VALUES LESS THAN (20));
188+
ALTER TABLE t1 DISCARD TABLESPACE;
189+
ALTER TABLE t1 IMPORT TABLESPACE;
190+
SELECT * from t1 ORDER BY f1;
191+
f1
192+
9
193+
19
194+
ALTER TABLE t1 FORCE;
195+
SELECT * from t1 ORDER BY f1;
196+
f1
197+
9
198+
19
199+
DROP TABLE t1;
200+
Test 6:-
201+
# 1. Create table in 8.0.13 version
202+
# 2. Upgrade the table to 8.0.15 version
203+
# 3. Add another partition (PART_two)
204+
# 4. Upgrade to 8.0.17 versiosn
205+
# 5. Add another partition (PART_three)
206+
# 6. Do flush table and generate cfg files
207+
# 7. These ibd and cfg files are present in 8.0.17_cfg.zip
208+
# 6. Do import from the cfg file and ibd from 8.0.17_cfg.zip
209+
use db1;
210+
CREATE TABLE t1 (
211+
f1 int
212+
) ENGINE=InnoDB
213+
PARTITION BY RANGE (f1)
214+
(PARTITION PART_one VALUES LESS THAN (10),
215+
PARTITION PART_two VALUES LESS THAN (20),
216+
PARTITION PART_three VALUES LESS THAN (30));
217+
ALTER TABLE t1 DISCARD TABLESPACE;
218+
ALTER TABLE t1 IMPORT TABLESPACE;
219+
SELECT * from t1 ORDER BY f1;
220+
f1
221+
9
222+
19
223+
29
224+
ALTER TABLE t1 FORCE;
225+
SELECT * from t1 ORDER BY f1;
226+
f1
227+
9
228+
19
229+
29
230+
DROP TABLE t1;
231+
DROP DATABASE db1;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
--initialize=--lower_case_table_names=1
2+
--lower_case_table_names=1

0 commit comments

Comments
 (0)