Skip to content

Commit fc93a32

Browse files
author
gshchepa/uchum@host.loc
committed
Merge host.loc:/work/bugs/5.0-bugteam-36055
into host.loc:/work/bk/5.1-bugteam
2 parents cc2a217 + 1e7be56 commit fc93a32

File tree

7 files changed

+75
-0
lines changed

7 files changed

+75
-0
lines changed

mysql-test/r/repair.result

+36
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,42 @@ SET myisam_repair_threads=@@global.myisam_repair_threads;
115115
SET myisam_sort_buffer_size=@@global.myisam_sort_buffer_size;
116116
DROP TABLE t1;
117117
End of 4.1 tests
118+
# Test with a saved table from 4.1
119+
SHOW TABLE STATUS LIKE 't1';
120+
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
121+
t1 MyISAM 9 Fixed 2 5 10 21474836479 1024 0 NULL # # NULL latin1_swedish_ci NULL
122+
SELECT * FROM t1;
123+
id
124+
1
125+
2
126+
# Run CHECK TABLE, it should indicate table need a REPAIR TABLE
127+
CHECK TABLE t1 FOR UPGRADE;
128+
Table Op Msg_type Msg_text
129+
test.t1 check error Table upgrade required. Please do "REPAIR TABLE `t1`" to fix it!
130+
# REPAIR old table USE_FRM should fail
131+
REPAIR TABLE t1 USE_FRM;
132+
Table Op Msg_type Msg_text
133+
t1 repair error Failed reparing incompatible .FRM file
134+
# Run REPAIR TABLE to upgrade .frm file
135+
REPAIR TABLE t1;
136+
Table Op Msg_type Msg_text
137+
test.t1 repair status OK
138+
SHOW TABLE STATUS LIKE 't1';
139+
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
140+
t1 MyISAM 10 Fixed 2 7 14 1970324836974591 1024 0 NULL # # NULL latin1_swedish_ci NULL
141+
SELECT * FROM t1;
142+
id
143+
1
144+
2
145+
REPAIR TABLE t1 USE_FRM;
146+
Table Op Msg_type Msg_text
147+
test.t1 repair warning Number of rows changed from 0 to 2
148+
test.t1 repair status OK
149+
SELECT * FROM t1;
150+
id
151+
1
152+
2
153+
DROP TABLE t1;
118154
DROP TABLE IF EXISTS tt1;
119155
CREATE TEMPORARY TABLE tt1 (c1 INT);
120156
REPAIR TABLE tt1 USE_FRM;

mysql-test/std_data/bug36055.MYD

10 Bytes
Binary file not shown.

mysql-test/std_data/bug36055.MYI

1 KB
Binary file not shown.

mysql-test/std_data/bug36055.frm

8.36 KB
Binary file not shown.

mysql-test/t/repair.test

+30
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,36 @@ SET myisam_sort_buffer_size=@@global.myisam_sort_buffer_size;
113113
DROP TABLE t1;
114114

115115
--echo End of 4.1 tests
116+
117+
#
118+
# BUG#36055 - mysql_upgrade doesn't really 'upgrade' tables
119+
#
120+
121+
--echo # Test with a saved table from 4.1
122+
--copy_file std_data/bug36055.frm $MYSQLTEST_VARDIR/master-data/test/t1.frm
123+
--copy_file std_data/bug36055.MYD $MYSQLTEST_VARDIR/master-data/test/t1.MYD
124+
--copy_file std_data/bug36055.MYI $MYSQLTEST_VARDIR/master-data/test/t1.MYI
125+
126+
--replace_column 12 # 13 #
127+
SHOW TABLE STATUS LIKE 't1';
128+
SELECT * FROM t1;
129+
130+
--echo # Run CHECK TABLE, it should indicate table need a REPAIR TABLE
131+
CHECK TABLE t1 FOR UPGRADE;
132+
133+
--echo # REPAIR old table USE_FRM should fail
134+
REPAIR TABLE t1 USE_FRM;
135+
136+
--echo # Run REPAIR TABLE to upgrade .frm file
137+
REPAIR TABLE t1;
138+
--replace_column 12 # 13 #
139+
SHOW TABLE STATUS LIKE 't1';
140+
SELECT * FROM t1;
141+
142+
REPAIR TABLE t1 USE_FRM;
143+
SELECT * FROM t1;
144+
145+
DROP TABLE t1;
116146
# End of 5.0 tests
117147

118148
#

sql/handler.cc

+2
Original file line numberDiff line numberDiff line change
@@ -2738,6 +2738,8 @@ int handler::ha_check_for_upgrade(HA_CHECK_OPT *check_opt)
27382738
}
27392739
}
27402740
}
2741+
if (table->s->frm_version != FRM_VER_TRUE_VARCHAR)
2742+
return HA_ADMIN_NEEDS_ALTER;
27412743
return check_for_upgrade(check_opt);
27422744
}
27432745

sql/sql_table.cc

+7
Original file line numberDiff line numberDiff line change
@@ -4021,6 +4021,13 @@ static int prepare_for_repair(THD *thd, TABLE_LIST *table_list,
40214021
- Run a normal repair using the new index file and the old data file
40224022
*/
40234023

4024+
if (table->s->frm_version != FRM_VER_TRUE_VARCHAR)
4025+
{
4026+
error= send_check_errmsg(thd, table_list, "repair",
4027+
"Failed reparing incompatible .FRM file");
4028+
goto end;
4029+
}
4030+
40244031
/*
40254032
Check if this is a table type that stores index and data separately,
40264033
like ISAM or MyISAM. We assume fixed order of engine file name

0 commit comments

Comments
 (0)