diff options
author | unknown <knielsen@knielsen-hq.org> | 2010-11-19 22:33:47 +0100 |
---|---|---|
committer | unknown <knielsen@knielsen-hq.org> | 2010-11-19 22:33:47 +0100 |
commit | 95b37a254b0797499b4a940ca8eb8fa907a7664f (patch) | |
tree | bcd57843b07d10746160f485e039446bf4bd616e /storage/myisam | |
parent | 01d41622ba4cdb99327f98d0d1c1772ad842c66a (diff) | |
parent | a967802ae94e1b0ce75436648446621a381838e7 (diff) | |
download | mariadb-git-95b37a254b0797499b4a940ca8eb8fa907a7664f.tar.gz |
Merge MariaDB 5.1->5.2
Diffstat (limited to 'storage/myisam')
-rw-r--r-- | storage/myisam/Makefile.am | 20 | ||||
-rw-r--r-- | storage/myisam/ha_myisam.cc | 15 | ||||
-rw-r--r-- | storage/myisam/ha_myisam.h | 1 | ||||
-rw-r--r-- | storage/myisam/mi_check.c | 24 | ||||
-rw-r--r-- | storage/myisam/myisamchk.c | 10 | ||||
-rw-r--r-- | storage/myisam/myisampack.c | 2 | ||||
-rw-r--r-- | storage/myisam/plug.in | 3 |
7 files changed, 56 insertions, 19 deletions
diff --git a/storage/myisam/Makefile.am b/storage/myisam/Makefile.am index ea942672856..8f3d51c4886 100644 --- a/storage/myisam/Makefile.am +++ b/storage/myisam/Makefile.am @@ -31,6 +31,10 @@ EXTRA_DIST = mi_test_all.sh mi_test_all.res ft_stem.c CMakeLists.txt plug.in pkgdata_DATA = pkglib_LIBRARIES = libmyisam.a +noinst_LTLIBRARIES = libmyisam.la libmyisam_s.la \ + @plugin_myisam_embedded_static_target@ +EXTRA_LTLIBRARIES = libmyisam_embedded.la + bin_PROGRAMS = myisamchk myisamlog myisampack myisam_ftdump myisamchk_DEPENDENCIES= $(LIBRARIES) myisamchk_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmyisam.a \ @@ -83,7 +87,8 @@ sp_test_LDADD = @CLIENT_EXTRA_LDFLAGS@ libmyisam.a \ $(top_builddir)/mysys/libmysys.a \ $(top_builddir)/dbug/libdbug.a \ $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@ -libmyisam_a_SOURCES = mi_open.c mi_extra.c mi_info.c mi_rkey.c \ + +libmyisam_la_SOURCES = mi_open.c mi_extra.c mi_info.c mi_rkey.c \ mi_rnext.c mi_rnext_same.c \ mi_search.c mi_page.c mi_key.c mi_locking.c \ mi_rrnd.c mi_scan.c mi_cache.c \ @@ -98,8 +103,19 @@ libmyisam_a_SOURCES = mi_open.c mi_extra.c mi_info.c mi_rkey.c \ mi_keycache.c mi_preload.c \ ft_parser.c ft_stopwords.c ft_static.c \ ft_update.c ft_boolean_search.c ft_nlq_search.c \ - sort.c ha_myisam.cc ft_myisam.c \ + sort.c ft_myisam.c \ rt_index.c rt_key.c rt_mbr.c rt_split.c sp_key.c +libmyisam_s_la_SOURCES = ha_myisam.cc +libmyisam_s_la_CXXFLAGS = $(AM_CXXFLAGS) +libmyisam_s_la_LIBADD = libmyisam.la +libmyisam_embedded_la_SOURCES = ha_myisam.cc +libmyisam_embedded_la_CXXFLAGS = $(AM_CXXFLAGS) @plugin_embedded_defs@ +libmyisam_embedded_la_LIBADD = libmyisam.la + +libmyisam_a_SOURCES= +libmyisam.a: libmyisam.la + $(CP) .libs/libmyisam.a $@ + CLEANFILES = test?.MY? FT?.MY? isam.log mi_test_all rt_test.MY? sp_test.MY? # Move to automake rules ? diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc index 39791ff254c..d3d073d2fbe 100644 --- a/storage/myisam/ha_myisam.cc +++ b/storage/myisam/ha_myisam.cc @@ -33,7 +33,7 @@ ulong myisam_recover_options= HA_RECOVER_NONE; /* bits in myisam_recover_options */ const char *myisam_recover_names[] = -{ "DEFAULT", "BACKUP", "FORCE", "QUICK", NullS}; +{ "DEFAULT", "BACKUP", "FORCE", "QUICK", "BACKUP_ALL", NullS}; TYPELIB myisam_recover_typelib= {array_elements(myisam_recover_names)-1,"", myisam_recover_names, NULL}; @@ -1055,6 +1055,7 @@ int ha_myisam::repair(THD* thd, HA_CHECK_OPT *check_opt) T_SILENT | T_FORCE_CREATE | T_CALC_CHECKSUM | (check_opt->flags & T_EXTEND ? T_REP : T_REP_BY_SORT)); param.sort_buffer_length= thd->variables.myisam_sort_buff_size; + param.backup_time= check_opt->start_time; start_records=file->state->records; while ((error=repair(thd,param,0)) && param.retry_repair) { @@ -1659,8 +1660,18 @@ bool ha_myisam::check_and_repair(THD *thd) if ((marked_crashed= mi_is_crashed(file)) || check(thd, &check_opt)) { sql_print_warning("Recovering table: '%s'",table->s->path.str); + if (myisam_recover_options & (HA_RECOVER_FULL_BACKUP | HA_RECOVER_BACKUP)) + { + char buff[MY_BACKUP_NAME_EXTRA_LENGTH+1]; + my_create_backup_name(buff, "", check_opt.start_time); + sql_print_information("Making backup of data with extension '%s'", buff); + } + if (myisam_recover_options & HA_RECOVER_FULL_BACKUP) + mi_make_backup_of_index(file, check_opt.start_time, + MYF(MY_WME | ME_JUST_WARNING)); check_opt.flags= - ((myisam_recover_options & HA_RECOVER_BACKUP ? T_BACKUP_DATA : 0) | + (((myisam_recover_options & + (HA_RECOVER_BACKUP | HA_RECOVER_FULL_BACKUP)) ? T_BACKUP_DATA : 0) | (marked_crashed ? 0 : T_QUICK) | (myisam_recover_options & HA_RECOVER_FORCE ? 0 : T_SAFE_REPAIR) | T_AUTO_REPAIR); diff --git a/storage/myisam/ha_myisam.h b/storage/myisam/ha_myisam.h index 9d8791c7eff..0cb89b64c3c 100644 --- a/storage/myisam/ha_myisam.h +++ b/storage/myisam/ha_myisam.h @@ -29,6 +29,7 @@ #define HA_RECOVER_BACKUP 2 /* Make a backupfile on recover */ #define HA_RECOVER_FORCE 4 /* Recover even if we loose rows */ #define HA_RECOVER_QUICK 8 /* Don't check rows in data file */ +#define HA_RECOVER_FULL_BACKUP 16 /* Make a copy of index file too */ extern ulong myisam_sort_buffer_size; extern TYPELIB myisam_recover_typelib; diff --git a/storage/myisam/mi_check.c b/storage/myisam/mi_check.c index d24dba3d6b3..e92c9879e57 100644 --- a/storage/myisam/mi_check.c +++ b/storage/myisam/mi_check.c @@ -1736,7 +1736,9 @@ err: my_close(new_file,MYF(0)); info->dfile=new_file= -1; if (change_to_newfile(share->data_file_name,MI_NAME_DEXT, - DATA_TMP_EXT, share->base.raid_chunks, + DATA_TMP_EXT, + param->backup_time, + share->base.raid_chunks, (param->testflag & T_BACKUP_DATA ? MYF(MY_REDEL_MAKE_BACKUP): MYF(0))) || mi_open_datafile(info,share,name,-1)) @@ -1997,8 +1999,8 @@ int mi_sort_index(HA_CHECK *param, register MI_INFO *info, char * name) VOID(my_close(share->kfile,MYF(MY_WME))); share->kfile = -1; VOID(my_close(new_file,MYF(MY_WME))); - if (change_to_newfile(share->index_file_name,MI_NAME_IEXT,INDEX_TMP_EXT,0, - MYF(0)) || + if (change_to_newfile(share->index_file_name,MI_NAME_IEXT,INDEX_TMP_EXT, + 0, 0, MYF(0)) || mi_open_keyfile(share)) goto err2; info->lock_type= F_UNLCK; /* Force mi_readinfo to lock */ @@ -2127,6 +2129,7 @@ err: int change_to_newfile(const char * filename, const char * old_ext, const char * new_ext, + time_t backup_time, uint raid_chunks __attribute__((unused)), myf MyFlags) { @@ -2142,7 +2145,7 @@ int change_to_newfile(const char * filename, const char * old_ext, (void) fn_format(old_filename,filename,"",old_ext,2+4+32); return my_redel(old_filename, fn_format(new_filename,old_filename,"",new_ext,2+4), - MYF(MY_WME | MY_LINK_WARNING | MyFlags)); + backup_time, MYF(MY_WME | MY_LINK_WARNING | MyFlags)); } /* change_to_newfile */ @@ -2551,7 +2554,8 @@ err: my_close(new_file,MYF(0)); info->dfile=new_file= -1; if (change_to_newfile(share->data_file_name,MI_NAME_DEXT, - DATA_TMP_EXT, share->base.raid_chunks, + DATA_TMP_EXT, param->backup_time, + share->base.raid_chunks, (param->testflag & T_BACKUP_DATA ? MYF(MY_REDEL_MAKE_BACKUP): MYF(0))) || mi_open_datafile(info,share,name,-1)) @@ -3089,7 +3093,8 @@ err: my_close(new_file,MYF(0)); info->dfile=new_file= -1; if (change_to_newfile(share->data_file_name,MI_NAME_DEXT, - DATA_TMP_EXT, share->base.raid_chunks, + DATA_TMP_EXT, param->backup_time, + share->base.raid_chunks, (param->testflag & T_BACKUP_DATA ? MYF(MY_REDEL_MAKE_BACKUP): MYF(0))) || mi_open_datafile(info,share,name,-1)) @@ -4751,3 +4756,10 @@ set_data_file_type(MI_SORT_INFO *sort_info, MYISAM_SHARE *share) share->delete_record=tmp.delete_record; } } + +int mi_make_backup_of_index(MI_INFO *info, time_t backup_time, myf flags) +{ + char backup_name[FN_REFLEN + MY_BACKUP_NAME_EXTRA_LENGTH]; + my_create_backup_name(backup_name, info->s->index_file_name, backup_time); + return my_copy(info->s->index_file_name, backup_name, flags); +} diff --git a/storage/myisam/myisamchk.c b/storage/myisam/myisamchk.c index 592426a3690..8c54d7f0411 100644 --- a/storage/myisam/myisamchk.c +++ b/storage/myisam/myisamchk.c @@ -1032,7 +1032,7 @@ static int myisamchk(HA_CHECK *param, char * filename) { /* Change temp file to org file */ VOID(my_close(info->dfile,MYF(MY_WME))); /* Close new file */ error|=change_to_newfile(filename,MI_NAME_DEXT,DATA_TMP_EXT, - raid_chunks, + 0, raid_chunks, MYF(0)); if (mi_open_datafile(info,info->s, NULL, -1)) error=1; @@ -1165,12 +1165,9 @@ end2: { if (param->out_flag & O_NEW_DATA) error|=change_to_newfile(filename,MI_NAME_DEXT,DATA_TMP_EXT, - raid_chunks, + param->backup_time, raid_chunks, ((param->testflag & T_BACKUP_DATA) ? MYF(MY_REDEL_MAKE_BACKUP) : MYF(0))); - if (param->out_flag & O_NEW_INDEX) - error|=change_to_newfile(filename,MI_NAME_IEXT,INDEX_TMP_EXT,0, - MYF(0)); } VOID(fflush(stdout)); VOID(fflush(stderr)); if (param->error_printed) @@ -1242,7 +1239,8 @@ static void descript(HA_CHECK *param, register MI_INFO *info, char * name) } pos=buff; if (share->state.changed & STATE_CRASHED) - strmov(buff,"crashed"); + strmov(buff, share->state.changed & STATE_CRASHED_ON_REPAIR ? + "crashed on repair" : "crashed"); else { if (share->state.open_count) diff --git a/storage/myisam/myisampack.c b/storage/myisam/myisampack.c index f2b28a008fc..ba3ff3cdf0d 100644 --- a/storage/myisam/myisampack.c +++ b/storage/myisam/myisampack.c @@ -720,7 +720,7 @@ static int compress(PACK_MRG_INFO *mrg,char *result_table) VOID(my_delete(new_name,MYF(MY_WME))); } else - error=my_redel(org_name,new_name,MYF(MY_WME | MY_COPYTIME)); + error=my_redel(org_name, new_name, 0, MYF(MY_WME | MY_COPYTIME)); } if (! error) error=save_state(isam_file,mrg,new_length,glob_crc); diff --git a/storage/myisam/plug.in b/storage/myisam/plug.in index e92b5e56d7f..95b29336493 100644 --- a/storage/myisam/plug.in +++ b/storage/myisam/plug.in @@ -1,7 +1,6 @@ dnl MYSQL_STORAGE_ENGINE(myisam,no, [MyISAM Storage Engine], dnl [Traditional non-transactional MySQL tables]) dnl MYSQL_PLUGIN_DIRECTORY(myisam, [storage/myisam]) -dnl MYSQL_PLUGIN_STATIC(myisam, [libmyisam.a]) +dnl MYSQL_PLUGIN_STATIC(myisam, [libmyisam_s.la], [libmyisam_embedded.la]) dnl MYSQL_PLUGIN_MANDATORY(myisam) dnl Default -dnl MYSQL_PLUGIN_DEPENDS_ON_MYSQL_INTERNALS(myisam, [ha_myisam.cc]) |