Skip to content

Commit b4abd20

Browse files
jhauglidHery Ramilison
authored andcommitted
Merge branch 'mysql-5.6' into mysql-5.7
(cherry picked from commit ef2eb6f448ec57693aab96cd6edb452d35e4a3d9)
1 parent f75735e commit b4abd20

File tree

6 files changed

+73
-28
lines changed

6 files changed

+73
-28
lines changed

include/my_sys.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ C_MODE_START
8989
#define MY_RESOLVE_LINK 128 /* my_realpath(); Only resolve links */
9090
#define MY_HOLD_ORIGINAL_MODES 128 /* my_copy() holds to file modes */
9191
#define MY_REDEL_MAKE_BACKUP 256
92+
#define MY_REDEL_NO_COPY_STAT 512 /* my_redel() doesn't call my_copystat() */
9293
#define MY_SEEK_NOT_DONE 32 /* my_lock may have to do a seek */
9394
#define MY_DONT_WAIT 64 /* my_lock() don't wait if can't lock */
9495
#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, 2015, 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
@@ -425,12 +425,13 @@ int chk_size(MI_CHECK *param, MI_INFO *info);
425425
int chk_key(MI_CHECK *param, MI_INFO *info);
426426
int chk_data_link(MI_CHECK *param, MI_INFO *info,int extend);
427427
int mi_repair(MI_CHECK *param, MI_INFO *info,
428-
char * name, int rep_quick);
429-
int mi_sort_index(MI_CHECK *param, MI_INFO *info, char * name);
428+
char * name, int rep_quick, my_bool no_copy_stat);
429+
int mi_sort_index(MI_CHECK *param, MI_INFO *info, char * name,
430+
my_bool no_copy_stat);
430431
int mi_repair_by_sort(MI_CHECK *param, MI_INFO *info,
431-
const char * name, int rep_quick);
432+
const char * name, int rep_quick, my_bool no_copy_stat);
432433
int mi_repair_parallel(MI_CHECK *param, MI_INFO *info,
433-
const char * name, int rep_quick);
434+
const char * name, int rep_quick, my_bool no_copy_stat);
434435
int change_to_newfile(const char * filename, const char * old_ext,
435436
const char * new_ext, myf myflags);
436437
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, 2015, 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
@@ -33,6 +33,9 @@
3333
3434
if MY_REDEL_MAKE_COPY is given, then the orginal file
3535
is renamed to org_name-'current_time'.BAK
36+
37+
if MY_REDEL_NO_COPY_STAT is given, stats are not copied
38+
from org_name to tmp_name.
3639
*/
3740

3841
#define REDEL_EXT ".BAK"
@@ -44,8 +47,11 @@ int my_redel(const char *org_name, const char *tmp_name, myf MyFlags)
4447
DBUG_PRINT("my",("org_name: '%s' tmp_name: '%s' MyFlags: %d",
4548
org_name,tmp_name,MyFlags));
4649

47-
if (my_copystat(org_name,tmp_name,MyFlags) < 0)
48-
goto end;
50+
if (!(MyFlags & MY_REDEL_NO_COPY_STAT))
51+
{
52+
if (my_copystat(org_name,tmp_name,MyFlags) < 0)
53+
goto end;
54+
}
4955
if (MyFlags & MY_REDEL_MAKE_BACKUP)
5056
{
5157
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
@@ -1145,24 +1145,36 @@ int ha_myisam::repair(THD *thd, MI_CHECK &param, bool do_optimize)
11451145
/* TODO: respect myisam_repair_threads variable */
11461146
my_snprintf(buf, 40, "Repair with %d threads", my_count_bits(key_map));
11471147
thd_proc_info(thd, buf);
1148+
/*
1149+
The new file is created with the right stats, so we can skip
1150+
copying file stats from old to new.
1151+
*/
11481152
error = mi_repair_parallel(&param, file, fixed_name,
1149-
param.testflag & T_QUICK);
1153+
param.testflag & T_QUICK, TRUE);
11501154
thd_proc_info(thd, "Repair done"); // to reset proc_info, as
11511155
// it was pointing to local buffer
11521156
}
11531157
else
11541158
{
11551159
thd_proc_info(thd, "Repair by sorting");
1160+
/*
1161+
The new file is created with the right stats, so we can skip
1162+
copying file stats from old to new.
1163+
*/
11561164
error = mi_repair_by_sort(&param, file, fixed_name,
1157-
param.testflag & T_QUICK);
1165+
param.testflag & T_QUICK, TRUE);
11581166
}
11591167
}
11601168
else
11611169
{
11621170
thd_proc_info(thd, "Repair with keycache");
11631171
param.testflag &= ~T_REP_BY_SORT;
1172+
/*
1173+
The new file is created with the right stats, so we can skip
1174+
copying file stats from old to new.
1175+
*/
11641176
error= mi_repair(&param, file, fixed_name,
1165-
param.testflag & T_QUICK);
1177+
param.testflag & T_QUICK, TRUE);
11661178
}
11671179
if (remap)
11681180
mi_dynmap_file(file, file->state->data_file_length);
@@ -1176,7 +1188,11 @@ int ha_myisam::repair(THD *thd, MI_CHECK &param, bool do_optimize)
11761188
{
11771189
optimize_done=1;
11781190
thd_proc_info(thd, "Sorting index");
1179-
error=mi_sort_index(&param,file,fixed_name);
1191+
/*
1192+
The new file is created with the right stats, so we can skip
1193+
copying file stats from old to new.
1194+
*/
1195+
error=mi_sort_index(&param,file,fixed_name, TRUE);
11801196
}
11811197
if (!statistics_done && (local_testflag & T_STATISTICS))
11821198
{

storage/myisam/mi_check.c

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

15191519
int mi_repair(MI_CHECK *param, MI_INFO *info,
1520-
char * name, int rep_quick)
1520+
char * name, int rep_quick, my_bool no_copy_stat)
15211521
{
15221522
int error,got_error;
15231523
ha_rows start_records,new_header_length;
@@ -1731,6 +1731,11 @@ int mi_repair(MI_CHECK *param, MI_INFO *info,
17311731
/* Replace the actual file with the temporary file */
17321732
if (new_file >= 0)
17331733
{
1734+
myf flags= 0;
1735+
if (param->testflag & T_BACKUP_DATA)
1736+
flags |= MY_REDEL_MAKE_BACKUP;
1737+
if (no_copy_stat)
1738+
flags |= MY_REDEL_NO_COPY_STAT;
17341739
mysql_file_close(new_file, MYF(0));
17351740
info->dfile=new_file= -1;
17361741
/*
@@ -1749,8 +1754,7 @@ int mi_repair(MI_CHECK *param, MI_INFO *info,
17491754
info->s->file_map= NULL;
17501755
}
17511756
if (change_to_newfile(share->data_file_name, MI_NAME_DEXT, DATA_TMP_EXT,
1752-
(param->testflag & T_BACKUP_DATA ?
1753-
MYF(MY_REDEL_MAKE_BACKUP): MYF(0))) ||
1757+
flags) ||
17541758
mi_open_datafile(info,share,name,-1))
17551759
got_error=1;
17561760

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

19381942
/* Sort index for more efficent reads */
19391943

1940-
int mi_sort_index(MI_CHECK *param, MI_INFO *info, char * name)
1944+
int mi_sort_index(MI_CHECK *param, MI_INFO *info, char * name,
1945+
my_bool no_copy_stat)
19411946
{
19421947
uint key;
19431948
MI_KEYDEF *keyinfo;
@@ -2015,7 +2020,7 @@ int mi_sort_index(MI_CHECK *param, MI_INFO *info, char * name)
20152020
share->kfile = -1;
20162021
(void) mysql_file_close(new_file, MYF(MY_WME));
20172022
if (change_to_newfile(share->index_file_name, MI_NAME_IEXT, INDEX_TMP_EXT,
2018-
MYF(0)) ||
2023+
no_copy_stat ? MYF(MY_REDEL_NO_COPY_STAT) : MYF(0)) ||
20192024
mi_open_keyfile(share))
20202025
goto err2;
20212026
info->lock_type= F_UNLCK; /* Force mi_readinfo to lock */
@@ -2219,14 +2224,16 @@ int filecopy(MI_CHECK *param, File to,File from,my_off_t start,
22192224
info MyISAM handler to repair
22202225
name Name of table (for warnings)
22212226
rep_quick set to <> 0 if we should not change data file
2227+
no_copy_stat Don't copy file stats from old to new file,
2228+
assume that new file was created with correct stats
22222229
22232230
RESULT
22242231
0 ok
22252232
<>0 Error
22262233
*/
22272234

22282235
int mi_repair_by_sort(MI_CHECK *param, MI_INFO *info,
2229-
const char * name, int rep_quick)
2236+
const char * name, int rep_quick, my_bool no_copy_stat)
22302237
{
22312238
int got_error;
22322239
uint i;
@@ -2549,11 +2556,15 @@ int mi_repair_by_sort(MI_CHECK *param, 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, 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, MI_INFO *info,
26352648
*/
26362649

26372650
int mi_repair_parallel(MI_CHECK *param, 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;
@@ -3070,11 +3083,15 @@ int mi_repair_parallel(MI_CHECK *param, MI_INFO *info,
30703083
/* Replace the actual file with the temporary file */
30713084
if (new_file >= 0)
30723085
{
3086+
myf flags= 0;
3087+
if (param->testflag & T_BACKUP_DATA)
3088+
flags |= MY_REDEL_MAKE_BACKUP;
3089+
if (no_copy_stat)
3090+
flags |= MY_REDEL_NO_COPY_STAT;
30733091
mysql_file_close(new_file, MYF(0));
30743092
info->dfile=new_file= -1;
30753093
if (change_to_newfile(share->data_file_name, MI_NAME_DEXT, DATA_TMP_EXT,
3076-
(param->testflag & T_BACKUP_DATA ?
3077-
MYF(MY_REDEL_MAKE_BACKUP): MYF(0))) ||
3094+
flags) ||
30783095
mi_open_datafile(info,share,name,-1))
30793096
got_error=1;
30803097
}

storage/myisam/myisamchk.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,14 +1007,18 @@ static int myisamchk(MI_CHECK *param, char * filename)
10071007
info->s->state.key_map,
10081008
param->force_sort))
10091009
{
1010+
/*
1011+
The new file might not be created with the right stats depending
1012+
on how myisamchk is run, so we must copy file stats from old to new.
1013+
*/
10101014
if (param->testflag & T_REP_BY_SORT)
1011-
error=mi_repair_by_sort(param,info,filename,rep_quick);
1015+
error= mi_repair_by_sort(param, info, filename, rep_quick, FALSE);
10121016
else
1013-
error=mi_repair_parallel(param,info,filename,rep_quick);
1017+
error= mi_repair_parallel(param, info, filename, rep_quick, FALSE);
10141018
state_updated=1;
10151019
}
10161020
else if (param->testflag & T_REP_ANY)
1017-
error=mi_repair(param, info,filename,rep_quick);
1021+
error= mi_repair(param, info, filename, rep_quick, FALSE);
10181022
}
10191023
if (!error && param->testflag & T_SORT_RECORDS)
10201024
{
@@ -1055,12 +1059,12 @@ static int myisamchk(MI_CHECK *param, char * filename)
10551059
{
10561060
if (param->verbose)
10571061
puts("Table had a compressed index; We must now recreate the index");
1058-
error=mi_repair_by_sort(param,info,filename,1);
1062+
error= mi_repair_by_sort(param, info, filename, 1, FALSE);
10591063
}
10601064
}
10611065
}
10621066
if (!error && param->testflag & T_SORT_INDEX)
1063-
error=mi_sort_index(param,info,filename);
1067+
error= mi_sort_index(param, info, filename, FALSE);
10641068
if (!error)
10651069
share->state.changed&= ~(STATE_CHANGED | STATE_CRASHED |
10661070
STATE_CRASHED_ON_REPAIR);

0 commit comments

Comments
 (0)