diff --git a/mysql-test/main/vector2.result b/mysql-test/main/vector2.result index b30babb1c6d..e1ed40d0774 100644 --- a/mysql-test/main/vector2.result +++ b/mysql-test/main/vector2.result @@ -395,4 +395,17 @@ flush tables; update t set v = 1; ERROR HY000: Cannot cast 'int' as 'vector' in assignment of `test`.`t`.`v` drop table t; +# +# MDEV-35792 Adding a regular index on a vector column leads to invalid table structure +# +create table t (v vector(800), key(v)); +ERROR 42000: Specified key was too long; max key length is 1000 bytes +create table t (v vector(8), key(v)); +show create table t; +Table Create Table +t CREATE TABLE `t` ( + `v` vector(8) DEFAULT NULL, + KEY `v` (`v`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +drop table t; # End of 11.7 tests diff --git a/mysql-test/main/vector2.test b/mysql-test/main/vector2.test index 916792277b1..d63583f9c07 100644 --- a/mysql-test/main/vector2.test +++ b/mysql-test/main/vector2.test @@ -289,4 +289,13 @@ flush tables; update t set v = 1; drop table t; +--echo # +--echo # MDEV-35792 Adding a regular index on a vector column leads to invalid table structure +--echo # +--error ER_TOO_LONG_KEY +create table t (v vector(800), key(v)); +create table t (v vector(8), key(v)); +show create table t; +drop table t; + --echo # End of 11.7 tests diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 6f9a7c2019f..3d29d1115b3 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -3012,7 +3012,7 @@ my_bool init_key_part_spec(THD *thd, Alter_info *alter_info, } if (key_part_length > max_key_part_length) { - if (key.type == Key::MULTIPLE) + if (key.type == Key::MULTIPLE && type_handler->type_can_have_key_part()) { key_part_length= max_key_part_length; /* not a critical problem */