MDEV-18922 Alter on long unique varchar column makes result null

Don't add long key into share->keys_for_keyread
parent 1ef50a34
......@@ -129,3 +129,17 @@ Comment
Index_comment
ALTER TABLE t1 ADD INDEX (pk);
DROP TABLE t1;
CREATE TABLE t1 (b int, a varchar(4000));
INSERT INTO t1 VALUES (1, 2),(2,3),(3,4);
ALTER TABLE t1 ADD UNIQUE INDEX (a);
SELECT * FROM t1;
b a
1 2
2 3
3 4
SELECT a FROM t1;
a
2
3
4
drop table t1;
......@@ -150,3 +150,13 @@ CREATE TABLE t1 (pk INT, PRIMARY KEY USING HASH (pk)) ENGINE=InnoDB;
--query_vertical show keys from t1;
ALTER TABLE t1 ADD INDEX (pk);
DROP TABLE t1;
#
# MDEV-18922 Alter on long unique varchar column makes result null
#
CREATE TABLE t1 (b int, a varchar(4000));
INSERT INTO t1 VALUES (1, 2),(2,3),(3,4);
ALTER TABLE t1 ADD UNIQUE INDEX (a);
SELECT * FROM t1;
SELECT a FROM t1;
drop table t1;
......@@ -2684,7 +2684,8 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write,
if (i == 0)
field->key_start.set_bit(key);
if (field->key_length() == key_part->length &&
!(field->flags & BLOB_FLAG))
!(field->flags & BLOB_FLAG) &&
key_info->algorithm != HA_KEY_ALG_LONG_HASH)
{
if (handler_file->index_flags(key, i, 0) & HA_KEYREAD_ONLY)
{
......
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