diff options
author | Alexander Barkov <bar@mariadb.com> | 2019-10-01 06:07:56 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mariadb.com> | 2019-10-01 06:07:56 +0400 |
commit | 4bcf524482b3a4260347b0fe912fa2660af97c43 (patch) | |
tree | 5ab57e9fc9925745d38be3223982af7ae3ca44ec | |
parent | 9b80f9300d6060f754d95d5a7b92706ee7d47e5e (diff) | |
parent | d481f69a7de919f9d699bf18a5b0bfd669f6131b (diff) | |
download | mariadb-git-4bcf524482b3a4260347b0fe912fa2660af97c43.tar.gz |
Merge remote-tracking branch 'origin/5.5' into 10.1
-rw-r--r-- | mysql-test/r/myisam.result | 23 | ||||
-rw-r--r-- | mysql-test/t/myisam.test | 19 | ||||
-rw-r--r-- | sql/sql_table.cc | 16 |
3 files changed, 50 insertions, 8 deletions
diff --git a/mysql-test/r/myisam.result b/mysql-test/r/myisam.result index 999f489457f..6b983b828c2 100644 --- a/mysql-test/r/myisam.result +++ b/mysql-test/r/myisam.result @@ -2560,3 +2560,26 @@ myisam_block_size 1024 select @@global.myisam_block_size; @@global.myisam_block_size 1024 +# +# MDEV-20704 An index on a double column erroneously uses prefix compression +# +CREATE TABLE t1 ( +id INT NOT NULL PRIMARY KEY, +d DOUBLE, +KEY (d) +) ENGINE=MyISAM; + +MyISAM file: MYSQLD_DATADIR/test/t1 +Record format: Fixed length +Character set: latin1_swedish_ci (8) +Data records: 0 Deleted blocks: 0 +Recordlength: 13 + +table description: +Key Start Len Index Type +1 2 4 unique long +2 6 8 multip. double NULL +DROP TABLE t1; +# +# End of 5.5 tests +# diff --git a/mysql-test/t/myisam.test b/mysql-test/t/myisam.test index 77baa695b6d..6ba4102a3e6 100644 --- a/mysql-test/t/myisam.test +++ b/mysql-test/t/myisam.test @@ -1781,3 +1781,22 @@ drop table t1; # show variables like 'myisam_block_size'; select @@global.myisam_block_size; + + +--echo # +--echo # MDEV-20704 An index on a double column erroneously uses prefix compression +--echo # + +CREATE TABLE t1 ( + id INT NOT NULL PRIMARY KEY, + d DOUBLE, + KEY (d) +) ENGINE=MyISAM; +let $MYSQLD_DATADIR= `select @@datadir`; +--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR +--exec $MYISAMCHK -d $MYSQLD_DATADIR/test/t1 +DROP TABLE t1; + +--echo # +--echo # End of 5.5 tests +--echo # diff --git a/sql/sql_table.cc b/sql/sql_table.cc index fe923d73200..467e91ce6c7 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -4059,16 +4059,16 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info, /* Use packed keys for long strings on the first column */ if (!((*db_options) & HA_OPTION_NO_PACK_KEYS) && !((create_info->table_options & HA_OPTION_NO_PACK_KEYS)) && - (key_part_length >= KEY_DEFAULT_PACK_LENGTH && - (sql_field->sql_type == MYSQL_TYPE_STRING || - sql_field->sql_type == MYSQL_TYPE_VARCHAR || - sql_field->pack_flag & FIELDFLAG_BLOB))) + (key_part_length >= KEY_DEFAULT_PACK_LENGTH && + (sql_field->sql_type == MYSQL_TYPE_STRING || + sql_field->sql_type == MYSQL_TYPE_VARCHAR || + f_is_blob(sql_field->pack_flag)))) { - if ((column_nr == 0 && (sql_field->pack_flag & FIELDFLAG_BLOB)) || + if ((column_nr == 0 && f_is_blob(sql_field->pack_flag)) || sql_field->sql_type == MYSQL_TYPE_VARCHAR) - key_info->flags|= HA_BINARY_PACK_KEY | HA_VAR_LENGTH_KEY; - else - key_info->flags|= HA_PACK_KEY; + key_info->flags|= HA_BINARY_PACK_KEY | HA_VAR_LENGTH_KEY; + else + key_info->flags|= HA_PACK_KEY; } /* Check if the key segment is partial, set the key flag accordingly */ if (key_part_length != sql_field->key_length) |