MDEV-35186 IGNORED attribute has no effect on vector keys

This commit is contained in:
Sergei Golubchik 2025-02-09 17:10:05 +01:00
parent 55d1f6c229
commit 2b17265ae2
4 changed files with 23 additions and 2 deletions

View File

@ -423,4 +423,16 @@ show warnings;
Level Code Message
Warning 1292 Incorrect inet6 value: '' for column ``.``.`a` at row 0
Error 1067 Invalid default value for 'a'
#
# MDEV-35186 IGNORED attribute has no effect on vector keys
#
create table t (a vector(1) not null, vector(a) ignored);
show index in t;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Ignored
t 1 a 1 a A NULL NULL NULL VECTOR YES
insert into t values (0x00000000),(0x00000000);
explain select vec_totext(a) from t order by vec_distance_euclidean(a,0x00000000) limit 1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t ALL NULL NULL NULL NULL 2 Using filesort
drop table t;
# End of 11.7 tests

View File

@ -309,4 +309,12 @@ show warnings;
create table t (a inet6 not null default '');
show warnings;
--echo #
--echo # MDEV-35186 IGNORED attribute has no effect on vector keys
--echo #
create table t (a vector(1) not null, vector(a) ignored);
show index in t;
insert into t values (0x00000000),(0x00000000);
explain select vec_totext(a) from t order by vec_distance_euclidean(a,0x00000000) limit 1;
drop table t;
--echo # End of 11.7 tests

View File

@ -32,7 +32,8 @@ key_map Item_func_vec_distance_common::part_of_sortkey() const
Field *f= item->field;
KEY *keyinfo= f->table->s->key_info;
for (uint i= f->table->s->keys; i < f->table->s->total_keys; i++)
if (keyinfo[i].algorithm == HA_KEY_ALG_VECTOR && f->key_start.is_set(i)
if (!keyinfo[i].is_ignored && keyinfo[i].algorithm == HA_KEY_ALG_VECTOR
&& f->key_start.is_set(i)
&& mhnsw_uses_distance(f->table, keyinfo + i, this))
map.set_bit(i);
}

View File

@ -2214,7 +2214,7 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write,
if (extra2.index_flags.str)
extra_index_flags_present= TRUE;
for (uint i= 0; i < share->keys; i++, keyinfo++)
for (uint i= 0; i < share->total_keys; i++, keyinfo++)
{
if (extra_index_flags_present)
{