1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

MDEV-35792 Adding a regular index on a vector column leads to invalid table structure

don't create a prefix key for types that don't support prefix keys
This commit is contained in:
Sergei Golubchik
2025-02-03 19:33:59 +01:00
parent 1ea79d1774
commit a37eb6d013
3 changed files with 23 additions and 1 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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 */