diff options
author | Sergey Vojtovich <svoj@mariadb.org> | 2015-06-09 16:08:09 +0400 |
---|---|---|
committer | Sergey Vojtovich <svoj@mariadb.org> | 2015-06-09 23:24:03 +0400 |
commit | 80f6b2259330f2bc4de1692b671ab553dc5b4353 (patch) | |
tree | a4e66963a6a2e096b36f806662fcd55365f94c85 | |
parent | 3a50a8c9bed9163beb3373cee8e2a51b3550b72e (diff) | |
download | mariadb-git-80f6b2259330f2bc4de1692b671ab553dc5b4353.tar.gz |
MDEV-3870 - Valgrind warnings on OPTIMIZE MyISAM or Aria TABLE with disabled
keys
Fixed that OPTIMIZE TABLE against MyISAM/Aria table may write uninitialized key
root position for disabled keys.
-rw-r--r-- | mysql-test/r/myisam.result | 11 | ||||
-rw-r--r-- | mysql-test/suite/maria/optimize.result | 11 | ||||
-rw-r--r-- | mysql-test/suite/maria/optimize.test | 10 | ||||
-rw-r--r-- | mysql-test/t/myisam.test | 10 | ||||
-rw-r--r-- | storage/maria/ma_check.c | 6 | ||||
-rw-r--r-- | storage/myisam/mi_check.c | 6 |
6 files changed, 46 insertions, 8 deletions
diff --git a/mysql-test/r/myisam.result b/mysql-test/r/myisam.result index c969b237293..85af643387e 100644 --- a/mysql-test/r/myisam.result +++ b/mysql-test/r/myisam.result @@ -2522,6 +2522,17 @@ test.t1 check error Size of indexfile is: 1024 Should be: 2048 test.t1 check warning Size of datafile is: 14 Should be: 7 test.t1 check error Corrupt DROP TABLE t1; +# +# MDEV-3870 - Valgrind warnings on OPTIMIZE MyISAM or Aria TABLE with +# disabled keys +# +CREATE TABLE t1 (a INT, KEY(a)) ENGINE=MyISAM; +INSERT INTO t1 VALUES (4),(3),(1),(0); +ALTER TABLE t1 DISABLE KEYS; +OPTIMIZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 optimize status OK +DROP TABLE t1; show variables like 'myisam_block_size'; Variable_name Value myisam_block_size 1024 diff --git a/mysql-test/suite/maria/optimize.result b/mysql-test/suite/maria/optimize.result index 9cce55d6199..a78e8e469aa 100644 --- a/mysql-test/suite/maria/optimize.result +++ b/mysql-test/suite/maria/optimize.result @@ -6,3 +6,14 @@ OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize status OK drop table t1; +# +# MDEV-3870 - Valgrind warnings on OPTIMIZE MyISAM or Aria TABLE with +# disabled keys +# +CREATE TABLE t1 (a INT, KEY(a)) ENGINE=Aria; +INSERT INTO t1 VALUES (4),(3),(1),(0); +ALTER TABLE t1 DISABLE KEYS; +OPTIMIZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 optimize status OK +DROP TABLE t1; diff --git a/mysql-test/suite/maria/optimize.test b/mysql-test/suite/maria/optimize.test index 6b310b1d1a6..b1fc250cd29 100644 --- a/mysql-test/suite/maria/optimize.test +++ b/mysql-test/suite/maria/optimize.test @@ -160,3 +160,13 @@ INSERT /*! IGNORE */ INTO t1 VALUES ('urxjxqvwabikpugvexxbxdpxjkeqiuhhuadbcuhoz check table t1; OPTIMIZE TABLE t1; drop table t1; + +--echo # +--echo # MDEV-3870 - Valgrind warnings on OPTIMIZE MyISAM or Aria TABLE with +--echo # disabled keys +--echo # +CREATE TABLE t1 (a INT, KEY(a)) ENGINE=Aria; +INSERT INTO t1 VALUES (4),(3),(1),(0); +ALTER TABLE t1 DISABLE KEYS; +OPTIMIZE TABLE t1; +DROP TABLE t1; diff --git a/mysql-test/t/myisam.test b/mysql-test/t/myisam.test index 8323890b028..43c12b42bc9 100644 --- a/mysql-test/t/myisam.test +++ b/mysql-test/t/myisam.test @@ -1749,6 +1749,16 @@ CHECK TABLE t1; DROP TABLE t1; +--echo # +--echo # MDEV-3870 - Valgrind warnings on OPTIMIZE MyISAM or Aria TABLE with +--echo # disabled keys +--echo # +CREATE TABLE t1 (a INT, KEY(a)) ENGINE=MyISAM; +INSERT INTO t1 VALUES (4),(3),(1),(0); +ALTER TABLE t1 DISABLE KEYS; +OPTIMIZE TABLE t1; +DROP TABLE t1; + # # Check some variables # diff --git a/storage/maria/ma_check.c b/storage/maria/ma_check.c index 3be4465c71e..ecdc512ef69 100644 --- a/storage/maria/ma_check.c +++ b/storage/maria/ma_check.c @@ -3119,10 +3119,8 @@ int maria_sort_index(HA_CHECK *param, register MARIA_HA *info, char *name) for (key= 0,keyinfo= &share->keyinfo[0]; key < share->base.keys ; key++,keyinfo++) { - if (! maria_is_key_active(share->state.key_map, key)) - continue; - - if (share->state.key_root[key] != HA_OFFSET_ERROR) + if (maria_is_key_active(share->state.key_map, key) && + share->state.key_root[key] != HA_OFFSET_ERROR) { index_pos[key]=param->new_file_pos; /* Write first block here */ if (sort_one_index(param,info,keyinfo,share->state.key_root[key], diff --git a/storage/myisam/mi_check.c b/storage/myisam/mi_check.c index 73558ce77b3..ff9ea4b82cb 100644 --- a/storage/myisam/mi_check.c +++ b/storage/myisam/mi_check.c @@ -1944,10 +1944,8 @@ int mi_sort_index(HA_CHECK *param, register MI_INFO *info, char * name) for (key= 0,keyinfo= &share->keyinfo[0]; key < share->base.keys ; key++,keyinfo++) { - if (! mi_is_key_active(info->s->state.key_map, key)) - continue; - - if (share->state.key_root[key] != HA_OFFSET_ERROR) + if (mi_is_key_active(info->s->state.key_map, key) && + share->state.key_root[key] != HA_OFFSET_ERROR) { index_pos[key]=param->new_file_pos; /* Write first block here */ if (sort_one_index(param,info,keyinfo,share->state.key_root[key], |