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
@@ -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
15141514int 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 ;
@@ -2004,7 +2009,7 @@ int mi_sort_index(MI_CHECK *param, register MI_INFO *info, char * name)
20042009 share -> kfile = -1 ;
20052010 (void ) mysql_file_close (new_file , MYF (MY_WME ));
20062011 if (change_to_newfile (share -> index_file_name , MI_NAME_IEXT , INDEX_TMP_EXT ,
2007- MYF (0 )) ||
2012+ no_copy_stat ? MYF ( MY_REDEL_NO_COPY_STAT ) : MYF (0 )) ||
20082013 mi_open_keyfile (share ))
20092014 goto err2 ;
20102015 info -> lock_type = F_UNLCK ; /* Force mi_readinfo to lock */
@@ -2209,14 +2214,16 @@ int filecopy(MI_CHECK *param, File to,File from,my_off_t start,
22092214 info MyISAM handler to repair
22102215 name Name of table (for warnings)
22112216 rep_quick set to <> 0 if we should not change data file
2217+ no_copy_stat Don't copy file stats from old to new file,
2218+ assume that new file was created with correct stats
22122219
22132220 RESULT
22142221 0 ok
22152222 <>0 Error
22162223*/
22172224
22182225int mi_repair_by_sort (MI_CHECK * param , register MI_INFO * info ,
2219- const char * name , int rep_quick )
2226+ const char * name , int rep_quick , my_bool no_copy_stat )
22202227{
22212228 int got_error ;
22222229 uint i ;
@@ -2543,11 +2550,15 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info,
25432550 /* Replace the actual file with the temporary file */
25442551 if (new_file >= 0 )
25452552 {
2553+ myf flags = 0 ;
2554+ if (param -> testflag & T_BACKUP_DATA )
2555+ flags |= MY_REDEL_MAKE_BACKUP ;
2556+ if (no_copy_stat )
2557+ flags |= MY_REDEL_NO_COPY_STAT ;
25462558 mysql_file_close (new_file , MYF (0 ));
25472559 info -> dfile = new_file = -1 ;
25482560 if (change_to_newfile (share -> data_file_name ,MI_NAME_DEXT , DATA_TMP_EXT ,
2549- (param -> testflag & T_BACKUP_DATA ?
2550- MYF (MY_REDEL_MAKE_BACKUP ): MYF (0 ))) ||
2561+ flags ) ||
25512562 mi_open_datafile (info ,share ,name ,-1 ))
25522563 got_error = 1 ;
25532564 }
@@ -2595,6 +2606,8 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info,
25952606 info MyISAM handler to repair
25962607 name Name of table (for warnings)
25972608 rep_quick set to <> 0 if we should not change data file
2609+ no_copy_stat Don't copy file stats from old to new file,
2610+ assume that new file was created with correct stats
25982611
25992612 DESCRIPTION
26002613 Same as mi_repair_by_sort but do it multithreaded
@@ -2629,7 +2642,7 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info,
26292642*/
26302643
26312644int mi_repair_parallel (MI_CHECK * param , register MI_INFO * info ,
2632- const char * name , int rep_quick )
2645+ const char * name , int rep_quick , my_bool no_copy_stat )
26332646{
26342647 int got_error ;
26352648 uint i ,key , total_key_length , istep ;
@@ -3076,11 +3089,15 @@ int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info,
30763089 /* Replace the actual file with the temporary file */
30773090 if (new_file >= 0 )
30783091 {
3092+ myf flags = 0 ;
3093+ if (param -> testflag & T_BACKUP_DATA )
3094+ flags |= MY_REDEL_MAKE_BACKUP ;
3095+ if (no_copy_stat )
3096+ flags |= MY_REDEL_NO_COPY_STAT ;
30793097 mysql_file_close (new_file , MYF (0 ));
30803098 info -> dfile = new_file = -1 ;
30813099 if (change_to_newfile (share -> data_file_name , MI_NAME_DEXT , DATA_TMP_EXT ,
3082- (param -> testflag & T_BACKUP_DATA ?
3083- MYF (MY_REDEL_MAKE_BACKUP ): MYF (0 ))) ||
3100+ flags ) ||
30843101 mi_open_datafile (info ,share ,name ,-1 ))
30853102 got_error = 1 ;
30863103 }
0 commit comments