Skip to content

Commit d481f69

Browse files
committed
MDEV-20704 An index on a double column erroneously uses prefix compression
1 parent 67b0faa commit d481f69

File tree

3 files changed

+50
-8
lines changed

3 files changed

+50
-8
lines changed

mysql-test/r/myisam.result

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2546,3 +2546,26 @@ myisam_block_size 1024
25462546
select @@global.myisam_block_size;
25472547
@@global.myisam_block_size
25482548
1024
2549+
#
2550+
# MDEV-20704 An index on a double column erroneously uses prefix compression
2551+
#
2552+
CREATE TABLE t1 (
2553+
id INT NOT NULL PRIMARY KEY,
2554+
d DOUBLE,
2555+
KEY (d)
2556+
) ENGINE=MyISAM;
2557+
2558+
MyISAM file: MYSQLD_DATADIR/test/t1
2559+
Record format: Fixed length
2560+
Character set: latin1_swedish_ci (8)
2561+
Data records: 0 Deleted blocks: 0
2562+
Recordlength: 13
2563+
2564+
table description:
2565+
Key Start Len Index Type
2566+
1 2 4 unique long
2567+
2 6 8 multip. double NULL
2568+
DROP TABLE t1;
2569+
#
2570+
# End of 5.5 tests
2571+
#

mysql-test/t/myisam.test

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1765,3 +1765,22 @@ DROP TABLE t1;
17651765
#
17661766
show variables like 'myisam_block_size';
17671767
select @@global.myisam_block_size;
1768+
1769+
1770+
--echo #
1771+
--echo # MDEV-20704 An index on a double column erroneously uses prefix compression
1772+
--echo #
1773+
1774+
CREATE TABLE t1 (
1775+
id INT NOT NULL PRIMARY KEY,
1776+
d DOUBLE,
1777+
KEY (d)
1778+
) ENGINE=MyISAM;
1779+
let $MYSQLD_DATADIR= `select @@datadir`;
1780+
--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
1781+
--exec $MYISAMCHK -d $MYSQLD_DATADIR/test/t1
1782+
DROP TABLE t1;
1783+
1784+
--echo #
1785+
--echo # End of 5.5 tests
1786+
--echo #

sql/sql_table.cc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3725,16 +3725,16 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
37253725
/* Use packed keys for long strings on the first column */
37263726
if (!((*db_options) & HA_OPTION_NO_PACK_KEYS) &&
37273727
!((create_info->table_options & HA_OPTION_NO_PACK_KEYS)) &&
3728-
(key_part_length >= KEY_DEFAULT_PACK_LENGTH &&
3729-
(sql_field->sql_type == MYSQL_TYPE_STRING ||
3730-
sql_field->sql_type == MYSQL_TYPE_VARCHAR ||
3731-
sql_field->pack_flag & FIELDFLAG_BLOB)))
3728+
(key_part_length >= KEY_DEFAULT_PACK_LENGTH &&
3729+
(sql_field->sql_type == MYSQL_TYPE_STRING ||
3730+
sql_field->sql_type == MYSQL_TYPE_VARCHAR ||
3731+
f_is_blob(sql_field->pack_flag))))
37323732
{
3733-
if ((column_nr == 0 && (sql_field->pack_flag & FIELDFLAG_BLOB)) ||
3733+
if ((column_nr == 0 && f_is_blob(sql_field->pack_flag)) ||
37343734
sql_field->sql_type == MYSQL_TYPE_VARCHAR)
3735-
key_info->flags|= HA_BINARY_PACK_KEY | HA_VAR_LENGTH_KEY;
3736-
else
3737-
key_info->flags|= HA_PACK_KEY;
3735+
key_info->flags|= HA_BINARY_PACK_KEY | HA_VAR_LENGTH_KEY;
3736+
else
3737+
key_info->flags|= HA_PACK_KEY;
37383738
}
37393739
/* Check if the key segment is partial, set the key flag accordingly */
37403740
if (key_part_length != sql_field->key_length)

0 commit comments

Comments
 (0)