Commit 80f6b225 authored by Sergey Vojtovich's avatar Sergey Vojtovich

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.
parent 3a50a8c9
......@@ -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
......
......@@ -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;
......@@ -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;
......@@ -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
#
......
......@@ -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],
......
......@@ -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],
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment