From 62171d25cf2752696833f29accb14bd1ecda81a2 Mon Sep 17 00:00:00 2001 From: "istruewing@chilla.local" <> Date: Thu, 22 Feb 2007 09:12:07 +0100 Subject: [PATCH 1/2] Bug#25460 - High concurrency MyISAM access causes severe mysqld crash. Decreased code duplication by calling memory mapping function through mi_extra(). --- storage/myisam/mi_open.c | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/storage/myisam/mi_open.c b/storage/myisam/mi_open.c index 830332fe0c1..a06b21ee5b4 100644 --- a/storage/myisam/mi_open.c +++ b/storage/myisam/mi_open.c @@ -506,22 +506,6 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) share->data_file_type = DYNAMIC_RECORD; my_afree((gptr) disk_cache); mi_setup_functions(share); - if (open_flags & HA_OPEN_MMAP) - { - info.s= share; - if (mi_dynmap_file(&info, share->state.state.data_file_length)) - { - /* purecov: begin inspected */ - /* Ignore if mmap fails. Use file I/O instead. */ - DBUG_PRINT("warning", ("mmap failed: errno: %d", errno)); - /* purecov: end */ - } - else - { - share->file_read= mi_mmap_pread; - share->file_write= mi_mmap_pwrite; - } - } share->is_log_table= FALSE; #ifdef THREAD thr_lock_init(&share->lock); @@ -552,6 +536,14 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) } } #endif + /* + Memory mapping can only be requested after initializing intern_lock. + */ + if (open_flags & HA_OPEN_MMAP) + { + info.s= share; + mi_extra(&info, HA_EXTRA_MMAP, 0); + } } else { From ddb8131207c7b58203ca5b5729827f507323c3c6 Mon Sep 17 00:00:00 2001 From: "svoj@mysql.com/june.mysql.com" <> Date: Wed, 28 Feb 2007 14:27:19 +0400 Subject: [PATCH 2/2] BUG#26080 - Memory Storage engine not working properly Extending varchar column length with ALTER TABLE may result in unusable memory table. The problem is that we use fast ALTER TABLE in this case, which is not supported by now. This is fixed by refusing fast ALTER TABLE when extending varchar column. In other words force copy of a table during ALTER TABLE. Affects MEMORY tables in 5.1 only. --- mysql-test/r/heap.result | 7 +++++++ mysql-test/t/heap.test | 9 +++++++++ storage/heap/ha_heap.cc | 7 ++++--- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/heap.result b/mysql-test/r/heap.result index 29bdfcbef7a..ddf675e2f73 100644 --- a/mysql-test/r/heap.result +++ b/mysql-test/r/heap.result @@ -731,3 +731,10 @@ SELECT COUNT(*) FROM t1 WHERE c=REPEAT('a',256); COUNT(*) 2 DROP TABLE t1; +CREATE TABLE t1(c1 VARCHAR(100), c2 INT) ENGINE=MEMORY; +INSERT INTO t1 VALUES('', 0); +ALTER TABLE t1 MODIFY c1 VARCHAR(101); +SELECT c2 FROM t1; +c2 +0 +DROP TABLE t1; diff --git a/mysql-test/t/heap.test b/mysql-test/t/heap.test index 624597cd8d7..b47a5fc2033 100644 --- a/mysql-test/t/heap.test +++ b/mysql-test/t/heap.test @@ -471,3 +471,12 @@ SELECT COUNT(*) FROM t1 WHERE c=REPEAT('a',256); DROP TABLE t1; # End of 5.0 tests + +# +# BUG#26080 - Memory Storage engine not working properly +# +CREATE TABLE t1(c1 VARCHAR(100), c2 INT) ENGINE=MEMORY; +INSERT INTO t1 VALUES('', 0); +ALTER TABLE t1 MODIFY c1 VARCHAR(101); +SELECT c2 FROM t1; +DROP TABLE t1; diff --git a/storage/heap/ha_heap.cc b/storage/heap/ha_heap.cc index cf11c9923eb..f2caa7e6d18 100644 --- a/storage/heap/ha_heap.cc +++ b/storage/heap/ha_heap.cc @@ -703,9 +703,10 @@ bool ha_heap::check_if_incompatible_data(HA_CREATE_INFO *info, uint table_changes) { /* Check that auto_increment value was not changed */ - if ((table_changes != IS_EQUAL_YES && - info->used_fields & HA_CREATE_USED_AUTO) && - info->auto_increment_value != 0) + if ((info->used_fields & HA_CREATE_USED_AUTO && + info->auto_increment_value != 0) || + table_changes == IS_EQUAL_NO || + table_changes & IS_EQUAL_PACK_LENGTH) // Not implemented yet return COMPATIBLE_DATA_NO; return COMPATIBLE_DATA_YES; }