diff --git a/mysql-test/main/vector2.result b/mysql-test/main/vector2.result index d9a13885b85..d53199ec3bf 100644 --- a/mysql-test/main/vector2.result +++ b/mysql-test/main/vector2.result @@ -1,3 +1,12 @@ # Aria doesn't support VECTOR yet create table t1(v blob not null, vector index(v)) engine=aria; ERROR HY000: Table storage engine 'Aria' does not support the create option 'VECTOR' +# +# MDEV-35038 Server crash in Index_statistics::get_avg_frequency upon EITS collection for vector index +# +create table t (a int, v blob not null, vector index (v)); +analyze table t persistent for columns() indexes (v); +Table Op Msg_type Msg_text +test.t analyze status Engine-independent statistics collected +test.t analyze status Table is already up to date +drop table t; diff --git a/mysql-test/main/vector2.test b/mysql-test/main/vector2.test index 6d81217d688..d6ef01221b4 100644 --- a/mysql-test/main/vector2.test +++ b/mysql-test/main/vector2.test @@ -5,3 +5,10 @@ --echo # Aria doesn't support VECTOR yet --error ER_ILLEGAL_HA_CREATE_OPTION create table t1(v blob not null, vector index(v)) engine=aria; + +--echo # +--echo # MDEV-35038 Server crash in Index_statistics::get_avg_frequency upon EITS collection for vector index +--echo # +create table t (a int, v blob not null, vector index (v)); +analyze table t persistent for columns() indexes (v); +drop table t; diff --git a/sql/sql_statistics.cc b/sql/sql_statistics.cc index 7d0a71c25ac..5498d42e24d 100644 --- a/sql/sql_statistics.cc +++ b/sql/sql_statistics.cc @@ -2965,12 +2965,12 @@ int update_statistics_for_table(THD *thd, TABLE *table) /* Update the statistical table index_stats */ stat_table= tables[INDEX_STAT].table; - uint key; - key_map::Iterator it(table->keys_in_use_for_query); Index_stat index_stat(stat_table, table); - while ((key= it++) != key_map::Iterator::BITMAP_END) + for (uint key= 0; key < table->s->keys; key++) { + if (!table->keys_in_use_for_query.is_set(key)) + continue; KEY *key_info= table->key_info+key; uint key_parts= table->actual_n_key_parts(key_info); for (i= 0; i < key_parts; i++)