Skip to content

Commit 2e1d916

Browse files
jhauglidbjornmu
authored andcommitted
Merge branch 'mysql-5.5' into mysql-5.6
(cherry picked from commit 3682c8928e0b538739ca3d7c93b74e3bd2f9a001)
1 parent 6a588aa commit 2e1d916

File tree

6 files changed

+74
-29
lines changed

6 files changed

+74
-29
lines changed

include/my_sys.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License as published by
@@ -84,6 +84,7 @@ typedef struct my_aio_result {
8484
#define MY_RESOLVE_LINK 128 /* my_realpath(); Only resolve links */
8585
#define MY_HOLD_ORIGINAL_MODES 128 /* my_copy() holds to file modes */
8686
#define MY_REDEL_MAKE_BACKUP 256
87+
#define MY_REDEL_NO_COPY_STAT 512 /* my_redel() doesn't call my_copystat() */
8788
#define MY_SEEK_NOT_DONE 32 /* my_lock may have to do a seek */
8889
#define MY_DONT_WAIT 64 /* my_lock() don't wait if can't lock */
8990
#define MY_ZEROFILL 32 /* my_malloc(), fill array with zero */

include/myisam.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
33
44
This program is free software; you can redistribute it and/or modify
55
it under the terms of the GNU General Public License as published by
@@ -426,12 +426,13 @@ int chk_size(MI_CHECK *param, MI_INFO *info);
426426
int chk_key(MI_CHECK *param, MI_INFO *info);
427427
int chk_data_link(MI_CHECK *param, MI_INFO *info,int extend);
428428
int mi_repair(MI_CHECK *param, register MI_INFO *info,
429-
char * name, int rep_quick);
430-
int mi_sort_index(MI_CHECK *param, register MI_INFO *info, char * name);
429+
char * name, int rep_quick, my_bool no_copy_stat);
430+
int mi_sort_index(MI_CHECK *param, register MI_INFO *info, char * name,
431+
my_bool no_copy_stat);
431432
int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info,
432-
const char * name, int rep_quick);
433+
const char * name, int rep_quick, my_bool no_copy_stat);
433434
int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info,
434-
const char * name, int rep_quick);
435+
const char * name, int rep_quick, my_bool no_copy_stat);
435436
int change_to_newfile(const char * filename, const char * old_ext,
436437
const char * new_ext, myf myflags);
437438
int lock_file(MI_CHECK *param, File file, my_off_t start, int lock_type,

mysys/my_redel.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License as published by
@@ -35,6 +35,9 @@ struct utimbuf {
3535
3636
if MY_REDEL_MAKE_COPY is given, then the orginal file
3737
is renamed to org_name-'current_time'.BAK
38+
39+
if MY_REDEL_NO_COPY_STAT is given, stats are not copied
40+
from org_name to tmp_name.
3841
*/
3942

4043
#define REDEL_EXT ".BAK"
@@ -46,8 +49,11 @@ int my_redel(const char *org_name, const char *tmp_name, myf MyFlags)
4649
DBUG_PRINT("my",("org_name: '%s' tmp_name: '%s' MyFlags: %d",
4750
org_name,tmp_name,MyFlags));
4851

49-
if (my_copystat(org_name,tmp_name,MyFlags) < 0)
50-
goto end;
52+
if (!(MyFlags & MY_REDEL_NO_COPY_STAT))
53+
{
54+
if (my_copystat(org_name,tmp_name,MyFlags) < 0)
55+
goto end;
56+
}
5157
if (MyFlags & MY_REDEL_MAKE_BACKUP)
5258
{
5359
char name_buff[FN_REFLEN+20];

storage/myisam/ha_myisam.cc

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,24 +1089,36 @@ int ha_myisam::repair(THD *thd, MI_CHECK &param, bool do_optimize)
10891089
/* TODO: respect myisam_repair_threads variable */
10901090
my_snprintf(buf, 40, "Repair with %d threads", my_count_bits(key_map));
10911091
thd_proc_info(thd, buf);
1092+
/*
1093+
The new file is created with the right stats, so we can skip
1094+
copying file stats from old to new.
1095+
*/
10921096
error = mi_repair_parallel(&param, file, fixed_name,
1093-
param.testflag & T_QUICK);
1097+
param.testflag & T_QUICK, TRUE);
10941098
thd_proc_info(thd, "Repair done"); // to reset proc_info, as
10951099
// it was pointing to local buffer
10961100
}
10971101
else
10981102
{
10991103
thd_proc_info(thd, "Repair by sorting");
1104+
/*
1105+
The new file is created with the right stats, so we can skip
1106+
copying file stats from old to new.
1107+
*/
11001108
error = mi_repair_by_sort(&param, file, fixed_name,
1101-
param.testflag & T_QUICK);
1109+
param.testflag & T_QUICK, TRUE);
11021110
}
11031111
}
11041112
else
11051113
{
11061114
thd_proc_info(thd, "Repair with keycache");
11071115
param.testflag &= ~T_REP_BY_SORT;
1116+
/*
1117+
The new file is created with the right stats, so we can skip
1118+
copying file stats from old to new.
1119+
*/
11081120
error= mi_repair(&param, file, fixed_name,
1109-
param.testflag & T_QUICK);
1121+
param.testflag & T_QUICK, TRUE);
11101122
}
11111123
#ifdef HAVE_MMAP
11121124
if (remap)
@@ -1122,7 +1134,11 @@ int ha_myisam::repair(THD *thd, MI_CHECK &param, bool do_optimize)
11221134
{
11231135
optimize_done=1;
11241136
thd_proc_info(thd, "Sorting index");
1125-
error=mi_sort_index(&param,file,fixed_name);
1137+
/*
1138+
The new file is created with the right stats, so we can skip
1139+
copying file stats from old to new.
1140+
*/
1141+
error=mi_sort_index(&param,file,fixed_name, TRUE);
11261142
}
11271143
if (!statistics_done && (local_testflag & T_STATISTICS))
11281144
{

storage/myisam/mi_check.c

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1512,7 +1512,7 @@ static int mi_drop_all_indexes(MI_CHECK *param, MI_INFO *info, my_bool force)
15121512
/* Save new datafile-name in temp_filename */
15131513

15141514
int mi_repair(MI_CHECK *param, register MI_INFO *info,
1515-
char * name, int rep_quick)
1515+
char * name, int rep_quick, my_bool no_copy_stat)
15161516
{
15171517
int error,got_error;
15181518
ha_rows start_records,new_header_length;
@@ -1726,6 +1726,11 @@ int mi_repair(MI_CHECK *param, register MI_INFO *info,
17261726
/* Replace the actual file with the temporary file */
17271727
if (new_file >= 0)
17281728
{
1729+
myf flags= 0;
1730+
if (param->testflag & T_BACKUP_DATA)
1731+
flags |= MY_REDEL_MAKE_BACKUP;
1732+
if (no_copy_stat)
1733+
flags |= MY_REDEL_NO_COPY_STAT;
17291734
mysql_file_close(new_file, MYF(0));
17301735
info->dfile=new_file= -1;
17311736
/*
@@ -1744,8 +1749,7 @@ int mi_repair(MI_CHECK *param, register MI_INFO *info,
17441749
info->s->file_map= NULL;
17451750
}
17461751
if (change_to_newfile(share->data_file_name, MI_NAME_DEXT, DATA_TMP_EXT,
1747-
(param->testflag & T_BACKUP_DATA ?
1748-
MYF(MY_REDEL_MAKE_BACKUP): MYF(0))) ||
1752+
flags) ||
17491753
mi_open_datafile(info,share,name,-1))
17501754
got_error=1;
17511755

@@ -1933,7 +1937,8 @@ int flush_blocks(MI_CHECK *param, KEY_CACHE *key_cache, File file)
19331937

19341938
/* Sort index for more efficent reads */
19351939

1936-
int mi_sort_index(MI_CHECK *param, register MI_INFO *info, char * name)
1940+
int mi_sort_index(MI_CHECK *param, register MI_INFO *info, char * name,
1941+
my_bool no_copy_stat)
19371942
{
19381943
reg2 uint key;
19391944
reg1 MI_KEYDEF *keyinfo;
@@ -2010,7 +2015,7 @@ int mi_sort_index(MI_CHECK *param, register MI_INFO *info, char * name)
20102015
share->kfile = -1;
20112016
(void) mysql_file_close(new_file, MYF(MY_WME));
20122017
if (change_to_newfile(share->index_file_name, MI_NAME_IEXT, INDEX_TMP_EXT,
2013-
MYF(0)) ||
2018+
no_copy_stat ? MYF(MY_REDEL_NO_COPY_STAT) : MYF(0)) ||
20142019
mi_open_keyfile(share))
20152020
goto err2;
20162021
info->lock_type= F_UNLCK; /* Force mi_readinfo to lock */
@@ -2215,14 +2220,16 @@ int filecopy(MI_CHECK *param, File to,File from,my_off_t start,
22152220
info MyISAM handler to repair
22162221
name Name of table (for warnings)
22172222
rep_quick set to <> 0 if we should not change data file
2223+
no_copy_stat Don't copy file stats from old to new file,
2224+
assume that new file was created with correct stats
22182225
22192226
RESULT
22202227
0 ok
22212228
<>0 Error
22222229
*/
22232230

22242231
int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info,
2225-
const char * name, int rep_quick)
2232+
const char * name, int rep_quick, my_bool no_copy_stat)
22262233
{
22272234
int got_error;
22282235
uint i;
@@ -2549,11 +2556,15 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info,
25492556
/* Replace the actual file with the temporary file */
25502557
if (new_file >= 0)
25512558
{
2559+
myf flags= 0;
2560+
if (param->testflag & T_BACKUP_DATA)
2561+
flags |= MY_REDEL_MAKE_BACKUP;
2562+
if (no_copy_stat)
2563+
flags |= MY_REDEL_NO_COPY_STAT;
25522564
mysql_file_close(new_file, MYF(0));
25532565
info->dfile=new_file= -1;
25542566
if (change_to_newfile(share->data_file_name,MI_NAME_DEXT, DATA_TMP_EXT,
2555-
(param->testflag & T_BACKUP_DATA ?
2556-
MYF(MY_REDEL_MAKE_BACKUP): MYF(0))) ||
2567+
flags) ||
25572568
mi_open_datafile(info,share,name,-1))
25582569
got_error=1;
25592570
}
@@ -2601,6 +2612,8 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info,
26012612
info MyISAM handler to repair
26022613
name Name of table (for warnings)
26032614
rep_quick set to <> 0 if we should not change data file
2615+
no_copy_stat Don't copy file stats from old to new file,
2616+
assume that new file was created with correct stats
26042617
26052618
DESCRIPTION
26062619
Same as mi_repair_by_sort but do it multithreaded
@@ -2635,7 +2648,7 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info,
26352648
*/
26362649

26372650
int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info,
2638-
const char * name, int rep_quick)
2651+
const char * name, int rep_quick, my_bool no_copy_stat)
26392652
{
26402653
int got_error;
26412654
uint i,key, total_key_length, istep;
@@ -3082,11 +3095,15 @@ int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info,
30823095
/* Replace the actual file with the temporary file */
30833096
if (new_file >= 0)
30843097
{
3098+
myf flags= 0;
3099+
if (param->testflag & T_BACKUP_DATA)
3100+
flags |= MY_REDEL_MAKE_BACKUP;
3101+
if (no_copy_stat)
3102+
flags |= MY_REDEL_NO_COPY_STAT;
30853103
mysql_file_close(new_file, MYF(0));
30863104
info->dfile=new_file= -1;
30873105
if (change_to_newfile(share->data_file_name, MI_NAME_DEXT, DATA_TMP_EXT,
3088-
(param->testflag & T_BACKUP_DATA ?
3089-
MYF(MY_REDEL_MAKE_BACKUP): MYF(0))) ||
3106+
flags) ||
30903107
mi_open_datafile(info,share,name,-1))
30913108
got_error=1;
30923109
}

storage/myisam/myisamchk.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -994,14 +994,18 @@ static int myisamchk(MI_CHECK *param, char * filename)
994994
info->s->state.key_map,
995995
param->force_sort))
996996
{
997+
/*
998+
The new file might not be created with the right stats depending
999+
on how myisamchk is run, so we must copy file stats from old to new.
1000+
*/
9971001
if (param->testflag & T_REP_BY_SORT)
998-
error=mi_repair_by_sort(param,info,filename,rep_quick);
1002+
error= mi_repair_by_sort(param, info, filename, rep_quick, FALSE);
9991003
else
1000-
error=mi_repair_parallel(param,info,filename,rep_quick);
1004+
error= mi_repair_parallel(param, info, filename, rep_quick, FALSE);
10011005
state_updated=1;
10021006
}
10031007
else if (param->testflag & T_REP_ANY)
1004-
error=mi_repair(param, info,filename,rep_quick);
1008+
error= mi_repair(param, info, filename, rep_quick, FALSE);
10051009
}
10061010
if (!error && param->testflag & T_SORT_RECORDS)
10071011
{
@@ -1041,12 +1045,12 @@ static int myisamchk(MI_CHECK *param, char * filename)
10411045
{
10421046
if (param->verbose)
10431047
puts("Table had a compressed index; We must now recreate the index");
1044-
error=mi_repair_by_sort(param,info,filename,1);
1048+
error= mi_repair_by_sort(param, info, filename, 1, FALSE);
10451049
}
10461050
}
10471051
}
10481052
if (!error && param->testflag & T_SORT_INDEX)
1049-
error=mi_sort_index(param,info,filename);
1053+
error= mi_sort_index(param, info, filename, FALSE);
10501054
if (!error)
10511055
share->state.changed&= ~(STATE_CHANGED | STATE_CRASHED |
10521056
STATE_CRASHED_ON_REPAIR);

0 commit comments

Comments
 (0)