diff --git a/mysql-test/main/vector_innodb.result b/mysql-test/main/vector_innodb.result index 5a20d3f4c54db..9cc79dcf011ff 100644 --- a/mysql-test/main/vector_innodb.result +++ b/mysql-test/main/vector_innodb.result @@ -376,3 +376,18 @@ Warning 1292 Incorrect vector value: '1' for column `test`.`t1`.`v` at row 1 drop table t1; set sql_mode=default; # End of 11.8 tests +# MDEV-35821: vector index sizes are not in information_schema.TABLES nor SHOW TABLE STATUS +CREATE TABLE t_vec ( +id INT PRIMARY KEY, +v VECTOR(4) NOT NULL, +VECTOR INDEX (v) +) ENGINE=InnoDB; +INSERT INTO t_vec VALUES (1, VEC_FromText('[1,2,3,4]')); +INSERT INTO t_vec VALUES (2, VEC_FromText('[2,3,4,5]')); +SELECT index_length > 0 AS index_length_is_nonzero +FROM information_schema.TABLES +WHERE table_schema = 'test' AND table_name = 't_vec'; +index_length_is_nonzero +1 +DROP TABLE t_vec; +# End of 11.9 tests diff --git a/mysql-test/main/vector_innodb.test b/mysql-test/main/vector_innodb.test index efc272798f3b1..71cb97ae15563 100644 --- a/mysql-test/main/vector_innodb.test +++ b/mysql-test/main/vector_innodb.test @@ -370,3 +370,22 @@ drop table t1; set sql_mode=default; --echo # End of 11.8 tests + +--echo # MDEV-35821: vector index sizes are not in information_schema.TABLES nor SHOW TABLE STATUS + +CREATE TABLE t_vec ( + id INT PRIMARY KEY, + v VECTOR(4) NOT NULL, + VECTOR INDEX (v) +) ENGINE=InnoDB; + +INSERT INTO t_vec VALUES (1, VEC_FromText('[1,2,3,4]')); +INSERT INTO t_vec VALUES (2, VEC_FromText('[2,3,4,5]')); + +SELECT index_length > 0 AS index_length_is_nonzero +FROM information_schema.TABLES +WHERE table_schema = 'test' AND table_name = 't_vec'; + +DROP TABLE t_vec; + +--echo # End of 11.9 tests diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 21dbe9ce1910d..248140f9465cb 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -14917,6 +14917,25 @@ ha_innobase::info_low( stats.index_file_length = ulonglong(stat_sum_of_other_index_sizes) * size; + /* Include hlindex (vector index) size in index_file_length */ + if (table->s->hlindexes()) + { + char hli_name[FN_REFLEN]; + char norm_path[FN_REFLEN]; + normalize_table_name(norm_path, sizeof(norm_path), + table->s->normalized_path.str); + my_snprintf(hli_name, sizeof(hli_name), + "%s" HLINDEX_TEMPLATE, + norm_path, table->s->keys); + if (dict_table_t *hli_table= dict_table_open_on_name(hli_name, false, + DICT_ERR_IGNORE_NONE)) + { + if (fil_space_t *hli_space= hli_table->space) + stats.index_file_length+= + ulonglong(hli_space->size) * hli_space->physical_size(); + dict_table_close(hli_table, m_user_thd, nullptr); + } + } if (flag & HA_STATUS_VARIABLE_EXTRA) { space->s_lock(); stats.delete_length = 1024