diff options
author | Sergey Vojtovich <sergey.vojtovich@oracle.com> | 2011-10-21 09:35:07 +0400 |
---|---|---|
committer | Sergey Vojtovich <sergey.vojtovich@oracle.com> | 2011-10-21 09:35:07 +0400 |
commit | a3491852b2ca61414ac6c730aeb064f075ebe029 (patch) | |
tree | c06c4e1f57daf52d46be75d1afe9d8e24f90dd30 | |
parent | 65968daea373021617e01ec333c275e56a06c29c (diff) | |
parent | ccd019dd269269e87f6a87190c795aac478b38b9 (diff) | |
download | mariadb-git-a3491852b2ca61414ac6c730aeb064f075ebe029.tar.gz |
Merge.
-rw-r--r-- | mysql-test/r/myisam.result | 24 | ||||
-rw-r--r-- | mysql-test/t/myisam.test | 18 | ||||
-rw-r--r-- | storage/myisam/ha_myisam.cc | 16 | ||||
-rw-r--r-- | storage/myisam/mi_delete_all.c | 5 |
4 files changed, 58 insertions, 5 deletions
diff --git a/mysql-test/r/myisam.result b/mysql-test/r/myisam.result index e366c5d1110..dfad082845f 100644 --- a/mysql-test/r/myisam.result +++ b/mysql-test/r/myisam.result @@ -2414,6 +2414,30 @@ CARDINALITY DROP TABLE t1; SET myisam_sort_buffer_size=@@global.myisam_sort_buffer_size; SET myisam_repair_threads=@@global.myisam_repair_threads; +# +# BUG#11757032 - 49030: OPTIMIZE TABLE BREAKS MYISAM TABLE WHEN +# USING MYISAM_USE_MMAP ON WINDOWS +# +SET GLOBAL myisam_use_mmap=1; +CREATE TABLE t1(a INT); +INSERT INTO t1 VALUES(1),(2); +DELETE FROM t1 WHERE a=1; +FLUSH TABLE t1; +LOCK TABLE t1 WRITE; +OPTIMIZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 optimize status OK +INSERT INTO t1 VALUES(3); +UNLOCK TABLES; +SELECT * FROM t1; +a +2 +3 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +DROP TABLE t1; +SET GLOBAL myisam_use_mmap=default; End of 5.1 tests # # Bug#51327 MyISAM table is automatically repaired on ALTER diff --git a/mysql-test/t/myisam.test b/mysql-test/t/myisam.test index d4b4d1555b6..8c9f51b1252 100644 --- a/mysql-test/t/myisam.test +++ b/mysql-test/t/myisam.test @@ -1647,6 +1647,24 @@ DROP TABLE t1; SET myisam_sort_buffer_size=@@global.myisam_sort_buffer_size; SET myisam_repair_threads=@@global.myisam_repair_threads; +--echo # +--echo # BUG#11757032 - 49030: OPTIMIZE TABLE BREAKS MYISAM TABLE WHEN +--echo # USING MYISAM_USE_MMAP ON WINDOWS +--echo # +SET GLOBAL myisam_use_mmap=1; +CREATE TABLE t1(a INT); +INSERT INTO t1 VALUES(1),(2); +DELETE FROM t1 WHERE a=1; +FLUSH TABLE t1; +LOCK TABLE t1 WRITE; +OPTIMIZE TABLE t1; +INSERT INTO t1 VALUES(3); +UNLOCK TABLES; +SELECT * FROM t1; +CHECK TABLE t1; +DROP TABLE t1; +SET GLOBAL myisam_use_mmap=default; + --echo End of 5.1 tests diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc index b2b64054cf9..47ca430d160 100644 --- a/storage/myisam/ha_myisam.cc +++ b/storage/myisam/ha_myisam.cc @@ -1026,6 +1026,18 @@ int ha_myisam::repair(THD *thd, MI_CHECK ¶m, bool do_optimize) mi_get_mask_all_keys_active(share->base.keys) : share->state.key_map); uint testflag=param.testflag; +#ifdef HAVE_MMAP + bool remap= test(share->file_map); + /* + mi_repair*() functions family use file I/O even if memory + mapping is available. + + Since mixing mmap I/O and file I/O may cause various artifacts, + memory mapping must be disabled. + */ + if (remap) + mi_munmap_file(file); +#endif if (mi_test_if_sort_rep(file,file->state->records,key_map,0) && (local_testflag & T_REP_BY_SORT)) { @@ -1057,6 +1069,10 @@ int ha_myisam::repair(THD *thd, MI_CHECK ¶m, bool do_optimize) error= mi_repair(¶m, file, fixed_name, param.testflag & T_QUICK); } +#ifdef HAVE_MMAP + if (remap) + mi_dynmap_file(file, file->state->data_file_length); +#endif param.testflag=testflag; optimize_done=1; } diff --git a/storage/myisam/mi_delete_all.c b/storage/myisam/mi_delete_all.c index dc9fa0981ba..3530af3eca1 100644 --- a/storage/myisam/mi_delete_all.c +++ b/storage/myisam/mi_delete_all.c @@ -61,11 +61,6 @@ int mi_delete_all_rows(MI_INFO *info) mysql_file_chsize(share->kfile, share->base.keystart, 0, MYF(MY_WME))) goto err; (void) _mi_writeinfo(info,WRITEINFO_UPDATE_KEYFILE); -#ifdef HAVE_MMAP - /* Map again */ - if (share->file_map) - mi_dynmap_file(info, (my_off_t) 0); -#endif DBUG_RETURN(0); err: |