diff options
author | Alexey Kopytov <Alexey.Kopytov@Sun.com> | 2010-04-03 12:37:53 +0400 |
---|---|---|
committer | Alexey Kopytov <Alexey.Kopytov@Sun.com> | 2010-04-03 12:37:53 +0400 |
commit | 374bd063193d3f0e0dace94a2dccdf6414a47382 (patch) | |
tree | 2e84ff7f9e6dcd233caa9e22272a48ae20c5209a /storage | |
parent | 87b98f6350b57a58e2a0c436c6c4c6783e3d27dd (diff) | |
parent | 8d0b9a8d9d7c205a47b2b5b6bce36ab53ae09f7f (diff) | |
download | mariadb-git-374bd063193d3f0e0dace94a2dccdf6414a47382.tar.gz |
Manual merge of mysql-5.1-bugteam into mysql-trunk-merge.
Conflicts:
Text conflict in mysql-test/r/partition.result
Text conflict in mysql-test/t/partition.test
Text conflict in storage/myisam/mi_dynrec.c
Diffstat (limited to 'storage')
-rw-r--r-- | storage/archive/ha_archive.cc | 14 | ||||
-rw-r--r-- | storage/myisam/ha_myisam.cc | 2 | ||||
-rw-r--r-- | storage/myisam/mi_delete_all.c | 2 | ||||
-rw-r--r-- | storage/myisam/mi_dynrec.c | 31 | ||||
-rw-r--r-- | storage/myisam/mi_extra.c | 5 | ||||
-rw-r--r-- | storage/myisam/myisamdef.h | 1 |
6 files changed, 42 insertions, 13 deletions
diff --git a/storage/archive/ha_archive.cc b/storage/archive/ha_archive.cc index f95a7252f2f..527362ef138 100644 --- a/storage/archive/ha_archive.cc +++ b/storage/archive/ha_archive.cc @@ -1324,13 +1324,12 @@ end: /* This method repairs the meta file. It does this by walking the datafile and - rewriting the meta file. Currently it does this by calling optimize with - the extended flag. + rewriting the meta file. If EXTENDED repair is requested, we attempt to + recover as much data as possible. */ int ha_archive::repair(THD* thd, HA_CHECK_OPT* check_opt) { DBUG_ENTER("ha_archive::repair"); - check_opt->flags= T_EXTEND; int rc= optimize(thd, check_opt); if (rc) @@ -1424,7 +1423,14 @@ int ha_archive::optimize(THD* thd, HA_CHECK_OPT* check_opt) DBUG_PRINT("ha_archive", ("recovered %llu archive rows", (unsigned long long)share->rows_recorded)); - if (rc && rc != HA_ERR_END_OF_FILE) + /* + If REPAIR ... EXTENDED is requested, try to recover as much data + from data file as possible. In this case if we failed to read a + record, we assume EOF. This allows massive data loss, but we can + hardly do more with broken zlib stream. And this is the only way + to restore at least what is still recoverable. + */ + if (rc && rc != HA_ERR_END_OF_FILE && !(check_opt->flags & T_EXTEND)) goto error; } diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc index 933347006fc..ab43e126ab4 100644 --- a/storage/myisam/ha_myisam.cc +++ b/storage/myisam/ha_myisam.cc @@ -76,7 +76,7 @@ static MYSQL_THDVAR_ULONG(repair_threads, PLUGIN_VAR_RQCMDARG, static MYSQL_THDVAR_ULONG(sort_buffer_size, PLUGIN_VAR_RQCMDARG, "The buffer that is allocated when sorting the index when doing " "a REPAIR or when creating indexes with CREATE INDEX or ALTER TABLE", NULL, NULL, - 8192*1024, 4, ULONG_MAX, 1); + 8192*1024, (long) (MIN_SORT_BUFFER + MALLOC_OVERHEAD), ULONG_MAX, 1); static MYSQL_SYSVAR_BOOL(use_mmap, opt_myisam_use_mmap, PLUGIN_VAR_NOCMDARG, "Use memory mapping for reading and writing MyISAM tables", NULL, NULL, FALSE); diff --git a/storage/myisam/mi_delete_all.c b/storage/myisam/mi_delete_all.c index b8706069ced..7a2e24189e6 100644 --- a/storage/myisam/mi_delete_all.c +++ b/storage/myisam/mi_delete_all.c @@ -55,7 +55,7 @@ int mi_delete_all_rows(MI_INFO *info) flush_key_blocks(share->key_cache, share->kfile, FLUSH_IGNORE_CHANGED); #ifdef HAVE_MMAP if (share->file_map) - _mi_unmap_file(info); + mi_munmap_file(info); #endif if (mysql_file_chsize(info->dfile, 0, 0, MYF(MY_WME)) || mysql_file_chsize(share->kfile, share->base.keystart, 0, MYF(MY_WME))) diff --git a/storage/myisam/mi_dynrec.c b/storage/myisam/mi_dynrec.c index 3830763c673..02a8f21e3e2 100644 --- a/storage/myisam/mi_dynrec.c +++ b/storage/myisam/mi_dynrec.c @@ -97,6 +97,34 @@ my_bool mi_dynmap_file(MI_INFO *info, my_off_t size) madvise((char*) info->s->file_map, size, MADV_RANDOM); #endif info->s->mmaped_length= size; + info->s->file_read= mi_mmap_pread; + info->s->file_write= mi_mmap_pwrite; + DBUG_RETURN(0); +} + + +/* + Destroy mmaped area for MyISAM handler + + SYNOPSIS + mi_munmap_file() + info MyISAM handler + + RETURN + 0 ok + !0 error. +*/ + +int mi_munmap_file(MI_INFO *info) +{ + int ret; + DBUG_ENTER("mi_unmap_file"); + if ((ret= my_munmap(info->s->file_map, info->s->mmaped_length))) + DBUG_RETURN(ret); + info->s->file_read= mi_nommap_pread; + info->s->file_write= mi_nommap_pwrite; + info->s->file_map= 0; + info->s->mmaped_length= 0; DBUG_RETURN(0); } @@ -115,8 +143,7 @@ void mi_remap_file(MI_INFO *info, my_off_t size) { if (info->s->file_map) { - (void) (my_munmap((char*) info->s->file_map, - (size_t) info->s->mmaped_length)); + mi_munmap_file(info); mi_dynmap_file(info, size); } } diff --git a/storage/myisam/mi_extra.c b/storage/myisam/mi_extra.c index d8f4fc99c8e..baf8cb5e240 100644 --- a/storage/myisam/mi_extra.c +++ b/storage/myisam/mi_extra.c @@ -364,11 +364,6 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg) DBUG_PRINT("warning",("mmap failed: errno: %d",errno)); error= my_errno= errno; } - else - { - share->file_read= mi_mmap_pread; - share->file_write= mi_mmap_pwrite; - } } mysql_mutex_unlock(&share->intern_lock); #endif diff --git a/storage/myisam/myisamdef.h b/storage/myisam/myisamdef.h index a1142ff418a..d88ebdf5f12 100644 --- a/storage/myisam/myisamdef.h +++ b/storage/myisam/myisamdef.h @@ -767,6 +767,7 @@ int mi_open_datafile(MI_INFO *info, MYISAM_SHARE *share, const char *orn_name, int mi_open_keyfile(MYISAM_SHARE *share); void mi_setup_functions(register MYISAM_SHARE *share); my_bool mi_dynmap_file(MI_INFO *info, my_off_t size); +int mi_munmap_file(MI_INFO *info); void mi_remap_file(MI_INFO *info, my_off_t size); void _mi_report_crashed(MI_INFO *file, const char *message, const char *sfile, uint sline); |